Fix: bug #33918 : Écriture bancaire fantôme
This commit is contained in:
parent
48ba4c12b6
commit
7a3f496502
@ -23,7 +23,7 @@
|
|||||||
* \file htdocs/compta/bank/class/account.class.php
|
* \file htdocs/compta/bank/class/account.class.php
|
||||||
* \ingroup banque
|
* \ingroup banque
|
||||||
* \brief File of class to manage bank accounts
|
* \brief File of class to manage bank accounts
|
||||||
* \version $Id: account.class.php,v 1.33 2011/07/31 22:23:30 eldy Exp $
|
* \version $Id: account.class.php,v 1.34 2011/08/05 21:05:19 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||||
@ -146,7 +146,7 @@ class Account extends CommonObject
|
|||||||
$sql.= ", '".$type."'";
|
$sql.= ", '".$type."'";
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog("Account::add_url_line sql=".$sql);
|
dol_syslog(get_class($this)."::add_url_line sql=".$sql);
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_url");
|
$rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_url");
|
||||||
@ -155,25 +155,37 @@ class Account extends CommonObject
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->lasterror();
|
$this->error=$this->db->lasterror();
|
||||||
dol_syslog("Account:add_url_line ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this)."::add_url_line ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return array with links
|
* TODO Move this into AccountLine
|
||||||
* @param line_id Id transaction line
|
* Return array with links from llx_bank_url
|
||||||
|
* @param fk_bank To search using bank transaction id
|
||||||
|
* @param url_id To search using link to
|
||||||
|
* @param type To search using type
|
||||||
* @return array Array of links
|
* @return array Array of links
|
||||||
*/
|
*/
|
||||||
function get_url($line_id)
|
function get_url($fk_bank='', $url_id='', $type='')
|
||||||
{
|
{
|
||||||
$lines = array();
|
$lines = array();
|
||||||
|
|
||||||
$sql = "SELECT url_id, url, label, type";
|
// Check parameters
|
||||||
|
if (! empty($fk_bank) && (! empty($url_id) || ! empty($type)))
|
||||||
|
{
|
||||||
|
$this->error="ErrorBadParameter";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT fk_bank, url_id, url, label, type";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_url";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank_url";
|
||||||
$sql.= " WHERE fk_bank = ".$line_id;
|
if ($fk_bank > 0) { $sql.= " WHERE fk_bank = ".$fk_bank; }
|
||||||
|
else { $sql.= " WHERE url_id = ".$url_id." AND type = '".$type."'"; }
|
||||||
$sql.= " ORDER BY type, label";
|
$sql.= " ORDER BY type, label";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::get_url sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@ -192,10 +204,13 @@ class Account extends CommonObject
|
|||||||
$lines[$i]['url_id'] = $obj->url_id;
|
$lines[$i]['url_id'] = $obj->url_id;
|
||||||
$lines[$i]['label'] = $obj->label;
|
$lines[$i]['label'] = $obj->label;
|
||||||
$lines[$i]['type'] = $obj->type;
|
$lines[$i]['type'] = $obj->type;
|
||||||
|
$lines[$i]['fk_bank'] = $obj->fk_bank;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
return $lines;
|
|
||||||
}
|
}
|
||||||
|
else dol_print_error($this->db);
|
||||||
|
|
||||||
|
return $lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -997,7 +1012,7 @@ class Account extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \class AccountLine
|
* \class AccountLine
|
||||||
* \brief Classto manage bank transaction lines
|
* \brief Class to manage bank transaction lines
|
||||||
*/
|
*/
|
||||||
class AccountLine extends CommonObject
|
class AccountLine extends CommonObject
|
||||||
{
|
{
|
||||||
@ -1112,7 +1127,7 @@ class AccountLine extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete bank line record
|
* Delete transaction bank line record
|
||||||
* @param user User object that delete
|
* @param user User object that delete
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
@ -1129,12 +1144,14 @@ class AccountLine extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid;
|
// Delete urls
|
||||||
dol_syslog("AccountLine::delete sql=".$sql);
|
$result=$this->delete_urls();
|
||||||
$result = $this->db->query($sql);
|
if ($result < 0)
|
||||||
if (! $result) $nbko++;
|
{
|
||||||
|
$nbko++;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$this->rowid;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid=".$this->rowid;
|
||||||
dol_syslog("AccountLine::delete sql=".$sql);
|
dol_syslog("AccountLine::delete sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (! $result) $nbko++;
|
if (! $result) $nbko++;
|
||||||
@ -1157,6 +1174,42 @@ class AccountLine extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete bank line records
|
||||||
|
* @param user User object that delete
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function delete_urls($user=0)
|
||||||
|
{
|
||||||
|
$nbko=0;
|
||||||
|
|
||||||
|
if ($this->rappro)
|
||||||
|
{
|
||||||
|
// Protection to avoid any delete of consolidated lines
|
||||||
|
$this->error="ErrorDeleteNotPossibleLineIsConsolidated";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$this->rowid;
|
||||||
|
dol_syslog("AccountLine::delete_urls sql=".$sql);
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if (! $result) $nbko++;
|
||||||
|
|
||||||
|
if (! $nbko)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -$nbko;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update bank account record in database
|
* Update bank account record in database
|
||||||
* @param user Object user making update
|
* @param user Object user making update
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
* \file htdocs/compta/paiement/class/paiement.class.php
|
* \file htdocs/compta/paiement/class/paiement.class.php
|
||||||
* \ingroup facture
|
* \ingroup facture
|
||||||
* \brief File of class to manage payments of customers invoices
|
* \brief File of class to manage payments of customers invoices
|
||||||
* \version $Id: paiement.class.php,v 1.22 2011/08/03 00:46:39 eldy Exp $
|
* \version $Id: paiement.class.php,v 1.23 2011/08/05 21:06:55 eldy Exp $
|
||||||
*/
|
*/
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ class Paiement extends CommonObject
|
|||||||
{
|
{
|
||||||
if (sizeof($billsarray))
|
if (sizeof($billsarray))
|
||||||
{
|
{
|
||||||
$this->error="Impossible de supprimer un paiement portant sur au moins une facture fermee";
|
$this->error="ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -284,18 +284,18 @@ class Paiement extends CommonObject
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verifier si paiement ne porte pas sur ecriture bancaire rapprochee
|
// Delete bank urls. If payment if on a conciliated line, return error.
|
||||||
// Si c'est le cas, on refuse le paiement
|
|
||||||
if ($bank_line_id)
|
if ($bank_line_id)
|
||||||
{
|
{
|
||||||
$accline = new AccountLine($this->db,$bank_line_id);
|
$accline = new AccountLine($this->db);
|
||||||
$accline->fetch($bank_line_id);
|
$accline->fetch($bank_line_id);
|
||||||
if ($accline->rappro)
|
$result=$accline->delete_urls($user);
|
||||||
{
|
if ($result < 0)
|
||||||
$this->error="Impossible de supprimer un paiement qui a genere une ecriture qui a ete rapprochee";
|
{
|
||||||
|
$this->error=$accline->error;
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete payment (into paiement_facture and paiement)
|
// Delete payment (into paiement_facture and paiement)
|
||||||
@ -309,7 +309,7 @@ class Paiement extends CommonObject
|
|||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->lasterror();
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
* \ingroup facture
|
* \ingroup facture
|
||||||
* \brief Page of a customer payment
|
* \brief Page of a customer payment
|
||||||
* \remarks Nearly same file than fournisseur/paiement/fiche.php
|
* \remarks Nearly same file than fournisseur/paiement/fiche.php
|
||||||
* \version $Id: fiche.php,v 1.76 2011/08/03 00:46:35 eldy Exp $
|
* \version $Id: fiche.php,v 1.77 2011/08/05 21:06:55 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../../main.inc.php");
|
require("../../main.inc.php");
|
||||||
@ -84,7 +84,8 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights-
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$paiement->error.'</div>';
|
$langs->load("errors");
|
||||||
|
$mesg='<div class="error">'.$langs->trans($paiement->error).'</div>';
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +121,8 @@ if ($action == 'confirm_valide' && GETPOST('confirm') == 'yes' && $user->rights-
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$paiement->error.'</div>';
|
$langs->load("errors");
|
||||||
|
$mesg='<div class="error">'.$langs->trans($paiement->error).'</div>';
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +180,7 @@ if ($action == 'valide')
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($mesg) print $mesg.'<br>';
|
dol_htmloutput_mesg($mesg);
|
||||||
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
@ -356,5 +358,5 @@ print '</div>';
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/08/03 00:46:35 $ - $Revision: 1.76 $');
|
llxFooter('$Date: 2011/08/05 21:06:55 $ - $Revision: 1.77 $');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -20,7 +20,7 @@
|
|||||||
* \file htdocs/compta/sociales/charges.php
|
* \file htdocs/compta/sociales/charges.php
|
||||||
* \ingroup tax
|
* \ingroup tax
|
||||||
* \brief Social contribution car page
|
* \brief Social contribution car page
|
||||||
* \version $Id: charges.php,v 1.65 2011/07/31 22:23:20 eldy Exp $
|
* \version $Id: charges.php,v 1.66 2011/08/05 21:11:50 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require('../../main.inc.php');
|
require('../../main.inc.php');
|
||||||
@ -29,10 +29,10 @@ require(DOL_DOCUMENT_ROOT."/compta/sociales/class/chargesociales.class.php");
|
|||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
$chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
|
$chid=GETPOST("id");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
$socid = GETPOST("socid");
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ if ($_REQUEST["action"] == 'confirm_paid' && $_REQUEST["confirm"] == 'yes')
|
|||||||
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes')
|
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes')
|
||||||
{
|
{
|
||||||
$chargesociales=new ChargeSociales($db);
|
$chargesociales=new ChargeSociales($db);
|
||||||
$chargesociales->id=$_GET["id"];
|
$chargesociales->fetch($chid);
|
||||||
$result=$chargesociales->delete($user);
|
$result=$chargesociales->delete($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
@ -129,8 +129,8 @@ if ($_POST["action"] == 'add' && $user->rights->tax->charges->creer)
|
|||||||
|
|
||||||
if ($_GET["action"] == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
|
if ($_GET["action"] == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
|
||||||
{
|
{
|
||||||
$dateech=@dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
$dateech=dol_mktime($_POST["echhour"],$_POST["echmin"],$_POST["echsec"],$_POST["echmonth"],$_POST["echday"],$_POST["echyear"]);
|
||||||
$dateperiod=@dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
$dateperiod=dol_mktime($_POST["periodhour"],$_POST["periodmin"],$_POST["periodsec"],$_POST["periodmonth"],$_POST["periodday"],$_POST["periodyear"]);
|
||||||
if (! $dateech)
|
if (! $dateech)
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")).'</div>';
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("DateDue")).'</div>';
|
||||||
@ -172,10 +172,7 @@ llxHeader('',$langs->trans("SocialContribution"));
|
|||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
/*
|
// Mode creation
|
||||||
* Mode creation
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if ($_GET["action"] == 'create')
|
if ($_GET["action"] == 'create')
|
||||||
{
|
{
|
||||||
print_fiche_titre($langs->trans("NewSocialContribution"));
|
print_fiche_titre($langs->trans("NewSocialContribution"));
|
||||||
@ -251,7 +248,7 @@ if ($chid > 0)
|
|||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
if ($mesg) print $mesg.'<br>';
|
dol_htmloutput_mesg($mesg);
|
||||||
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$cha->id;
|
$head[$h][0] = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$cha->id;
|
||||||
@ -268,15 +265,13 @@ if ($chid > 0)
|
|||||||
if ($_GET["action"] == 'paid')
|
if ($_GET["action"] == 'paid')
|
||||||
{
|
{
|
||||||
$text=$langs->trans('ConfirmPaySocialContribution');
|
$text=$langs->trans('ConfirmPaySocialContribution');
|
||||||
$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=$cha->id&action=confirm_paid",$langs->trans('PaySocialContribution'),$text,"confirm_paid");
|
print $html->formconfirm($_SERVER["PHP_SELF"]."?id=".$cha->id,$langs->trans('PaySocialContribution'),$text,"confirm_paid",'','',2);
|
||||||
if ($ret == 'html') print '<br>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET['action'] == 'delete')
|
if ($_GET['action'] == 'delete')
|
||||||
{
|
{
|
||||||
$text=$langs->trans('ConfirmDeleteSocialContribution');
|
$text=$langs->trans('ConfirmDeleteSocialContribution');
|
||||||
$ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$cha->id,$langs->trans('DeleteSocialContribution'),$text,'confirm_delete');
|
print $html->formconfirm($_SERVER['PHP_SELF'].'?id='.$cha->id,$langs->trans('DeleteSocialContribution'),$text,'confirm_delete','','',2);
|
||||||
if ($ret == 'html') print '<br>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET['action'] == 'edit')
|
if ($_GET['action'] == 'edit')
|
||||||
@ -353,9 +348,9 @@ if ($chid > 0)
|
|||||||
{
|
{
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]><td>";
|
print "<tr ".$bc[$var]."><td>";
|
||||||
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").'</a> ';
|
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").'</a> ';
|
||||||
print dol_print_date($db->jdate($objp->dp))."</td>\n";
|
print dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
|
||||||
print "<td>".$objp->paiement_type.' '.$objp->num_paiement."</td>\n";
|
print "<td>".$objp->paiement_type.' '.$objp->num_paiement."</td>\n";
|
||||||
print '<td align="right">'.price($objp->amount)."</td><td> ".$langs->trans("Currency".$conf->monnaie)."</td>\n";
|
print '<td align="right">'.price($objp->amount)."</td><td> ".$langs->trans("Currency".$conf->monnaie)."</td>\n";
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
@ -445,7 +440,7 @@ if ($chid > 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if ($cha->paye == 0 && $totalpaye <=0 && $user->rights->tax->charges->supprimer)
|
if ($user->rights->tax->charges->supprimer)
|
||||||
{
|
{
|
||||||
print "<a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$cha->id&action=delete\">".$langs->trans("Delete")."</a>";
|
print "<a class=\"butActionDelete\" href=\"".DOL_URL_ROOT."/compta/sociales/charges.php?id=$cha->id&action=delete\">".$langs->trans("Delete")."</a>";
|
||||||
}
|
}
|
||||||
@ -462,5 +457,5 @@ if ($chid > 0)
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/07/31 22:23:20 $ - $Revision: 1.65 $');
|
llxFooter('$Date: 2011/08/05 21:11:50 $ - $Revision: 1.66 $');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
* \file htdocs/compta/sociales/class/chargesociales.class.php
|
* \file htdocs/compta/sociales/class/chargesociales.class.php
|
||||||
* \ingroup facture
|
* \ingroup facture
|
||||||
* \brief Fichier de la classe des charges sociales
|
* \brief Fichier de la classe des charges sociales
|
||||||
* \version $Id: chargesociales.class.php,v 1.14 2011/08/03 00:46:38 eldy Exp $
|
* \version $Id: chargesociales.class.php,v 1.15 2011/08/05 21:11:50 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||||
@ -147,25 +147,72 @@ class ChargeSociales extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Efface un charge sociale
|
* Delete a social contribution
|
||||||
* \param user Utilisateur qui cree le paiement
|
* @param user Object user making delete
|
||||||
* \return int <0 si erreur, >0 si ok
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function delete($user)
|
function delete($user)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales where rowid='".$this->id."'";
|
$error=0;
|
||||||
|
|
||||||
dol_syslog("ChargesSociales::delete sql=".$sql);
|
$this->db->begin();
|
||||||
$resql=$this->db->query($sql);
|
|
||||||
if ($resql)
|
// Get bank transaction lines for this social contributions
|
||||||
|
include_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
|
||||||
|
$account=new Account($this->db);
|
||||||
|
$lines_url=$account->get_url('',$this->id,'sc');
|
||||||
|
|
||||||
|
// Delete bank urls
|
||||||
|
foreach ($lines_url as $line_url)
|
||||||
|
{
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$accountline=new AccountLine($this->db);
|
||||||
|
$accountline->fetch($line_url['fk_bank']);
|
||||||
|
$result=$accountline->delete_urls($user);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete payments
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge where fk_charge='".$this->id."'";
|
||||||
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales where rowid='".$this->id."'";
|
||||||
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -82,3 +82,4 @@ ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number
|
|||||||
ErrorBadMaskBadRazMonth=Error, bad reset value
|
ErrorBadMaskBadRazMonth=Error, bad reset value
|
||||||
ErrorSelectAtLeastOne=Error. Select at least one entry.
|
ErrorSelectAtLeastOne=Error. Select at least one entry.
|
||||||
ErrorProductWithRefNotExist=Product with reference '<i>%s</i>' don't exist
|
ErrorProductWithRefNotExist=Product with reference '<i>%s</i>' don't exist
|
||||||
|
ErrorDeleteNotPossibleLineIsConsolidated=Delete not possible because record is linked to a bank transation that is conciliated
|
||||||
@ -83,3 +83,4 @@ ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence
|
|||||||
ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro
|
ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro
|
||||||
ErrorSelectAtLeastOne=Erreur. Sélectionnez au moins une entrée.
|
ErrorSelectAtLeastOne=Erreur. Sélectionnez au moins une entrée.
|
||||||
ErrorProductWithRefNotExist=La référence produit '<i>%s</i>' n'existe pas
|
ErrorProductWithRefNotExist=La référence produit '<i>%s</i>' n'existe pas
|
||||||
|
ErrorDeleteNotPossibleLineIsConsolidated=Suppression impossible car l'enregistrement porte sur au moins une transaction bancaire rapprochée
|
||||||
Loading…
Reference in New Issue
Block a user