diff --git a/Makefile b/Makefile index b97a0f56a5f38d48dc03c67d36152bc08d4dd2d3..39e416764dc585c6b9c54612cf0535799ec5d7cf 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BASE=rules_shipping BASE_ADV=rules_shipping_advanced PLUGINTYPE=vmshipment -VERSION=2.2.1 +VERSION=2.2.2 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_vmshipment_rules_shipping_advanced_v2.2.2.zip b/releases/plg_vmshipment_rules_shipping_advanced_v2.2.2.zip new file mode 100644 index 0000000000000000000000000000000000000000..da1a3ad650ebf86c8263daa0f5107e96587c754e Binary files /dev/null and b/releases/plg_vmshipment_rules_shipping_advanced_v2.2.2.zip differ diff --git a/releases/plg_vmshipment_rules_shipping_v2.2.2.zip b/releases/plg_vmshipment_rules_shipping_v2.2.2.zip new file mode 100644 index 0000000000000000000000000000000000000000..627c00433f46dd9c7c6400fe34a46325d162b784 Binary files /dev/null and b/releases/plg_vmshipment_rules_shipping_v2.2.2.zip differ diff --git a/rules_shipping.xml b/rules_shipping.xml index 7a8170825f2c9865aba37c1e3da6696ef8dd60c1..a2c3f8cfd804521ba2c27e26958577097bd3b9fb 100644 --- a/rules_shipping.xml +++ b/rules_shipping.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.kainhofer.com</authorUrl> <copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>2.2.1</version> + <version>2.2.2</version> <description>VMSHIPMENT_RULES_DESC</description> <files> <filename plugin="rules_shipping">rules_shipping.php</filename> diff --git a/rules_shipping_advanced.xml b/rules_shipping_advanced.xml index ec8abf4e523421d851d1b932d52715be10b218fd..b50b16db90941ae6ff74f8ee4c11003805fff555 100644 --- a/rules_shipping_advanced.xml +++ b/rules_shipping_advanced.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.kainhofer.com</authorUrl> <copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>2.2.1</version> + <version>2.2.2</version> <description>VMSHIPMENT_RULES_ADV_DESC</description> <files> <filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename> diff --git a/rules_shipping_base.php b/rules_shipping_base.php index 9a7cd93586a9bbd114a6f944f5140fc26243f09e..37d3d03610e041b6e8387a43721c83412fd4f5b2 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -251,21 +251,37 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { } $calculator = calculationHelper::getInstance (); - $value = $calculator->roundInternal ($this->getCosts ($cart, $method, $cart_prices), 'salesPrice'); - $_psType = ucfirst ($this->_psType); $cart_prices[$this->_psType . 'Value'] = $value; $taxrules = array(); - if (!empty($method->tax_id)) { + if(isset($method->tax_id) and (int)$method->tax_id === -1){ + + } else if (!empty($method->tax_id)) { $cart_prices[$this->_psType . '_calc_id'] = $method->tax_id; $db = JFactory::getDBO (); $q = 'SELECT * FROM #__virtuemart_calcs WHERE `virtuemart_calc_id`="' . $method->tax_id . '" '; $db->setQuery ($q); $taxrules = $db->loadAssocList (); + } else { + //This construction makes trouble, if there are products with different vats in the cart + //on the other side, it is very unlikely to have different vats in the cart and simultan it is not possible to use a fixed tax rule for the shipment + if(!empty($calculator->_cartData['VatTax']) and count ($calculator->_cartData['VatTax']) == 1){ + $taxrules = $calculator->_cartData['VatTax']; + foreach($taxrules as &$rule){ + $rule['subTotal'] = $cart_prices[$this->_psType . 'Value']; + } + + } else { + $taxrules = $calculator->_cartData['taxRulesBill']; + foreach($taxrules as &$rule){ + unset($rule['subTotal']); + } + } } + if (count ($taxrules) > 0) { if ($method->includes_tax) { @@ -278,6 +294,8 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { $cart_prices['salesPrice' . $_psType] = $calculator->roundInternal ($calculator->executeCalculation ($taxrules, $cart_prices[$this->_psType . 'Value']), 'salesPrice'); $cart_prices[$this->_psType . 'Tax'] = $calculator->roundInternal (($cart_prices['salesPrice' . $_psType] - $cart_prices[$this->_psType . 'Value']), 'salesPrice'); } + reset($taxrules); + $taxrule = current($taxrules); $cart_prices[$this->_psType . '_calc_id'] = $taxrules[0]['virtuemart_calc_id']; } else { $cart_prices['salesPrice' . $_psType] = $value; @@ -286,6 +304,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { } return $cart_prices['salesPrice' . $_psType]; } + protected function createMethodRule ($r, $countries, $tax) { return new ShippingRule($r, $countries, $tax); } @@ -407,7 +426,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { 'salesPriceWithDiscount'=>$cart_prices['salesPriceWithDiscount'], 'discountAmount'=>$cart_prices['discountAmount'], 'priceWithoutTax'=>$cart_prices['priceWithoutTax'], - 'discountBeforeTaxBill'=>$cart_prices['discountBeforeTaxBill'], +// 'discountBeforeTaxBill'=>$cart_prices['discountBeforeTaxBill'], 'country'=>$address['virtuemart_country_id'], );