swt23w23/src/main/java/catering/inventory/InventoryMutateForm.java

74 lines
2.2 KiB
Java
Raw Normal View History

2023-11-05 16:11:36 +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.inventory;
import java.util.Optional;
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 double wholesalePrice, retailPrice;
private final @NotNull Optional<Double> promotionPrice;
2023-11-05 16:11:36 +01:00
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 = wholesalePrice;
this.retailPrice = retailPrice;
this.promotionPrice = promotionPrice;
}
public static InventoryMutateForm empty() {
return new InventoryMutateForm(null, "", Quantity.of(0), 0, 0, Optional.empty());
2023-11-05 16:11:36 +01:00
}
public CatalogDummyType getType() {
return type;
}
public String getName() {
return name;
}
public Quantity getQuantity() {
return quantity;
}
public double getWholesalePrice() {
2023-11-05 16:11:36 +01:00
return wholesalePrice;
}
public double getRetailPrice() {
2023-11-05 16:11:36 +01:00
return retailPrice;
}
public Optional<Double> getPromotionPrice() {
2023-11-05 16:11:36 +01:00
return promotionPrice;
}
}