Merge pull request #32346 from aspangaro/18_fixloanpayment

FIX #32339 Delete a loan settlement is partial
This commit is contained in:
Laurent Destailleur 2025-01-20 04:13:26 +01:00 committed by GitHub
commit 1fa3b63fdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015-2018 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
/* Copyright (C) 2014-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2015-2018 Frederic France <frederic.france@free.fr>
* Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
*
* 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
@ -380,19 +385,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 +425,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) {