Skip to content

Commit

Permalink
Merge pull request #361 from Nosto/division-by-zero-when-tax-is-zero
Browse files Browse the repository at this point in the history
Release 4.4.1 - Prevent division by zero when the total product tax included in the product is zero (Free items without tax)
  • Loading branch information
supercid authored Sep 17, 2024
2 parents bfb83d0 + 6b16cb6 commit b5d96ed
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
./libs/bin/phpcs --standard=ruleset.xml --severity=10 --report=checkstyle --report-file=chkphpcs.xml .
- name: Archive code sniffing results
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: phpcs-xml-result
path: chkphpcs.xml
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
run: ./libs/bin/phpmd . xml codesize,naming,unusedcode,controversial,design --exclude libs,var,build,tests,.phan --reportfile pmdphpmd.xml --ignore-violations-on-exit

- name: Archive mess detection results
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: phpmd-xml-result
path: pmdphpmd.xml
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
continue-on-error: true

- name: Archive copy-paste detection results
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: phdpcpd-xml-result
path: phdpcpd.xml
Expand Down Expand Up @@ -193,7 +193,7 @@ jobs:
run: ./libs/bin/phing -verbose -Dversion="${{steps.plugin_version.outputs.PLUGIN_VERSION}}"

- name: Archive built package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{steps.plugin_version.outputs.PLUGIN_VERSION}}-Nosto.-.Personalization.for.PrestaShop
path: build/src
2 changes: 1 addition & 1 deletion .github/workflows/ide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

- name: Archive inspection results
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: inspection-results
path: output
2 changes: 1 addition & 1 deletion .github/workflows/phan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
continue-on-error: true

- name: Archive static analysis results
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: phan-analysis-results
path: chkphan.xml
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning(http://semver.org/).

## 4.4.1
- Fixes an issue that can cause division by zero errors when a product has zero total taxes associated with

## 4.4.0
- Add compatibility with Prestashop 8.1

Expand Down
4 changes: 3 additions & 1 deletion classes/models/NostoOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ protected static function findPurchasedItems(Order $order)

//deduct the gift product among from product among
$totalProductTaxIncl -= $totalGiftTaxIncl;
$discountPercentage = max(0, $totalDiscountsTaxIncl / $totalProductTaxIncl);
$discountPercentage = ($totalProductTaxIncl > 0)
? max(0, $totalDiscountsTaxIncl / $totalProductTaxIncl)
: 0;

/** @var NostoOrderPurchasedItem $purchasedItem */
foreach ($purchasedItems as $purchasedItem) {
Expand Down
2 changes: 1 addition & 1 deletion nostotagging.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class NostoTagging extends Module
*
* @var string
*/
const PLUGIN_VERSION = '4.4.0';
const PLUGIN_VERSION = '4.4.1';

/**
* Internal name of the Nosto plug-in
Expand Down

0 comments on commit b5d96ed

Please sign in to comment.