Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const handleUpdateAdjustment = (adjustmentId: string, selected: AdjustmentType)
:placeholder="$t('COST_EXPLORER.ADVANCED_SETTINGS.AMOUNT')"
:invalid="!item.amount"
class="w-auto"
:min="0"
>
<template #input-left>
<div :class="['symbol-icon', getAmountSymbol(item.adjustment) === 'ic_minus' ? 'text-red-500' : 'text-green-500']">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,34 +222,36 @@ const handleSave = async () => {
try {
// CUD Adjustment Policy
const deletedPolicyIds = await deleteAdjustmentPolicy();
await Promise.all(formPolicies.value.map(async (policy, idx) => {
const policyPromises = formPolicies.value.map(async (policy, idx) => {
if (policy.id.startsWith('rap-')) {
await updateAdjustmentPolicy(policy, idx);
} else {
await createAdjustmentPolicy(policy, idx);
return updateAdjustmentPolicy(policy, idx);
}
}));
return createAdjustmentPolicy(policy, idx);
});
await Promise.all(policyPromises);

// CUD Adjustment
await deleteAdjustment(deletedPolicyIds);
await Promise.all(formPolicies.value.map(async (policy) => {
const adjustmentPromises = formPolicies.value.flatMap(async (policy) => {
const adjustments = formAdjustments.value.filter((adjustment) => adjustment.policyId === policy.id);
await Promise.all(adjustments.map(async (adjustment, idx) => {
return adjustments.map(async (adjustment, idx) => {
if (adjustment.id.startsWith('ra-')) {
await updateAdjustment(adjustment, idx);
} else {
await createAdjustment(adjustment, idx);
return updateAdjustment(adjustment, idx);
}
}));
}));

queryClient.invalidateQueries({ queryKey: rapQueryKey.value });
queryClient.invalidateQueries({ queryKey: raQueryKey.value });
return createAdjustment(adjustment, idx);
});
});
const resolvedAdjustments = await Promise.all(adjustmentPromises);
await Promise.all(resolvedAdjustments.flat());

showSuccessMessage(i18n.t('COST_EXPLORER.ADVANCED_SETTINGS.ALT_S_SAVE_COST_REPORT_ADJUSTMENTS'), '');
} catch (error) {
ErrorHandler.handleRequestError(error, i18n.t('COST_EXPLORER.ADVANCED_SETTINGS.ALT_E_SAVE_COST_REPORT_ADJUSTMENTS'));
} finally {
await Promise.all([
queryClient.invalidateQueries({ queryKey: rapQueryKey.value }),
queryClient.invalidateQueries({ queryKey: raQueryKey.value }),
]);
state.loading = false;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const useAdvancedSettingsPageStore = defineStore('page-advanced-settings'
}),
getters: {
isAdjustmentPolicyValid: (state) => state.adjustmentPolicyList
.every((item) => (item.isAllWorkspaceSelected || !!item.workspaceMenuItems?.length) && !!state.adjustmentListMap[item.id]?.length),
.every((item) => (item.isAllWorkspaceSelected || !!item.workspaceMenuItems?.length)),
isAdjustmentValid: (state) => Object.values(state.adjustmentListMap)
.every((item) => item.every((adjustment) => adjustment.name && adjustment.provider && adjustment.adjustment && !!adjustment.amount && Number(adjustment.amount) > 0)),
},
Expand Down
Loading