New: Il est possible de choisir le compte de dbit 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
|
||||
\version $Revision$
|
||||
*/
|
||||
@ -29,55 +30,82 @@
|
||||
require("./pre.inc.php");
|
||||
require("../../tva.class.php");
|
||||
|
||||
$langs->load("compta");
|
||||
|
||||
|
||||
$mesg = '';
|
||||
|
||||
|
||||
/**
|
||||
* Action ajout paiement tva
|
||||
*/
|
||||
if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
{
|
||||
$tva = new Tva($db);
|
||||
$tva = new Tva($db);
|
||||
|
||||
$db->begin();
|
||||
|
||||
$tva->label = $langs->trans("VATPayment");
|
||||
$tva->accountid=$_POST["accountid"];
|
||||
$tva->paymenttype=$_POST["paiementtype"];
|
||||
$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->amount=$_POST["amount"];
|
||||
|
||||
$tva->add_payement(mktime(12,0,0,
|
||||
$_POST["datevmonth"],
|
||||
$_POST["datevday"],
|
||||
$_POST["datevyear"]
|
||||
),
|
||||
mktime(12,0,0,
|
||||
$_POST["datepmonth"],
|
||||
$_POST["datepday"],
|
||||
$_POST["datepyear"]
|
||||
),
|
||||
$_POST["amount"]
|
||||
);
|
||||
Header ( "Location: reglement.php");
|
||||
$ret=$tva->add_payement($user);
|
||||
if ($ret > 0)
|
||||
{
|
||||
$db->commit();
|
||||
Header ("Location: reglement.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$message=$langs->trans("Error");
|
||||
$_GET["action"]="create";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
$html = new Form($db);
|
||||
|
||||
// Formulaire saisie tva
|
||||
if ($_GET["action"] == 'create')
|
||||
{
|
||||
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<div class="titre">Nouveau réglement TVA</div><br>';
|
||||
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<div class="titre">'.$langs->trans("NewVATPayment").'</div><br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("DatePayment").'</td><td>';
|
||||
print $html->select_date("","datev");
|
||||
print '</td></tr>';
|
||||
print '<td>'.$langs->trans("DateValue").'</td><td>';
|
||||
print $html->select_date("","datep");
|
||||
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>';
|
||||
if ($message) print '<br>'.$message.'</br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("DatePayment").'</td><td>';
|
||||
print $html->select_date("","datev");
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
|
||||
print $html->select_date("","datep");
|
||||
print '</td></tr>';
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
$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
|
||||
*/
|
||||
|
||||
function add_payement($datep, $datev, $amount)
|
||||
function add_payement($user)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount) ";
|
||||
$sql .= " VALUES ('".$this->db->idate($datep)."',";
|
||||
$sql .= "'".$this->db->idate($datev)."'," . ereg_replace(",",".",$amount) .")";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount";
|
||||
if ($this->note) $sql.=", note";
|
||||
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);
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user