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