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   @NotNull
043   @Valid
044   @XmlElement(name = "SpecifiedExchangedDocumentContext", required = true)
045   private Context context;
046
047   @NotNull
048   @Valid
049   @XmlElement(name = "HeaderExchangedDocument", required = true)
050   private Header header;
051
052   @NotNull
053   @Valid
054   @XmlElement(name = "SpecifiedSupplyChainTradeTransaction", required = true)
055   private Trade trade;
056
057   Invoice() {
058   }
059
060   /**
061    * Instantiates a new invoice with a profile.
062    * 
063    * @param profile the profile
064    */
065   public Invoice(ConformanceLevel profile) {
066      this.context = new Context(profile);
067   }
068
069   /**
070    * Gets the exchanged document context.
071    * 
072    * @return the exchanged document context
073    */
074   public Context getContext() {
075      return context;
076   }
077
078   /**
079    * Sets the exchanged document context.
080    * 
081    * @param context the new exchanged document context
082    * @return the invoice
083    */
084   public Invoice setContext(Context context) {
085      this.context = context;
086      return this;
087   }
088
089   /**
090    * Gets the document header
091    * 
092    * @return the exchange document header
093    */
094   public Header getHeader() {
095      return header;
096   }
097
098   /**
099    * Sets the header.
100    * 
101    * @param header the new exchange document header
102    * @return the invoice
103    */
104   public Invoice setHeader(Header header) {
105      this.header = header;
106      return this;
107   }
108
109   /**
110    * Gets the trade transaction.
111    *
112    * @return the trade
113    */
114   public Trade getTrade() {
115      return trade;
116   }
117
118   /**
119    * Sets the trade transaction.
120    *
121    * @param trade the new trade
122    * @return the invoice
123    */
124   public Invoice setTrade(Trade trade) {
125      this.trade = trade;
126      return this;
127   }
128}