Skip to content

Commit

Permalink
Implemented: reject/recycle button on open and in-progress orders page (
Browse files Browse the repository at this point in the history
  • Loading branch information
k2maan committed Aug 4, 2023
1 parent b2dc030 commit 39bce06
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 148 deletions.
41 changes: 41 additions & 0 deletions src/views/InProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<ion-title v-else>{{ inProgressOrders.query.viewSize }} {{ $t('of') }} {{ inProgressOrders.total }} {{ $t('orders') }}</ion-title>

<ion-buttons slot="end">
<ion-button :disabled="!hasPermission(Actions.APP_RECYCLE_ORDER)" fill="outline" color="secondary" size="medium" @click="recycleInProgressOrders()">
{{ $t("Recycle all in progress orders") }}
</ion-button>
<ion-menu-button menu="end" :disabled="!inProgressOrders.total">
<ion-icon :icon="optionsOutline" />
</ion-menu-button>
Expand Down Expand Up @@ -208,6 +211,8 @@ import { prepareOrderQuery } from '@/utils/solrHelper';
import { UtilService } from '@/services/UtilService';
import { DateTime } from 'luxon';
import logger from '@/logger';
import { UserService } from '@/services/UserService';
import { Actions, hasPermission } from '@/authorization'
export default defineComponent({
name: 'InProgress',
Expand Down Expand Up @@ -820,6 +825,40 @@ export default defineComponent({
picklist.isGeneratingPicklist = true;
await OrderService.printPicklist(picklist.id)
picklist.isGeneratingPicklist = false;
},
async recycleInProgressOrders() {
const alert = await alertController.create({
header: translate('Recycle in progress orders'),
message: this.$t('Are you sure you want to recycle in progress order(s)?', { ordersCount: this.inProgressOrders.total }),
buttons: [{
text: translate('No'),
role: 'cancel'
}, {
text: translate('Yes'),
handler: async () => {
let resp;
try {
resp = await UserService.recycleInProgressOrders({
"facilityId": this.currentFacility.facilityId,
"productStoreId": this.currentEComStore.productStoreId,
"reasonId": "INACTIVE_STORE"
})
if(!hasError(resp)) {
showToast(translate('Recycling has been started. All in progress orders will be recycled shortly.'))
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to recycle in progress orders'))
logger.error('Failed to recycle in progress orders', err)
}
}
}]
});
await alert.present();
}
},
async mounted () {
Expand All @@ -835,13 +874,15 @@ export default defineComponent({
const store = useStore();
return {
Actions,
copyToClipboard,
addOutline,
printOutline,
ellipsisVerticalOutline,
optionsOutline,
formatUtcDate,
getFeature,
hasPermission,
checkmarkDoneOutline,
pricetagOutline,
store
Expand Down
47 changes: 45 additions & 2 deletions src/views/OpenOrders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<ion-title v-else>{{ openOrders.query.viewSize }} {{ $t('of') }} {{ openOrders.total }} {{ $t('orders') }}</ion-title>

<ion-buttons slot="end">
<ion-button :disabled="!hasPermission(Actions.APP_RECYCLE_ORDER)" fill="outline" color="secondary" @click="recycleOutstandingOrders()">
{{ $t("Recycle all open orders") }}
</ion-button>
<ion-menu-button menu="end" :disabled="!openOrders.total">
<ion-icon :icon="optionsOutline" />
</ion-menu-button>
Expand Down Expand Up @@ -123,19 +126,24 @@ import {
IonThumbnail,
IonTitle,
IonToolbar,
modalController } from '@ionic/vue';
modalController,
alertController
} from '@ionic/vue';
import { defineComponent } from 'vue';
import { optionsOutline, pricetagOutline, printOutline, refreshCircleOutline } from 'ionicons/icons';
import AssignPickerModal from '@/views/AssignPickerModal.vue';
import { mapGetters, useStore } from 'vuex';
import Image from '@/components/Image.vue'
import { copyToClipboard, formatUtcDate, getFeature } from '@/utils'
import { copyToClipboard, formatUtcDate, getFeature, showToast } from '@/utils'
import { hasError } from '@/adapter';
import { UtilService } from '@/services/UtilService';
import { prepareOrderQuery } from '@/utils/solrHelper';
import ViewSizeSelector from '@/components/ViewSizeSelector.vue'
import emitter from '@/event-bus';
import logger from '@/logger';
import { translate } from '@/i18n';
import { UserService } from '@/services/UserService';
import { Actions, hasPermission } from '@/authorization'
export default defineComponent({
name: 'OpenOrders',
Expand Down Expand Up @@ -280,6 +288,39 @@ export default defineComponent({
openOrdersQuery.viewSize = process.env.VUE_APP_VIEW_SIZE
await this.store.dispatch('order/updateOpenQuery', { ...openOrdersQuery })
},
async recycleOutstandingOrders() {
const alert = await alertController.create({
header: translate('Recycle outstanding orders'),
message: this.$t('Are you sure you want to recycle outstanding order(s)?', { ordersCount: this.openOrders.total }),
buttons: [{
text: translate('No'),
role: 'cancel'
}, {
text: translate('Yes'),
handler: async () => {
let resp;
try {
resp = await UserService.recycleOutstandingOrders({
"facilityId": this.currentFacility.facilityId,
"productStoreId": this.currentEComStore.productStoreId,
"reasonId": "INACTIVE_STORE"
})
if (!hasError(resp)) {
showToast(translate('Recycling has been started. All outstanding orders will be recycled shortly.'))
} else {
throw resp.data
}
} catch (err) {
showToast(translate('Failed to recycle outstanding orders'))
logger.error('Failed to recycle outstanding orders', err)
}
}
}]
});
await alert.present();
},
},
async mounted () {
emitter.on('updateOrderQuery', this.updateOrderQuery)
Expand All @@ -293,9 +334,11 @@ export default defineComponent({
const store = useStore();
return{
Actions,
copyToClipboard,
formatUtcDate,
getFeature,
hasPermission,
optionsOutline,
pricetagOutline,
printOutline,
Expand Down
147 changes: 1 addition & 146 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
<ion-label class="text-wrap">{{ $t("has outstanding orders and in progress orders.", {storeName: currentFacility.name, outstandingOrdersCount, inProgressOrdersCount}) }}</ion-label>
</ion-item>
<div class="actions">
<div>
<ion-button :disabled="!hasPermission(Actions.APP_RECYCLE_ORDER)" fill="outline" color="secondary" size="medium" @click="recycleOutstandingOrders()">{{ $t("Recycle all open orders") }}</ion-button>
<ion-button :disabled="!hasPermission(Actions.APP_RECYCLE_ORDER)" fill="outline" color="secondary" size="medium" @click="recycleInProgressOrders()">{{ $t("Recycle all in progress orders") }}</ion-button>
<!-- <ion-button fill="outline" color="secondary" size="medium">{{ $t("Recycle all orders") }}</ion-button> -->
</div>
<div>
<ion-button :disabled="!hasPermission(Actions.APP_TURN_OFF_STORE)" v-if="isStoreFulfillmentTurnOn" fill="outline" color="danger" size="medium" @click="turnOffFulfillment()">{{ $t("Turn off fulfillment") }}</ion-button>
<ion-button v-else fill="outline" color="success" size="medium" @click="turnOnFulfillment()">{{ $t("Turn on fulfillment") }}</ion-button>
Expand Down Expand Up @@ -137,9 +132,7 @@ export default defineComponent({
data() {
return {
baseURL: process.env.VUE_APP_BASE_URL,
currentFacilityDetails: {} as any,
outstandingOrdersCount: 0,
inProgressOrdersCount: 0
currentFacilityDetails: {} as any
};
},
computed: {
Expand All @@ -157,74 +150,8 @@ export default defineComponent({
},
ionViewWillEnter() {
this.getCurrentFacilityDetails()
this.getOutstandingOrdersCount()
this.getInProgressOrdersCount()
},
methods: {
async getOutstandingOrdersCount() {
let resp;
try {
this.outstandingOrdersCount = 0
const payload = {
"json": {
"params": {
"rows": "0",
"group": true,
"group.field": "orderId",
"group.limit": 10000,
"group.ngroups": true,
"q.op": "AND"
},
"query": "(*:*)",
"filter": ["docType: OISGIR", "quantityNotAvailable: 0", "isPicked: N", "-shipmentMethodTypeId: STOREPICKUP", "-fulfillmentStatus: Cancelled", "orderStatusId: ORDER_APPROVED", "orderTypeId: SALES_ORDER", `facilityId: ${this.currentFacility.facilityId}`, `productStoreId: ${this.currentEComStore.productStoreId}`]
}
}
resp = await UserService.getOutstandingOrdersCount(payload)
if(!hasError(resp)) {
this.outstandingOrdersCount = resp.data.grouped.orderId.ngroups
} else {
throw resp.data
}
} catch(err) {
logger.error('Failed to get outstanding orders count', err)
}
},
async getInProgressOrdersCount() {
let resp;
try {
this.inProgressOrdersCount = 0
const payload = {
"json": {
"params": {
"rows": "0",
"group": true,
"group.field": "picklistBinId",
"group.limit": 10000,
"group.ngroups": true,
"q.op": "AND"
},
"query": "(*:*)",
"filter": ["docType: OISGIR", "picklistItemStatusId: PICKITEM_PENDING", "-shipmentMethodTypeId: STOREPICKUP", "-fulfillmentStatus: Rejected", `facilityId: ${this.currentFacility.facilityId}`, `productStoreId: ${this.currentEComStore.productStoreId}`]
}
}
resp = await UserService.getInProgressOrdersCount(payload)
if(!hasError(resp)) {
this.inProgressOrdersCount = resp.data.grouped.picklistBinId.ngroups
} else {
throw resp.data
}
} catch(err) {
logger.error('Failed to get inProgress orders count', err)
}
},
async getCurrentFacilityDetails() {
let resp: any;
try {
Expand Down Expand Up @@ -277,8 +204,6 @@ export default defineComponent({
});
this.store.dispatch('order/clearOrders')
this.getCurrentFacilityDetails();
this.getOutstandingOrdersCount();
this.getInProgressOrdersCount();
}
},
async changeTimeZone() {
Expand Down Expand Up @@ -351,74 +276,6 @@ export default defineComponent({
await alert.present();
},
async recycleOutstandingOrders() {
const alert = await alertController.create({
header: translate('Recycle outstanding orders'),
message: this.$t('Are you sure you want to recycle outstanding order(s)?', { ordersCount: this.outstandingOrdersCount }),
buttons: [{
text: translate('No'),
role: 'cancel'
}, {
text: translate('Yes'),
handler: async () => {
let resp;
try {
resp = await UserService.recycleOutstandingOrders({
"facilityId": this.currentFacility.facilityId,
"productStoreId": this.currentEComStore.productStoreId,
"reasonId": "INACTIVE_STORE"
})
if(!hasError(resp)) {
showToast(translate('Recycling has been started. All outstanding orders will be recycled shortly.'))
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to recycle outstanding orders'))
logger.error('Failed to recycle outstanding orders', err)
}
}
}]
});
await alert.present();
},
async recycleInProgressOrders() {
const alert = await alertController.create({
header: translate('Recycle in progress orders'),
message: this.$t('Are you sure you want to recycle in progress order(s)?', { ordersCount: this.inProgressOrdersCount }),
buttons: [{
text: translate('No'),
role: 'cancel'
}, {
text: translate('Yes'),
handler: async () => {
let resp;
try {
resp = await UserService.recycleInProgressOrders({
"facilityId": this.currentFacility.facilityId,
"productStoreId": this.currentEComStore.productStoreId,
"reasonId": "INACTIVE_STORE"
})
if(!hasError(resp)) {
showToast(translate('Recycling has been started. All in progress orders will be recycled shortly.'))
} else {
throw resp.data
}
} catch(err) {
showToast(translate('Failed to recycle in progress orders'))
logger.error('Failed to recycle in progress orders', err)
}
}
}]
});
await alert.present();
},
async setEComStore(event: any) {
// not updating the ecomstore when the current value in vuex state and selected value are same
// or when an empty value is given (on logout)
Expand All @@ -430,8 +287,6 @@ export default defineComponent({
await this.store.dispatch('user/setEComStore', {
'eComStore': this.userProfile.stores.find((str: any) => str.productStoreId == event.detail.value)
})
this.getOutstandingOrdersCount();
this.getInProgressOrdersCount();
}
},
setPrintShippingLabelPreference (ev: any) {
Expand Down

0 comments on commit 39bce06

Please sign in to comment.