Ajout du lien entre la saisie du paiement TVA et la ligne ecriture bancaire
This commit is contained in:
parent
9b1f74d99d
commit
fc047d04c1
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,7 +17,6 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
* $Source$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +30,8 @@ require("../../tva.class.php");
|
|||||||
|
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
|
|
||||||
|
$id=$_GET["id"];
|
||||||
|
|
||||||
|
|
||||||
$mesg = '';
|
$mesg = '';
|
||||||
|
|
||||||
@ -44,14 +45,14 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
|||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$tva->label = $langs->trans("VATPayment");
|
|
||||||
$tva->accountid=$_POST["accountid"];
|
$tva->accountid=$_POST["accountid"];
|
||||||
$tva->paymenttype=$_POST["paiementtype"];
|
$tva->paymenttype=$_POST["paiementtype"];
|
||||||
$tva->datev=mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
$tva->datev=mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||||
$tva->datep=mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
$tva->datep=mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
||||||
$tva->amount=$_POST["amount"];
|
$tva->amount=$_POST["amount"];
|
||||||
|
$tva->label=$_POST["label"];
|
||||||
|
|
||||||
$ret=$tva->add_payement($user);
|
$ret=$tva->addPayment($user);
|
||||||
if ($ret > 0)
|
if ($ret > 0)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
@ -93,18 +94,23 @@ if ($_GET["action"] == 'create')
|
|||||||
print $html->select_date("","datep",'','','','add');
|
print $html->select_date("","datep",'','','','add');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Type").'</td><td>';
|
// Label
|
||||||
$html->select_types_paiements($charge->paiementtype, "paiementtype");
|
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="label" size="40" value="'.$langs->trans("VATPayment").'"></td></tr>';
|
||||||
print "</td>\n";
|
|
||||||
|
// Amount
|
||||||
|
print '<tr><td>'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value=""></td></tr>';
|
||||||
|
|
||||||
if ($conf->banque->enabled)
|
if ($conf->banque->enabled)
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Account").'</td><td>';
|
print '<tr><td>'.$langs->trans("Account").'</td><td>';
|
||||||
$html->select_comptes($charge->accountid,"accountid",0,"courant=1",1); // Affiche liste des comptes courant
|
$html->select_comptes($charge->accountid,"accountid",0,"courant=1",1); // Affiche liste des comptes courant
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("Type").'</td><td>';
|
||||||
|
$html->select_types_paiements($charge->paiementtype, "paiementtype");
|
||||||
|
print "</td>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value=""></td></tr>';
|
|
||||||
print '<tr><td> </td><td><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
print '<tr><td> </td><td><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
@ -118,7 +124,52 @@ if ($_GET["action"] == 'create')
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
// Aucune action
|
if ($id)
|
||||||
|
{
|
||||||
|
print_fiche_titre($langs->trans("VATPayment"));
|
||||||
|
|
||||||
|
$vatpayment = new Tva($db);
|
||||||
|
|
||||||
|
if ($vatpayment->fetch($id) > 0)
|
||||||
|
{
|
||||||
|
if ($mesg) print $mesg.'<br>';
|
||||||
|
|
||||||
|
$h = 0;
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/compta/tva/fiche.php?id='.$tva->id;
|
||||||
|
$head[$h][1] = $langs->trans('Card');
|
||||||
|
$head[$h][2] = 'card';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
dolibarr_fiche_head($head, 'card', $langs->trans("VATPayment"));
|
||||||
|
|
||||||
|
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
print "<tr>";
|
||||||
|
print '<td>'.$langs->trans("DatePayment").'</td><td>';
|
||||||
|
print dolibarr_print_date($vatpayment->date);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
|
||||||
|
print $html->select_date("","datep",'','','','add');
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("Type").'</td><td>';
|
||||||
|
$html->select_types_paiements($charge->paiementtype, "paiementtype");
|
||||||
|
print "</td>\n";
|
||||||
|
|
||||||
|
if ($conf->banque->enabled)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Account").'</td><td>';
|
||||||
|
$html->select_comptes($charge->accountid,"accountid",0,"courant=1",1); // Affiche liste des comptes courant
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value=""></td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
* $Source$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,7 +31,6 @@
|
|||||||
/** \class Tva
|
/** \class Tva
|
||||||
\brief Classe permettant la gestion de la tva
|
\brief Classe permettant la gestion de la tva
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Tva
|
class Tva
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
@ -190,39 +188,44 @@ class Tva
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Ajoute un paiement de TVA
|
* \brief Ajoute un paiement de TVA
|
||||||
|
* \param user Object user that insert
|
||||||
|
* \return int <0 if KO, rowid in tva table if OK
|
||||||
*/
|
*/
|
||||||
|
function addPayment($user)
|
||||||
function add_payement($user)
|
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Validation parameteres
|
// Check parameters
|
||||||
$this->amount=price2num($this->amount);
|
$this->amount=price2num($this->amount);
|
||||||
if ($conf->banque->enabled)
|
if (! $this->label)
|
||||||
{
|
{
|
||||||
if (! $this->accountid)
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
|
||||||
{
|
|
||||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Account"));
|
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($this->amount <= 0)
|
if ($this->amount <= 0)
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Amount"));
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"));
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
if ($conf->banque->enabled && ! $this->accountid)
|
||||||
|
{
|
||||||
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account"));
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
|
||||||
// Insertion dans table des paiement tva
|
// Insertion dans table des paiement tva
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount";
|
||||||
if ($this->note) $sql.=", note";
|
if ($this->note) $sql.=", note";
|
||||||
if ($this->label) $sql.=", label";
|
if ($this->label) $sql.=", label";
|
||||||
|
$sql.= ", fk_user_creat";
|
||||||
$sql.= ") ";
|
$sql.= ") ";
|
||||||
$sql.= " VALUES ('".$this->db->idate($this->datep)."',";
|
$sql.= " VALUES ('".$this->db->idate($this->datep)."',";
|
||||||
$sql.= "'".$this->db->idate($this->datev)."'," . $this->amount;
|
$sql.= "'".$this->db->idate($this->datev)."'," . $this->amount;
|
||||||
if ($this->note) $sql.=", '".addslashes($this->note)."'";
|
if ($this->note) $sql.=", '".addslashes($this->note)."'";
|
||||||
if ($this->label) $sql.=", '".addslashes($this->label)."'";
|
if ($this->label) $sql.=", '".addslashes($this->label)."'";
|
||||||
|
$sql.=", '".$user->id."'";
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@ -240,9 +243,10 @@ class Tva
|
|||||||
$acc = new Account($this->db, $this->accountid);
|
$acc = new Account($this->db, $this->accountid);
|
||||||
$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_paiementtva. On connait ainsi la ligne de tva qui a généré l'écriture bancaire
|
// Mise a jour fk_bank dans llx_tva. On connait ainsi la ligne de tva qui a généré l'écriture bancaire
|
||||||
if ($bank_line_id) {
|
if ($bank_line_id)
|
||||||
// $tva->update_fk_bank($bank_line_id);
|
{
|
||||||
|
$this->update_fk_bank($bank_line_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mise a jour liens (pour chaque charge concernée par le paiement)
|
// Mise a jour liens (pour chaque charge concernée par le paiement)
|
||||||
@ -273,6 +277,27 @@ class Tva
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Mise a jour du lien entre le paiement tva et la ligne générée dans llx_bank
|
||||||
|
* \param id_bank Id compte bancaire
|
||||||
|
* \return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function update_fk_bank($id_bank)
|
||||||
|
{
|
||||||
|
$sql = 'UPDATE llx_tva set fk_bank = '.$id_bank;
|
||||||
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -53,6 +53,14 @@ delete from llx_adherent_type where libelle IS NULL;
|
|||||||
alter table llx_adherent_type modify libelle varchar(50) NOT NULL;
|
alter table llx_adherent_type modify libelle varchar(50) NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
|
alter table llx_tva add fk_bank integer NOT NULL;
|
||||||
|
alter table llx_tva add fk_user_creat integer;
|
||||||
|
alter table llx_tva add fk_user_modif integer;
|
||||||
|
|
||||||
|
-- V4.1 UPDATE llx_tva as t set fk_bank = (SELECT IFNULL(MIN(rowid),0) FROM llx_bank as b WHERE b.datev = t.datev AND b.amount = -t.amount AND b.label like 'R%glement TVA') WHERE t.fk_bank = 0;
|
||||||
|
-- V4.1 UPDATE llx_tva as t set fk_user_creat = (SELECT MIN(fk_user_author) FROM llx_bank as b WHERE b.datev = t.datev AND b.amount = -t.amount AND b.label like 'R%glement TVA') WHERE t.fk_user_creat IS NULL;
|
||||||
|
|
||||||
|
|
||||||
-- Extention de la gestion des catégories
|
-- Extention de la gestion des catégories
|
||||||
alter table llx_categorie ADD type int not null default '0';
|
alter table llx_categorie ADD type int not null default '0';
|
||||||
-- V4 ALTER TABLE llx_categorie DROP INDEX uk_categorie_ref;
|
-- V4 ALTER TABLE llx_categorie DROP INDEX uk_categorie_ref;
|
||||||
@ -901,6 +909,8 @@ ALTER TABLE llx_element_contact ADD INDEX idx_element_contact_fk_socpeople (fk_s
|
|||||||
-- Supprimme orphelins pour permettre montée de la clé
|
-- Supprimme orphelins pour permettre montée de la clé
|
||||||
-- V4 DELETE llx_fichinter FROM llx_fichinter LEFT JOIN llx_societe ON llx_fichinter.fk_soc = llx_societe.rowid WHERE llx_societe.rowid IS NULL;
|
-- V4 DELETE llx_fichinter FROM llx_fichinter LEFT JOIN llx_societe ON llx_fichinter.fk_soc = llx_societe.rowid WHERE llx_societe.rowid IS NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE llx_societe ADD COLUMN supplier_account varchar(32) after fournisseur;
|
ALTER TABLE llx_societe ADD COLUMN supplier_account varchar(32) after fournisseur;
|
||||||
|
|
||||||
drop table if exists llx_c_barcode;
|
drop table if exists llx_c_barcode;
|
||||||
|
|||||||
@ -28,5 +28,8 @@ create table llx_tva
|
|||||||
datev date, -- date de valeur
|
datev date, -- date de valeur
|
||||||
amount real NOT NULL DEFAULT 0,
|
amount real NOT NULL DEFAULT 0,
|
||||||
label varchar(255),
|
label varchar(255),
|
||||||
note text
|
note text,
|
||||||
|
fk_bank integer NOT NULL,
|
||||||
|
fk_user_creat integer, -- utilisateur qui a créé l'info
|
||||||
|
fk_user_modif integer -- utilisateur qui a modifié l'info
|
||||||
)type=innodb;
|
)type=innodb;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user