Skip to content

Commit

Permalink
Merge pull request #258 from ymaheshwari1/#257
Browse files Browse the repository at this point in the history
Improved: condition to make the value of partial allocation updated on server when selecting promise date and also enabled partial group allocation when partial allocation is enabled(#257)
  • Loading branch information
ymaheshwari1 authored Sep 3, 2024
2 parents 028ff9c + 3a30564 commit 8ac59fc
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/views/BrokeringQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@
<ion-item>
<ion-icon slot="start" :icon="filterOutline"/>
<h4>{{ translate("Filters") }}</h4>
<ion-button v-if="inventoryRuleFilterOptions && Object.keys(inventoryRuleFilterOptions).length" slot="end" fill="clear" @click="addInventoryFilterOptions('INV_FILTER_PRM_TYPE', 'ENTCT_FILTER', 'Filters')">
<ion-button v-if="isInventoryRuleFiltersApplied()" slot="end" fill="clear" @click="addInventoryFilterOptions('INV_FILTER_PRM_TYPE', 'ENTCT_FILTER', 'Filters')">
<ion-icon slot="icon-only" :icon="optionsOutline"/>
</ion-button>
</ion-item>
<p class="empty-state" v-if="!inventoryRuleFilterOptions || !Object.keys(inventoryRuleFilterOptions).length">
<p class="empty-state" v-if="!isInventoryRuleFiltersApplied()">
{{ translate("All facilities enabled for online fulfillment will be attempted for brokering if no filter is applied.") }}<br /><br />
<span><a target="_blank" rel="noopener noreferrer" href="https://docs.hotwax.co/documents/v/system-admins/administration/facilities/configure-fulfillment-capacity">{{ translate("Learn more") }}</a>{{ translate(" about enabling a facility for online fulfillment.") }}</span>
<ion-button fill="clear" @click="addInventoryFilterOptions('INV_FILTER_PRM_TYPE', 'ENTCT_FILTER', 'Filters')">
Expand Down Expand Up @@ -257,8 +257,7 @@
{{ translate("Select if partial allocation should be allowed in this inventory rule") }}
</ion-card-content>
<ion-item lines="none">
<!-- When selecting promiseDate route filter we will show the partial allocation option as checked on UI, but will not update its value on backend. Discussed with Aditya Sir -->
<ion-toggle :disabled="isPromiseDateFilterApplied()" :checked="selectedRoutingRule.assignmentEnumId === 'ORA_MULTI' || isPromiseDateFilterApplied()" @ionChange="updatePartialAllocation($event.detail.checked)">{{ translate("Allow partial allocation") }}</ion-toggle>
<ion-toggle :disabled="isPromiseDateFilterApplied()" :checked="selectedRoutingRule.assignmentEnumId === 'ORA_MULTI'" @ionChange="updatePartialAllocation($event.detail.checked)">{{ translate("Allow partial allocation") }}</ion-toggle>
</ion-item>
<ion-item v-show="isPromiseDateFilterApplied()" lines="none">
<ion-label class="ion-text-wrap">
Expand Down Expand Up @@ -808,17 +807,26 @@ function updatePartialAllocation(checked: any) {
if(inventoryRule.routingRuleId === selectedRoutingRule.value.routingRuleId) {
// Updating selected routing rule explicitely as we are using rulesForReorder for fetching selected values
inventoryRule.assignmentEnumId = selectedRoutingRule.value.assignmentEnumId = checked ? "ORA_MULTI" : "ORA_SINGLE"
// When enabling partial allocation, updating the value of partial group item allocation by default,
// as when partial allocation is enabled we are saying to partial allocate all items of orders thus need to make
// group items allocation enabled as well in this case.
updatePartialGroupItemsAllocation(checked)
}
})
hasUnsavedChanges.value = true
}
function isInventoryRuleFiltersApplied() {
const ruleFilters = Object.keys(inventoryRuleFilterOptions.value).filter((rule: string) => rule !== conditionFilterEnums["SPLIT_ITEM_GROUP"].code);
return ruleFilters.length
}
function isPromiseDateFilterApplied() {
if(!currentRouting.value["rules"]?.length) {
return;
}
// When user updates partial allocation and then selects promiseDate filter then we will assume that the user wants to change the value for partialAllocation on server and thus we will not revert any change made in the partial allocation action and update its value on server
const filter = getFilterValue(orderRoutingFilterOptions.value, ruleEnums, "PROMISE_DATE")
return filter?.fieldValue || filter?.fieldValue == 0
}
Expand Down Expand Up @@ -876,6 +884,9 @@ async function selectPromiseFilterValue(ev: CustomEvent) {
if(result.data?.duration || result.data?.duration == 0) {
getFilterValue(orderRoutingFilterOptions.value, ruleEnums, "PROMISE_DATE").fieldValue = result.data?.isPastDuration ? `-${result.data?.duration}` : result.data?.duration
hasUnsavedChanges.value = true
// When selecting promiseDate route filter value, we also need to enable partial allocation and make its value change on the server
updatePartialAllocation(true);
}
getFilterValue(orderRoutingFilterOptions.value, ruleEnums, "PROMISE_DATE").operator = "less-equals"
})
Expand Down

0 comments on commit 8ac59fc

Please sign in to comment.