Correction calcul net appel à virement
This commit is contained in:
parent
254c20221b
commit
add33bdb8f
1 changed files with 6 additions and 3 deletions
|
|
@ -264,14 +264,15 @@ export async function POST(req: NextRequest) {
|
|||
has_contract: !!contract,
|
||||
has_salarie: !!salarie,
|
||||
employee_name,
|
||||
net_amount: p.net_amount
|
||||
net_amount: p.net_amount,
|
||||
net_after_withholding: p.net_after_withholding
|
||||
});
|
||||
|
||||
return {
|
||||
employee_name,
|
||||
matricule: contract?.employee_matricule || "",
|
||||
contrat: contract?.contract_number || "",
|
||||
montant: parseFloat(p.net_amount || 0),
|
||||
montant: parseFloat(p.net_after_withholding || p.net_amount || 0),
|
||||
analytique: contract?.analytique || "",
|
||||
profession: contract?.profession || "",
|
||||
};
|
||||
|
|
@ -284,7 +285,9 @@ export async function POST(req: NextRequest) {
|
|||
|
||||
// Calculate totals
|
||||
const totalNet = (payslips || []).reduce((sum: number, p: any) => {
|
||||
const net = typeof p.net_amount === "string" ? parseFloat(p.net_amount) : (p.net_amount || 0);
|
||||
const net = typeof p.net_after_withholding === "string"
|
||||
? parseFloat(p.net_after_withholding)
|
||||
: (p.net_after_withholding || (typeof p.net_amount === "string" ? parseFloat(p.net_amount) : p.net_amount) || 0);
|
||||
return sum + net;
|
||||
}, 0);
|
||||
console.log("[generate-pdf] Total net amount:", totalNet);
|
||||
|
|
|
|||
Loading…
Reference in a new issue