<?php
namespace App\Utils\BaseParser\Structure\StructureParser\Types;

/**
 * Base structure for each individual tax component
 * @author Lucian Sirbu
 */
abstract class PriceTaxComponent extends \App\Utils\BaseParser\Structure\StructureParser\Types\BaseAbstract
{
	public $amount = 	null;
	public $VAT = 		null;
	public $currency = 	null;
	public $code = 		null;

	/**
	 * Create this object with predefined params
	 * @param string $code
	 * @param float $amount
	 * @param string $currency
	 * @param string $VAT
	 */
	public function __construct($code=null, $amount=null, $currency=null, $VAT=null)
	{
		$this->code = 		$code;
		$this->amount = 	$amount;
		$this->currency = 	$currency;
		$this->VAT = 		$VAT;
	}

	/**
	 * Generate a tax unique ID, according to its current values
	 * @return string
	 */
	public function getId()
	{
		return sprintf("%s:%.6f,%.6f,%s", $this->code, $this->amount, $this->VAT, $this->currency);
	}
}
