Qual: Normalize code of vat class
New: Can enter a vat payment of zero.
This commit is contained in:
parent
bcd63d2466
commit
837d5f2e76
@ -65,6 +65,7 @@ For users:
|
|||||||
- New: Add hidden option MAIN_FORCE_DEFAULT_STATE_ID.
|
- New: Add hidden option MAIN_FORCE_DEFAULT_STATE_ID.
|
||||||
- New: Add page to make mass stock movement.
|
- New: Add page to make mass stock movement.
|
||||||
- New: Add field oustanding limit into thirdparty properties.
|
- New: Add field oustanding limit into thirdparty properties.
|
||||||
|
- New: Can enter a vat payment of zero.
|
||||||
|
|
||||||
For translators:
|
For translators:
|
||||||
- Qual: Normalized sort order of all languages files with english reference files.
|
- Qual: Normalized sort order of all languages files with english reference files.
|
||||||
|
|||||||
@ -27,10 +27,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class Tva
|
* Put here description of your class
|
||||||
\brief Put here description of your class
|
*/
|
||||||
\remarks Initialy built by build_class_from_table on 2008-04-03 21:01
|
|
||||||
*/
|
|
||||||
class Tva extends CommonObject
|
class Tva extends CommonObject
|
||||||
{
|
{
|
||||||
//public $element='tva'; //!< Id that identify managed objects
|
//public $element='tva'; //!< Id that identify managed objects
|
||||||
@ -51,7 +49,6 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -115,7 +112,7 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog("Tva::create sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -133,16 +130,17 @@ class Tva extends CommonObject
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error="Error ".$this->db->lasterror();
|
||||||
dol_syslog("Tva::create ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Update database
|
* Update database
|
||||||
* \param user User that modify
|
*
|
||||||
* \param notrigger 0=no, 1=yes (no update trigger)
|
* @param User $user User that modify
|
||||||
* \return int <0 if KO, >0 if OK
|
* @param int $notrigger 0=no, 1=yes (no update trigger)
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function update($user=0, $notrigger=0)
|
function update($user=0, $notrigger=0)
|
||||||
{
|
{
|
||||||
@ -177,12 +175,12 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
dol_syslog("Tva::update sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error="Error ".$this->db->lasterror();
|
||||||
dol_syslog("Tva::update ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,11 +198,12 @@ class Tva extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Load object in memory from database
|
* Load object in memory from database
|
||||||
* \param id id object
|
*
|
||||||
* \param user User that load
|
* @param int $id id object
|
||||||
* \return int <0 if KO, >0 if OK
|
* @param User $user User that load
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch($id, $user=0)
|
function fetch($id, $user=0)
|
||||||
{
|
{
|
||||||
@ -229,7 +228,7 @@ class Tva extends CommonObject
|
|||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
|
||||||
$sql.= " WHERE t.rowid = ".$id;
|
$sql.= " WHERE t.rowid = ".$id;
|
||||||
|
|
||||||
dol_syslog("Tva::fetch sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -259,16 +258,17 @@ class Tva extends CommonObject
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error="Error ".$this->db->lasterror();
|
||||||
dol_syslog("Tva::fetch ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Delete object in database
|
* Delete object in database
|
||||||
* \param user User that delete
|
*
|
||||||
* \return int <0 if KO, >0 if OK
|
* @param User $user User that delete
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function delete($user)
|
function delete($user)
|
||||||
{
|
{
|
||||||
@ -279,12 +279,12 @@ class Tva extends CommonObject
|
|||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
dol_syslog("Tva::delete sql=".$sql);
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql)
|
if (! $resql)
|
||||||
{
|
{
|
||||||
$this->error="Error ".$this->db->lasterror();
|
$this->error="Error ".$this->db->lasterror();
|
||||||
dol_syslog("Tva::delete ".$this->error, LOG_ERR);
|
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,9 +322,11 @@ class Tva extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de TVA, non ?
|
* Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de TVA, non ?
|
||||||
*
|
*
|
||||||
|
* @param int $year Year
|
||||||
|
* @return double Amount
|
||||||
*/
|
*/
|
||||||
function solde($year = 0)
|
function solde($year = 0)
|
||||||
{
|
{
|
||||||
@ -339,11 +341,12 @@ class Tva extends CommonObject
|
|||||||
return $solde;
|
return $solde;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Total de la TVA des factures emises par la societe.
|
* Total de la TVA des factures emises par la societe.
|
||||||
*
|
*
|
||||||
|
* @param int $year Year
|
||||||
|
* @return double Amount
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function tva_sum_collectee($year = 0)
|
function tva_sum_collectee($year = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -352,7 +355,7 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
if ($year)
|
if ($year)
|
||||||
{
|
{
|
||||||
$sql .= " AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
|
$sql .= " AND f.datef >= '".$year."-01-01' AND f.datef <= '".$year."-12-31' ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -379,11 +382,12 @@ class Tva extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Tva pay<EFBFBD>e
|
* VAT payed
|
||||||
*
|
*
|
||||||
|
* @param int $year Year
|
||||||
|
* @return double Amount
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function tva_sum_payee($year = 0)
|
function tva_sum_payee($year = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -392,7 +396,7 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
if ($year)
|
if ($year)
|
||||||
{
|
{
|
||||||
$sql .= " WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
|
$sql .= " WHERE f.datef >= '".$year."-01-01' AND f.datef <= '".$year."-12-31' ";
|
||||||
}
|
}
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
@ -419,12 +423,12 @@ class Tva extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* \brief Tva r<EFBFBD>gl<EFBFBD>e
|
* Total de la TVA reglee aupres de qui de droit
|
||||||
* Total de la TVA r<EFBFBD>glee aupres de qui de droit
|
|
||||||
*
|
*
|
||||||
|
* @param int $year Year
|
||||||
|
* @return double Amount
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function tva_sum_reglee($year = 0)
|
function tva_sum_reglee($year = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -433,7 +437,7 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
if ($year)
|
if ($year)
|
||||||
{
|
{
|
||||||
$sql .= " WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' ";
|
$sql .= " WHERE f.datev >= '".$year."-01-01' AND f.datev <= '".$year."-12-31' ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -473,14 +477,16 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
// Clean parameters
|
||||||
|
$this->amount=price2num(trim($this->amount));
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
$this->amount=price2num($this->amount);
|
|
||||||
if (! $this->label)
|
if (! $this->label)
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if ($this->amount <= 0)
|
if ($this->amount < 0 || $this->amount == '')
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"));
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"));
|
||||||
return -4;
|
return -4;
|
||||||
@ -509,7 +515,7 @@ class Tva extends CommonObject
|
|||||||
$sql.=", '".$user->id."', NULL, ".$conf->entity;
|
$sql.=", '".$user->id."', NULL, ".$conf->entity;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog("Tva::addPayment sql=".$sql);
|
dol_syslog(get_class($this)."::addPayment sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@ -525,7 +531,7 @@ class Tva extends CommonObject
|
|||||||
if ($this->id > 0)
|
if ($this->id > 0)
|
||||||
{
|
{
|
||||||
$ok=1;
|
$ok=1;
|
||||||
if (! empty($conf->banque->enabled))
|
if (! empty($conf->banque->enabled) && ! empty($this->amount))
|
||||||
{
|
{
|
||||||
// Insertion dans llx_bank
|
// Insertion dans llx_bank
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
@ -536,7 +542,7 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
$bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
|
$bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
|
||||||
|
|
||||||
// Mise a jour fk_bank dans llx_tva. On connait ainsi la ligne de tva qui a g<>n<EFBFBD>r<EFBFBD> l'<27>criture bancaire
|
// Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
|
||||||
if ($bank_line_id > 0)
|
if ($bank_line_id > 0)
|
||||||
{
|
{
|
||||||
$this->update_fk_bank($bank_line_id);
|
$this->update_fk_bank($bank_line_id);
|
||||||
@ -547,7 +553,7 @@ class Tva extends CommonObject
|
|||||||
$ok=0;
|
$ok=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise a jour liens
|
// Update links
|
||||||
$result=$acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/fiche.php?id=', "(VATPayment)", "payment_vat");
|
$result=$acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/fiche.php?id=', "(VATPayment)", "payment_vat");
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -34,8 +34,6 @@ $langs->load("bills");
|
|||||||
$id=GETPOST("id");
|
$id=GETPOST("id");
|
||||||
$action=GETPOST('action');
|
$action=GETPOST('action');
|
||||||
|
|
||||||
$mesg = '';
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
@ -82,7 +80,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
$mesg='<div class="error">'.$tva->error.'</div>';
|
setEventMessage($tva->error, 'errors');
|
||||||
$action="create";
|
$action="create";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,18 +113,18 @@ if ($action == 'delete')
|
|||||||
{
|
{
|
||||||
$tva->error=$accountline->error;
|
$tva->error=$accountline->error;
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
$mesg='<div class="error">'.$tva->error.'</div>';
|
setEventMessage($tva->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
$mesg='<div class="error">'.$tva->error.'</div>';
|
setEventMessage($tva->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">Error try do delete a line linked to a conciliated bank transaction</div>';
|
setEventMessage('Error try do delete a line linked to a conciliated bank transaction','errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +157,6 @@ if ($action == 'create')
|
|||||||
|
|
||||||
print_fiche_titre($langs->trans("NewVATPayment"));
|
print_fiche_titre($langs->trans("NewVATPayment"));
|
||||||
|
|
||||||
if ($mesg) print $mesg;
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
print "<tr>";
|
print "<tr>";
|
||||||
@ -213,8 +209,6 @@ if ($action == 'create')
|
|||||||
|
|
||||||
if ($id)
|
if ($id)
|
||||||
{
|
{
|
||||||
if ($mesg) print $mesg;
|
|
||||||
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/compta/tva/fiche.php?id='.$vatpayment->id;
|
$head[$h][0] = DOL_URL_ROOT.'/compta/tva/fiche.php?id='.$vatpayment->id;
|
||||||
$head[$h][1] = $langs->trans('Card');
|
$head[$h][1] = $langs->trans('Card');
|
||||||
@ -274,9 +268,20 @@ if ($id)
|
|||||||
*/
|
*/
|
||||||
print "<div class=\"tabsAction\">\n";
|
print "<div class=\"tabsAction\">\n";
|
||||||
if ($vatpayment->rappro == 0)
|
if ($vatpayment->rappro == 0)
|
||||||
|
{
|
||||||
|
if (! empty($user->rights->tax->charges->supprimer))
|
||||||
|
{
|
||||||
print '<a class="butActionDelete" href="fiche.php?id='.$vatpayment->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
print '<a class="butActionDelete" href="fiche.php?id='.$vatpayment->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
print '<a class="butActionRefused" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans("LinkedToAConcialitedTransaction").'">'.$langs->trans("Delete").'</a>';
|
print '<a class="butActionRefused" href="#" title="'.$langs->trans("LinkedToAConcialitedTransaction").'">'.$langs->trans("Delete").'</a>';
|
||||||
|
}
|
||||||
print "</div>";
|
print "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user