Skip to content

Commit

Permalink
No tax should apply Tax basis = Store & store zone has no tax set
Browse files Browse the repository at this point in the history
fixes issue zencart#6384
  • Loading branch information
piloujp committed Apr 11, 2024
1 parent a0135a2 commit b9193fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 4 additions & 3 deletions includes/classes/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ function determineTaxAddressZones($billToAddressId, $shipToAddressId)
if (isset($this->billing['zone_id']) && $this->billing['zone_id'] == STORE_ZONE) {
$address_book_id = $billToAddressId;
} else {
$address_book_id = ($this->content_type === 'virtual' ? $billToAddressId : $shipToAddressId);
$address_book_id = ($this->content_type === 'virtual' ? $billToAddressId : -1);
}
}
$tax_address_query = "SELECT ab.entry_country_id, ab.entry_zone_id
Expand Down Expand Up @@ -903,8 +903,9 @@ protected function calculateProductsTaxForOrder()
$tax_to_add = zen_calculate_tax($tax_info['subtotal'], $tax_info['tax_rate']);
} else {
$tax_rate = $tax_info['tax_rate'];
$tax_rate_divisor = ($tax_rate >= 10) ? "1.$tax_rate" : "1.0$tax_rate";
$tax_to_add = $tax_info['subtotal'] - $tax_info['subtotal'] / $tax_rate_divisor;
//$tax_rate_divisor = ($tax_rate >= 10) ? "1.$tax_rate" : "1.0$tax_rate";
//$tax_rate_divisor = 1 + ($tax_rate / 100);
$tax_to_add = $tax_info['subtotal'] - $tax_info['subtotal'] / (1 + ($tax_rate / 100));
}

$this->info['tax'] += $tax_to_add;
Expand Down
16 changes: 9 additions & 7 deletions includes/functions/functions_taxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ function zen_get_multiple_tax_rates($class_id, $country_id = -1, $zone_id = -1,
$rates_array = [];

if ($country_id == -1 && $zone_id == -1) {
if (zen_is_logged_in()) {
$country_id = $_SESSION['customer_country_id'];
$zone_id = $_SESSION['customer_zone_id'];
} else {
$country_id = STORE_COUNTRY;
$zone_id = STORE_ZONE;
}
if (STORE_PRODUCT_TAX_BASIS != 'Store') {
if (zen_is_logged_in()) {
$country_id = $_SESSION['customer_country_id'];
$zone_id = $_SESSION['customer_zone_id'];
} else {
$country_id = STORE_COUNTRY;
$zone_id = STORE_ZONE;
}
}
}

$tax_query = "SELECT tax_description, tax_rate, tax_priority
Expand Down

0 comments on commit b9193fd

Please sign in to comment.