Skip to content
Snippets Groups Projects
Commit 7e92d9f6 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Version 2.2.2: Fix default tax rule (copied code over from vmpsplugin's...

Version 2.2.2: Fix default tax rule (copied code over from vmpsplugin's setCartPrices function), disabled discountBeforeTaxBill variable, which is hardly ever available and thus produces php warnings in the server log
parent 45e6bcaf
No related branches found
No related tags found
No related merge requests found
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
......
File added
File added
......@@ -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>
......
......@@ -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>
......
......@@ -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'],
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment