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.unece.codes.Reference;
022import io.konik.zugferd.unqualified.ID;
023
024import javax.xml.bind.annotation.XmlAccessType;
025import javax.xml.bind.annotation.XmlAccessorType;
026import javax.xml.bind.annotation.XmlElement;
027import javax.xml.bind.annotation.XmlType;
028
029
030/**
031 * = The Tax Registration
032 * 
033 * Represents the tax number and its type. 
034 * The {@link ID#getValue()} is value added tax identification number
035 * The {@link ID#getSchemeId()} is the Tax payer's number or VAT number according to (UNCL 1153) eg. FC or VA
036 */
037@XmlAccessorType(XmlAccessType.FIELD)
038@XmlType(name = "TaxRegistrationType", propOrder = { "id" })
039public class TaxRegistration {
040
041        /** The id. */
042        @XmlElement(name = "ID")
043        private final 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         * Profile:: BASIC
073         * 
074         * Example:: {@code DE234567891}
075         * 
076         * @return the number
077         */
078        public String getNumber() {
079                return id.getValue();
080        }
081
082        /**
083    * Sets the tax number.
084    * 
085    * Profile:: BASIC
086    * 
087    * Example:: {@code DE234567891}
088    *
089    * @param taxNumber the new value
090    * @return the tax registration
091    */
092        public TaxRegistration setNumber(String taxNumber) {
093                this.id.setValue(taxNumber);
094                return this;
095        }
096
097        /**
098    * Gets the tax type. The UNCL 1153 tax type.
099    * 
100    * Profile:: BASIC
101    * 
102    * Example:: {@code VA}
103    *
104    * @return the type
105    */
106        public Reference getType() {
107                return Reference.getByCode(id.getSchemeId());
108        }
109
110        /**
111    * Sets the UNCL 1153 tax type.
112    * 
113    * Profile:: BASIC
114    * 
115    * Example:: {@code VA}
116    *
117    * @param taxType the new type
118    * @return the tax registration
119    */
120        public TaxRegistration setType(Reference taxType) {
121                this.id.setValue(taxType.getCode());
122                return this;
123        }
124
125}