diff --git a/Makefile b/Makefile index 095836dbc0df06bba156cdb3e47b0c0598c6ef8d..44ffcc06dc71842589710a58ed0df3a7cfcbc7a9 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ BASE=rules_shipping BASE_ADV=rules_shipping_advanced PLUGINTYPE=vmshipment ZIPBASE=opentools_vm2 -VERSION=3.95 +VERSION=3.96 PLUGINFILES=$(BASE).php $(BASE)_base.php $(BASE).script.php $(BASE).xml index.html PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html diff --git a/releases/plg_opentools_vm2_rules_shipping_advanced_v3.96.zip b/releases/plg_opentools_vm2_rules_shipping_advanced_v3.96.zip new file mode 100644 index 0000000000000000000000000000000000000000..995d06003d7cbb43e8c9d8e950cda563a750b7ef Binary files /dev/null and b/releases/plg_opentools_vm2_rules_shipping_advanced_v3.96.zip differ diff --git a/releases/plg_opentools_vm2_rules_shipping_v3.96.zip b/releases/plg_opentools_vm2_rules_shipping_v3.96.zip new file mode 100644 index 0000000000000000000000000000000000000000..ce3869d35bcdfcd66cda76a0490d2143a297d15c Binary files /dev/null and b/releases/plg_opentools_vm2_rules_shipping_v3.96.zip differ diff --git a/rules_shipping.xml b/rules_shipping.xml index 02d70b3a18637b3e9bc38840bfa7d4636216d238..348d38cc8905a7447c2f42dbafd5690c4f5f4333 100644 --- a/rules_shipping.xml +++ b/rules_shipping.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.open-tools.net</authorUrl> <copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>3.95</version> + <version>3.96</version> <description>VMSHIPMENT_RULES_DESC</description> <files> <filename plugin="rules_shipping">rules_shipping.php</filename> diff --git a/rules_shipping_base.php b/rules_shipping_base.php index d84798546ed9ba0723f5e47be9a98a4bb60371d7..0148223b3ed29a34991fd0c7e92a61bf2784f9f7 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -316,7 +316,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { } $_psType = ucfirst ($this->_psType); $calculator = calculationHelper::getInstance (); - + $cart_prices[$this->_psType . 'Value'] = $calculator->roundInternal ($this->getCosts ($cart, $method, $cart_prices), 'salesPrice'); if($this->_psType=='payment'){ @@ -336,15 +336,26 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { $q = 'SELECT * FROM #__virtuemart_calcs WHERE `virtuemart_calc_id`="' . $method->tax_id . '" '; $db->setQuery ($q); $taxrules = $db->loadAssocList (); - } else { - $taxrules = array(); - if(!empty($calculator->_cartData['VatTax']) ){ - $taxrules = $calculator->_cartData['VatTax']; + if(!empty($taxrules) ){ + foreach($taxrules as &$rule){ + if(!isset($rule['subTotal'])) $rule['subTotal'] = 0; + if(!isset($rule['taxAmount'])) $rule['taxAmount'] = 0; + $rule['subTotalOld'] = $rule['subTotal']; + $rule['taxAmountOld'] = $rule['taxAmount']; + $rule['taxAmount'] = 0; + $rule['subTotal'] = $cart_prices[$this->_psType . 'Value']; + } + } + } else { + $taxrules = array_merge($calculator->_cartData['VatTax'],$calculator->_cartData['taxRulesBill']); - $denominator = 0; + if(!empty($taxrules) ){ + $denominator = 0.0; foreach($taxrules as &$rule){ //$rule['numerator'] = $rule['calc_value']/100.0 * $rule['subTotal']; + if(!isset($rule['subTotal'])) $rule['subTotal'] = 0; + if(!isset($rule['taxAmount'])) $rule['taxAmount'] = 0; $denominator += ($rule['subTotal']-$rule['taxAmount']); $rule['subTotalOld'] = $rule['subTotal']; $rule['subTotal'] = 0; @@ -359,21 +370,15 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { foreach($taxrules as &$rule){ $frac = ($rule['subTotalOld']-$rule['taxAmountOld'])/$denominator; $rule['subTotal'] = $cart_prices[$this->_psType . 'Value'] * $frac; + vmdebug('Part $denominator '.$denominator.' $frac '.$frac,$rule['subTotal']); } - } else if(!empty($calculator->_cartData['taxRulesBill']) ){ - $taxrules = array_merge($taxrules,$calculator->_cartData['taxRulesBill']); } - } + if(empty($method->cost_per_transaction)) $method->cost_per_transaction = 0.0; if(empty($method->cost_percent_total)) $method->cost_percent_total = 0.0; - //If the taxing via unpublished categories is used, then the rules use the subtotal which is now overriden here - /*if (count ($taxrules) == 1 and isset($taxrules[1]['subTotal'] )) { - $taxrules[1]['subTotal'] = $cart_prices[$this->_psType . 'Value']; - }/*/ - if (count ($taxrules) > 0 ) { // BEGIN_RK_CHANGES @@ -387,8 +392,9 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { $calculator->setRevert (false); } else { // END_RK_CHANGES - $cart_prices['salesPrice' . $_psType] = $calculator->roundInternal ($calculator->executeCalculation ($taxrules, $cart_prices[$this->_psType . 'Value'],true,false), 'salesPrice'); - $cart_prices[$this->_psType . 'Tax'] = $calculator->roundInternal (($cart_prices['salesPrice' . $_psType] - $cart_prices[$this->_psType . 'Value']), 'salesPrice'); + $cart_prices['salesPrice' . $_psType] = $calculator->roundInternal ($calculator->executeCalculation ($taxrules, $cart_prices[$this->_psType . 'Value'],true,false), 'salesPrice'); + //vmdebug('I am in '.get_class($this).' and have this rules now',$taxrules,$cart_prices[$this->_psType . 'Value'],$cart_prices['salesPrice' . $_psType]); + $cart_prices[$this->_psType . 'Tax'] = $calculator->roundInternal (($cart_prices['salesPrice' . $_psType] - $cart_prices[$this->_psType . 'Value']), 'salesPrice'); // BEGIN_RK_CHANGES } // END_RK_CHANGES @@ -910,7 +916,7 @@ class ShippingRule { } if (count($args) == 3) { switch ($func) { - case "substring": return substr($args[0], $args[1], $args[2]); break; + case "substring": return substr($args[0], $args[1]-1, $args[2]); break; } } // List functions