Skip to content

Commit 09be43e

Browse files
fix(OUT-3816): address regression review on the product mapping changes
- webhookProductUpdated now sends sparse:true so a name/description update no longer resets the QB item's UnitPrice to 0 (mapped items store null unitPrice now). - handleProductMap calls unsetTransaction() before the initial-save early return, so the DB singleton isn't left on a closed tx. - Drop the now-unused createdAt from the flatten DTO + getProductsForMapping. - Remove stale numericPrice from the productKeyed test fixture; fix stale handleProductMap comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 315b31a commit 09be43e

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

‎src/app/api/quickbooks/product/product.service.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export class ProductService extends BaseService {
206206

207207
/**
208208
* On intial save, save all flatten products. If mapped, we include and if not, those are excluded
209-
* On every save after that, we update the record on the basis of productId and priceId
209+
* On every save after that, we update the record on the basis of productId
210210
*/
211211
async handleProductMap(
212212
body: ProductMappingSchemaType,
@@ -234,6 +234,7 @@ export class ProductService extends BaseService {
234234
buildReturningFields(QBProductSync, returningFields),
235235
)
236236
: await query.returning()
237+
this.unsetTransaction()
237238
return products
238239
}
239240

@@ -338,7 +339,6 @@ export class ProductService extends BaseService {
338339
id: product.id,
339340
name: product.name,
340341
description: convert(product.description),
341-
createdAt: product.createdAt,
342342
}))
343343

344344
return { products: formatted }
@@ -447,10 +447,11 @@ export class ProductService extends BaseService {
447447
qbTokenInfo.incomeAccountRef,
448448
)
449449

450-
const fullUpdatePayload: QBItemFullUpdatePayloadType = {
450+
const updatePayload: QBItemFullUpdatePayloadType = {
451451
Id: qbItemId,
452452
SyncToken: syncToken,
453453
Name: qbItemName,
454+
sparse: true,
454455
...(productDescription && { Description: productDescription }),
455456
...(product.unitPrice
456457
? { UnitPrice: parseFloat(product.unitPrice) / 100 }
@@ -462,7 +463,7 @@ export class ProductService extends BaseService {
462463
Type: QBItemType.SERVICE,
463464
}
464465

465-
const itemRes = await intuitApi.itemFullUpdate(fullUpdatePayload)
466+
const itemRes = await intuitApi.itemFullUpdate(updatePayload)
466467

467468
// update the product map in db
468469
const mapUpdatePayload = {

‎src/type/dto/api.dto.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export const ProductFlattenResponseSchema = z.object({
44
id: z.string(),
55
name: z.string(),
66
description: z.string().nullish(),
7-
createdAt: z.string().datetime(),
87
})
98
export type ProductFlattenResponseType = z.infer<
109
typeof ProductFlattenResponseSchema

‎test/integration/quickbooks/productMap/productKeyed.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('POST /api/quickbooks/product/map — product-keyed upsert', () => {
3030
id: '777',
3131
name: 'Test Product',
3232
syncToken: '0',
33-
numericPrice: 1499,
3433
description: '',
3534
},
3635
},

0 commit comments

Comments
 (0)