2
0
forked from Wavyzz/dolibarr

Merge branch 'develop' of github.com:Dolibarr/dolibarr into develop

This commit is contained in:
Laurent Destailleur
2024-03-21 23:28:50 +01:00
695 changed files with 13321 additions and 6861 deletions

View File

@@ -3,6 +3,7 @@
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -58,12 +59,20 @@ class PaymentVAT extends CommonObject
public $datep = '';
/**
* @deprecated
* @deprecated Use $amount instead
* @see $amount
* @var float|int
*/
public $total;
/**
* @var float|int
*/
public $amount; // Total amount of payment
/**
* @var array<float|int>
*/
public $amounts = array(); // Array of amounts
/**
@@ -73,7 +82,7 @@ class PaymentVAT extends CommonObject
/**
* @var string
* @deprecated
* @deprecated Use $num_payment instead
* @see $num_payment
*/
public $num_paiement;
@@ -178,7 +187,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;
@@ -204,11 +213,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) {
@@ -235,7 +244,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) {
@@ -246,8 +255,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 {
@@ -363,7 +372,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;
@@ -537,12 +546,12 @@ class PaymentVAT extends CommonObject
$this->fk_tva = 0;
$this->datec = dol_now();
$this->tms = dol_now();
$this->datep = '';
$this->amount = '';
$this->datep = dol_now();
$this->amount = 100;
$this->fk_typepaiement = 0;
$this->num_payment = '';
$this->note_private = '';
$this->note_public = '';
$this->num_payment = '123456';
$this->note_private = 'Private note';
$this->note_public = 'Public note';
$this->fk_bank = 0;
$this->fk_user_creat = 0;
$this->fk_user_modif = 0;
@@ -576,7 +585,7 @@ class PaymentVAT extends CommonObject
$acc = new Account($this->db);
$acc->fetch($accountid);
$total = $this->total;
$total = $this->amount;
if ($mode == 'payment_vat') {
$total = -$total;
}

View File

@@ -5,6 +5,7 @@
* Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -661,9 +662,9 @@ class Tva extends CommonObject
}
if ($this->amount > 0) {
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), $this->num_payment, '', $user);
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs((float) $this->amount), $this->num_payment, '', $user);
} else {
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user);
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs((float) $this->amount), $this->num_payment, '', $user);
}
// Update fk_bank into llx_tva. So we know vat line used to generate bank transaction