mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-06-23 21:23:43 +02:00
75 lines
2.3 KiB
Java
75 lines
2.3 KiB
Java
/*
|
|
* 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.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<MonetaryAmount> promotionPrice;
|
|
|
|
public InventoryMutateForm(@NotNull CatalogDummyType type, @NotEmpty String name,
|
|
@NotNull Quantity quantity, @PositiveOrZero double wholesalePrice, @PositiveOrZero double retailPrice,
|
|
@PositiveOrZero Optional<Double> 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<MonetaryAmount> getPromotionPrice() {
|
|
return promotionPrice;
|
|
}
|
|
}
|