001/* Copyright (C) 2014 konik.io 002 * 003 * This file is part of the Konik library. 004 * 005 * The Konik library is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * The Konik library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with the Konik library. If not, see <http://www.gnu.org/licenses/>. 017 */ 018package io.konik.zugferd.entity; 019 020import io.konik.jaxb.adapter.FourDigitRoundingAdapter; 021import io.konik.validator.annotation.Comfort; 022import io.konik.zugferd.unqualified.Amount; 023import io.konik.zugferd.unqualified.Quantity; 024 025import javax.validation.Valid; 026import javax.validation.constraints.NotNull; 027import javax.xml.bind.annotation.XmlAccessType; 028import javax.xml.bind.annotation.XmlAccessorType; 029import javax.xml.bind.annotation.XmlElement; 030import javax.xml.bind.annotation.XmlType; 031import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 032import java.io.Serializable; 033import java.util.List; 034 035/** 036 * = The Price 037 * 038 * 039 */ 040@XmlAccessorType(XmlAccessType.FIELD) 041@XmlType(name = "TradePriceType", propOrder = { "chargeAmount", "basis", "allowanceCharges" }) 042public class Price implements Serializable { 043 044 @XmlElement(name = "ChargeAmount") 045 @XmlJavaTypeAdapter(value = FourDigitRoundingAdapter.class) 046 private Amount chargeAmount; 047 048 @XmlElement(name = "BasisQuantity") 049 private Quantity basis; 050 051 @XmlElement(name = "AppliedTradeAllowanceCharge") 052 protected List<AllowanceCharge> allowanceCharges;//grossprice 053 054 Price() { 055 } 056 057 /** 058 * Instantiates a new price. 059 * 060 * @param chargeAmount the charge amount 061 */ 062 public Price(Amount chargeAmount) { 063 super(); 064 this.chargeAmount = chargeAmount; 065 } 066 067 /** 068 * Gets the charge amount. 069 * 070 * @return the charge amount 071 */ 072 @Valid 073 @NotNull(groups = Comfort.class) 074 public Amount getChargeAmount() { 075 return chargeAmount; 076 } 077 078 /** 079 * Sets the charge amount. 080 * 081 * @param chargeAmount the new charge amount 082 * @return the price 083 */ 084 public Price setChargeAmount(Amount chargeAmount) { 085 this.chargeAmount = chargeAmount; 086 return this; 087 } 088 089 /** 090 * Gets the unit of price base quantity. 091 * 092 * @return the basis quantity 093 */ 094 @Valid 095 @Comfort 096 public Quantity getBasis() { 097 return basis; 098 } 099 100 /** 101 * Sets the unit of price base quantity. 102 * 103 * @param quantity the new basis quantity 104 * @return the price 105 */ 106 public Price setBasis(Quantity quantity) { 107 this.basis = quantity; 108 return this; 109 } 110 111}