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.validator.annotation.Extended;
021import io.konik.zugferd.entity.CommonAgreement;
022import io.konik.zugferd.entity.GrossPrice;
023import io.konik.zugferd.entity.Price;
024
025import javax.validation.Valid;
026import javax.xml.bind.annotation.XmlElement;
027import javax.xml.bind.annotation.XmlType;
028import java.util.ArrayList;
029import java.util.List;
030
031/**
032 * = The Agreement used on the trade item level.
033 */
034@XmlType(propOrder = { "buyerOrder", "contract", "additional", "grossPrice", "netPrice", "customerOrder" })
035public class SpecifiedAgreement implements CommonAgreement<ReferencedDocumentItem, ReferencedDocumentItemAdditional> {
036
037   private ReferencedDocumentItem buyerOrder;
038   private ReferencedDocumentItem contract;
039   private List<ReferencedDocumentItemAdditional> additional;
040   private GrossPrice grossPrice;
041   private Price netPrice;
042   private ReferencedDocumentItem customerOrder;
043
044  
045   @Valid
046   @Extended
047   @Override
048   @XmlElement(name = "BuyerOrderReferencedDocument")
049   public ReferencedDocumentItem getBuyerOrder() {
050      return buyerOrder;
051   }
052
053   @Override
054   public SpecifiedAgreement setBuyerOrder(ReferencedDocumentItem buyerOrder) {
055      this.buyerOrder = buyerOrder;
056      return this;
057   }
058
059   @Valid
060   @Extended
061   @Override
062   @XmlElement(name = "ContractReferencedDocument")
063   public ReferencedDocumentItem getContract() {
064      return contract;
065   }
066   
067   @Valid
068   @Extended
069   @Override
070   public SpecifiedAgreement setContract(ReferencedDocumentItem contract) {
071      this.contract = contract;
072      return this;
073   }
074
075   @Valid
076   @Extended
077   @Override
078   @XmlElement(name = "AdditionalReferencedDocument")
079   public List<ReferencedDocumentItemAdditional> getAdditional() {
080      if (additional == null) {
081         additional = new ArrayList<ReferencedDocumentItemAdditional>();
082      }
083      return additional;
084   }
085
086   @Override
087   public SpecifiedAgreement addAdditional(ReferencedDocumentItemAdditional additionalReference) {
088      getAdditional().add(additionalReference);
089      return this;
090   }
091
092   /**
093    * Gets details on item based gross price excluding taxes
094    *
095    * @return the item gross price
096    */
097   @Valid
098   @XmlElement(name = "GrossPriceProductTradePrice")
099   public GrossPrice getGrossPrice() {
100      return grossPrice;
101   }
102
103   /**
104    * Sets details on item based gross price excluding taxes.
105    *
106    * @param grossPrice the new  the item gross price
107    * @return the specified agreement
108    */
109   public SpecifiedAgreement setGrossPrice(GrossPrice grossPrice) {
110      this.grossPrice = grossPrice;
111      return this;
112   }
113
114   /**
115    * Gets the details on net price without tax
116    * The net prices included all allowances and charges, but no taxes.
117    *
118    * @return the net price product trade price
119    */
120   @Valid
121   @XmlElement(name = "NetPriceProductTradePrice")
122   public Price getNetPrice() {
123      return netPrice;
124   }
125
126   /**
127    * Sets the details on net price without tax
128    * The net prices included all allowances and charges, but no taxes.
129    *
130    * @param netPrice the new net price product trade price
131    * @return the supply chain trade agreement
132    */
133   public SpecifiedAgreement setNetPrice(Price netPrice) {
134      this.netPrice = netPrice;
135      return this;
136   }
137
138   /**
139    * Gets the customer order referenced document.
140    * 
141    * @return the customer order referenced document
142    */
143   @Valid
144   @Extended
145   @Override
146   @XmlElement(name = "CustomerOrderReferencedDocument")
147   public ReferencedDocumentItem getCustomerOrder() {
148      return customerOrder;
149   }
150
151   /**
152    * Sets the customer order referenced document.
153    * 
154    * @param customerOrder the new customer order referenced document
155    * @return the supply chain trade agreement
156    */
157   @Override
158   public SpecifiedAgreement setCustomerOrder(ReferencedDocumentItem customerOrder) {
159      this.customerOrder = customerOrder;
160      return this;
161   }
162
163}