Fix: Possibilité de saisir les paiements de tva meme si module banque non actif
This commit is contained in:
parent
54f160a821
commit
8607afc479
@ -18,7 +18,6 @@
|
|||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
* $Source$
|
* $Source$
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,11 +56,12 @@ if ($_POST["action"] == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
|||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
Header ("Location: reglement.php");
|
Header ("Location: reglement.php");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
$message=$langs->trans("Error");
|
$message='<div class="error">'.$tva->error.'</div>';
|
||||||
$_GET["action"]="create";
|
$_GET["action"]="create";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ if ($_GET["action"] == 'create')
|
|||||||
|
|
||||||
print_fiche_titre($langs->trans("NewVATPayment"));
|
print_fiche_titre($langs->trans("NewVATPayment"));
|
||||||
|
|
||||||
if ($message) print '<br>'.$message.'</br>';
|
if ($message) print $message;
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
@ -97,13 +97,16 @@ if ($_GET["action"] == 'create')
|
|||||||
$html->select_types_paiements($charge->paiementtype, "paiementtype");
|
$html->select_types_paiements($charge->paiementtype, "paiementtype");
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
print '<tr><td>Compte à créditer :</td><td>';
|
if ($conf->banque->enabled)
|
||||||
$html->select_comptes($charge->accountid, "accountid", 0, "courant=1"); // Affiche liste des comptes courant
|
{
|
||||||
print '</td></tr>';
|
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>';
|
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> </td><td><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||||
print '<input type="submit" 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>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -194,12 +194,33 @@ class Tva
|
|||||||
|
|
||||||
function add_payement($user)
|
function add_payement($user)
|
||||||
{
|
{
|
||||||
|
global $conf,$langs;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
// Validation parameteres
|
||||||
|
$this->amount=price2num($this->amount);
|
||||||
|
if ($conf->banque->enabled)
|
||||||
|
{
|
||||||
|
if (! $this->accountid)
|
||||||
|
{
|
||||||
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Account"));
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($this->amount <= 0)
|
||||||
|
{
|
||||||
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Amount"));
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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.= ") ";
|
$sql.= ") ";
|
||||||
$sql.= " VALUES ('".$this->db->idate($this->datep)."',";
|
$sql.= " VALUES ('".$this->db->idate($this->datep)."',";
|
||||||
$sql.= "'".$this->db->idate($this->datev)."'," . ereg_replace(",",".",$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.= ")";
|
$sql.= ")";
|
||||||
@ -207,37 +228,48 @@ class Tva
|
|||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // \todo devrait s'appeler paiementtva
|
||||||
if ($this->id > 0)
|
if ($this->id > 0)
|
||||||
{
|
{
|
||||||
|
if ($conf->banque->enabled)
|
||||||
|
{
|
||||||
|
// Insertion dans llx_bank
|
||||||
|
|
||||||
// Insertion dans llx_bank
|
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/account.class.php');
|
||||||
$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
|
$acc = new Account($this->db, $this->accountid);
|
||||||
if ($bank_line_id) {
|
$bank_line_id = $acc->addline($this->db->idate($this->datep), $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
|
||||||
// $tva->update_fk_bank($bank_line_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mise a jour liens (pour chaque charge concernée par le paiement)
|
// Mise a jour fk_bank dans llx_paiementtva. On connait ainsi la ligne de tva qui a généré l'écriture bancaire
|
||||||
//foreach ($paiement->amounts as $key => $value)
|
if ($bank_line_id) {
|
||||||
//{
|
// $tva->update_fk_bank($bank_line_id);
|
||||||
// $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);
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
// Mise a jour liens (pour chaque charge concernée par le paiement)
|
||||||
|
//foreach ($paiement->amounts as $key => $value)
|
||||||
return $this->id;
|
//{
|
||||||
|
// $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);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
$this->db->commit();
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user