2023-12-11 17:59:14 +01:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
2024-01-07 00:32:52 +01:00
|
|
|
// SPDX-FileCopyrightText: 2023-2024 swt23w23
|
2023-11-05 16:10:59 +01:00
|
|
|
package catering.catalog;
|
|
|
|
|
|
|
|
import static org.salespointframework.core.Currencies.EURO;
|
|
|
|
|
2023-11-29 17:13:07 +01:00
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Optional;
|
|
|
|
|
2023-11-05 16:10:59 +01:00
|
|
|
import org.javamoney.moneta.Money;
|
|
|
|
import org.salespointframework.core.DataInitializer;
|
2024-01-07 00:32:52 +01:00
|
|
|
import org.salespointframework.quantity.Metric;
|
2023-11-05 16:10:59 +01:00
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
2023-11-29 17:13:07 +01:00
|
|
|
import catering.order.OrderType;
|
|
|
|
|
2023-11-05 16:10:59 +01:00
|
|
|
@Component
|
|
|
|
@Order(20)
|
|
|
|
class CatalogDataInitializer implements DataInitializer {
|
|
|
|
|
|
|
|
private final CateringCatalog cateringCatalog;
|
|
|
|
|
|
|
|
CatalogDataInitializer(CateringCatalog cateringCatalog) {
|
|
|
|
Assert.notNull(cateringCatalog, "CateringCatalog must not be null!");
|
|
|
|
this.cateringCatalog = cateringCatalog;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initialize() {
|
|
|
|
if (cateringCatalog.findAll().iterator().hasNext()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-01-07 00:32:52 +01:00
|
|
|
// !!! These need to be kept in sync with CatalogUnitTests
|
2023-11-29 17:13:07 +01:00
|
|
|
cateringCatalog.save(new Consumable(
|
|
|
|
"Brötchen Vollkorn",
|
|
|
|
Money.of(1, EURO),
|
|
|
|
Money.of(0.5, EURO),
|
|
|
|
Optional.of(Money.of(0.75, EURO)),
|
2024-01-07 00:32:52 +01:00
|
|
|
Set.of(OrderType.EVENT_CATERING, OrderType.MOBILE_BREAKFAST),
|
|
|
|
Metric.UNIT));
|
|
|
|
cateringCatalog.save(new Consumable(
|
|
|
|
"Tafelwasser",
|
|
|
|
Money.of(5, EURO),
|
|
|
|
Money.of(0.01, EURO),
|
|
|
|
Optional.empty(),
|
|
|
|
Set.of(OrderType.PARTY_SERVICE, OrderType.EVENT_CATERING),
|
|
|
|
Metric.LITER));
|
2023-11-29 17:13:07 +01:00
|
|
|
cateringCatalog.save(new Rentable(
|
|
|
|
"Kerze Rot",
|
|
|
|
Money.of(2, EURO),
|
|
|
|
Money.of(1.5, EURO),
|
2024-01-07 00:32:52 +01:00
|
|
|
Set.of(OrderType.EVENT_CATERING, OrderType.MOBILE_BREAKFAST),
|
|
|
|
Metric.UNIT));
|
2023-11-29 17:13:07 +01:00
|
|
|
cateringCatalog.save(new Rentable(
|
|
|
|
"Brotschneidemaschine Power X 3000",
|
|
|
|
Money.of(25, EURO),
|
|
|
|
Money.of(10000, EURO),
|
2024-01-07 00:32:52 +01:00
|
|
|
Set.of(OrderType.EVENT_CATERING, OrderType.MOBILE_BREAKFAST),
|
|
|
|
Metric.UNIT));
|
2023-11-05 16:10:59 +01:00
|
|
|
}
|
|
|
|
}
|