Skip to content

Commit

Permalink
chore(processor): adjust helper.converter tax rate function call to l…
Browse files Browse the repository at this point in the history
…atest sdk
  • Loading branch information
joey-koster-ct committed Feb 6, 2025
1 parent ab2f4c8 commit 225536b
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions processor/src/services/converters/helper.converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export const mapCoCoLineItemToAdyenLineItem = (lineItem: CoCoLineItem): LineItem
amountExcludingTax: getItemAmount(getAmountExcludingTax(lineItem), lineItem.quantity),
amountIncludingTax: getItemAmount(getAmountIncludingTax(lineItem), lineItem.quantity),
taxAmount: getItemAmount(getTaxAmount(lineItem), lineItem.quantity),
taxPercentage: TaxRateConverter.convertCoCoTaxPercentage(
lineItem.totalPrice.fractionDigits,
lineItem.taxRate?.amount,
),
taxPercentage: TaxRateConverter.convertCoCoTaxPercentage(lineItem.taxRate?.amount),
};
};

Expand All @@ -42,10 +39,7 @@ export const mapCoCoCustomLineItemToAdyenLineItem = (customLineItem: CustomLineI
amountExcludingTax: getItemAmount(getAmountExcludingTax(customLineItem), customLineItem.quantity),
amountIncludingTax: getItemAmount(getAmountIncludingTax(customLineItem), customLineItem.quantity),
taxAmount: getItemAmount(getTaxAmount(customLineItem), customLineItem.quantity),
taxPercentage: TaxRateConverter.convertCoCoTaxPercentage(
customLineItem.totalPrice.fractionDigits,
customLineItem.taxRate?.amount,
),
taxPercentage: TaxRateConverter.convertCoCoTaxPercentage(customLineItem.taxRate?.amount),
};
};

Expand Down Expand Up @@ -84,10 +78,7 @@ export const mapCoCoShippingInfoToAdyenLineItem = (normalizedShippings: Normaliz
amountExcludingTax: amountExcludingTaxValue,
amountIncludingTax: amountIncludingTaxValue,
taxAmount: taxAmountValue,
taxPercentage: TaxRateConverter.convertCoCoTaxPercentage(
shipping.shippingInfo.price.fractionDigits,
shipping.shippingInfo.taxRate?.amount,
),
taxPercentage: TaxRateConverter.convertCoCoTaxPercentage(shipping.shippingInfo.taxRate?.amount),
};
});
};
Expand Down Expand Up @@ -169,23 +160,23 @@ export const mapCoCoCartItemsToAdyenLineItems = (
| 'discountOnTotalPrice'
>,
): LineItem[] => {
const aydenLineItems: LineItem[] = [];
const adyenLineItems: LineItem[] = [];

cart.lineItems.forEach((lineItem) => aydenLineItems.push(mapCoCoLineItemToAdyenLineItem(lineItem)));
cart.lineItems.forEach((lineItem) => adyenLineItems.push(mapCoCoLineItemToAdyenLineItem(lineItem)));

cart.customLineItems.forEach((customLineItem) =>
aydenLineItems.push(mapCoCoCustomLineItemToAdyenLineItem(customLineItem)),
adyenLineItems.push(mapCoCoCustomLineItemToAdyenLineItem(customLineItem)),
);

aydenLineItems.push(...mapCoCoShippingInfoToAdyenLineItem(paymentSDK.ctCartService.getNormalizedShipping({ cart })));
adyenLineItems.push(...mapCoCoShippingInfoToAdyenLineItem(paymentSDK.ctCartService.getNormalizedShipping({ cart })));

if (cart.discountOnTotalPrice) {
aydenLineItems.push(
adyenLineItems.push(
mapCoCoDiscountOnTotalPriceToAdyenLineItem({ discountOnTotalPrice: cart.discountOnTotalPrice }),
);
}

return aydenLineItems;
return adyenLineItems;
};

export const populateCartAddress = (address?: CartAddress): Address => {
Expand Down

0 comments on commit 225536b

Please sign in to comment.