<?php
namespace App\Amadeus\CompatibilityWithImportedOrders; class TaxManipulations extends \App\Utils\BaseParser\Structure\CompatibilityWithImportedOrders\TaxManipulations { protected function getAssocMapFromTransactionTypeToEntity() { return [ 'ticketing' => [ 'serviceCode' => ['ticketing', ], 'transactionStatus' => ['new', 'reissued', 'refunded', ], ], 'reissue' => [ 'serviceCode' => ['ticketing', ], 'transactionStatus' => ['reissue', ], ], 'refund' => [ 'serviceCode' => ['ticketing', ], 'transactionStatus' => ['refund', ], ], 'EMD' => [ 'serviceCode' => ['EMD', ], 'transactionStatus' => ['new', ], ], 'MCO' => [ 'serviceCode' => ['MCO', ], 'transactionStatus' => ['new', ], ], 'car' => [ 'serviceCode' => ['car', ], 'transactionStatus' => ['new', ], ], 'hotel' => [ 'serviceCode' => ['hotel', ], 'transactionStatus' => ['new', ], ], ]; } protected function getGdsConfig() { return \App\Amadeus\Config::getInstance(); } protected function getSystemCode() { return \Entity\AmadeusService::systemCode; } protected function getPriceTaxComponentObject() { return new \App\Amadeus\StructureParser\Types\PriceTaxComponent(); } public function TINA_getServiceItinerary($entity, $parentEntity=null) { $serviceSegments = $entity->transactionSegmentData->getSegments(); if ($entity->transactionStatus=='refund') { $serviceSegments = $parentEntity->transactionSegmentData->getSegments(); } return $serviceSegments; } protected function action_moveTaxToSupplier(array $taxManipulationRule, $applyRule, $priceData) { $applyRule = true; $taxes = $priceData->tax->getTaxesByCode($taxManipulationRule['taxCode']); if ($applyRule) { foreach ($taxes as $tax) { if ($tax->currency != $priceData->supplierCurrency) { $applyRule = false; throw new \App\Amadeus\StructureParser\StructureException(sprintf("[%s] cannot move tax %s, the tax currency should be the same as the supplier currency(%s, %s)", __METHOD__, $taxManipulationRule['taxCode'], $tax->currency, $priceData->supplierCurrency)); } } } if ($applyRule) { $selectedTaxAmount = 0; foreach ($priceData->tax->components as $idx => $tax) { if ($tax->code == $taxManipulationRule['taxCode']) { $selectedTaxAmount+= $tax->amount + $tax->VAT; $priceData->tax->setAmount($priceData->tax->getAmount() - ($tax->amount + $tax->VAT)); unset($priceData->tax->components[$idx]); } } $priceData->tax->components = array_values($priceData->tax->components); $priceData->supplier+= $selectedTaxAmount; $priceData->total = $priceData->calculateTotal(); $priceData->totalVAT = $priceData->calculateTotalVAT(); } return [$applyRule, $priceData, ]; } } 