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.entity; 020 021import io.konik.zugferd.unqualified.ID; 022 023import java.util.ArrayList; 024import java.util.Collections; 025import java.util.List; 026 027import javax.validation.Valid; 028import javax.validation.constraints.NotNull; 029import javax.xml.bind.annotation.XmlElement; 030import javax.xml.bind.annotation.XmlType; 031import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 032import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 033 034/** 035 * = The Trade Party 036 * 037 * Applies to a buyer, seller, order recipient or invoice recipient. 038 */ 039@XmlType(name = "TradePartyType", propOrder = { "id", "globalId", "name", "contact", "address", "taxRegistrations" }) 040public class TradeParty { 041 042 /** The vendor number or customer number */ 043 @XmlElement(name = "ID") 044 @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 045 private String id; 046 047 /** The global vendor number or customer number id */ 048 @XmlElement(name = "GlobalID") 049 private List<ID> globalId; 050 051 /** The name of the trade party. */ 052 @NotNull 053 @XmlElement(name = "Name") 054 private String name; 055 056 /** The contact person. */ 057 @Valid 058 @XmlElement(name = "DefinedTradeContact") 059 private Contact contact; 060 061 /** The postal address. */ 062 @Valid 063 @XmlElement(name = "PostalTradeAddress") 064 private Address address; 065 066 /** The tax registration. */ 067 @Valid 068 @XmlElement(name = "SpecifiedTaxRegistration") 069 private List<TaxRegistration> taxRegistrations; 070 071 /** 072 * Gets the id. 073 * 074 * Profile:: COMFORT when part of Trade.agreements.seller 075 * 076 * Example:: {@code The supplier number given by the customer/buyer } 077 * 078 * @return the id 079 */ 080 public String getId() { 081 return id; 082 } 083 084 /** 085 * Sets the id. 086 * Profile:: COMFORT when part of Trade.agreements.seller 087 * 088 * Example:: {@code The supplier number given by the customer/buyer } 089 * 090 * @param id the new id 091 * @return the trade party 092 */ 093 public TradeParty setId(String id) { 094 this.id = id; 095 return this; 096 } 097 098 /** 099 * Gets the trade party global id. (GLN, DUNS, BIC, ODETTE) 100 * 101 * Profile:: COMFORT when part of Trade.agreements.seller 102 * 103 * Example:: 104 * - {@link ID#getValue()} {@code GENODED1SPK, 4000001000005 } - {@link ID#getSchemeId()} the ISO 6523 code 105 * {@code 0021, 0088, 0060, 0177 } 106 * 107 * @return the global id 108 */ 109 public List<ID> getGlobalId() { 110 if (globalId == null) { 111 globalId = new ArrayList<ID>(); 112 } 113 return this.globalId; 114 } 115 116 /** 117 * Adds the global id. 118 * 119 * Profile:: COMFORT when part of Trade.agreements.seller 120 * 121 * Example:: 122 * - {@link ID#getValue()} {@code GENODED1SPK, 4000001000005 } - {@link ID#getSchemeId()} the ISO 6523 code 123 * {@code 0021, 0088, 0060, 0177 } 124 * 125 * @param additionalGlobalId the additional global id 126 * @return the trade party 127 */ 128 public TradeParty addGlobalId(ID additionalGlobalId) { 129 getGlobalId().add(additionalGlobalId); 130 return this; 131 } 132 133 /** 134 * Gets the trade party name. Usually the Company name. 135 * 136 * Profile:: BASIC when part of Trade.agreements.seller/buyer. 137 * 138 * Example:: {@code ACME Inc.} 139 * 140 * @return the name 141 */ 142 public String getName() { 143 return name; 144 } 145 146 /** 147 * Sets the trade party name. Usually the Company name. 148 * 149 * Profile:: BASIC when part of Trade.agreements.seller/buyer. 150 * 151 * Example:: {@code ACME Inc.} 152 * 153 * @param name the name 154 * @return the trade party 155 */ 156 public TradeParty setName(String name) { 157 this.name = name; 158 return this; 159 } 160 161 /** 162 * Gets the contact person. 163 * 164 * Profile:: BASIC when part of Trade.agreements.seller/buyer. 165 * 166 * 167 * @return the defined trade contact 168 */ 169 public Contact getContact() { 170 return contact; 171 } 172 173 /** 174 * Sets the contact person. 175 * 176 * Profile:: BASIC when part of Trade.agreements.seller/buyer. 177 * 178 * 179 * @param contact the new defined trade contact 180 * @return the trade party 181 */ 182 public TradeParty setContact(Contact contact) { 183 this.contact = contact; 184 return this; 185 } 186 187 /** 188 * Gets the postal trade address. 189 * 190 * Profile:: BASIC when part of Trade.agreements.seller/buyer. 191 * 192 * 193 * @return the postal trade address 194 */ 195 public Address getAddress() { 196 return address; 197 } 198 199 /** 200 * Sets the postal trade address. 201 * 202 * Profile:: BASIC when part of Trade.agreements.seller/buyer. 203 * 204 * 205 * @param postalAddress the new postal trade address 206 * @return the trade party 207 */ 208 public TradeParty setAddress(Address postalAddress) { 209 this.address = postalAddress; 210 return this; 211 } 212 213 /** 214 * Gets the specified tax registration. 215 * 216 * Profile:: BASIC 217 * 218 * 219 * @return the specified tax registration 220 */ 221 public List<TaxRegistration> getTaxRegistrations() { 222 if (taxRegistrations == null) { 223 taxRegistrations = new ArrayList<TaxRegistration>(); 224 } 225 return this.taxRegistrations; 226 } 227 228 /** 229 * Adds the tax registration. 230 * 231 * Profile:: BASIC 232 * 233 * 234 * @param additionalTaxRegistration an additional Tax Registration 235 * @return the trade party 236 */ 237 public TradeParty addTaxRegistrations(TaxRegistration... additionalTaxRegistration) { 238 Collections.addAll(getTaxRegistrations(), additionalTaxRegistration); 239 return this; 240 } 241 242}