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