mirror of
https://origin.cursor.com/mrdevmx/panels.git
synced 2026-10-09 17:33:16 +00:00
Proveedor y unidad pasan a Select de catálogo (no texto libre). Subtotal, IVA y total se calculan al vuelo. El comprobante usa FileUpload de PrimeVue. Co-authored-by: alberto.martinez <alberto.martinez@mrdev.mx>
21 lines
636 B
TypeScript
21 lines
636 B
TypeScript
export function roundMoney(value: number) {
|
|
return Math.round((Number(value) || 0) * 100) / 100;
|
|
}
|
|
|
|
export function expenseAmounts(
|
|
quantity: number,
|
|
unitPrice: number,
|
|
taxIncluded: boolean,
|
|
ivaRate = 0.16,
|
|
) {
|
|
const line = roundMoney(quantity * unitPrice);
|
|
const rate = Number(ivaRate) || 0.16;
|
|
if (taxIncluded) {
|
|
const total = line;
|
|
const subtotal = roundMoney(total / (1 + rate));
|
|
return { subtotal, ivaAmount: roundMoney(total - subtotal), total };
|
|
}
|
|
const subtotal = line;
|
|
const ivaAmount = roundMoney(subtotal * rate);
|
|
return { subtotal, ivaAmount, total: roundMoney(subtotal + ivaAmount) };
|
|
}
|