Skip to content

Commit

Permalink
Updated: remove the optionals, update logic of Inventory Information …
Browse files Browse the repository at this point in the history
…action & mutation(#386)
  • Loading branch information
R-Sourabh committed May 21, 2024
1 parent adc1639 commit 62661cf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/components/InventoryDetailsPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
<ion-list-header>{{ translate("Inventory computation")}}</ion-list-header>
<ion-item>
<ion-label class="ion-text-wrap">{{ translate("Quantity on hands")}}</ion-label>
<ion-note slot="end">{{ getProductStock(item.productId)?.quantityOnHandTotal ?? '0' }}</ion-note>
<ion-note slot="end">{{ getProductStock(item.productId).quantityOnHandTotal ?? '0' }}</ion-note>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">{{ translate("Safety stock")}}</ion-label>
<ion-note slot="end">{{ getInventoryInformation(item.productId)?.minimumStock ?? '0' }}</ion-note>
<ion-note slot="end">{{ getInventoryInformation(item.productId).minimumStock ?? '0' }}</ion-note>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">{{ translate("Order reservations")}}</ion-label>
<ion-note slot="end">{{ getInventoryInformation(item.productId)?.reservedQuantity ?? '0' }}</ion-note>
<ion-note slot="end">{{ getInventoryInformation(item.productId).reservedQuantity ?? '0' }}</ion-note>
</ion-item>
<ion-item lines="none">
<ion-label class="ion-text-wrap">{{ translate("Online ATP")}}</ion-label>
<ion-badge slot="end" color="success">{{ getInventoryInformation(item.productId)?.onlineAtp ?? '0' }}</ion-badge>
<ion-badge slot="end" color="success">{{ getInventoryInformation(item.productId).onlineAtp ?? '0' }}</ion-badge>
</ion-item>
</ion-list>
</ion-content>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProductListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ion-icon color="medium" slot="icon-only" :icon="cubeOutline" />
</ion-button>
<div v-else-if="showInfoIcon" class="atp-info">
<ion-note slot="end"> {{ getInventoryInformation(item.productId)?.onlineAtp ?? '0' }} </ion-note>
<ion-note slot="end"> {{ getInventoryInformation(item.productId).onlineAtp ?? '0' }} </ion-note>
<ion-button fill="clear" @click.stop="getInventoryComputationDetails($event)">
<ion-icon slot="icon-only" :icon="informationCircleOutline" color="medium" />
</ion-button>
Expand Down
9 changes: 4 additions & 5 deletions src/store/modules/stock/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ const actions: ActionTree<StockState, RootState> = {
} as any

const resp: any = await StockService.getInventoryComputation(params);
if(!hasError(resp)) {
commit(types.STOCK_ADD_PRODUCT_INFORMATION, { productId: productId, facilityId: this.state.user.currentFacility.facilityId, minimumStock: resp.data.docs[0].minimumStock, onlineAtp: resp.data.docs[0].computedLastInventoryCount })
if(!hasError(resp) && resp.data.docs.length > 0) {
commit(types.STOCK_ADD_PRODUCT_INFORMATION, { productId: productId, facilityId: this.state.user.currentFacility.facilityId, payload: { minimumStock: resp.data.docs[0].minimumStock, onlineAtp: resp.data.docs[0].computedLastInventoryCount }})
} else {
throw resp.data;
}
}
catch (err) {
logger.error(err)
showToast(translate('No data available!'))
}
},

