001/* 002 * Copyright (C) 2014 konik.io 003 * 004 * This file is part of Konik library. 005 * 006 * Konik library is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU Affero General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Konik library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU Affero General Public License for more details. 015 * 016 * You should have received a copy of the GNU Affero General Public License 017 * along with Konik library. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package io.konik.zugferd.entity; 020 021import io.konik.zugferd.unqualified.Amount; 022 023import javax.validation.Valid; 024import javax.xml.bind.annotation.XmlAccessType; 025import javax.xml.bind.annotation.XmlAccessorType; 026import javax.xml.bind.annotation.XmlElement; 027import javax.xml.bind.annotation.XmlType; 028 029 030/** 031 * = The Allowance Charge 032 * 033 * Represents trade surcharges and discounts as well as a reason. 034 */ 035@XmlAccessorType(XmlAccessType.FIELD) 036@XmlType(name = "TradeAllowanceChargeType", propOrder = { "surcharge", "basisAmount", "actualAmount", 037 "reason", "category" }) 038public class AllowanceCharge { 039 040 @XmlElement(name = "ChargeIndicator") 041 private boolean surcharge; 042 043 @Valid 044 @XmlElement(name = "BasisAmount") 045 private Amount basisAmount; 046 047 @Valid 048 @XmlElement(name = "ActualAmount") 049 private Amount actualAmount; 050 051 @XmlElement(name = "Reason") 052 private String reason; 053 054 @XmlElement(name = "CategoryTradeTax") 055 private Tax category; 056 057 /** 058 * Checks if is a surcharge. 059 * 060 * @return true if charge otherwise discount 061 */ 062 public boolean isSurcharge() { 063 return surcharge; 064 } 065 066 /** 067 * Checks if is discount. 068 * 069 * @return true if discount otherwise charge 070 */ 071 public boolean isDiscount() { 072 return !surcharge; 073 } 074 075 /** 076 * Sets amount to be a surcharge. 077 * 078 * @return the allowance charge 079 */ 080 public AllowanceCharge setSurcharge() { 081 this.surcharge = true; 082 return this; 083 } 084 085 /** 086 * Sets the amount to be a discount. 087 * 088 * @return the allowance charge 089 */ 090 public AllowanceCharge setDiscount() { 091 this.surcharge = false; 092 return this; 093 } 094 095 /** 096 * Gets the basis amount. 097 * 098 * @return the basis amount 099 */ 100 public Amount getBasisAmount() { 101 return basisAmount; 102 } 103 104 /** 105 * Sets the basis amount. 106 * 107 * @param basisAmount the new basis amount 108 * @return the allowance charge 109 */ 110 public AllowanceCharge setBasisAmount(Amount basisAmount) { 111 this.basisAmount = basisAmount; 112 return this; 113 } 114 115 /** 116 * Gets the actual amount. 117 * 118 * @return the actual amount 119 */ 120 public Amount getActualAmount() { 121 return actualAmount; 122 } 123 124 /** 125 * Sets the actual amount. 126 * 127 * @param actualAmount the new actual amount 128 * @return the allowance charge 129 */ 130 public AllowanceCharge setActualAmount(Amount actualAmount) { 131 this.actualAmount = actualAmount; 132 return this; 133 } 134 135 /** 136 * Gets the reason. 137 * 138 * @return the reason 139 */ 140 public String getReason() { 141 return reason; 142 } 143 144 /** 145 * Sets the reason. 146 * 147 * @param reason the new reason 148 * @return the allowance charge 149 */ 150 public AllowanceCharge setReason(String reason) { 151 this.reason = reason; 152 return this; 153 } 154 155 /** 156 * Gets the category. 157 * 158 * @return the category 159 */ 160 public Tax getCategory() { 161 return category; 162 } 163 164 /** 165 * Sets the category. 166 * 167 * @param category the new category 168 * @return the allowance charge 169 */ 170 public AllowanceCharge setCategory(Tax category) { 171 this.category = category; 172 return this; 173 } 174}