Skip to content

Commit

Permalink
fix bug of remove all inventories
Browse files Browse the repository at this point in the history
  • Loading branch information
bahram1249 committed Feb 22, 2024
1 parent abe710b commit d66a3b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions apps/e-commerce/src/admin/product/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,10 @@ export class ProductService {
const oldItemInvenotryIds = oldItemInventories.map((item) => item.id);

// all old inventories exists in database
const allOldInventories =
await this.inventoryService.findByVendorIds(vendorIds);
const allOldInventories = await this.inventoryService.findByVendorIds(
vendorIds,
entityId,
);

// find the items not exists in dto's for deleting in database
const deletedInventoryIds = allOldInventories
Expand Down
5 changes: 4 additions & 1 deletion apps/e-commerce/src/inventory/services/inventory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class InventoryService {
}
}

async findByVendorIds(vendorIds: number[]) {
async findByVendorIds(vendorIds: number[], productId: bigint) {
return await this.repository.findAll(
new QueryOptionsBuilder()
.filter({
Expand All @@ -177,6 +177,9 @@ export class InventoryService {
},
),
)
.filter({
productId: productId,
})
.build(),
);
}
Expand Down

0 comments on commit d66a3b4

Please sign in to comment.