Skip to content

Commit 8e377a8

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(quickbooks): allow rounded purchasing line totals
1 parent 773067b commit 8e377a8

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

apps/sim/tools/quickbooks/purchasing.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@ describe('QuickBooks purchasing line and allocation validation', () => {
196196
'[{"lineType":"item","amount":10,"itemId":"21","quantity":2,"unitPrice":6}]'
197197
)
198198
).toThrow('amount must equal')
199+
expect(
200+
parseQuickBooksPurchasingLines(
201+
'[{"lineType":"item","amount":1.01,"itemId":"21","quantity":3,"unitPrice":0.335}]'
202+
)
203+
).toEqual([
204+
{
205+
lineType: 'item',
206+
amount: 1.01,
207+
itemId: '21',
208+
quantity: 3,
209+
unitPrice: 0.335,
210+
},
211+
])
199212
expect(() =>
200213
parseQuickBooksPurchasingLines(Array.from({ length: 101 }, () => accountLine))
201214
).toThrow('more than 100')

apps/sim/tools/quickbooks/purchasing_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function parseQuickBooksPurchasingLines(
122122
if (
123123
quantity !== undefined &&
124124
unitPrice !== undefined &&
125-
!new Decimal(quantity).times(unitPrice).equals(new Decimal(amount))
125+
!new Decimal(quantity).times(unitPrice).toDecimalPlaces(2).equals(new Decimal(amount))
126126
) {
127127
throw new Error(`${itemName}.amount must equal quantity multiplied by unitPrice`)
128128
}

0 commit comments

Comments
 (0)