Skip to content

Commit

Permalink
Merge branch 'main' into ST-2160-coupons-display-bonus-in-order-table
Browse files Browse the repository at this point in the history
  • Loading branch information
JoFont authored Nov 18, 2024
2 parents d0e8808 + 39eba93 commit d1b14ea
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,22 +366,14 @@ export const computeAggregatedAndPriceTotals = (priceItems: PriceItemsDto): Pric

const priceItemToAppend = immutablePriceItem
? (immutablePriceItem as PriceItemDto)
: computePriceItem(
priceItem as PriceItemDto,
price,
tax,
priceItem.quantity!,
priceMapping,
externalFeeMapping,
coupons,
);
: computePriceItem(priceItem, price, tax, priceItem.quantity!, priceMapping, externalFeeMapping, coupons);

const updatedTotals = isUnitAmountApproved(
priceItem,
priceItemToAppend?._price?.price_display_in_journeys ?? price?.price_display_in_journeys,
undefined,
)
? recomputeDetailTotals(details, price!, priceItemToAppend)
? recomputeDetailTotals(details, price, priceItemToAppend)
: {
amount_subtotal: details.amount_subtotal,
amount_total: details.amount_total,
Expand Down Expand Up @@ -414,7 +406,11 @@ export const computePriceItemDetails = (priceItem: PriceItemDto | CompositePrice
/**
* Computes all the pricing total amounts to integers with a decimal precision of DECIMAL_PRECISION.
*/
const recomputeDetailTotals = (details: PricingDetails, price: Price, priceItemToAppend: PriceItem): PricingDetails => {
const recomputeDetailTotals = (
details: PricingDetails,
price: Price | undefined,
priceItemToAppend: PriceItem,
): PricingDetails => {
const taxes = details.total_details?.breakdown?.taxes || [];
const firstTax = priceItemToAppend.taxes?.[0];
const itemTax = firstTax?.tax ?? ({ rate: Number(firstTax?.rateValue) } as Partial<Tax>);
Expand Down

0 comments on commit d1b14ea

Please sign in to comment.