From d9be3efa90a081f6b5c3c64c1e3a36d3432cb2f4 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 13 Dec 2024 06:18:45 +0100 Subject: [PATCH 1/2] FIX #32339 Delete a loan settlement is partial --- htdocs/loan/class/paymentloan.class.php | 44 +++++++++---------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index bd02374a24c..77c8b183b87 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2018 Frederic France - * Copyright (C) 2020 Maxime DEMAREST +/* Copyright (C) 2014-2024 Alexandre Spangaro + * Copyright (C) 2015-2018 Frederic France + * Copyright (C) 2020 Maxime DEMAREST * * 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 @@ -99,6 +99,11 @@ class PaymentLoan extends CommonObject public $type_code; public $type_label; + /** + * @var int + */ + public $bank_line; + /** * Constructor @@ -364,6 +369,7 @@ class PaymentLoan extends CommonObject } $this->db->rollback(); return -1 * $error; + } else { $this->db->commit(); return 1; @@ -380,19 +386,17 @@ class PaymentLoan extends CommonObject */ public function delete($user, $notrigger = 0) { - global $conf, $langs; $error = 0; $this->db->begin(); - if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql .= " WHERE type='payment_loan' AND url_id=".((int) $this->id); - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + if ($this->bank_line > 0) { + $accline = new AccountLine($this->db); + $accline->fetch($this->bank_line); + $result = $accline->delete($user); + if ($result < 0) { + $this->errors[] = $accline->error; + $error++; } } @@ -422,22 +426,6 @@ class PaymentLoan extends CommonObject } } - //if (! $error) - //{ - // if (! $notrigger) - // { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. - - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - // } - //} - // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { From ef090aa895dc7d33482f4bd6d4b1ef9bb8d1d395 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 13 Dec 2024 06:22:44 +0100 Subject: [PATCH 2/2] CI --- htdocs/loan/class/paymentloan.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 77c8b183b87..1604383b700 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -369,7 +369,6 @@ class PaymentLoan extends CommonObject } $this->db->rollback(); return -1 * $error; - } else { $this->db->commit(); return 1;