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.trade;
019
020import io.konik.jaxb.bindable.unqualified.PercentRoundingAdapter;
021import io.konik.validator.annotation.Basic;
022import io.konik.validator.annotation.Comfort;
023import io.konik.validator.annotation.Extended;
024import io.konik.zugferd.entity.trade.item.SpecifiedTax;
025import io.konik.zugferd.unece.codes.TaxCategory;
026import io.konik.zugferd.unece.codes.TaxCode;
027import io.konik.zugferd.unqualified.Amount;
028
029import java.math.BigDecimal;
030
031import javax.validation.Valid;
032import javax.validation.constraints.NotNull;
033import javax.xml.bind.annotation.XmlElement;
034import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
035
036/**
037 * = The tax applied to a trade.
038 */
039public class TradeTax implements SpecifiedTax {
040
041   @XmlElement(name = "CalculatedAmount")
042   private Amount calculated;
043
044   @XmlElement(name = "TypeCode")
045   private TaxCode type;
046
047   @XmlElement(name = "ExemptionReason")
048   private String exemptionReason;
049
050   @XmlElement(name = "BasisAmount")
051   private Amount basis;
052
053   @XmlElement(name = "LineTotalBasisAmount")
054   private Amount lineTotal;
055
056   @XmlElement(name = "AllowanceChargeBasisAmount")
057   private Amount allowanceCharge;
058
059   @XmlElement(name = "CategoryCode")
060   private TaxCategory category;
061
062   @XmlElement(name = "ApplicablePercent")
063   @XmlJavaTypeAdapter(PercentRoundingAdapter.class)
064   private BigDecimal percentage;   
065
066   
067   @Basic
068   @NotNull
069   @Valid
070   @Override
071   public Amount getCalculated() {      
072      return calculated;
073   }
074
075   @Override
076   public TradeTax setCalculated(Amount calculatedAmount) {
077       this.calculated = calculatedAmount;
078       return this;
079   }
080
081   @Basic
082   @NotNull
083   @Override
084   public TaxCode getType() {
085      return type;
086   }
087
088   @Override
089   public TradeTax setType(TaxCode taxTypeCode) {
090      this.type = taxTypeCode;
091      return this;
092   }
093   
094   @Override
095   public String getExemptionReason() {
096      return exemptionReason;
097   }
098   
099   @Override
100   public TradeTax setExemptionReason(String exemptionReason) {
101      this.exemptionReason = exemptionReason;
102      return this;
103   }
104
105   /**
106    * Gets the basis amount for tax calculation.
107    * 
108    * @return the basis amount
109    */
110   @Basic
111   @Valid
112   @NotNull
113   public Amount getBasis() {
114      return basis;
115   }
116
117   /**
118    * Sets the basis amount for tax calculation.
119    * 
120    * @param basisAmount the new basis amount
121    * @return the tax
122    */
123   public TradeTax setBasis(Amount basisAmount) {
124      this.basis = basisAmount;
125      return this;
126   }
127
128   /**
129    * Gets the line total.
130    *
131    * @return the line total
132    */
133   @Valid
134   @Extended
135   public Amount getLineTotal() {
136      return lineTotal;
137   }
138
139   /**
140    * Sets the line total.
141    *
142    * @param lineTotal the new line total
143    */
144   public void setLineTotal(Amount lineTotal) {
145      this.lineTotal = lineTotal;
146   }
147
148   /**
149    * Gets the allowance charge.
150    *
151    * @return the allowance charge
152    */
153   @Valid
154   @Extended
155   public Amount getAllowanceCharge() {
156      return allowanceCharge;
157   }
158
159   /**
160    * Sets the allowance charge.
161    *
162    * @param allowanceCharge the new allowance charge
163    */
164   public void setAllowanceCharge(Amount allowanceCharge) {
165      this.allowanceCharge = allowanceCharge;
166   }
167
168   @Comfort
169   @Override
170   public TaxCategory getCategory() {
171      return category;
172   }
173
174   @Override
175   public TradeTax setCategory(TaxCategory taxCategory) {
176      this.category = taxCategory;
177      return this;
178   }
179
180   @Basic
181   @NotNull
182   @Override
183   public BigDecimal getPercentage() {
184      return percentage;
185   }
186
187   @Override
188   public TradeTax setPercentage(BigDecimal applicablePercentage) {      
189      this.percentage = applicablePercentage;
190      return this; 
191   }
192
193
194
195}