diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 08346ad502bc8..4ba09c30bd450 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2023 Frederic France - * Copyright (C) 2020 Maxime DEMAREST +/* Copyright (C) 2014-2025 Alexandre Spangaro + * Copyright (C) 2015-2023 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 @@ -102,6 +102,10 @@ class PaymentLoan extends CommonObject public $label; public $paymenttype; public $bank_account; + + /** + * @var int + */ public $bank_line; @@ -386,20 +390,17 @@ public function update($user = null, $notrigger = 0) */ 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) { + 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++; - $this->errors[] = "Error ".$this->db->lasterror(); } } @@ -430,22 +431,6 @@ public function delete($user, $notrigger = 0) } } - //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) {