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