/* * 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 . */ package catering.inventory; import static org.salespointframework.core.Currencies.EURO; import java.util.Optional; import javax.money.MonetaryAmount; import org.javamoney.moneta.Money; import org.salespointframework.quantity.Quantity; import catering.catalog.CatalogDummyType; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.PositiveOrZero; // NonNegative in enterprise java class InventoryMutateForm { private final @NotNull CatalogDummyType type; private final @NotEmpty String name; private final @NotNull Quantity quantity; private final @NotNull MonetaryAmount wholesalePrice, retailPrice; private final @NotNull Optional promotionPrice; public InventoryMutateForm(@NotNull CatalogDummyType type, @NotEmpty String name, @NotNull Quantity quantity, @PositiveOrZero double wholesalePrice, @PositiveOrZero double retailPrice, @PositiveOrZero Optional promotionPrice) { this.type = type; this.name = name; this.quantity = quantity; this.wholesalePrice = Money.of(wholesalePrice, EURO); this.retailPrice = Money.of(retailPrice, EURO); this.promotionPrice = promotionPrice.map(price -> (MonetaryAmount) Money.of(price, EURO)); } public CatalogDummyType getType() { return type; } public String getName() { return name; } public Quantity getQuantity() { return quantity; } public MonetaryAmount getWholesalePrice() { return wholesalePrice; } public MonetaryAmount getRetailPrice() { return retailPrice; } public Optional getPromotionPrice() { return promotionPrice; } }