Skip to content

Commit

Permalink
fix: get taxRates info
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Apr 28, 2023
1 parent 14a5800 commit bdf9deb
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions apps/storefront/src/utils/b3Product/b3TaxRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@ const getTaxRate = (taxClassId: number) => {
let taxRates: TaxZoneRates[] = []

if (taxZoneRates.length) {
taxZoneRates.forEach((taxZoneRate: TaxZoneRatesProps) => {
if (taxZoneRate.rates.length > 0 && taxZoneRate.rates[0].priority === 1) {
taxRates = taxZoneRate?.rates[0]?.classRates || []
}
})
const withValueTaxZoneRates =
taxZoneRates.filter(
(taxZoneRate: TaxZoneRatesProps) => taxZoneRate.rates.length > 0
) || []

if (withValueTaxZoneRates.length > 0) {
const currentTaxZoneRate =
withValueTaxZoneRates.find(
(taxZoneRate: TaxZoneRatesProps) =>
taxZoneRate.rates[0].priority === 1
) || withValueTaxZoneRates[0]

taxRates = currentTaxZoneRate?.rates[0]?.classRates || []
}
}

const rate =
Expand Down

0 comments on commit bdf9deb

Please sign in to comment.