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

Implemented code to make the open orders flow functional(#1wut90a) #27

Merged
merged 84 commits into from
Mar 30, 2023

Conversation

ymaheshwari1
Copy link
Contributor

@ymaheshwari1 ymaheshwari1 commented Dec 20, 2021

closes #81 #83

ymaheshwari1 and others added 27 commits December 17, 2021 12:46
…nt and defined state to store the shipment methods(#1wut90a)
…code to show and save the response(#1wut90a)
…anted object assignment when calling the API(#1wut90a)
@ymaheshwari1 ymaheshwari1 marked this pull request as ready for review January 11, 2022 11:16
computed: {
...mapGetters({
openOrders: 'order/getOpenOrders',
viewSize: 'util/getViewSize'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not store the current view size in util, it should be part of open order query

@@ -0,0 +1,8 @@
export default interface OrderState {
open: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should query and list together as we will keep inprogress/completed list too

const actions: ActionTree<OrderState, RootState> = {

// get open orders
async fetchOpenOrders ({ commit, state }, payload = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async fetchOpenOrders ({ commit, state }, payload = {}) {
async findOpenOrders ({ commit, state }, payload = {}) {

resp = await OrderService.fetchOpenOrders(orderQueryPayload);
if (resp.status === 200 && resp.data.grouped.orderId.matches > 0 && !hasError(resp)) {
const total = resp.data.grouped.orderId.ngroups
commit(types.ORDER_OPEN_UPDATED, {list: resp.data.grouped.orderId.groups, total})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initially prepare orders object, assign it values and commit at end


emitter.emit("dismissLoader")
},
async fetchPickers() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async fetchPickers() {
async findPickers() {

closeModal() {
modalController.dismiss({ dismissed: true });
},
pickerChanged(id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pickerChanged(id) {
changePicker(id) {

this.fetchPickers()
},
async printPicklist () {
if (!this.selectedPickers.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should handle by disabling the button

Comment on lines 130 to 146
orders.map((order) => {
order.doclist.docs.map((item) => items.push(item))
});

items.map((item, index) => {
formData.append("facilityId_o_"+index, this.currentFacility.facilityId)
formData.append("shipmentMethodTypeId_o_"+index, item.shipmentMethodTypeId)
formData.append("itemStatusId_o_"+index, "PICKITEM_PENDING")
formData.append("shipGroupSeqId_o_"+index, item.shipGroupSeqId)
formData.append("orderId_o_"+index, item.orderId)
formData.append("orderItemSeqId_o_"+index, item.orderItemSeqId)
formData.append("productId_o_"+index, item.productId)
formData.append("quantity_o_"+index, item.itemQuantity)
formData.append("inventoryItemId_o_"+index, item.inventoryItemId)
formData.append("picked_o_"+index, item.itemQuantity)
formData.append("_rowSubmit_o_"+index, "Y")
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could skip an iteration

Suggested change
orders.map((order) => {
order.doclist.docs.map((item) => items.push(item))
});
items.map((item, index) => {
formData.append("facilityId_o_"+index, this.currentFacility.facilityId)
formData.append("shipmentMethodTypeId_o_"+index, item.shipmentMethodTypeId)
formData.append("itemStatusId_o_"+index, "PICKITEM_PENDING")
formData.append("shipGroupSeqId_o_"+index, item.shipGroupSeqId)
formData.append("orderId_o_"+index, item.orderId)
formData.append("orderItemSeqId_o_"+index, item.orderItemSeqId)
formData.append("productId_o_"+index, item.productId)
formData.append("quantity_o_"+index, item.itemQuantity)
formData.append("inventoryItemId_o_"+index, item.inventoryItemId)
formData.append("picked_o_"+index, item.itemQuantity)
formData.append("_rowSubmit_o_"+index, "Y")
})
int index = 0;
orders.map((order) => {
order.doclist.docs.map((item) => {
formData.append("facilityId_o_"+index, this.currentFacility.facilityId)
formData.append("shipmentMethodTypeId_o_"+index, item.shipmentMethodTypeId)
formData.append("itemStatusId_o_"+index, "PICKITEM_PENDING")
formData.append("shipGroupSeqId_o_"+index, item.shipGroupSeqId)
formData.append("orderId_o_"+index, item.orderId)
formData.append("orderItemSeqId_o_"+index, item.orderItemSeqId)
formData.append("productId_o_"+index, item.productId)
formData.append("quantity_o_"+index, item.itemQuantity)
formData.append("inventoryItemId_o_"+index, item.inventoryItemId)
formData.append("picked_o_"+index, item.itemQuantity)
formData.append("_rowSubmit_o_"+index, "Y")
index++;
}
});


try {
const resp = await UtilService.getAvailablePickers(payload);
if (resp.status === 200 && !hasError(resp) && resp.data.count > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not show "Something went wrong" error when there are no pickers found. It should be empty state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sir, we are not displaying it on the UI, we are just adding the error in console for debugging, also we already have empty state for the same.
I'll update the message to be more informative.

// This scenario occurs when we have selected a shipping method having for example 3 orders, so we set the size to 3
// Now when we de-select the shipping method or select another shipping method than the orders totals will increase,
// and thus 3 as an option will not be available, thus checking for below condition
viewSizeOptions.includes(this.viewSize) || (viewSizeOptions.includes(+process.env.VUE_APP_VIEW_SIZE) ? this.setViewSize(+process.env.VUE_APP_VIEW_SIZE) : this.setViewSize(viewSizeOptions[0]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should set it with query while fetching the order, if not already. This way one of the check would be reduced

return;
}

await this.store.dispatch('order/updateViewSize', { size, page: this.currentPage })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not bind it with page, viewSize should be passed to respective page in progress, open etc and page should decide what to do with it

showToast(translate('Something went wrong'))
}

dispatch('updateViewSize', { size: orders.length, page: 'open' })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a separate action here, we could directly commit

closeModal() {
modalController.dismiss({ dismissed: true });
},
changePicker(id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
changePicker(id) {
selectPicker(id) {

this.selectedPickers.push(this.pickers.find((picker) => picker.id == id))
}
},
async searchPicker () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 2 methods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement support to make the open orders flow functional
3 participants