Skip to content

Commit

Permalink
Merge pull request amabnl#86 in FLIGHT/service.amadeus from fix-get-p…
Browse files Browse the repository at this point in the history
…rice-for-manipulated-pricing to master

* commit 'e8bf3dd13de5ed3c2a72fa77f66f77886a50ee1d':
  - fixing internal server error for manipulated price-quotes
  • Loading branch information
mlamm committed Sep 17, 2018
2 parents cd2b0e0 + e8bf3dd commit c9b727f
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/Price/Model/PriceResponseTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,28 @@ public function mapResult(\stdClass $response) : PriceGetResponse
$passengerPrice = new ArrayCollection();

if (array_key_exists('pricingInformation', $fareList)) {
$price->setValidatingCarrier(
(string) $response->fareList->validatingCarrier
->carrierInformation
->carrierCode
);
$tktDate = '0000-00-00';
$tktDate = null;
foreach ($fareList['lastTktDate'] as $lastTktDate) {
if ($lastTktDate->businessSemantic == 'LT') {
$tktDate = $lastTktDate->dateTime->year
. '-' . $lastTktDate->dateTime->month
. '-' . $lastTktDate->dateTime->day;
}
};
$price->setLastTicketingDate(date('Y-m-d', strtotime($tktDate)));
$price->setValidatingCarrier(
(string) $fareList['validatingCarrier']
->carrierInformation
->carrierCode
);
}

if ($tktDate === null) {
$price->setLastTicketingDate('0000-00-00');
} else {
$price->setLastTicketingDate(date('Y-m-d', strtotime($tktDate)));
}

if (isset($fareList['validatingCarrier'])) {
$price->setValidatingCarrier(
(string)$fareList['validatingCarrier']
->carrierInformation
->carrierCode
);
}
$passengerPrice->add($this->mapPassengerPrice((object) $fareList));
} else {
$passengerPrice = new ArrayCollection();
Expand Down Expand Up @@ -97,8 +100,10 @@ public function mapPassengerPrice($fare) : PassengerPrice
$price = new PassengerPrice();
$totalTax = 0.00;

foreach ($fare->taxInformation as $taxData) {
$totalTax += (float) $taxData->amountDetails->fareDataMainInformation->fareAmount;
if (isset($fare->taxInformation)) {
foreach ($fare->taxInformation as $taxData) {
$totalTax += (float) $taxData->amountDetails->fareDataMainInformation->fareAmount;
}
}

$price->setTotalTax(round($totalTax, 2));
Expand Down

0 comments on commit c9b727f

Please sign in to comment.