Expand All @@ -69,9 +68,9 @@ const actions: ActionTree<StockState, RootState> = {
})
try {
const resp = await UtilService.fetchReservedQuantity(payload)
if(resp.status == 200 && !hasError(resp)) {
if(!hasError(resp) && resp.data.facets.reservedQuantityFacet) {
const reservedQuantity = resp.data.facets.reservedQuantityFacet
commit(types.STOCK_ADD_PRODUCT_INFORMATION, { productId, facilityId: this.state.user.currentFacility.facilityId, reservedQuantity });
commit(types.STOCK_ADD_PRODUCT_INFORMATION, { productId, facilityId: this.state.user.currentFacility.facilityId, payload: { reservedQuantity }});
} else {
throw resp.data
}
Expand Down
14 changes: 7 additions & 7 deletions src/store/modules/stock/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ const mutations: MutationTree <StockState> = {
}
}
},
[types.STOCK_ADD_PRODUCT_INFORMATION] (state, { productId, facilityId, minimumStock, onlineAtp, reservedQuantity }) {
[types.STOCK_ADD_PRODUCT_INFORMATION] (state, { productId, facilityId, payload }) {
if (!state.inventoryInformation[productId]) {
state.inventoryInformation[productId] = {}
state.inventoryInformation[productId] = {
[facilityId]: payload
}
return;
}

const inventoryData = state.inventoryInformation[productId][facilityId] || {};

state.inventoryInformation[productId][facilityId] = {
minimumStock: minimumStock != undefined ? minimumStock : inventoryData.minimumStock,
onlineAtp: onlineAtp != undefined ? onlineAtp : inventoryData.onlineAtp,
reservedQuantity: reservedQuantity != undefined ? reservedQuantity : inventoryData.reservedQuantity,
...state.inventoryInformation[productId][facilityId],
...payload
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/utils/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const orderCategoryParameters = {
},
},
'Packed': {
// Array to denote ORing
'shipmentStatusId': {
'value': 'SHIPMENT_SHIPPED'
}
Expand Down
3 changes: 1 addition & 2 deletions src/views/OtherStoresInventoryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ export default defineComponent({
},
searchFacilities(){
if (this.queryString !== "") {
this.filteredInventory = this.otherStoresInventory.filter((facility: any) =>
facility.facilityName.toLowerCase().includes(this.queryString.toLowerCase()));
this.filteredInventory = this.otherStoresInventory.filter((facility: any) => facility.facilityName.toLowerCase().includes(this.queryString.toLowerCase()));
} else {
// Reset filteredInventory when query is empty
this.filteredInventory = this.otherStoresInventory.slice();
Expand Down
19 changes: 9 additions & 10 deletions src/views/ProductDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@
<ion-list v-if="selectedSegment === 'inStore'">
<ion-item>
<ion-label class="ion-text-wrap">{{ translate("Quantity on hands")}}</ion-label>
<ion-note slot="end">{{ getProductStock(product.variants[0].productId)?.quantityOnHandTotal ?? '0' }}</ion-note>
<ion-note slot="end">{{ getProductStock(currentVariant.productId).quantityOnHandTotal ?? '0' }}</ion-note>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">{{ translate("Safety stock")}}</ion-label>
<ion-note slot="end">{{ getInventoryInformation(product.variants[0].productId)?.minimumStock ?? '0' }}</ion-note>
<ion-note slot="end">{{ getInventoryInformation(currentVariant.productId).minimumStock ?? '0' }}</ion-note>
</ion-item>
<ion-item>
<ion-label class="ion-text-wrap">{{ translate("Order reservations")}}</ion-label>
<ion-note slot="end">{{ getInventoryInformation(product.variants[0].productId)?.reservedQuantity ?? '0' }}</ion-note>
<ion-note slot="end">{{ getInventoryInformation(currentVariant.productId).reservedQuantity ?? '0' }}</ion-note>
</ion-item>
<ion-item lines="none">
<ion-label class="ion-text-wrap">{{ translate("Available to promise")}}</ion-label>
<ion-badge color="success" slot="end">{{ getInventoryInformation(product.variants[0].productId)?.onlineAtp ?? '0' }}</ion-badge>
<ion-badge color="success" slot="end">{{ getInventoryInformation(currentVariant.productId).onlineAtp ?? '0' }}</ion-badge>
</ion-item>
</ion-list>

<ion-list v-if="selectedSegment === 'otherLocations'">
<ion-list v-if="selectedSegment === 'otherLocations'">
<ion-item>
<ion-label class="ion-text-wrap">{{ translate("Other stores")}}</ion-label>
<ion-button @click="getOtherStoresInventoryDetails()" fill="outline">{{ otherStoresInventory }}</ion-button>
Expand All @@ -91,7 +91,7 @@
</div>

<div v-if="otherItem.length > 0">
<h3>{{ translate('order reservtions at the store', { count: getInventoryInformation(product.variants[0].productId)?.reservedQuantity ?? '0' }) }}</h3>
<h3>{{ translate('order reservtions at the store', { count: getInventoryInformation(currentVariant.productId).reservedQuantity ?? '0' }) }}</h3>
<div class="reservation-section">
<div v-for="(order, index) in otherItem" :key="index">
<ion-card>
Expand Down Expand Up @@ -225,9 +225,6 @@ export default defineComponent({
},
async beforeMount() {
await this.store.dispatch('product/setCurrent', { productId: this.$route.params.productId })
await this.store.dispatch('stock/fetchStock', { productId: this.product.variants[0].productId })
await this.store.dispatch('stock/fetchInventoryCount', { productId: this.product.variants[0].productId });
await this.store.dispatch('stock/fetchReservedQuantity', { productId: this.product.variants[0].productId });
if (this.product.variants) {
this.getFeatures()
await this.updateVariant()
Expand Down Expand Up @@ -278,7 +275,9 @@ export default defineComponent({
this.currentVariant = variant || this.product.variants[0];
await this.checkInventory();
await this.getOrderDetails();
// this.fetchReservedQuantity( this.currentVariant.productId );
await this.store.dispatch('stock/fetchStock', { productId: this.currentVariant.productId })
await this.store.dispatch('stock/fetchInventoryCount', { productId: this.currentVariant.productId });
await this.store.dispatch('stock/fetchReservedQuantity', { productId: this.currentVariant.productId });
},
async checkInventory() {
this.currentStoreInventory = this.otherStoresInventory = this.warehouseInventory = 0
Expand Down

0 comments on commit 62661cf

Please sign in to comment.