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.item;
019
020import io.konik.jaxb.bindable.entity.AccountingAccountAdapter;
021import io.konik.validator.annotation.Comfort;
022import io.konik.validator.annotation.Extended;
023import io.konik.zugferd.entity.CommonSettlement;
024import io.konik.zugferd.entity.Period;
025
026import java.util.ArrayList;
027import java.util.List;
028
029import javax.validation.Valid;
030import javax.xml.bind.annotation.XmlElement;
031import javax.xml.bind.annotation.XmlType;
032import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
033
034/**
035 * = The Trade Item Settlement
036 * 
037 * Contains payment related information on an Item basis.
038 */
039@XmlType(propOrder = { "tradeTax", "billingPeriod", "bookingReference", "monetarySummation" })
040public class SpecifiedSettlement implements CommonSettlement<SpecifiedTax, SpecifiedMonetarySummation> {
041
042   @Valid
043   @XmlElement(name = "ApplicableTradeTax")
044   private List<SpecifiedTax> tradeTax;
045
046   @Valid
047   @XmlElement(name = "BillingSpecifiedPeriod")
048   private Period billingPeriod;
049
050   @XmlElement(name = "SpecifiedTradeAccountingAccount")
051   @XmlJavaTypeAdapter(AccountingAccountAdapter.class)
052   private String bookingReference;
053
054   @Valid
055   @XmlElement(name = "SpecifiedTradeSettlementMonetarySummation")
056   private SpecifiedMonetarySummation monetarySummation;
057
058   /**
059    * Gets the applicable trade tax.
060    *
061    * @return the applicable trade tax
062    */
063   @Override
064   public List<SpecifiedTax> getTradeTax() {
065      if (tradeTax == null) {
066         tradeTax = new ArrayList<SpecifiedTax>();
067      }
068      return this.tradeTax;
069   }
070
071   /**
072    * Adds a trade tax.
073    * 
074    * @param additionalTradeTax
075    * @return the trade settlement
076    */
077   @Override
078   public SpecifiedSettlement addTradeTax(SpecifiedTax additionalTradeTax) {
079      getTradeTax().add(additionalTradeTax);
080      return this;
081   }
082
083   /**
084    * Gets the billing specified period.
085    * 
086    * Profile:: COMFORT
087    *
088    * @return the billing specified period
089    */
090   @Override
091   public Period getBillingPeriod() {
092      return billingPeriod;
093   }
094
095   /**
096    * Sets the billing specified period.
097    * 
098    * Profile:: COMFORT
099    * 
100    *
101    * @param billingPeriod the new billing specified period
102    * @return the supply chain trade settlement
103    */
104   @Override
105   public SpecifiedSettlement setBillingPeriod(Period billingPeriod) {
106      this.billingPeriod = billingPeriod;
107      return this;
108   }
109
110   /**
111    * Gets the specified booking reference.
112    * 
113    * Profile:: EXTENDED
114    *
115    * @return the specified booking reference
116    */
117   @Extended
118   public String getBookingReference() {
119      return bookingReference;
120   }
121
122   /**
123    * Sets the specified booking reference.
124    *
125    * Profile:: EXTENDED
126    *
127    * @param specifiedBookingReference the specified booking reference
128    * @return
129    */
130   public SpecifiedSettlement setBookingReference(String specifiedBookingReference) {
131      this.bookingReference = specifiedBookingReference;
132      return this;
133   }
134
135   /**
136    * Gets the trade settlement monetary summation.
137    *
138    * @return the monetary summation
139    */
140   @Override
141   @Comfort
142   public SpecifiedMonetarySummation getMonetarySummation() {
143      return monetarySummation;
144   }
145
146   /**
147    * Sets the trade settlement monetary summation.
148    * 
149    * @param monetarySummation the new monetary summation
150    * @return the supply chain trade settlement
151    */
152   @Override
153   public SpecifiedSettlement setMonetarySummation(SpecifiedMonetarySummation monetarySummation) {
154      this.monetarySummation = monetarySummation;
155      return this;
156   }
157}