Prepare code to fix too many sql error

This commit is contained in:
Laurent Destailleur 2023-02-13 21:08:53 +01:00
parent 2dec660763
commit 212f24ac9e
2 changed files with 12 additions and 5 deletions

View File

@ -1863,11 +1863,14 @@ if ($resql) {
$paiement = $facturestatic->getSommePaiement();
$totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
$totaldeposits = $facturestatic->getSumDepositsUsed();
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
$remaintopay = price2num($facturestatic->total_ttc - $totalpay);
$multicurrency_paiement = $facturestatic->getSommePaiement(1);
$multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
$multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
$remaintopay = price2num($facturestatic->total_ttc - $totalpay);
$multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
$multicurrency_remaintopay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);

View File

@ -131,8 +131,8 @@ abstract class CommonInvoice extends CommonObject
* Return amount of payments already done. This must include ONLY the record into the payment table.
* Payments dones using discounts, credit notes, etc are not included.
*
* @param int $multicurrency Return multicurrency_amount instead of amount
* @return float|int Amount of payment already done, <0 and set ->error if KO
* @param int $multicurrency Return multicurrency_amount instead of amount. -1=Return both.
* @return float|int|array Amount of payment already done, <0 and set ->error if KO
*/
public function getSommePaiement($multicurrency = 0)
{
@ -156,7 +156,11 @@ abstract class CommonInvoice extends CommonObject
$this->db->free($resql);
if ($obj) {
if ($multicurrency) {
if ($multicurrency < 0) {
$this->sumpayed = $obj->amount;
$this->sumpayed_multicurrency = $obj->multicurrency_amount;
return array('alreadypaid'=>(float) $obj->amount, 'alreadypaid_multicurrency'=>(float) $obj->multicurrency_amount);
} elseif ($multicurrency) {
$this->sumpayed_multicurrency = $obj->multicurrency_amount;
return (float) $obj->multicurrency_amount;
} else {