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.*; 029import java.io.Serializable; 030 031/** 032 * = The Root of the ZUGFeRD Document Model. 033 */ 034@XmlRootElement(name = "CrossIndustryDocument") 035@XmlAccessorType(XmlAccessType.FIELD) 036@XmlType(propOrder = { "context", "header", "trade" }) 037public class Invoice implements Serializable { 038 039 @XmlElement(name = "SpecifiedExchangedDocumentContext", required = true) 040 private Context context; 041 @XmlElement(name = "HeaderExchangedDocument", required = true) 042 private Header header; 043 @XmlElement(name = "SpecifiedSupplyChainTradeTransaction", required = true) 044 private Trade trade; 045 046 Invoice() { 047 } 048 049 /** 050 * Instantiates a new invoice with a profile. 051 * 052 * @param profile the profile 053 */ 054 public Invoice(ConformanceLevel profile) { 055 this.context = new Context(profile); 056 } 057 058 /** 059 * Gets the exchanged document context. 060 * 061 * @return the exchanged document context 062 */ 063 @NotNull 064 @Valid 065 public Context getContext() { 066 return context; 067 } 068 069 /** 070 * Sets the exchanged document context. 071 * 072 * @param context the new exchanged document context 073 * @return the invoice 074 */ 075 public Invoice setContext(Context context) { 076 this.context = context; 077 return this; 078 } 079 080 /** 081 * Gets the document header 082 * 083 * @return the exchange document header 084 */ 085 @NotNull 086 @Valid 087 public Header getHeader() { 088 return header; 089 } 090 091 /** 092 * Sets the header. 093 * 094 * @param header the new exchange document header 095 * @return the invoice 096 */ 097 public Invoice setHeader(Header header) { 098 this.header = header; 099 return this; 100 } 101 102 /** 103 * Gets the trade transaction. 104 * 105 * @return the trade 106 */ 107 @NotNull 108 @Valid 109 public Trade getTrade() { 110 return trade; 111 } 112 113 /** 114 * Sets the trade transaction. 115 * 116 * @param trade the new trade 117 * @return the invoice 118 */ 119 public Invoice setTrade(Trade trade) { 120 this.trade = trade; 121 return this; 122 } 123}