|
From: <te...@us...> - 2013-07-11 02:49:38
|
Revision: 6074
http://sourceforge.net/p/web-erp/reponame/6074
Author: tehonu
Date: 2013-07-11 02:49:35 +0000 (Thu, 11 Jul 2013)
Log Message:
-----------
Proper calculation of International shipment costs and return the freight cost in the curreny of the invoice
Modified Paths:
--------------
trunk/ConfirmDispatch_Invoice.php
trunk/DeliveryDetails.php
trunk/includes/FreightCalculation.inc
Modified: trunk/ConfirmDispatch_Invoice.php
===================================================================
--- trunk/ConfirmDispatch_Invoice.php 2013-07-11 00:46:22 UTC (rev 6073)
+++ trunk/ConfirmDispatch_Invoice.php 2013-07-11 02:49:35 UTC (rev 6074)
@@ -437,6 +437,7 @@
$_SESSION['Items'.$identifier]->totalVolume,
$_SESSION['Items'.$identifier]->totalWeight,
$_SESSION['Items'.$identifier]->Location,
+ $_SESSION['Items'.$identifier]->DefaultCurrency,
$db);
$_SESSION['Items'.$identifier]->ShipVia = $BestShipper;
}
Modified: trunk/DeliveryDetails.php
===================================================================
--- trunk/DeliveryDetails.php 2013-07-11 00:46:22 UTC (rev 6073)
+++ trunk/DeliveryDetails.php 2013-07-11 02:49:35 UTC (rev 6074)
@@ -126,7 +126,9 @@
$_POST['BrAdd6'],
$_SESSION['Items'.$identifier]->totalVolume,
$_SESSION['Items'.$identifier]->totalWeight,
- $_SESSION['Items'.$identifier]->Location, $db);
+ $_SESSION['Items'.$identifier]->Location,
+ $_SESSION['Items'.$identifier]->DefaultCurrency,
+ $db);
if ( !empty($BestShipper) ){
$_POST['FreightCost'] = round($_POST['FreightCost'],2);
$_POST['ShipVia'] = $BestShipper;
@@ -917,7 +919,7 @@
</tr>
</table>';
- $DisplayVolume = locale_number_format($_SESSION['Items'.$identifier]->totalVolume,2);
+ $DisplayVolume = locale_number_format($_SESSION['Items'.$identifier]->totalVolume,5);
$DisplayWeight = locale_number_format($_SESSION['Items'.$identifier]->totalWeight,2);
echo '<br />
<table>
@@ -976,7 +978,7 @@
$DisplayTotal = locale_number_format($_SESSION['Items'.$identifier]->total,$_SESSION['Items'.$identifier]->CurrDecimalPlaces);
- $DisplayVolume = locale_number_format($_SESSION['Items'.$identifier]->totalVolume,2);
+ $DisplayVolume = locale_number_format($_SESSION['Items'.$identifier]->totalVolume,5);
$DisplayWeight = locale_number_format($_SESSION['Items'.$identifier]->totalWeight,2);
echo '<table class="selection">
<tr>
@@ -1079,13 +1081,8 @@
}
echo '</select></td>
</tr>';
-/*
+
echo' <tr>
- <td>'. _('Delivery Address 6') . ':</td>
- <td><input type="text" size="42" maxlength="40" name="BrAdd6" value="' . $_SESSION['Items'.$identifier]->DelAdd6 . '" /></td>
- </tr>';
-*/
-echo' <tr>
<td>'. _('Contact Phone Number') .':</td>
<td><input type="text" size="25" maxlength="25" required name="PhoneNo" value="' . $_SESSION['Items'.$identifier]->PhoneNo . '" /></td>
</tr>
Modified: trunk/includes/FreightCalculation.inc
===================================================================
--- trunk/includes/FreightCalculation.inc 2013-07-11 00:46:22 UTC (rev 6073)
+++ trunk/includes/FreightCalculation.inc 2013-07-11 02:49:35 UTC (rev 6074)
@@ -13,9 +13,10 @@
$TotalVolume,
$TotalWeight,
$FromLocation,
+ $Currency,
$db){
- # make an array of all the words that could be the name of the destination zone (city, state or ZIP)
+ // make an array of all the words that could be the name of the destination zone (city, state or ZIP)
$FindCity = explode(' ', $BrAdd2 . ' ' . $BrAdd3 . ' ' . $BrAdd4 . ' ' . $BrAdd5);
$sql = "SELECT shipperid,
@@ -34,8 +35,13 @@
foreach ($FindCity as $City) {
$sql = $sql . " destination LIKE '" . ucwords($City) . "%' OR";
}
+ if ($BrAddCountry != $CountriesArray[$_SESSION['CountryOfOperation']]){
+ /* For international shipments empty destination (ANY) is allowed */
+ $sql = $sql . " destination = '' OR";
+ }
$sql = mb_substr($sql, 0, strrpos($sql,' OR')) . ')';
}
+
$CalcFreightCostResult = DB_query($sql,$db);
if (DB_error_no($db) !=0) {
echo _('The freight calculation for the destination city cannot be performed because') . ' - ' . DB_error_msg($db);
@@ -45,9 +51,9 @@
while ($myrow = DB_fetch_array($CalcFreightCostResult)) {
- /********** FREIGHT CALCULATION
- IF FIXED PRICE TAKE IT IF BEST PRICE SO FAR OTHERWISE
- TAKE HIGHER OF CUBE, KG OR MINIMUM CHARGE COST **********/
+ /********** FREIGHT CALCULATION
+ IF FIXED PRICE TAKE IT IF BEST PRICE SO FAR OTHERWISE
+ TAKE HIGHER OF CUBE, KG OR MINIMUM CHARGE COST **********/
if ($myrow['fixedprice']!=0) {
if ($myrow['fixedprice'] < $CalcFreightCost) {
@@ -72,14 +78,24 @@
}
}
} else {
- $CalcFreightCost = _('Unrecognised destination, delivery only to cities in') . ' ' . $_SESSION['CountryOfOperation'];
+ $CalcFreightCost = _('Unrecognised destination');
}
if ($TotalValue >= $_SESSION['FreightChargeAppliesIfLessThan']){
-
/*Even though the order is over the freight free threshold - still need to calculate the best shipper to ensure get best deal*/
-
$CalcFreightCost =0;
}
+
+ if ($Currency != $_SESSION['CompanyRecord']['currencydefault']){
+ $ExRateResult = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $Currency . "'",$db);
+ if (DB_num_rows($ExRateResult)>0){
+ $ExRateRow = DB_fetch_row($ExRateResult);
+ $ExRate = $ExRateRow[0];
+ } else {
+ $ExRate =1;
+ }
+ $CalcFreightCost = $CalcFreightCost * $ExRate;
+ }
+
return array ($CalcFreightCost, $CalcBestShipper);
}
|