From 0c91e3fe068af441c38b38796a6914f35eff19b1 Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Sat, 9 Mar 2024 22:01:30 +0100 Subject: [PATCH 1/4] attempt at fixing #28645 --- htdocs/compta/bank/class/api_bankaccounts.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 2f5f532e7468c..5dcb390ace321 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -187,6 +187,7 @@ public function post($request_data = null) * @param string $description Description of the internal wire transfer {@from body}{@required true} * @param float $amount Amount to transfer from the source to the destination BankAccount {@from body}{@required true} * @param float $amount_to Amount to transfer to the destination BankAccount (only when accounts does not share the same currency) {@from body}{@required false} + * @param string $cheque_number Cheque numero {@from body} * * @url POST /transfer * @@ -199,7 +200,7 @@ public function post($request_data = null) * @throws RestException 422 Unprocessable Entity: Refer to detailed exception message for the cause * @throws RestException 500 Internal Server Error: Error(s) returned by the RDBMS */ - public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0) + public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0, $cheque_number = "" ) { if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); @@ -257,21 +258,21 @@ public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date // Clean data $description = sanitizeVal($description, 'alphanohtml'); - + $cheque_number = sanitizeVal($cheque_number); /** * Creating bank line records */ if (!$error) { - $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1 * price2num($amount), '', '', $user); + $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1 * price2num($amount), '', '', $user, $cheque_number); } if (!($bank_line_id_from > 0)) { $error++; } if (!$error) { - $bank_line_id_to = $accountto->addline($date, $typeto, $description, price2num($amount_to), '', '', $user); + $bank_line_id_to = $accountto->addline($date, $typeto, $description, price2num($amount_to), '', '', $user, $cheque_number); } if (!($bank_line_id_to > 0)) { $error++; From 95d644615c71c4cf8a34712274fb6fa2756919c2 Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Sat, 9 Mar 2024 22:14:02 +0100 Subject: [PATCH 2/4] remove trailing whitespace --- htdocs/compta/bank/class/api_bankaccounts.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 5dcb390ace321..47eb9bf84a62b 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -200,7 +200,7 @@ public function post($request_data = null) * @throws RestException 422 Unprocessable Entity: Refer to detailed exception message for the cause * @throws RestException 500 Internal Server Error: Error(s) returned by the RDBMS */ - public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0, $cheque_number = "" ) + public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0, $cheque_number = "") { if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); From 668d2fa6e88b0cfdcd9e71efeb54b41f197cdf7f Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Sat, 9 Mar 2024 22:43:53 +0100 Subject: [PATCH 3/4] making param string cheque_number line up and conform better with previous code --- htdocs/compta/bank/class/api_bankaccounts.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 47eb9bf84a62b..c2f57b7605660 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -187,7 +187,7 @@ public function post($request_data = null) * @param string $description Description of the internal wire transfer {@from body}{@required true} * @param float $amount Amount to transfer from the source to the destination BankAccount {@from body}{@required true} * @param float $amount_to Amount to transfer to the destination BankAccount (only when accounts does not share the same currency) {@from body}{@required false} - * @param string $cheque_number Cheque numero {@from body} + * @param string $cheque_number Cheque numero {@from body}{@required false} * * @url POST /transfer * From f7024b61ee6797e02f2c969dda280d53668c707b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2024 15:37:16 +0100 Subject: [PATCH 4/4] Update api_bankaccounts.class.php --- htdocs/compta/bank/class/api_bankaccounts.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index c2f57b7605660..bc973b0045b32 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -258,7 +258,7 @@ public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date // Clean data $description = sanitizeVal($description, 'alphanohtml'); - $cheque_number = sanitizeVal($cheque_number); + $cheque_number = sanitizeVal($cheque_number, 'alphanohtml'); /** * Creating bank line records