Skip to content

Commit

Permalink
removed the COD amount rounding
Browse files Browse the repository at this point in the history
Different currencies have different rules regarding Cash on Delivery. GLS can only collect a certain fraction of HUF in cash. That makes cash collection difficult in other currencies, e.g. Romanian RON or European EUR.
Thus, the rounding should be handled by the client and not the library for now.
  • Loading branch information
schiggi authored Nov 27, 2020
1 parent f5d4c62 commit 7e9b530
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ public function getParcelNumbers($parcel_data) {
// validate parcel data
$this->validateParcelPrepare($parcel);

$parcel['CodCurr'] = $parcel['CodCurr'] ?? 'HUF';
// the smallest fraction is 5 for COD amount
$parcel['CodAmount'] = round((float)$parcel['CodAmount'] / 5, 0) * 5;
$parcel['CodCurr'] = $parcel['CodCurr'] ?? 'HUF';
$data .= "<Shipment SenderID=\"" . $this->config["client_number"] . "\" ExpSenderID=\"\" PickupDate=\"" . (isset($parcel["PickupDate"]) ? date(DATE_ATOM, strtotime($parcel["PickupDate"])) : date(DATE_ATOM)) . "\" ClientRef=\"" . $parcel['ClientRef'] . "\" CODAmount=\"" . $parcel['CodAmount'] . "\" CODCurr=\"" . $parcel['CodCurr'] . "\" CODRef=\"" . $parcel['CodRef'] . "\" PCount=\"" . (isset($parcel["Pcount"]) ? $parcel["Pcount"] : "1") . "\" Info=\"".(isset($parcel['ConsigComment']) ? $parcel['ConsigComment'] : "" ) . "\">";
$data .= "<From Name=\"" . $parcel['SenderName'] . "\" Address=\"" . $parcel['SenderAddress'] . "\" ZipCode=\"" . $parcel['SenderZipcode'] . "\" City=\"" . $parcel['SenderCity'] . "\" CtrCode=\"" . $parcel['SenderCountry'] . "\" ContactName=\"" . $parcel['SenderContact'] . "\" ContactPhone=\"" . $parcel['SenderPhone'] . "\" EmailAddress=\"" . $parcel['SenderEmail'] . "\" />";
$data .= "<To Name=\"" . $parcel['ConsigName'] . "\" Address=\"" . $parcel['ConsigAddress'] . "\" ZipCode=\"" . $parcel['ConsigZipcode'] . "\" City=\"" . $parcel['ConsigCity'] . "\" CtrCode=\"" . $parcel['ConsigCountry'] . "\" ContactName=\"" . $parcel['ConsigContact'] . " #" . $parcel["ClientRef"] . "\" ContactPhone=\"" . $parcel["ConsigPhone"] . "\" EmailAddress=\"" . $parcel["ConsigEmail"] . "\" />";
Expand Down Expand Up @@ -421,4 +419,4 @@ private function validateParcelPrepare ($data) {
echo $exception->getFullMessage();
}
}
}
}

0 comments on commit 7e9b530

Please sign in to comment.