001/*
002 * Copyright (C) 2014 konik.io
003 *
004 * This file is part of Konik library.
005 *
006 * Konik library is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU Affero General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * Konik library is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU Affero General Public License for more details.
015 *
016 * You should have received a copy of the GNU Affero General Public License
017 * along with Konik library.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package io.konik.zugferd;
020
021import io.konik.zugferd.entity.Context;
022import io.konik.zugferd.entity.Header;
023import io.konik.zugferd.entity.trade.Trade;
024import io.konik.zugferd.profile.ConformanceLevel;
025
026import javax.validation.Valid;
027import javax.validation.constraints.NotNull;
028import javax.xml.bind.annotation.XmlAccessType;
029import javax.xml.bind.annotation.XmlAccessorType;
030import javax.xml.bind.annotation.XmlElement;
031import javax.xml.bind.annotation.XmlRootElement;
032import javax.xml.bind.annotation.XmlType;
033
034/**
035 * = The Root of the ZUGFeRD Invoice Model.
036 */
037@XmlRootElement(name = "CrossIndustryDocument")
038@XmlAccessorType(XmlAccessType.FIELD)
039@XmlType(propOrder = { "context", "header", "trade" })
040public class Invoice {
041
042   @XmlElement(name = "SpecifiedExchangedDocumentContext", required = true)
043   private Context context;
044   @XmlElement(name = "HeaderExchangedDocument", required = true)
045   private Header header;
046   @XmlElement(name = "SpecifiedSupplyChainTradeTransaction", required = true)
047   private Trade trade;
048
049   Invoice() {
050   }
051
052   /**
053    * Instantiates a new invoice with a profile.
054    * 
055    * @param profile the profile
056    */
057   public Invoice(ConformanceLevel profile) {
058      this.context = new Context(profile);
059   }
060
061   /**
062    * Gets the exchanged document context.
063    * 
064    * @return the exchanged document context
065    */
066   @NotNull
067   @Valid
068   public Context getContext() {
069      return context;
070   }
071
072   /**
073    * Sets the exchanged document context.
074    * 
075    * @param context the new exchanged document context
076    * @return the invoice
077    */
078   public Invoice setContext(Context context) {
079      this.context = context;
080      return this;
081   }
082
083   /**
084    * Gets the document header
085    * 
086    * @return the exchange document header
087    */
088   @NotNull
089   @Valid
090   public Header getHeader() {
091      return header;
092   }
093
094   /**
095    * Sets the header.
096    * 
097    * @param header the new exchange document header
098    * @return the invoice
099    */
100   public Invoice setHeader(Header header) {
101      this.header = header;
102      return this;
103   }
104
105   /**
106    * Gets the trade transaction.
107    *
108    * @return the trade
109    */
110   @NotNull
111   @Valid
112   public Trade getTrade() {
113      return trade;
114   }
115
116   /**
117    * Sets the trade transaction.
118    *
119    * @param trade the new trade
120    * @return the invoice
121    */
122   public Invoice setTrade(Trade trade) {
123      this.trade = trade;
124      return this;
125   }
126}