<?php
namespace App\Sabre\StructureParser\Structures\Base;

abstract class PriceRefundDistributed extends \App\Utils\BaseParser\Structure\StructureParser\Structures\Base\PriceRefundDistributed
{
	protected function createPriceTaxComponentObject($code=null, $amount=null, $currency=null, $VAT=null)
	{
		return new \App\Sabre\StructureParser\Types\PriceTaxComponent($code, $amount, $currency, $VAT);
	}

	protected function createPriceObject()
	{
		return new \App\Sabre\StructureParser\Types\Price();
	}

	protected function _getData()
	{
		list($totalPrice, $remainingPrice) = $this->transaction->getAmounts();
		$referenceService = $this->transaction->getReferenceService();
		$referencePrice =  $referenceService->transactionData->price;

		if (($referencePrice->commission!==null && $totalPrice->commission!==null) || ($referencePrice->commission===null && $totalPrice->commission===null)) {
			return $this->_getData_withExplicitRefundCommission();	// default
		}
		else {
			return $this->_getData_withoutExplicitRefundCommission();
		}
	}
}
