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.validator.annotation.Basic; 021import io.konik.validator.annotation.Comfort; 022import io.konik.zugferd.entity.CommonMonetarySummation; 023import io.konik.zugferd.unqualified.Amount; 024 025import javax.validation.Valid; 026import javax.validation.constraints.NotNull; 027import javax.xml.bind.annotation.XmlElement; 028import javax.xml.bind.annotation.XmlType; 029 030/** 031 * = The Monetary Summation of a trade settlement 032 * 033 */ 034@XmlType(propOrder = { "lineTotal", "chargeTotal", "allowanceTotal", "taxBasisTotal", "taxTotal", "grandTotal", 035 "totalPrepaid", "duePayable" }) 036public class MonetarySummation implements CommonMonetarySummation { 037 038 @Valid 039 @XmlElement(name = "LineTotalAmount") 040 private Amount lineTotal; 041 042 @XmlElement(name = "ChargeTotalAmount") 043 private Amount chargeTotal; 044 045 @XmlElement(name = "AllowanceTotalAmount") 046 private Amount allowanceTotal; 047 048 @XmlElement(name = "TaxBasisTotalAmount") 049 private Amount taxBasisTotal; 050 051 @XmlElement(name = "TaxTotalAmount") 052 private Amount taxTotal; 053 054 @XmlElement(name = "GrandTotalAmount") 055 private Amount grandTotal; 056 057 @XmlElement(name = "TotalPrepaidAmount") 058 private Amount totalPrepaid; 059 060 @XmlElement(name = "DuePayableAmount") 061 private Amount duePayable; 062 063 @Override 064 public Amount getLineTotal() { 065 return lineTotal; 066 } 067 068 @Override 069 public MonetarySummation setLineTotal(Amount lineTotal) { 070 this.lineTotal = lineTotal; 071 return this; 072 } 073 074 /** 075 * Gets the total amount of surcharges. 076 * 077 * @return the charge total amount 078 */ 079 @Basic 080 @Valid 081 @NotNull 082 public Amount getChargeTotal() { 083 return chargeTotal; 084 } 085 086 /** 087 * Sets the total amount of surcharges. 088 * 089 * @param chargeTotal the new charge total amount 090 * @return the trade settlement monetary summation 091 */ 092 public MonetarySummation setChargeTotal(Amount chargeTotal) { 093 this.chargeTotal = chargeTotal; 094 return this; 095 } 096 097 /** 098 * Gets the total amount of discounts. 099 * 100 * @return the allowance total amount 101 */ 102 @Basic 103 @Valid 104 @NotNull 105 public Amount getAllowanceTotal() { 106 return allowanceTotal; 107 } 108 109 /** 110 * Sets the total amount of discounts. 111 * 112 * @param allowanceTotal the new allowance total amount 113 * @return the trade settlement monetary summation 114 */ 115 public MonetarySummation setAllowanceTotal(Amount allowanceTotal) { 116 this.allowanceTotal = allowanceTotal; 117 return this; 118 } 119 120 /** 121 * Gets the invoice total value excluding VAT. 122 * 123 * Example:: The taxBasisTotal = netTotal + chargeTotal - allowanceTotal. 124 * 125 * @return the tax basis total amount 126 */ 127 @Basic 128 @Valid 129 @NotNull 130 public Amount getTaxBasisTotal() { 131 return taxBasisTotal; 132 } 133 134 /** 135 * Sets the invoice total value excluding VAT. 136 * 137 * Example:: The taxBasisTotal = netTotal + chargeTotal - allowanceTotal. 138 * 139 * @param taxBasisTotal the new tax basis total amount 140 * @return the trade settlement monetary summation 141 */ 142 public MonetarySummation setTaxBasisTotal(Amount taxBasisTotal) { 143 this.taxBasisTotal = taxBasisTotal; 144 return this; 145 } 146 147 /** 148 * Gets the total tax amount. 149 * 150 * @return the tax total amount 151 */ 152 @Basic 153 @Valid 154 @NotNull 155 public Amount getTaxTotal() { 156 return taxTotal; 157 } 158 159 /** 160 * Sets the total tax amount. 161 * 162 * @param taxTotal the new tax total amount 163 * @return the trade settlement monetary summation 164 */ 165 public MonetarySummation setTaxTotal(Amount taxTotal) { 166 this.taxTotal = taxTotal; 167 return this; 168 } 169 170 /** 171 * Gets the grand total amount. 172 * 173 * Example:: grandTotal == + taxTotal 174 * 175 * @return the grand total amount 176 */ 177 @Basic 178 @Valid 179 @NotNull 180 public Amount getGrandTotal() { 181 return grandTotal; 182 } 183 184 /** 185 * Sets the grand total amount. 186 * 187 * @param grandTotal the new grand total amount 188 * @return the trade settlement monetary summation 189 */ 190 public MonetarySummation setGrandTotal(Amount grandTotal) { 191 this.grandTotal = grandTotal; 192 return this; 193 } 194 195 /** 196 * Gets the total prepaid amount. 197 * 198 * @return the total prepaid amount 199 */ 200 @Comfort 201 @Valid 202 public Amount getTotalPrepaid() { 203 return totalPrepaid; 204 } 205 206 /** 207 * Sets the total prepaid amount. 208 * 209 * @param totalPrepaid the new total prepaid amount 210 * @return the trade settlement monetary summation 211 */ 212 public MonetarySummation setTotalPrepaid(Amount totalPrepaid) { 213 this.totalPrepaid = totalPrepaid; 214 return this; 215 } 216 217 /** 218 * Gets the due payable amount. 219 * 220 * @return the due payable amount 221 */ 222 @Comfort 223 @Valid 224 public Amount getDuePayable() { 225 return duePayable; 226 } 227 228 /** 229 * Sets the due payable amount. 230 * 231 * @param duePayable the new due payable amount 232 * @return the trade settlement monetary summation 233 */ 234 public MonetarySummation setDuePayable(Amount duePayable) { 235 this.duePayable = duePayable; 236 return this; 237 } 238 239 240 @Override 241 public String toString() { 242 StringBuilder builder = new StringBuilder(); 243 builder.append("MonetarySummation ["); 244 if (lineTotal != null) builder.append("lineTotal=").append(lineTotal).append(", "); 245 if (chargeTotal != null) builder.append("chargeTotal=").append(chargeTotal).append(", "); 246 if (allowanceTotal != null) builder.append("allowanceTotal=").append(allowanceTotal).append(", "); 247 if (taxBasisTotal != null) builder.append("taxBasisTotal=").append(taxBasisTotal).append(", "); 248 if (taxTotal != null) builder.append("taxTotal=").append(taxTotal).append(", "); 249 if (grandTotal != null) builder.append("grandTotal=").append(grandTotal).append(", "); 250 if (totalPrepaid != null) builder.append("totalPrepaid=").append(totalPrepaid).append(", "); 251 if (duePayable != null) builder.append("duePayable=").append(duePayable); 252 builder.append("]"); 253 return builder.toString(); 254 } 255 256}