<?php
namespace App\Worldspan\StructureParser\Structures\Ticketing;

class Price extends \App\Worldspan\StructureParser\Structures\Base\Price
{
	protected function _getData()
	{
		list($parsedStructure, , $transactionIndexes, $internalAssociations) = $this->getTransactionDetails();

		$item = new \App\Worldspan\StructureParser\Types\Price();

		$passengerWithRG = $internalAssociations['passenger->passengerWithRG'][$transactionIndexes['paxIdx']][0];

		$RG = $parsedStructure['passenger'][$passengerWithRG]['RG'];
		$R8 = $parsedStructure['passenger'][$passengerWithRG]['R8'];
		if ($RG['noFare']) {
			return $item;
		}

		$currency = $this->determineCurrency($parsedStructure, $RG, [], [], [], []);

		if ($transactionIndexes['loadPricesAsReissue']) {
			// reissue for MCO's, used for US/Downtown
			$RX = $parsedStructure['passenger'][$passengerWithRG]['RX'];
			$item = $this->intern_loadSupplierPriceFromRX($item, $currency, $RX);
		}
		else {
			// ticketing default
			$item = $this->intern_loadSupplierPriceFromRG($item, $currency, $RG);
		}

		$item = $this->internal_extract_commission($item, $currency, $R8);
		$item = $this->internal_extract_serviceFee($item);
		$item = $this->internal_extract_discount($item);
		$item = $this->internal_extract_formOfPaymentFromR7($item, $parsedStructure['R7']);
		$item = $this->internal_extract_determineFareCalculation($item, $parsedStructure, $internalAssociations, $parsedStructure['passenger'][$passengerWithRG]['RB']);

		return $item;
	}

}
