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.bindable.unqualified.PercentRoundingAdapter; 021import io.konik.validator.annotation.Comfort; 022import io.konik.zugferd.unece.codes.TaxCategory; 023import io.konik.zugferd.unece.codes.TaxCode; 024 025import java.math.BigDecimal; 026 027import javax.validation.constraints.NotNull; 028import javax.xml.bind.annotation.XmlElement; 029import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 030 031/** 032 * = The trade tax 033 * 034 */ 035@Comfort 036public class AppliedTax implements Tax { 037 038 @XmlElement(name = "TypeCode") 039 private TaxCode type; 040 041 @XmlElement(name = "CategoryCode") 042 private TaxCategory category; 043 044 @XmlElement(name = "ApplicablePercent") 045 @XmlJavaTypeAdapter(PercentRoundingAdapter.class) 046 private BigDecimal percentage; 047 048 /** 049 * Gets the UNCL 5153 tax type code. 050 * 051 * @return the type code 052 */ 053 @Override 054 @NotNull(groups = Comfort.class) 055 public TaxCode getType() { 056 return type; 057 } 058 059 /** 060 * Sets the UNCL 5153 tax type code. 061 * 062 * @param taxTypeCode the tax type code 063 * @return the tax 064 * @see <a href="http://www.unece.org/trade/untdid/d98b/uncl/uncl5153.htm">UNCL 5153</a> 065 */ 066 @Override 067 public AppliedTax setType(TaxCode taxTypeCode) { 068 this.type = taxTypeCode; 069 return this; 070 } 071 072 /** 073 * Gets the tax category. 074 * 075 * @return the category code 076 */ 077 @Override 078 @NotNull(groups = Comfort.class) 079 public TaxCategory getCategory() { 080 return category; 081 } 082 083 /** 084 * Sets the tax category. 085 * 086 * @param taxCategory the new category code 087 * @return the tax 088 */ 089 @Override 090 public AppliedTax setCategory(TaxCategory taxCategory) { 091 this.category = taxCategory; 092 return this; 093 } 094 095 /** 096 * Gets the applicable tax percentage. 097 * 098 * @return the applicable tax percentage 099 */ 100 @Override 101 @NotNull(groups = Comfort.class) 102 public BigDecimal getPercentage() { 103 return percentage; 104 } 105 106 /** 107 * Sets the applicable tax percentage. 108 * 109 * @param applicablePercentage the new applicable tax percentage 110 * @return the tax 111 */ 112 @Override 113 public AppliedTax setPercentage(BigDecimal applicablePercentage) { 114 this.percentage = applicablePercentage; 115 return this; 116 } 117}