Fix : Social contribution payment deletion was not deleting the bank line

This commit is contained in:
Maxime Kohlhaas 2015-07-03 16:38:54 +02:00
parent ee643ed2a7
commit 5d14d05ce1
2 changed files with 11 additions and 8 deletions

View File

@ -1152,7 +1152,7 @@ class AccountLine extends CommonObject
if ($this->rappro) if ($this->rappro)
{ {
// Protection to avoid any delete of consolidated lines // Protection to avoid any delete of consolidated lines
$this->error="DeleteNotPossibleLineIsConsolidated"; $this->error="ErrorDeleteNotPossibleLineIsConsolidated";
return -1; return -1;
} }

View File

@ -313,17 +313,20 @@ class PaymentSocialContribution extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
dol_syslog(get_class($this)."::delete");
$this->db->begin(); $this->db->begin();
if (! $error) if ($this->bank_line > 0)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; $accline = new AccountLine($this->db);
$sql.= " WHERE type='payment_sc' AND url_id=".$this->id; $accline->fetch($this->bank_line);
$result = $accline->delete();
dol_syslog(get_class($this)."::delete sql=".$sql); if($result < 0) {
$resql = $this->db->query($sql); $this->errors[] = $accline->error;
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } $error++;
}
} }
if (! $error) if (! $error)