<?php
namespace App\Galileo\StructureParser\Structures\Hotel; class Price extends \App\Galileo\StructureParser\Structures\Base\Price { protected function _getData() { list($parsedStructure, $transactionType, $transactionIndexes, $internalAssociations) = $this->getTransactionDetails(); $item = new \App\Galileo\StructureParser\Types\Price(); if ($transactionIndexes['source']=='A167') { $item = $this->_getData_A167($item, $parsedStructure, $transactionType, $transactionIndexes, $internalAssociations); } elseif($transactionIndexes['source']=='A16A') { $item = $this->_getData_A16A($item, $parsedStructure, $transactionType, $transactionIndexes, $internalAssociations); } else { throw new \Exception("Unknown transaction source: '{$transactionIndexes['source']}'"); } return $item; } protected function _getData_A167(\App\Utils\BaseParser\Structure\StructureParser\Types\Price $item, $parsedStructure, $transactionType, $transactionIndexes, $internalAssociations) { if (count($parsedStructure['A167'])>1) { $this->transaction->getMessagesCollector()->addWarning(sprintf("[%s] There are multiple A167 lines defined. Using only the first one", __METHOD__)); } $A167 = $parsedStructure['A167'][0]; $item->componentSetAndUpdateTotal(new \App\Utils\BaseParser\Structure\StructureParser\Types\PriceComponent( 'supplier', 'A16ODD_:rateQuoted', $A167['A167OD']['A16ODD_']['rateQuoted']['amount'], null, $A167['A167OD']['A16ODD_']['rateQuoted']['currency'] )); return $item; } protected function _getData_A16A(\App\Utils\BaseParser\Structure\StructureParser\Types\Price $item, $parsedStructure, $transactionType, $transactionIndexes, $internalAssociations) { if (count($parsedStructure['A16A'])>1) { $this->transaction->getMessagesCollector()->addWarning(sprintf("[%s] There are multiple A16A lines defined. Using only the first one", __METHOD__)); } $A16A = $parsedStructure['A16A'][0]; $item->componentSetAndUpdateTotal(new \App\Utils\BaseParser\Structure\StructureParser\Types\PriceComponent( 'supplier', 'A16O1_:approximateTotal', $A16A['A16AO1']['A16O1_']['approximateTotal']['amount'], null, $A16A['A16AO1']['A16O1_']['approximateTotal']['currency'] )); return $item; } } 