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

abstract class TransactionRefundDistribuited extends Transaction
{
	/**
	 * The transaction document data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Document
	 */
	public $documents = 	null;

	/**
	 * The transaction itinerary data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Itinerary
	 */
	public $itinerary = 	null;

	/**
	 * The transaction passengers data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Passengers
	 */
	public $passengers = 	null;

	/**
	 * The transaction price data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Price
	 */
	public $price = 		null;

	/**
	 * The transaction supplier data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Supplier
	 */
	public $supplier = 		null;

	/**
	 * The transaction agent data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\User
	 */
	public $agent = 		null;

	/**
	 * The transaction relations data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Relations
	 */
	public $relations = 	null;

	/**
	 * The transaction remarks data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Remarks
	 */
	public $remarks = 		null;

	/**
	 * The transaction extra data
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Extradata
	 */
	public $extraData = 	null;

	/**
	 * The main refund transaction
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Structures\Transaction
	 */
	protected $refundRaw = null;

	/**
	 * The total amount
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Price
	 */
	protected $amountTotal = null;

	/**
	 * The remaining amount
	 * @var \App\Utils\BaseParser\Structure\StructureParser\Types\Price
	 */
	protected $amountRemaining = null;

	/**
	 * The total count of services that should be refunded
	 * @var int
	 */
	protected $servicesTotalCount = null;

	/**
	 * This service index, lower than $this->servicesTotalCount
	 * @var int
	 */
	protected $thisServiceIdx = null;

	/**
	 * List of refundable services
	 * @var array
	 */
	protected $refundableServices = [];

	/**
	 * The reference service
	 * @var \App\Entity\GeneralAbstract
	 */
	protected $referenceService = null;

	/**
	 * (non-PHPdoc)
	 * @see \App\Utils\BaseParser\Structure\StructureParser\Structures\Transaction::_getSerializedRepresentation()
	 */
	public function _getSerializedRepresentation(&$serializedObjects)
	{
		$tmpKeys = ['refundRaw', 'amountTotal', 'amountRemaining', 'servicesTotalCount', 'thisServiceIdx', 'refundableServices', 'referenceService',];
		$tmpData = array_combine($tmpKeys, array_fill(0, count($tmpKeys), null));

		foreach ($tmpKeys as $key) {
			$tmpData[$key] = $this->{$key};
			$this->{$key} = null;
		}

		$ret = parent::_getSerializedRepresentation($serializedObjects);

		foreach ($tmpKeys as $key) {
			$this->{$key} = $tmpData[$key];
			$tmpData[$key] = null;
		}

		return $ret;
	}

	/**
	 * Set the raw refund data
	 * @return \App\Utils\BaseParser\Structure\StructureParser\Structures\TransactionRefundDistribuited
	 */
	public function setRefundRaw($refundRaw)
	{
		$this->refundRaw = $refundRaw;
		return $this;
	}

	/**
	 * Get the raw refund data
	 * @return \App\Utils\BaseParser\Structure\StructureParser\Structures\Transaction
	 */
	public function getRefundRaw()
	{
		return $this->refundRaw;
	}

	/**
	 * Set the referenced service
	 * @param \App\Entity\GeneralAbstract $referenceService
	 * @return \App\Utils\BaseParser\Structure\StructureParser\Structures\TransactionRefundDistribuited
	 */
	public function setReferenceService($referenceService)
	{
		$this->referenceService = $referenceService;
		return $this;
	}

	/**
	 * Get the referenced service
	 * @return \App\Entity\GeneralAbstract
	 */
	public function getReferenceService()
	{
		return $this->referenceService;
	}

	/**
	 * Set the service index
	 * @param int $thisServiceIdx
	 * @return \App\Utils\BaseParser\Structure\StructureParser\Structures\TransactionRefundDistribuited
	 */
	public function setServiceIndex($thisServiceIdx)
	{
		$this->thisServiceIdx = $thisServiceIdx;
		return $this;
	}

	/**
	 * Get the service index
	 * @return number
	 */
	public function getServiceIndex()
	{
		return $this->thisServiceIdx;
	}

	/**
	 * Set the list of refundable services
	 * @param array $refundableServices
	 * @return \App\Utils\BaseParser\Structure\StructureParser\Structures\TransactionRefundDistribuited
	 */
	public function setRefundableServicesList($refundableServices)
	{
		$this->refundableServices = $refundableServices;
		$this->servicesTotalCount = count($refundableServices);
		return $this;
	}

	/**
	 * Get the services count
	 * @return number
	 */
	public function getServicesCount()
	{
		return $this->servicesTotalCount;
	}

	/**
	 * Set the amounts to handle
	 * @param \App\Utils\BaseParser\Structure\StructureParser\Types\Price $amountTotal
	 * @param \App\Utils\BaseParser\Structure\StructureParser\Types\Price $amountRemaining
	 * @return \App\Utils\BaseParser\Structure\StructureParser\Structures\TransactionRefundDistribuited
	 */
	public function setAmounts($amountTotal, $amountRemaining)
	{
		$this->amountTotal = $amountTotal;
		$this->amountRemaining = $amountRemaining;
		return $this;
	}

	/**
	 * Get the amounts. Returns the total and remainign amounts
	 * @return multitype:\App\Utils\BaseParser\Structure\StructureParser\Types\Price
	 */
	public function getAmounts()
	{
		return [$this->amountTotal, $this->amountRemaining,];
	}
}