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