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;
019
020import io.konik.zugferd.unqualified.Amount;
021import io.konik.zugferd.unqualified.ZfDate;
022
023import java.util.ArrayList;
024import java.util.List;
025
026import javax.validation.Valid;
027import javax.xml.bind.annotation.XmlAccessType;
028import javax.xml.bind.annotation.XmlAccessorType;
029import javax.xml.bind.annotation.XmlElement;
030import javax.xml.bind.annotation.XmlType;
031
032/**
033 * = The payment terms of a trade.
034 */
035@XmlAccessorType(XmlAccessType.FIELD)
036@XmlType(name = "TradePaymentTermsType", propOrder = { "descriptions", "due", "partialPayments", "penalty", "discount" })
037public class PaymentTerm {
038
039   @XmlElement(name = "Description")
040   protected List<String> descriptions;
041
042   @Valid
043   @XmlElement(name = "DueDateDateTime")
044   private ZfDate due;
045
046   @XmlElement(name = "PartialPaymentAmount")
047   @Valid
048   private List<Amount> partialPayments;
049
050   @Valid
051   @XmlElement(name = "ApplicableTradePaymentPenaltyTerms")
052   private PaymentPenaltyTerms penalty;
053
054   @Valid
055   @XmlElement(name = "ApplicableTradePaymentDiscountTerms")
056   private PaymentDiscountTerms discount;
057
058   /**
059    * Gets the description.
060    * 
061    * @return the description
062    */
063   public List<String> getDescriptions() {
064      if (descriptions == null) {
065         descriptions = new ArrayList<String>();
066      }
067      return this.descriptions;
068   }
069
070   /**
071    * Sets the description.
072    *
073    * @param description the new description
074    * @return the payment term
075    */
076   public PaymentTerm addDescription(String description) {
077      getDescriptions().add(description);
078      return this;
079   }
080
081   /**
082    * Gets the due date time.
083    * 
084    * @return the due date time
085    */
086   public ZfDate getDue() {
087      return due;
088   }
089
090   /**
091    * Sets the due date time.
092    *
093    * @param due the new due date time
094    * @return the payment term
095    */
096   public PaymentTerm setDue(ZfDate due) {
097      this.due = due;
098      return this;
099   }
100
101   /**
102    * Gets the partial payments.
103    *
104    * @return the partial payments
105    */
106   public List<Amount> getPartialPayments() {
107      if (partialPayments == null) {
108         this.partialPayments = new ArrayList<Amount>();
109      }
110      return partialPayments;
111   }
112
113   /**
114    * Sets the partial payments.
115    *
116    * @param partialPayment the partial payment
117    * @return the payment term
118    */
119   public PaymentTerm addPartialPayments(Amount partialPayment) {
120      getPartialPayments().add(partialPayment);
121      return this;
122   }
123
124   /**
125    * Gets the payment penalty terms.
126    *
127    * @return the penalty
128    */
129   public PaymentPenaltyTerms getPenalty() {
130      return penalty;
131   }
132
133   /**
134    * Sets the payment penalty terms..
135    *
136    * @param penalty the new penalty
137    * @return
138    */
139   public PaymentTerm setPenalty(PaymentPenaltyTerms penalty) {
140      this.penalty = penalty;
141      return this;
142   }
143
144   /**
145    * Gets the discount.
146    *
147    * @return the discount
148    */
149   public PaymentDiscountTerms getDiscount() {
150      return discount;
151   }
152
153   /**
154    * Sets the discount.
155    *
156    * @param discount the new discount
157    * @return
158    */
159   public PaymentTerm setDiscount(PaymentDiscountTerms discount) {
160      this.discount = discount;
161      return this;
162   }
163}