refactor: refs #6696 remove VnUsesMana component and update related logic in TicketEditMana and TicketSale #1675

Merged
jgallego merged 11 commits from 6696-manaAfterDepartment into dev 2025-04-11 10:39:58 +00:00
2 changed files with 14 additions and 9 deletions
Showing only changes of commit b521aa86f3 - Show all commits

View File

@ -327,28 +327,31 @@ const changeDiscount = async (sale) => {
const newDiscount = edit.value.discount;
if (newDiscount != null && newDiscount != sale.discount) {
if (await isSalePrepared(sale))
await confirmUpdate(() => updateDiscount([sale], newDiscount));
else await updateDiscount([sale], newDiscount);
await confirmUpdate(() =>
updateDiscount([sale], newDiscount, componentId.value),
);
else await updateDiscount([sale], newDiscount, componentId.value);
}
};
const updateDiscounts = async (sales, newDiscount) => {
const updateDiscounts = async (sales, newDiscount, componentId) => {
const salesTracking = await fetchSalesTracking();
const someSaleIsPrepared = salesTracking.some((sale) =>
matchSale(salesTracking, sale),
);
if (someSaleIsPrepared) await confirmUpdate(() => updateDiscount(sales, newDiscount));
else updateDiscount(sales, newDiscount);
if (someSaleIsPrepared)
await confirmUpdate(() => updateDiscount(sales, newDiscount, componentId));
else updateDiscount(sales, newDiscount, componentId);
};
const updateDiscount = async (sales, newDiscount = 0) => {
const updateDiscount = async (sales, newDiscount, componentId) => {
try {
const salesIds = sales.map(({ id }) => id);
const params = {
salesIds,
newDiscount,
componentId: componentId.value,
newDiscount: newDiscount ?? 0,
componentId,
};
await axios.post(`Tickets/${route.params.id}/updateDiscount`, params);
notify('globals.dataSaved', 'positive');

View File

@ -47,6 +47,7 @@ const { notify } = useNotify();
const acl = useAcl();
const btnDropdownRef = ref(null);
const editManaProxyRef = ref(null);
const componentId = ref(null);
const { openConfirmationModal } = useVnConfirm();
const newDiscount = ref(null);
@ -112,7 +113,7 @@ const changeMultipleDiscount = () => {
});
if (newDiscount.value != null && hasChanges)
emit('updateDiscounts', props.sales, newDiscount.value);
emit('updateDiscounts', props.sales, newDiscount.value, componentId.value);
btnDropdownRef.value.hide();
};
@ -206,6 +207,7 @@ const createRefund = async (withWarehouse) => {
ref="editManaProxyRef"
:sale="row"
@save="changeMultipleDiscount"
v-model:component-id="componentId"
>
<VnInput
autofocus