diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 1c72b1ff444..1776fe56a77 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -189,7 +189,7 @@ class PaymentVAT extends CommonObject $this->fk_tva = (int) $this->fk_tva; } if (isset($this->amount)) { - $this->amount = trim($this->amount); + $this->amount = (float) $this->amount; } if (isset($this->fk_typepaiement)) { $this->fk_typepaiement = (int) $this->fk_typepaiement; @@ -215,11 +215,11 @@ class PaymentVAT extends CommonObject $totalamount = 0; foreach ($this->amounts as $key => $value) { // How payment is dispatch - $newvalue = price2num($value, 'MT'); + $newvalue = (float) price2num($value, 'MT'); $this->amounts[$key] = $newvalue; $totalamount += $newvalue; } - $totalamount = price2num($totalamount); + // $totalamount = price2num($totalamount); // Check parameters if ($totalamount == 0) { @@ -246,7 +246,7 @@ class PaymentVAT extends CommonObject foreach ($this->amounts as $key => $amount) { $contribid = $key; if (is_numeric($amount) && $amount != 0) { - $amount = price2num($amount); + $amount = (float) price2num($amount); // If we want to closed paid invoices if ($closepaidvat) { @@ -257,8 +257,8 @@ class PaymentVAT extends CommonObject $creditnotes = 0; //$deposits=$contrib->getSumDepositsUsed(); $deposits = 0; - $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); - $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); + $alreadypayed = (float) price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = (float) price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { $result = $contrib->setPaid($user); } else { @@ -374,7 +374,7 @@ class PaymentVAT extends CommonObject $this->fk_tva = (int) $this->fk_tva; } if (isset($this->amount)) { - $this->amount = trim($this->amount); + $this->amount = (float) $this->amount; } if (isset($this->fk_typepaiement)) { $this->fk_typepaiement = (int) $this->fk_typepaiement; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 5541cdc9ac3..7a9e9171de3 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -160,7 +160,7 @@ class PaymentExpenseReport extends CommonObject $this->fk_expensereport = (int) $this->fk_expensereport; } if (isset($this->amount)) { - $this->amount = trim($this->amount); + $this->amount = (float) $this->amount; } if (isset($this->fk_typepayment)) { $this->fk_typepayment = (int) $this->fk_typepayment; @@ -189,11 +189,11 @@ class PaymentExpenseReport extends CommonObject $totalamount = 0; foreach ($this->amounts as $key => $value) { // How payment is dispatch - $newvalue = price2num($value, 'MT'); + $newvalue = (float) price2num($value, 'MT'); $this->amounts[$key] = $newvalue; $totalamount += $newvalue; } - $totalamount = price2num($totalamount); + // $totalamount = (float) price2num($totalamount); // Check parameters if ($totalamount == 0) { @@ -315,7 +315,7 @@ class PaymentExpenseReport extends CommonObject $this->fk_expensereport = (int) $this->fk_expensereport; } if (isset($this->amount)) { - $this->amount = trim($this->amount); + $this->amount = (float) $this->amount; } if (isset($this->fk_typepayment)) { $this->fk_typepayment = (int) $this->fk_typepayment; diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index e1de1f7015b..df91a49f3f7 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -1,7 +1,7 @@ * Copyright (C) 2015 Laurent Destailleur - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -85,14 +85,14 @@ if ($action == 'add_payment') { if (!$error) { $paymentid = 0; - $total = 0; + // $total = 0; // Read possible payments foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_') { if (GETPOST($key)) { - $amounts[$expensereport->fk_user_author] = price2num(GETPOST($key)); - $total += price2num(GETPOST($key)); + $amounts[$expensereport->fk_user_author] = (float) price2num(GETPOST($key)); + // $total += price2num(GETPOST($key)); } } } @@ -109,8 +109,9 @@ if ($action == 'add_payment') { $payment = new PaymentExpenseReport($db); $payment->fk_expensereport = $expensereport->id; $payment->datep = $datepaid; - $payment->amounts = $amounts; // Tableau de montant - $payment->total = $total; + $payment->amounts = $amounts; // array of amounts + // total is calculated in class + // $payment->total = $total; $payment->fk_typepayment = GETPOSTINT("fk_typepayment"); $payment->num_payment = GETPOST("num_payment", 'alphanohtml'); $payment->note_public = GETPOST("note_public", 'restricthtml');