Skip to content

Commit

Permalink
Improved: conditions which are not required and if syntax (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Sep 20, 2023
1 parent 9770a27 commit 75398ef
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/views/ClosePurchaseOrderModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default defineComponent({
text: this.$t('Proceed'),
role: 'proceed',
handler: async () => {
if(this.isEligibileForCreatingShipment()){
if(this.isEligibileForCreatingShipment()) {
await this.createShipment()
}
this.updatePOItemStatus()
Expand All @@ -127,16 +127,16 @@ export default defineComponent({
return alert.present();
},
async updatePOItemStatus() {
const eligibleItems = this.order.items.filter((item: any) => item.isChecked == true)
const areAllItemSelected = this.areAllItemSelected(eligibleItems)
const eligibleItems = this.order.items.filter((item: any) => item.isChecked)
const areAllItemsSelected = this.areAllItemsSelected(eligibleItems)
eligibleItems.forEach(async (item:any) => {
const selectedItem = {
orderId: item.orderId,
orderItemSeqId: item.orderItemSeqId
} as any
if(!areAllItemSelected){
if(!areAllItemsSelected) {
selectedItem.statusId = "ITEM_COMPLETED"
}
Expand All @@ -147,15 +147,17 @@ export default defineComponent({
})
});
},
areAllItemSelected(eligibleItems:any) {
areAllItemsSelected(eligibleItems: any) {
return eligibleItems.length === this.order.items.filter((item:any) => item.orderItemStatusId != "ITEM_COMPLETED" || item.orderItemStatusId != "ITEM_REJECTED").length
},
isEligibleToClosePOItems() {
return this.order.items.some((item: any) => item.isChecked)
},
selectAllItems() {
this.order.items.map((item:any) => {
if ( !(item.orderItemStatusId === "ITEM_COMPLETED") || !(item.orderItemStatusId === "ITEM_REJECTED")) item.isChecked = true;
if(!(item.orderItemStatusId === "ITEM_COMPLETED") || !(item.orderItemStatusId === "ITEM_REJECTED")) {
item.isChecked = true;
}
})
}
},
Expand Down

0 comments on commit 75398ef

Please sign in to comment.