Skip to content

Commit

Permalink
log suspicious taxes calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
lkostrowski committed Dec 15, 2024
1 parent 93f0068 commit 14902a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-lamps-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-avatax": patch
---

Add log when suspicious calculation happen - when line tax rate is non-zero but amount of taxes is zero
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ export class AvataxCalculateTaxesAdapter {

const transformedResponse = this.avataxCalculateTaxesResponseTransformer.transform(response);

transformedResponse.lines.forEach((l) => {
const tax = (l.total_gross_amount = l.total_net_amount);
const rate = l.tax_rate;

if (tax === 0 && rate !== 0) {
this.logger.warn("Line has zero tax, but rate is not zero", {
taxCalculationSummary: response.summary,
});
}
});

this.logger.debug("Transformed AvaTax createTransaction response");

return transformedResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const handler = checkoutCalculateTaxesSyncWebhook.createHandler(async (req, res,

/**
* Create deps in handler, so it's potentially faster and reduce lambda start
* TODO: It's rather not true, we should move it outside
*/
const subscriptionErrorChecker = new SubscriptionPayloadErrorChecker(logger, captureException);
const useCase = new CalculateTaxesUseCase({
Expand Down

0 comments on commit 14902a4

Please sign in to comment.