New: Il est possible de choisir le compte de débit lors d'une saisie de paiement de TVA.
This commit is contained in:
parent
ac55764f7e
commit
613bb9f290
@ -21,7 +21,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file htdocs/compta/tva/fiche.php
|
/**
|
||||||
|
\file htdocs/compta/tva/fiche.php
|
||||||
\brief Page des règlements de TVA
|
\brief Page des règlements de TVA
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
@ -29,55 +30,82 @@
|
|||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
require("../../tva.class.php");
|
require("../../tva.class.php");
|
||||||
|
|
||||||
|
$langs->load("compta");
|
||||||
|
|
||||||
|
|
||||||
$mesg = '';
|
$mesg = '';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action ajout paiement tva
|
||||||
|
*/
|
||||||
if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
$tva = new Tva($db);
|
$tva = new Tva($db);
|
||||||
|
|
||||||
$tva->add_payement(mktime(12,0,0,
|
$db->begin();
|
||||||
$_POST["datevmonth"],
|
|
||||||
$_POST["datevday"],
|
$tva->label = $langs->trans("VATPayment");
|
||||||
$_POST["datevyear"]
|
$tva->accountid=$_POST["accountid"];
|
||||||
),
|
$tva->paymenttype=$_POST["paiementtype"];
|
||||||
mktime(12,0,0,
|
$tva->datev=mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||||
$_POST["datepmonth"],
|
$tva->datep=mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
||||||
$_POST["datepday"],
|
$tva->amount=$_POST["amount"];
|
||||||
$_POST["datepyear"]
|
|
||||||
),
|
$ret=$tva->add_payement($user);
|
||||||
$_POST["amount"]
|
if ($ret > 0)
|
||||||
);
|
{
|
||||||
Header ( "Location: reglement.php");
|
$db->commit();
|
||||||
|
Header ("Location: reglement.php");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
$message=$langs->trans("Error");
|
||||||
|
$_GET["action"]="create";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
|
// Formulaire saisie tva
|
||||||
if ($_GET["action"] == 'create')
|
if ($_GET["action"] == 'create')
|
||||||
{
|
{
|
||||||
print "<form action=\"fiche.php\" method=\"post\">\n";
|
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
|
|
||||||
print '<div class="titre">Nouveau réglement TVA</div><br>';
|
print '<div class="titre">'.$langs->trans("NewVATPayment").'</div><br>';
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
if ($message) print '<br>'.$message.'</br>';
|
||||||
print "<tr>";
|
|
||||||
print '<td>'.$langs->trans("DatePayment").'</td><td>';
|
print '<table class="border" width="100%">';
|
||||||
print $html->select_date("","datev");
|
|
||||||
print '</td></tr>';
|
print "<tr>";
|
||||||
print '<td>'.$langs->trans("DateValue").'</td><td>';
|
print '<td>'.$langs->trans("DatePayment").'</td><td>';
|
||||||
print $html->select_date("","datep");
|
print $html->select_date("","datev");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value=""></td></tr>';
|
|
||||||
print '<tr><td> </td><td><input type="submit" value="'.$langs->trans("Save").'"> ';
|
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
|
||||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
print $html->select_date("","datep");
|
||||||
print '</table>';
|
print '</td></tr>';
|
||||||
print '</form>';
|
|
||||||
|
print '<tr><td>'.$langs->trans("Type").'</td><td>';
|
||||||
|
$html->select_types_paiements($charge->paiementtype, "paiementtype");
|
||||||
|
print "</td>\n";
|
||||||
|
|
||||||
|
print '<tr><td>Compte à créditer :</td><td>';
|
||||||
|
$html->select_comptes($charge->accountid, "accountid", 0, "courant=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>';
|
||||||
|
print '<tr><td> </td><td><input type="submit" value="'.$langs->trans("Save").'"> ';
|
||||||
|
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||||
|
print '</table>';
|
||||||
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,9 +117,8 @@ if ($_GET["action"] == 'create')
|
|||||||
|
|
||||||
// Aucune action
|
// Aucune action
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
llxFooter('$Date$ - $Revision$');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -192,17 +192,48 @@ class Tva
|
|||||||
* \brief Ajoute un paiement de TVA
|
* \brief Ajoute un paiement de TVA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function add_payement($datep, $datev, $amount)
|
function add_payement($user)
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount) ";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount";
|
||||||
$sql .= " VALUES ('".$this->db->idate($datep)."',";
|
if ($this->note) $sql.=", note";
|
||||||
$sql .= "'".$this->db->idate($datev)."'," . ereg_replace(",",".",$amount) .")";
|
if ($this->label) $sql.=", label";
|
||||||
|
$sql.= ") ";
|
||||||
|
$sql.= " VALUES ('".$this->db->idate($this->datep)."',";
|
||||||
|
$sql.= "'".$this->db->idate($this->datev)."'," . ereg_replace(",",".",$this->amount);
|
||||||
|
if ($this->note) $sql.=", '".addslashes($this->note)."'";
|
||||||
|
if ($this->label) $sql.=", '".addslashes($this->label)."'";
|
||||||
|
$sql.= ")";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
return 1;
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
|
||||||
|
if ($this->id > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Insertion dans llx_bank
|
||||||
|
$acc = new Account($this->db, $this->accountid);
|
||||||
|
$bank_line_id = $acc->addline($this->db->idate($this->datep), $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
|
||||||
|
|
||||||
|
// Mise a jour fk_bank dans llx_paiementcharge. On connait ainsi la ligne de tva qui a généré l'écriture bancaire
|
||||||
|
if ($bank_line_id) {
|
||||||
|
// $tva->update_fk_bank($bank_line_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mise a jour liens (pour chaque charge concernée par le paiement)
|
||||||
|
//foreach ($paiement->amounts as $key => $value)
|
||||||
|
//{
|
||||||
|
// $chid = $key;
|
||||||
|
// $fac = new Facture($db);
|
||||||
|
// $fac->fetch($chid);
|
||||||
|
// $fac->fetch_client();
|
||||||
|
// $acc->add_url_line($bank_line_id, $paiement_id, DOL_URL_ROOT.'/compta/paiement/fiche.php?id=', "(paiement)");
|
||||||
|
// $acc->add_url_line($bank_line_id, $fac->client->id, DOL_URL_ROOT.'/compta/fiche.php?socid=', $fac->client->nom);
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user