<?php
namespace ModulesAbstract\ElectronicInvoice\UBL30Structure;

/**
 * cac:AllowanceCharge, BG-20, BG-21
 * A group of business terms providing information about allowances applicable to the Invoice as a whole. A group of business terms providing information about charges and taxes other than VAT, applicable to the Invoice as a whole.
 * @see https://docs.peppol.eu/poacc/billing/3.0/syntax/ubl-invoice/cac-AllowanceCharge/
 */
class AllowanceCharge extends AbstractPeppolElement
{

	/**
	 * cbc:ChargeIndicator, MANDATORY tag
	 *
	 * Use “true” when informing about Charges and “false” when informing about Allowances.
	 *
	 * Example value: false
	 * @var mixed
	 */
	public $ChargeIndicator = null;

	/**
	 * cbc:AllowanceChargeReasonCode, optional tag
	 *
	 * Document level allowance or charge reason code
	 * The reason for the document level allowance or charge, expressed as a code. For allowances a subset of codelist UNCL5189
	 *   is to be used, and for charges codelist UNCL7161 applies. The Document level allowance reason code and the Document
	 *   level allowance reason shall indicate the same allowance reason
	 *
	 * Example value: 95
	 * @var mixed
	 */
	public $AllowanceChargeReasonCode = null;

	/**
	 * cbc:AllowanceChargeReason, optional tag
	 *
	 * Document level allowance or charge reason
	 * The reason for the document level allowance or charge, expressed as text. The Document level allowance reason code and
	 *   the Document level allowance reason shall indicate the same allowance reason
	 *
	 * Example value: Discount
	 * @var mixed
	 */
	public $AllowanceChargeReason = null;

	/**
	 * cbc:MultiplierFactorNumeric, optional tag
	 *
	 * Document level allowance or charge percentage
	 * The percentage that may be used, in conjunction with the document level allowance base amount, to calculate the document
	 *   level allowance or charge amount. To state 20%, use value 20.
	 *
	 * Example value: 20
	 * @var mixed
	 */
	public $MultiplierFactorNumeric = null;

	/**
	 * cbc:Amount, MANDATORY tag
	 *
	 * Document level allowance or charge amount
	 * The amount of an allowance or a charge, without VAT. Must be rounded to maximum 2 decimals
	 *
	 * Example value: 200
	 * @var mixed
	 */
	public $Amount = null;

	/**
	 * cbc:BaseAmount, optional tag
	 *
	 * Document level allowance or charge base amount
	 * The base amount that may be used, in conjunction with the document level allowance or charge percentage, to calculate
	 *   the document level allowance or charge amount. Must be rounded to maximum 2 decimals
	 *
	 * Example value: 1000
	 * @var mixed
	 */
	public $BaseAmount = null;

	/**
	 * cac:TaxCategory, MANDATORY tag
	 *
	 * TAX CATEGORY
	 *
	 * @var mixed
	 */
	public $TaxCategory = null;

	public function renderField(string $field, $value): string
	{
		$fieldMapping = [
			'ChargeIndicator' => 'B',
		];

		return $this->customRenderer($fieldMapping[$field], $value);
	}

}
