TVA : Add type_payment & num_payment who are missing
This commit is contained in:
parent
11b0bc4b38
commit
eb926103e0
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -41,6 +42,8 @@ class Tva extends CommonObject
|
|||||||
var $datep;
|
var $datep;
|
||||||
var $datev;
|
var $datev;
|
||||||
var $amount;
|
var $amount;
|
||||||
|
var $type_payment;
|
||||||
|
var $num_payment;
|
||||||
var $label;
|
var $label;
|
||||||
var $note;
|
var $note;
|
||||||
var $fk_bank;
|
var $fk_bank;
|
||||||
@ -215,6 +218,8 @@ class Tva extends CommonObject
|
|||||||
$sql.= " t.datep,";
|
$sql.= " t.datep,";
|
||||||
$sql.= " t.datev,";
|
$sql.= " t.datev,";
|
||||||
$sql.= " t.amount,";
|
$sql.= " t.amount,";
|
||||||
|
$sql.= " t.fk_typepayment,";
|
||||||
|
$sql.= " t.num_payment,";
|
||||||
$sql.= " t.label,";
|
$sql.= " t.label,";
|
||||||
$sql.= " t.note,";
|
$sql.= " t.note,";
|
||||||
$sql.= " t.fk_bank,";
|
$sql.= " t.fk_bank,";
|
||||||
@ -242,6 +247,8 @@ class Tva extends CommonObject
|
|||||||
$this->datep = $this->db->jdate($obj->datep);
|
$this->datep = $this->db->jdate($obj->datep);
|
||||||
$this->datev = $this->db->jdate($obj->datev);
|
$this->datev = $this->db->jdate($obj->datev);
|
||||||
$this->amount = $obj->amount;
|
$this->amount = $obj->amount;
|
||||||
|
$this->type_payment = $obj->fk_typepayment;
|
||||||
|
$this->num_payment = $obj->num_payment;
|
||||||
$this->label = $obj->label;
|
$this->label = $obj->label;
|
||||||
$this->note = $obj->note;
|
$this->note = $obj->note;
|
||||||
$this->fk_bank = $obj->fk_bank;
|
$this->fk_bank = $obj->fk_bank;
|
||||||
@ -479,6 +486,11 @@ class Tva extends CommonObject
|
|||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
$this->amount=price2num(trim($this->amount));
|
$this->amount=price2num(trim($this->amount));
|
||||||
|
$this->label=trim($this->label);
|
||||||
|
$this->note=trim($this->note);
|
||||||
|
$this->fk_bank=trim($this->fk_bank);
|
||||||
|
$this->fk_user_creat=trim($this->fk_user_creat);
|
||||||
|
$this->fk_user_modif=trim($this->fk_user_modif);
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (! $this->label)
|
if (! $this->label)
|
||||||
@ -496,23 +508,35 @@ class Tva extends CommonObject
|
|||||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account"));
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Account"));
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
if (! empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0))
|
if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insertion dans table des paiement tva
|
// Insertion dans la table d'un paiement tva
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep, datev, amount";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (datep";
|
||||||
|
$sql.= ", datev";
|
||||||
|
$sql.= ", amount";
|
||||||
|
$sql.= ", fk_typepayment";
|
||||||
|
$sql.= ", num_payment";
|
||||||
if ($this->note) $sql.= ", note";
|
if ($this->note) $sql.= ", note";
|
||||||
if ($this->label) $sql.= ", label";
|
if ($this->label) $sql.= ", label";
|
||||||
$sql.= ", fk_user_creat, fk_bank, entity";
|
$sql.= ", fk_user_creat";
|
||||||
|
$sql.= ", fk_bank";
|
||||||
|
$sql.= ", entity";
|
||||||
$sql.= ") ";
|
$sql.= ") ";
|
||||||
$sql.= " VALUES ('".$this->db->idate($this->datep)."',";
|
$sql.= " VALUES (";
|
||||||
$sql.= "'".$this->db->idate($this->datev)."'," . $this->amount;
|
$sql.= "'".$this->db->idate($this->datep)."'";
|
||||||
|
$sql.= ", '".$this->db->idate($this->datev)."'";
|
||||||
|
$sql.= ", ".$this->amount;
|
||||||
|
$sql.= ", '".$this->type_payment."'";
|
||||||
|
$sql.= ", '".$this->num_payment."'";
|
||||||
if ($this->note) $sql.=", '".$this->db->escape($this->note)."'";
|
if ($this->note) $sql.=", '".$this->db->escape($this->note)."'";
|
||||||
if ($this->label) $sql.=", '".$this->db->escape($this->label)."'";
|
if ($this->label) $sql.=", '".$this->db->escape($this->label)."'";
|
||||||
$sql.=", '".$user->id."', NULL, ".$conf->entity;
|
$sql.= ", '".$user->id."'";
|
||||||
|
$sql.= ", NULL";
|
||||||
|
$sql.= ", ".$conf->entity;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::addPayment sql=".$sql);
|
dol_syslog(get_class($this)."::addPayment sql=".$sql);
|
||||||
@ -540,7 +564,7 @@ class Tva extends CommonObject
|
|||||||
$result=$acc->fetch($this->accountid);
|
$result=$acc->fetch($this->accountid);
|
||||||
if ($result <= 0) dol_print_error($this->db);
|
if ($result <= 0) dol_print_error($this->db);
|
||||||
|
|
||||||
$bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);
|
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), '', '', $user);
|
||||||
|
|
||||||
// Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
|
// 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)
|
||||||
|
|||||||
@ -58,17 +58,34 @@ if ($_POST["cancel"] == $langs->trans("Cancel"))
|
|||||||
|
|
||||||
if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
$db->begin();
|
$error=0;
|
||||||
|
|
||||||
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
$datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
|
||||||
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
$datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
|
||||||
|
|
||||||
$tva->accountid=$_POST["accountid"];
|
$tva->accountid=GETPOST("accountid");
|
||||||
$tva->paymenttype=$_POST["paiementtype"];
|
$tva->type_payment=GETPOST("type_payment");
|
||||||
|
$tva->num_payment=GETPOST("num_payment");
|
||||||
$tva->datev=$datev;
|
$tva->datev=$datev;
|
||||||
$tva->datep=$datep;
|
$tva->datep=$datep;
|
||||||
$tva->amount=$_POST["amount"];
|
$tva->amount=GETPOST("amount");
|
||||||
$tva->label=$_POST["label"];
|
$tva->label=GETPOST("label");
|
||||||
|
$tva->note=GETPOST("note");
|
||||||
|
|
||||||
|
if (empty($tva->type_payment) || $tva->type_payment < 0)
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentMode")),'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
if (empty($tva->amount))
|
||||||
|
{
|
||||||
|
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")),'errors');
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$ret=$tva->addPayment($user);
|
$ret=$tva->addPayment($user);
|
||||||
if ($ret > 0)
|
if ($ret > 0)
|
||||||
@ -85,6 +102,9 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$action='create';
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'delete')
|
if ($action == 'delete')
|
||||||
{
|
{
|
||||||
$result=$tva->fetch($id);
|
$result=$tva->fetch($id);
|
||||||
@ -180,10 +200,16 @@ if ($action == 'create')
|
|||||||
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
|
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Type payment
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||||
$form->select_types_paiements($_POST["paiementtype"], "paiementtype");
|
$form->select_types_paiements(GETPOST("type_payment"), "type_payment");
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
|
|
||||||
|
// Number
|
||||||
|
print '<tr><td>'.$langs->trans('Numero');
|
||||||
|
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||||
|
print '<td><input name="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -27,7 +28,7 @@ require '../../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||||
|
|
||||||
$langs->load("compta");
|
$langs->load("compta");
|
||||||
$langs->load("compta");
|
$langs->load("bills");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||||
@ -46,9 +47,10 @@ $tva_static = new Tva($db);
|
|||||||
|
|
||||||
print_fiche_titre($langs->trans("VATPayments"));
|
print_fiche_titre($langs->trans("VATPayments"));
|
||||||
|
|
||||||
$sql = "SELECT rowid, amount, label, f.datev as dm";
|
$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dm, t.num_payment, pst.code as payment_code";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f ";
|
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
|
||||||
$sql.= " WHERE f.entity = ".$conf->entity;
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
|
||||||
|
$sql.= " WHERE t.entity = ".$conf->entity;
|
||||||
$sql.= " ORDER BY dm DESC";
|
$sql.= " ORDER BY dm DESC";
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
@ -63,6 +65,7 @@ if ($result)
|
|||||||
print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
|
print '<td class="nowrap" align="left">'.$langs->trans("Ref").'</td>';
|
||||||
print "<td>".$langs->trans("Label")."</td>";
|
print "<td>".$langs->trans("Label")."</td>";
|
||||||
print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
|
print '<td class="nowrap" align="left">'.$langs->trans("DatePayment").'</td>';
|
||||||
|
print '<td class="nowrap" align="left">'.$langs->trans("Type").'</td>';
|
||||||
print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
|
print "<td align=\"right\">".$langs->trans("PayedByThisPayment")."</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$var=1;
|
$var=1;
|
||||||
@ -77,14 +80,16 @@ if ($result)
|
|||||||
print "<td>".$tva_static->getNomUrl(1)."</td>\n";
|
print "<td>".$tva_static->getNomUrl(1)."</td>\n";
|
||||||
print "<td>".dol_trunc($obj->label,40)."</td>\n";
|
print "<td>".dol_trunc($obj->label,40)."</td>\n";
|
||||||
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
|
print '<td align="left">'.dol_print_date($db->jdate($obj->dm),'day')."</td>\n";
|
||||||
|
// Type
|
||||||
|
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
|
||||||
|
// Amount
|
||||||
$total = $total + $obj->amount;
|
$total = $total + $obj->amount;
|
||||||
|
|
||||||
print "<td align=\"right\">".price($obj->amount)."</td>";
|
print "<td align=\"right\">".price($obj->amount)."</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total").'</td>';
|
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Total").'</td>';
|
||||||
print "<td align=\"right\"><b>".price($total)."</b></td></tr>";
|
print "<td align=\"right\"><b>".price($total)."</b></td></tr>";
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user