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.validator.annotation.NotBlank; 022import io.konik.zugferd.unece.codes.Reference; 023import io.konik.zugferd.unqualified.ID; 024 025import javax.validation.constraints.NotNull; 026import javax.xml.bind.annotation.XmlAccessType; 027import javax.xml.bind.annotation.XmlAccessorType; 028import javax.xml.bind.annotation.XmlElement; 029import javax.xml.bind.annotation.XmlType; 030 031/** 032 * = The Tax Registration 033 * 034 * Represents the tax number and its type. 035 * The {@link ID#getValue()} is value added tax identification number 036 * The {@link ID#getSchemeId()} is the Tax payer's number or VAT number according to (UNCL 1153) eg. FC or VA 037 */ 038@XmlAccessorType(XmlAccessType.FIELD) 039@XmlType(name = "TaxRegistrationType", propOrder = { "id" }) 040public class TaxRegistration { 041 042 @XmlElement(name = "ID") 043 private ID id; 044 045 /** Instantiates a new tax registration. */ 046 public TaxRegistration() { 047 this.id = new ID(); 048 } 049 050 /** 051 * Instantiates a new tax registration without a type. 052 * 053 * @param taxNumber the id 054 */ 055 public TaxRegistration(String taxNumber) { 056 this.id = new ID(taxNumber); 057 } 058 059 /** 060 * Instantiates a new tax registration. 061 * 062 * @param taxNumber the tax id 063 * @param typeOfTax the scheme id 064 */ 065 public TaxRegistration(String taxNumber, Reference typeOfTax) { 066 this.id = new ID(taxNumber, typeOfTax.getCode()); 067 } 068 069 /** 070 * Gets the tax number. 071 * 072 * Example:: {@code DE234567891} 073 * 074 * @return the number 075 */ 076 @NotBlank 077 public String getTaxNumber() { 078 return id.getValue(); 079 } 080 081 /** 082 * Sets the tax number. 083 * 084 * Example:: {@code DE234567891} 085 * 086 * @param taxNumber the new value 087 * @return the tax registration 088 */ 089 public TaxRegistration setTaxNumber(String taxNumber) { 090 this.id.setValue(taxNumber); 091 return this; 092 } 093 094 /** 095 * Gets the tax type. The UNCL 1153 tax type. 096 * 097 * Example:: {@code VA} 098 * 099 * @return the type 100 */ 101 @NotNull 102 public Reference getType() { 103 return Reference.getByCode(id.getSchemeId()); 104 } 105 106 /** 107 * Sets the UNCL 1153 tax type. 108 * 109 * Example:: {@code VA} 110 * 111 * @param taxType the new type 112 * @return the tax registration 113 */ 114 public TaxRegistration setType(Reference taxType) { 115 this.id.setSchemeId(taxType.getCode()); 116 return this; 117 } 118 119}