All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tectonica.jonix.onix3.Tax Maven / Gradle / Ivy

/*
 * Copyright (C) 2012-2024 Zach Melamed
 *
 * Latest version available online at https://github.com/zach-m/jonix
 * Contact me at [email protected]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tectonica.jonix.onix3;

import com.tectonica.jonix.common.JPU;
import com.tectonica.jonix.common.ListOfOnixDataCompositeWithKey;
import com.tectonica.jonix.common.ListOfOnixElement;
import com.tectonica.jonix.common.OnixComposite.OnixSuperComposite;
import com.tectonica.jonix.common.codelist.ProductIdentifierTypes;
import com.tectonica.jonix.common.codelist.RecordSourceTypes;
import com.tectonica.jonix.common.struct.JonixProductIdentifier;

import java.io.Serializable;
import java.util.function.Consumer;

/*
 * NOTE: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT MANUALLY
 */

/**
 * 

Tax composite

*

* A repeatable group of data elements which together specify tax included within a price amount. Optional, and used * only when <PriceType> indicates an inc-tax price. For items to which different taxes or tax rates apply * (eg mixed media products in the UK which are partly taxed at standard rate and partly at zero rate), the * composite is repeated for each separate tax or tax rate. Although only one of <TaxRatePercent> or * <TaxAmount> is mandatory within the composite, it is recommended that all tax elements in the composite should * be explicitly populated. *

*

* If the tax regime requires separate tax rates and amounts linked explicitly to particular product parts (eg in * Germany), the <ProductIdentifier> composite may be included in each <Tax> composite. Where tax is payable * on multiple product parts, each should have its own instance of the <Tax> composite. *

* * * * * * * * * * * * * *
Reference name<Tax>
Short tag<tax>
Cardinality0…n
*

* This tag may be included in the following composites: *

    *
  • <{@link Price}>
  • *
*

* Possible placements within ONIX message: *

    *
  • {@link Product} ⯈ {@link ProductSupply} ⯈ {@link SupplyDetail} ⯈ {@link Reissue} ⯈ {@link Price} ⯈ * {@link Tax}
  • *
  • {@link Product} ⯈ {@link ProductSupply} ⯈ {@link SupplyDetail} ⯈ {@link Price} ⯈ {@link Tax}
  • *
*/ public class Tax implements OnixSuperComposite, Serializable { private static final long serialVersionUID = 1L; public static final String refname = "Tax"; public static final String shortname = "tax"; ///////////////////////////////////////////////////////////////////////////////// // ATTRIBUTES ///////////////////////////////////////////////////////////////////////////////// /** * (type: dt.DateOrDateTime) */ public String datestamp; /** * (type: dt.NonEmptyString) */ public String sourcename; public RecordSourceTypes sourcetype; ///////////////////////////////////////////////////////////////////////////////// // CONSTRUCTION ///////////////////////////////////////////////////////////////////////////////// private boolean initialized; private final boolean exists; private final org.w3c.dom.Element element; public static final Tax EMPTY = new Tax(); public Tax() { exists = false; element = null; initialized = true; // so that no further processing will be done on this intentionally-empty object } public Tax(org.w3c.dom.Element element) { exists = true; initialized = false; this.element = element; datestamp = JPU.getAttribute(element, "datestamp"); sourcename = JPU.getAttribute(element, "sourcename"); sourcetype = RecordSourceTypes.byCode(JPU.getAttribute(element, "sourcetype")); } @Override public void _initialize() { if (initialized) { return; } initialized = true; JPU.forElementsOf(element, e -> { final String name = e.getNodeName(); switch (name) { case TaxRatePercent.refname: case TaxRatePercent.shortname: taxRatePercent = new TaxRatePercent(e); break; case TaxType.refname: case TaxType.shortname: taxType = new TaxType(e); break; case TaxRateCode.refname: case TaxRateCode.shortname: taxRateCode = new TaxRateCode(e); break; case TaxableAmount.refname: case TaxableAmount.shortname: taxableAmount = new TaxableAmount(e); break; case TaxAmount.refname: case TaxAmount.shortname: taxAmount = new TaxAmount(e); break; case ProductIdentifier.refname: case ProductIdentifier.shortname: productIdentifiers = JPU.addToList(productIdentifiers, new ProductIdentifier(e)); break; case PricePartDescription.refname: case PricePartDescription.shortname: pricePartDescriptions = JPU.addToList(pricePartDescriptions, new PricePartDescription(e)); break; default: break; } }); } /** * @return whether this tag (<Tax> or <tax>) is explicitly provided in the ONIX XML */ @Override public boolean exists() { return exists; } public void ifExists(Consumer action) { if (exists) { action.accept(this); } } @Override public org.w3c.dom.Element getXmlElement() { return element; } ///////////////////////////////////////////////////////////////////////////////// // MEMBERS ///////////////////////////////////////////////////////////////////////////////// private TaxRatePercent taxRatePercent = TaxRatePercent.EMPTY; /** *

* A tax rate expressed numerically as a percentage. Optional and non-repeating; but either <TaxRatePercent> * or <TaxAmount> or both must be present in each occurrence of the <Tax> composite. *

* Jonix-Comment: this field is required */ public TaxRatePercent taxRatePercent() { _initialize(); return taxRatePercent; } private TaxType taxType = TaxType.EMPTY; /** *

* An ONIX code identifying a tax type, eg VAT. Optional, and non-repeating. *

* Jonix-Comment: this field is optional */ public TaxType taxType() { _initialize(); return taxType; } private TaxRateCode taxRateCode = TaxRateCode.EMPTY; /** *

* An ONIX code which specifies a tax rate. Optional and non-repeating. *

* Jonix-Comment: this field is optional */ public TaxRateCode taxRateCode() { _initialize(); return taxRateCode; } private TaxableAmount taxableAmount = TaxableAmount.EMPTY; /** *

* The amount of the unit price of the product, excluding tax, which is taxable at the rate specified in an * occurrence of the <Tax> composite. Optional and non-repeating; but required if tax is charged on part of * the price. Omission of this element implies that tax is charged on the full amount of the price. *

* Jonix-Comment: this field is optional */ public TaxableAmount taxableAmount() { _initialize(); return taxableAmount; } private TaxAmount taxAmount = TaxAmount.EMPTY; /** *

* The amount of tax chargeable at the rate specified in an occurrence of the <Tax> composite. Optional and * non-repeating; but either <TaxRatePercent> or <TaxAmount> or both must be present in each occurrence * of the <Tax> composite. *

* Jonix-Comment: this field is optional */ public TaxAmount taxAmount() { _initialize(); return taxAmount; } private ListOfOnixDataCompositeWithKey productIdentifiers = JPU.emptyListOfOnixDataCompositeWithKey(ProductIdentifier.class); /** *

* Optional and repeatable group of data elements which together specify one or more identifiers of a product part * in accordance with a specified scheme, used here only when it is necessary to link a particular tax rate or * amount with a particular product part contained within a multiple-item product or a trade pack. All identifiers * included here must also be included in an instance of <ProductPart>, and where multiple identifiers are * provided in any one occurrence of the <Tax> composite, they must all identify the same product part. *

* Jonix-Comment: this list may be empty */ public ListOfOnixDataCompositeWithKey productIdentifiers() { _initialize(); return productIdentifiers; } private ListOfOnixElement pricePartDescriptions = ListOfOnixElement.empty(); /** *

* A name or description which identifies a part of the product price that is subject to the relevant tax, for * example a product part that may be taxed with a particular tax rate or amount (separately from other components), * or a levy added to a product price that is itself subject to tax. Optional, and repeatable to provide parallel * descriptive text in multiple languages. The language attribute is optional for a single instance of * <PricePartDescription>, but must be included in each instance if <PricePartDescription> is repeated. *

* Jonix-Comment: this list may be empty */ public ListOfOnixElement pricePartDescriptions() { _initialize(); return pricePartDescriptions; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy