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 com.neovisionaries.i18n.CurrencyCode; 021import io.konik.jaxb.bindable.entity.AccountingAccountAdapter; 022import io.konik.validator.annotation.Basic; 023import io.konik.validator.annotation.Comfort; 024import io.konik.validator.annotation.Extended; 025import io.konik.zugferd.entity.*; 026 027import javax.validation.Valid; 028import javax.validation.constraints.NotNull; 029import javax.xml.bind.annotation.XmlElement; 030import javax.xml.bind.annotation.XmlType; 031import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 032import java.util.ArrayList; 033import java.util.List; 034 035/** 036 * = The Trade Settlement 037 * 038 * Contains trade specific payment and price related informations 039 */ 040@XmlType(propOrder = { "paymentReference", "currency", "invoicee", "payee", "paymentMeans", "tradeTax", 041 "billingPeriod", "allowanceCharge", "serviceCharge", "paymentTerms", "monetarySummation", 042 "costCenter" }) 043public class Settlement implements CommonSettlement<TradeTax, MonetarySummation> { 044 045 @XmlElement(name = "PaymentReference") 046 private String paymentReference; 047 048 @XmlElement(name = "InvoiceCurrencyCode") 049 private CurrencyCode currency; 050 051 @XmlElement(name = "InvoiceeTradeParty") 052 private TradeParty invoicee; 053 054 @XmlElement(name = "PayeeTradeParty") 055 private TradeParty payee; 056 057 @XmlElement(name = "SpecifiedTradeSettlementPaymentMeans") 058 private List<PaymentMeans> paymentMeans; 059 060 @XmlElement(name = "ApplicableTradeTax") 061 private List<TradeTax> tradeTax; 062 063 @XmlElement(name = "BillingSpecifiedPeriod") 064 private Period billingPeriod; 065 066 @XmlElement(name = "SpecifiedTradeAllowanceCharge") 067 private List<SpecifiedAllowanceCharge> allowanceCharge; 068 069 @XmlElement(name = "SpecifiedLogisticsServiceCharge") 070 private List<LogisticsServiceCharge> serviceCharge; 071 072 @XmlElement(name = "SpecifiedTradePaymentTerms") 073 private List<PaymentTerm> paymentTerms; 074 075 @XmlElement(name = "SpecifiedTradeSettlementMonetarySummation") 076 private MonetarySummation monetarySummation; 077 078 @XmlElement(name = "ReceivableSpecifiedTradeAccountingAccount") 079 @XmlJavaTypeAdapter(AccountingAccountAdapter.class) 080 private String costCenter; 081 082 /** 083 * Gets the payment reference. 084 * 085 * Can be same as invoice number. 086 * 087 * @return the payment reference 088 */ 089 @Basic 090 public String getPaymentReference() { 091 return paymentReference; 092 } 093 094 /** 095 * Sets the payment reference or note to payee 096 * 097 * Can be same as invoice number. 098 * 099 * @param referenceText the reference text 100 * @return the trade settlement 101 */ 102 public Settlement setPaymentReference(String referenceText) { 103 this.paymentReference = referenceText; 104 return this; 105 } 106 107 /** 108 * Gets the invoice currency code 109 * specifiedBookingReference 110 * 111 * @return the +ISO 4217 3A+ currency code 112 */ 113 @Basic 114 @NotNull 115 public CurrencyCode getCurrency() { 116 return currency; 117 } 118 119 /** 120 * Sets the invoice currency code. 121 * 122 * @param currency the new currency 123 * @return the trade settlement 124 */ 125 public Settlement setCurrency(CurrencyCode currency) { 126 this.currency = currency; 127 return this; 128 } 129 130 /** 131 * Gets the details on the alternative invoicee. 132 * 133 * Additional role, if different from Buyer 134 * 135 * @return the invoicee trade party 136 */ 137 @Valid 138 @Comfort 139 public TradeParty getInvoicee() { 140 return invoicee; 141 } 142 143 /** 144 * Sets the details on the alternative invoicee. 145 * 146 * Additional role, if different from Buyer 147 * 148 * @param invoicee the new invoicee trade party 149 * @return the trade settlement 150 */ 151 public Settlement setInvoicee(TradeParty invoicee) { 152 this.invoicee = invoicee; 153 return this; 154 } 155 156 /** 157 * Gets the payee. 158 * 159 * @return the payee 160 */ 161 @Valid 162 @Extended 163 public TradeParty getPayee() { 164 return payee; 165 } 166 167 /** 168 * Sets the payee. 169 * 170 * @param payee the payee 171 * @return the trade settlement 172 */ 173 public Settlement setPayee(TradeParty payee) { 174 this.payee = payee; 175 return this; 176 } 177 178 /** 179 * Gets the specified trade settlement payment means. 180 * 181 * @return the specified trade settlement payment means 182 */ 183 @Valid 184 public List<PaymentMeans> getPaymentMeans() { 185 if (paymentMeans == null) { 186 paymentMeans = new ArrayList<PaymentMeans>(); 187 } 188 return this.paymentMeans; 189 } 190 191 /** 192 * Adds the payment method. 193 * 194 * @param newPaymentMethod the new payment method 195 * @return the trade settlement 196 */ 197 public Settlement addPaymentMeans(PaymentMeans newPaymentMethod) { 198 getPaymentMeans().add(newPaymentMethod); 199 return this; 200 } 201 202 /** 203 * Gets the applicable trade tradeTax. 204 * 205 * @return the applicable trade tradeTax 206 */ 207 @Override 208 public List<TradeTax> getTradeTax() { 209 if (tradeTax == null) { 210 tradeTax = new ArrayList<TradeTax>(); 211 } 212 return this.tradeTax; 213 } 214 215 /** 216 * Adds a trade tradeTax. 217 * 218 * @param additionalTradeTax the additional trade tradeTax 219 * @return the trade settlement 220 */ 221 @Override 222 public Settlement addTradeTax(TradeTax additionalTradeTax) { 223 getTradeTax().add(additionalTradeTax); 224 return this; 225 } 226 227 /** 228 * Gets the billing specified period. 229 * 230 * @return the billing specified period 231 */ 232 @Valid 233 @Comfort 234 @Override 235 public Period getBillingPeriod() { 236 return billingPeriod; 237 } 238 239 /** 240 * Sets the billing specified period. 241 * 242 * @param billingPeriod the new billing specified period 243 * @return the trade settlement 244 */ 245 @Override 246 public Settlement setBillingPeriod(Period billingPeriod) { 247 this.billingPeriod = billingPeriod; 248 return this; 249 } 250 251 /** 252 * Gets the trade allowance charge. 253 * 254 * @return the specified trade allowance charge 255 */ 256 @Comfort 257 public List<SpecifiedAllowanceCharge> getAllowanceCharge() { 258 if (allowanceCharge == null) { 259 allowanceCharge = new ArrayList<SpecifiedAllowanceCharge>(); 260 } 261 return this.allowanceCharge; 262 } 263 264 /** 265 * Adds the trade allowance charge. 266 * 267 * @param additionalAllowanceCharge an additional allowance charge 268 * @return the trade settlement 269 */ 270 @Comfort 271 public Settlement addAllowanceCharge(SpecifiedAllowanceCharge additionalAllowanceCharge) { 272 getAllowanceCharge().add(additionalAllowanceCharge); 273 return this; 274 } 275 276 /** 277 * Gets the specified logistics service charge. 278 * 279 * @return the specified logistics service charge 280 */ 281 @Comfort 282 public List<LogisticsServiceCharge> getServiceCharge() { 283 if (serviceCharge == null) { 284 serviceCharge = new ArrayList<LogisticsServiceCharge>(); 285 } 286 return this.serviceCharge; 287 } 288 289 /** 290 * Adds the specified logistics service charge. 291 * 292 * @param logisticsServiceCharge the logistics service charge 293 * @return the trade settlement 294 */ 295 @Comfort 296 public Settlement addServiceCharge(LogisticsServiceCharge logisticsServiceCharge) { 297 getServiceCharge().add(logisticsServiceCharge); 298 return this; 299 } 300 301 /** 302 * Gets the specified trade payment terms. 303 * 304 * @return the specified trade payment terms 305 */ 306 @Comfort 307 public List<PaymentTerm> getPaymentTerms() { 308 if (paymentTerms == null) { 309 paymentTerms = new ArrayList<PaymentTerm>(); 310 } 311 return this.paymentTerms; 312 } 313 314 /** 315 * Adds a Payment Term. 316 * 317 * @param additionalPaymentTerm the additional payment term 318 * @return the trade settlement 319 */ 320 @Comfort 321 public Settlement addPaymentTerm(PaymentTerm additionalPaymentTerm) { 322 getPaymentTerms().add(additionalPaymentTerm); 323 return this; 324 } 325 326 /** 327 * Gets the trade settlement monetary summation. 328 * 329 * @return the specified trade settlement monetary summation 330 */ 331 @Basic@Valid@NotNull 332 @Override 333 public MonetarySummation getMonetarySummation() { 334 return monetarySummation; 335 } 336 337 /** 338 * Sets the trade settlement monetary summation. 339 * 340 * @param monetarySummation the new monetary summation 341 * @return the trade settlement 342 */ 343 @Basic 344 @Override 345 public Settlement setMonetarySummation(MonetarySummation monetarySummation) { 346 this.monetarySummation = monetarySummation; 347 return this; 348 } 349 350 /** 351 * Gets the booking reference or cost center account. 352 * 353 * @return the account of the booking reference 354 */ 355 @Extended 356 public String getCostCenter() { 357 return costCenter; 358 } 359 360 361 /** 362 * Sets the booking reference or cost center account. 363 * 364 * @param costCenter the booking reference or cost center account. 365 * @return the trade settlement 366 */ 367 public Settlement setCostCenter(String costCenter) { 368 this.costCenter = costCenter; 369 return this; 370 } 371 372}