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