Skip to content

Commit

Permalink
misc: make sure Netsuite item's data is fully valid before flagging i…
Browse files Browse the repository at this point in the history
…t as mapped (#1852)
  • Loading branch information
ansmonjol authored Nov 6, 2024
1 parent c521ddd commit f1248f4
Showing 1 changed file with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,29 @@ const NetsuiteIntegrationItemsListDefault = ({
subscriptionFee,
tax,
} = useMemo(() => {
const findDefaultItem = (mappingType: MappingTypeEnum) =>
defaultItems?.find(
(mapping) =>
mapping.mappingType === mappingType &&
!!mapping.externalId &&
!!mapping.externalName &&
!!mapping.externalAccountCode,
)

return {
fallbackItem: defaultItems?.find(
(mapping) => mapping.mappingType === MappingTypeEnum.FallbackItem,
),
coupon: defaultItems?.find((mapping) => mapping.mappingType === MappingTypeEnum.Coupon),
creditNote: defaultItems?.find(
(mapping) => mapping.mappingType === MappingTypeEnum.CreditNote,
),
minimumCommitment: defaultItems?.find(
(mapping) => mapping.mappingType === MappingTypeEnum.MinimumCommitment,
),
prepaidCredit: defaultItems?.find(
(mapping) => mapping.mappingType === MappingTypeEnum.PrepaidCredit,
),
subscriptionFee: defaultItems?.find(
(mapping) => mapping.mappingType === MappingTypeEnum.SubscriptionFee,
fallbackItem: findDefaultItem(MappingTypeEnum.FallbackItem),
coupon: findDefaultItem(MappingTypeEnum.Coupon),
creditNote: findDefaultItem(MappingTypeEnum.CreditNote),
minimumCommitment: findDefaultItem(MappingTypeEnum.MinimumCommitment),
prepaidCredit: findDefaultItem(MappingTypeEnum.PrepaidCredit),
subscriptionFee: findDefaultItem(MappingTypeEnum.SubscriptionFee),
tax: defaultItems?.find(
(mapping) =>
mapping.mappingType === MappingTypeEnum.Tax &&
!!mapping.taxCode &&
!!mapping.taxNexus &&
!!mapping.taxType,
),
tax: defaultItems?.find((mapping) => mapping.mappingType === MappingTypeEnum.Tax),
}
}, [defaultItems])

Expand Down

0 comments on commit f1248f4

Please sign in to comment.