2023-11-05 16:10:59 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023 Simon Bruder
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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)),
|
|
|
|
Set.of(OrderType.EVENT_CATERING, OrderType.MOBILE_BREAKFAST)));
|
|
|
|
cateringCatalog.save(new Rentable(
|
|
|
|
"Kerze Rot",
|
|
|
|
Money.of(2, EURO),
|
|
|
|
Money.of(1.5, EURO),
|
|
|
|
Set.of(OrderType.EVENT_CATERING, OrderType.MOBILE_BREAKFAST)));
|
|
|
|
cateringCatalog.save(new Rentable(
|
|
|
|
"Brotschneidemaschine Power X 3000",
|
|
|
|
Money.of(25, EURO),
|
|
|
|
Money.of(10000, EURO),
|
|
|
|
Set.of(OrderType.EVENT_CATERING, OrderType.MOBILE_BREAKFAST)));
|
2023-11-05 16:10:59 +01:00
|
|
|
}
|
|
|
|
}
|