Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt at fixing #28645 - API bankaccounts/transfer POST missing the cheque_number #28736

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading