Skip to content

Commit

Permalink
Fix tax rate calculation bug (#61)
Browse files Browse the repository at this point in the history
dont divide by zero
  • Loading branch information
peelar committed May 7, 2024
1 parent 45c3f27 commit 108366a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/modules/klarna/klarna-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ export const createMerchantConfirmationUrl = (
};

export const calculateTaxRate = (taxAmount: number, netAmount: number) => {
if (netAmount === 0 || taxAmount === 0) {
return 0;
}

return getKlarnaIntegerAmountFromSaleor(Math.round((100 * taxAmount) / netAmount));
};

Expand Down

0 comments on commit 108366a

Please sign in to comment.