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.TradeDeliveryTermsAdapter; 021import io.konik.validator.annotation.Basic; 022import io.konik.validator.annotation.Comfort; 023import io.konik.validator.annotation.Extended; 024import io.konik.zugferd.entity.CommonAgreement; 025import io.konik.zugferd.entity.ReferencedDocument; 026import io.konik.zugferd.entity.TradeParty; 027 028import javax.validation.Valid; 029import javax.validation.constraints.NotNull; 030import javax.xml.bind.annotation.XmlElement; 031import javax.xml.bind.annotation.XmlType; 032import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 033import java.util.ArrayList; 034import java.util.List; 035 036/** 037 * 038 * = The Trade Agreement. 039 * 040 */ 041@XmlType(propOrder = { "buyerReference", "seller", "buyer", "productEndUser", "deliveryTerms", "buyerOrder", 042 "contract", "additional", "customerOrder" }) 043public class Agreement implements CommonAgreement<ReferencedDocument, ReferencedDocumentAdditional> { 044 045 private String buyerReference; 046 private TradeParty seller; 047 private TradeParty buyer; 048 private TradeParty productEndUser; 049 private String deliveryTerms; 050 private ReferencedDocument buyerOrder; 051 private ReferencedDocument contract; 052 private List<ReferencedDocumentAdditional> additional; 053 private ReferencedDocument customerOrder; 054 055 /** 056 * Gets the buyer reference. 057 * 058 * The reference to ease the attribution for the buyer 059 * 060 * @return the buyer reference 061 */ 062 @Comfort 063 @XmlElement(name = "BuyerReference") 064 public String getBuyerReference() { 065 return buyerReference; 066 } 067 068 /** 069 * Sets the buyer reference. 070 * 071 * The reference to ease the attribution for the buyer 072 * 073 * @param buyerReference the new buyer reference 074 * @return the trade agreement 075 */ 076 public Agreement setBuyerReference(String buyerReference) { 077 this.buyerReference = buyerReference; 078 return this; 079 } 080 081 /** 082 * Gets the seller trade party 083 * 084 * @return the seller 085 */ 086 @NotNull 087 @Valid 088 @Basic 089 @XmlElement(name = "SellerTradeParty") 090 public TradeParty getSeller() { 091 return seller; 092 } 093 094 /** 095 * Sets the seller trade party 096 * 097 * @param seller the seller 098 * @return the agreement 099 */ 100 public Agreement setSeller(TradeParty seller) { 101 this.seller = seller; 102 return this; 103 } 104 105 /** 106 * Gets the product end user. 107 * 108 * @return the product end user 109 */ 110 @Valid 111 @Extended 112 @XmlElement(name = "ProductEndUserTradeParty") 113 public TradeParty getProductEndUser() { 114 return productEndUser; 115 } 116 117 /** 118 * Sets the product end user. 119 * 120 * @param productEndUser the new product end user 121 * @return the agreement 122 */ 123 public Agreement setProductEndUser(TradeParty productEndUser) { 124 this.productEndUser = productEndUser; 125 return this; 126 } 127 128 /** 129 * Gets the buyer trade party. 130 * 131 * @return the buyer trade party 132 */ 133 @XmlElement(name = "BuyerTradeParty") 134 public TradeParty getBuyer() { 135 return buyer; 136 } 137 138 /** 139 * Sets the buyer trade party. 140 * 141 * @param buyer the new buyer trade party 142 * @return the supply chain trade agreement 143 */ 144 public Agreement setBuyer(TradeParty buyer) { 145 this.buyer = buyer; 146 return this; 147 } 148 149 /** 150 * Gets the delivery terms Incoterms code. 151 * 152 * @return the delivery terms Incoterms code 153 */ 154 @Extended 155 @XmlElement(name = "ApplicableTradeDeliveryTerms") 156 @XmlJavaTypeAdapter(value = TradeDeliveryTermsAdapter.class) 157 public String getDeliveryTerms() { 158 return deliveryTerms; 159 } 160 161 /** 162 * Sets the delivery terms Incoterms code. 163 * 164 * @param deliveryTerms the delivery Incoterms terms 165 * @return 166 */ 167 public Agreement setDeliveryTerms(String deliveryTerms) { 168 this.deliveryTerms = deliveryTerms; 169 return this; 170 } 171 172 /** 173 * Gets the buyer order referenced document. 174 * 175 * @return the buyer order referenced document 176 */ 177 @Comfort 178 @Override 179 @XmlElement(name = "BuyerOrderReferencedDocument") 180 public ReferencedDocument getBuyerOrder() { 181 return buyerOrder; 182 } 183 184 /** 185 * Sets the buyer order referenced document. 186 * 187 * @param buyerOrder the new buyer order referenced document 188 * @return the supply chain trade agreement 189 */ 190 @Override 191 public Agreement setBuyerOrder(ReferencedDocument buyerOrder) { 192 this.buyerOrder = buyerOrder; 193 return this; 194 } 195 196 /** 197 * Gets the contract referenced document. 198 * 199 * @return the contract referenced document 200 */ 201 @Comfort 202 @Override 203 @XmlElement(name = "ContractReferencedDocument") 204 public ReferencedDocument getContract() { 205 return contract; 206 } 207 208 /** 209 * Sets the contract referenced document. 210 * 211 * @param contract the new contract referenced document 212 * @return the supply chain trade agreement 213 */ 214 @Override 215 public Agreement setContract(ReferencedDocument contract) { 216 this.contract = contract; 217 return this; 218 } 219 220 /** 221 * Gets the additional. 222 * 223 * @return the additional 224 */ 225 @Extended 226 @Override 227 @XmlElement(name = "AdditionalReferencedDocument") 228 public List<ReferencedDocumentAdditional> getAdditional() { 229 if (additional == null) { 230 additional = new ArrayList<ReferencedDocumentAdditional>(); 231 } 232 return additional; 233 } 234 235 /** 236 * Adds the additional. 237 * 238 * @param additionalReference the additional reference 239 * @return the common agreement 240 */ 241 @Override 242 public Agreement addAdditional(ReferencedDocumentAdditional additionalReference) { 243 getAdditional().add(additionalReference); 244 return this; 245 } 246 247 /** 248 * Gets the customer order referenced document. 249 * 250 * @return the customer order referenced document 251 */ 252 @Comfort 253 @Override 254 @XmlElement(name = "CustomerOrderReferencedDocument") 255 public ReferencedDocument getCustomerOrder() { 256 return customerOrder; 257 } 258 259 /** 260 * Sets the customer order referenced document. 261 * 262 * @param customerOrder the new customer order referenced document 263 * @return the supply chain trade agreement 264 */ 265 @Override 266 public Agreement setCustomerOrder(ReferencedDocument customerOrder) { 267 this.customerOrder = customerOrder; 268 return this; 269 } 270}