Skip to content

Commit

Permalink
Merge pull request #474 from R-Sourabh/#468-completed-tab-item-inventory
Browse files Browse the repository at this point in the history
Improved: Added support for fetching the updated inventory in the Completed tab after the handover or ship of an order (#468)
  • Loading branch information
ymaheshwari1 authored Dec 11, 2024
2 parents 22a9a31 + de5033c commit c3f2e26
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/views/Orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ export default defineComponent({
isCompletedOrdersScrollable: 'order/isCompletedOrdersScrollable',
notifications: 'user/getNotifications',
unreadNotificationsStatus: 'user/getUnreadNotificationsStatus',
getBopisProductStoreSettings: 'user/getBopisProductStoreSettings'
getBopisProductStoreSettings: 'user/getBopisProductStoreSettings',
getProductStock: 'stock/getProductStock',
})
},
data() {
Expand Down Expand Up @@ -435,8 +436,22 @@ export default defineComponent({
async deliverShipment (order: any) {
await this.store.dispatch('order/deliverShipment', order)
.then((resp) => {
if(!hasError(resp)){
if(!hasError(resp)) {
showToast(translate('Order delivered to', {customerName: order.customer.name}))
// We are collecting the product IDs of the order items and then fetching stock information
// for each product ID if it is available for updated inventory.
const productIds = [...new Set(order.parts.reduce((productId: any, part: any) => {
const ids = part.items.map((item: any) => item.productId)
return productId.concat(ids)
}, []))]
productIds.map((productId: any) => {
const productStock = this.getProductStock(productId);
if (productStock && productStock.quantityOnHandTotal >= 0) {
this.store.dispatch('stock/fetchStock', { productId });
}
})
}
})
},
Expand Down

0 comments on commit c3f2e26

Please sign in to comment.