Skip to content

Commit

Permalink
Add logging for missing shipping line in Avatax response
Browse files Browse the repository at this point in the history
  • Loading branch information
peelar committed Feb 1, 2024
1 parent c43c2ee commit fb97d08
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { TaxBadProviderResponseError } from "../../taxes/tax-error";
import { taxProviderUtils } from "../../taxes/tax-provider-utils";
import { CalculateTaxesResponse } from "../../taxes/tax-provider-webhook";
import { avataxShippingLine } from "./avatax-shipping-line";
import { createLogger } from "@saleor/apps-logger";

const logger = createLogger("transformAvataxTransactionModelIntoShipping");

// why is tax rate 0?
export function transformAvataxTransactionModelIntoShipping(
transaction: TransactionModel,
): Pick<
Expand All @@ -14,6 +18,10 @@ export function transformAvataxTransactionModelIntoShipping(
const shippingLine = avataxShippingLine.getFromTransactionModel(transaction);

if (!shippingLine) {
logger.warn(
"Shipping line was not found in the response from AvaTax. The app will return 0s for shipping fields.",
);

return {
shipping_price_gross_amount: 0,
shipping_price_net_amount: 0,
Expand Down

0 comments on commit fb97d08

Please sign in to comment.