Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved: Added support for fetching the updated inventory in the Completed tab after the handover or ship of an order (#468) #474

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading