<?php
namespace ModulesAbstract\ElectronicInvoice\UBL21Structure;

/**
 * TaxCategory
 *
 * @see http://www.datypic.com/sc/ubl21/e-cac_TaxCategory.html
 *
 * @see https://docs.peppol.eu/pracc/catalogue/1.0/codelist/UNCL5305/
 */
class TypeTaxCategory extends AbstractPeppolElement
{

	/**
	 * cbc:ID, 0..1, optional tag
	 *
	 * An identifier for this tax category.
	 * @var mixed
	 */
	public $ID = null;

	/**
	 * cbc:Name, 0..1, optional tag
	 *
	 * The name of this tax category.
	 * @var mixed
	 */
	public $Name = null;

	/**
	 * cbc:Percent, 0..1, optional tag
	 *
	 * The tax rate for this category, expressed as a percentage.
	 * @var mixed
	 */
	public $Percent = null;

	/**
	 * cbc:BaseUnitMeasure, 0..1, optional tag
	 *
	 * A Unit of Measures used as the basic for the tax calculation applied at a certain rate per unit.
	 * @var mixed
	 */
	public $BaseUnitMeasure = null;

	/**
	 * cbc:PerUnitAmount, 0..1, optional tag
	 *
	 * Where a tax is applied at a certain rate per unit, the rate per unit applied.
	 * @var mixed
	 */
	public $PerUnitAmount = null;

	/**
	 * cbc:TaxExemptionReasonCode, 0..1, optional tag
	 *
	 * The reason for tax being exempted, expressed as a code.
	 * @var mixed
	 */
	public $TaxExemptionReasonCode = null;

	/**
	 * cbc:TaxExemptionReason, 0..*
	 *
	 * The reason for tax being exempted, expressed as text.
	 * @var mixed
	 */
	public $TaxExemptionReason = null;

	/**
	 * cbc:TierRange, 0..1, optional tag
	 *
	 * Where a tax is tiered, the range of taxable amounts that determines the rate of tax applicable to this tax category.
	 * @var mixed
	 */
	public $TierRange = null;

	/**
	 * cbc:TierRatePercent, 0..1, optional tag
	 *
	 * Where a tax is tiered, the tax rate that applies within the specified range of taxable amounts for this tax category.
	 * @var mixed
	 */
	public $TierRatePercent = null;

	/**
	 * cac:TaxScheme, 1..1, MANDATORY tag
	 *
	 * The taxation scheme within which this tax category is defined.
	 * @var mixed
	 */
	public $TaxScheme = null;


	public function renderField(string $field, $value): string
	{
		$fieldMapping = [
			'Percent' => 'NF.1',
		];
		return $this->customRenderer($fieldMapping[$field], $value);
	}
}
