Fix refund with no items available
This commit is contained in:
parent
69c09b8e25
commit
512274a11f
1 changed files with 32 additions and 26 deletions
|
|
@ -14,32 +14,32 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
}
|
||||
// * Calcule la somme des produits que l'on veux déclarer comme remboursés.
|
||||
const fetchRefundTotal = (): number => {
|
||||
return Array.from(
|
||||
const refundQtys = Array.from(
|
||||
confirmSubmitJSPreparation.getElementsByClassName(
|
||||
"item_value"
|
||||
) as HTMLCollectionOf<HTMLTableCellElement>
|
||||
)
|
||||
.map((tdElement) => {
|
||||
const checked = (
|
||||
tdElement.querySelector(
|
||||
"input[type=\"checkbox\"]"
|
||||
) as HTMLInputElement
|
||||
).checked,
|
||||
price_ttc = Number.parseInt(
|
||||
String(tdElement.dataset["price_ttc"])
|
||||
),
|
||||
qty = Number.parseInt(
|
||||
String(
|
||||
(
|
||||
tdElement.querySelector(
|
||||
"input[type=\"number\"]"
|
||||
) as HTMLInputElement
|
||||
).value
|
||||
)
|
||||
);
|
||||
return checked ? price_ttc * qty : 0;
|
||||
})
|
||||
.reduce((prev, curr) => prev + curr);
|
||||
).map((tdElement) => {
|
||||
const checked = (
|
||||
tdElement.querySelector(
|
||||
"input[type=\"checkbox\"]"
|
||||
) as HTMLInputElement
|
||||
).checked,
|
||||
price_ttc = Number.parseInt(
|
||||
String(tdElement.dataset["price_ttc"])
|
||||
),
|
||||
qty = Number.parseInt(
|
||||
String(
|
||||
(
|
||||
tdElement.querySelector(
|
||||
"input[type=\"number\"]"
|
||||
) as HTMLInputElement
|
||||
).value
|
||||
)
|
||||
);
|
||||
return checked ? price_ttc * qty : 0;
|
||||
});
|
||||
refundQtys.push(0);
|
||||
return refundQtys.reduce((prev, curr) => prev + curr);
|
||||
};
|
||||
|
||||
// * Handle switches
|
||||
|
|
@ -89,12 +89,18 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
);
|
||||
return;
|
||||
}
|
||||
let confirmMessage = trans.methods.__(
|
||||
"Les produits sélectionnés seront inclus dans la facture de remboursement."
|
||||
);
|
||||
if (!wantToRefund) {
|
||||
confirmMessage = trans.methods.__(
|
||||
"Vous allez justifier ce remboursement, continuer ?"
|
||||
);
|
||||
}
|
||||
// ? Confirmer la résolution ?
|
||||
sweetalertConfirm.methods.confirm(
|
||||
trans.methods.__("Confirmez"),
|
||||
trans.methods.__(
|
||||
"Les produits sélectionnés seront inclus dans la facture de remboursement."
|
||||
),
|
||||
confirmMessage,
|
||||
this as HTMLFormElement,
|
||||
() => (this as HTMLFormElement).submit(),
|
||||
{ icon: "warning" }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue