Skip to content

Commit

Permalink
Merge pull request #28736 from JonBendtsen/cheque_number
Browse files Browse the repository at this point in the history
attempt at fixing #28645 - API bankaccounts/transfer POST missing the cheque_number
  • Loading branch information
eldy authored Mar 11, 2024
2 parents a8a2f0f + f7024b6 commit 464b124
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions htdocs/compta/bank/class/api_bankaccounts.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}{@required false}
*
* @url POST /transfer
*
Expand All @@ -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);
Expand Down Expand Up @@ -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, 'alphanohtml');

/**
* 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++;
Expand Down

0 comments on commit 464b124

Please sign in to comment.