Fix: Error when creating a supplier payment
This commit is contained in:
parent
8ae77a8d49
commit
91a5463ca2
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -17,15 +17,13 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/bank/account.class.php
|
||||
\ingroup banque
|
||||
\brief Fichier de la classe des comptes bancaires
|
||||
\version $Revision$
|
||||
\version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
|
||||
@ -164,16 +162,16 @@ class Account extends CommonObject
|
||||
|
||||
/**
|
||||
\brief Ajoute une entree dans la table ".MAIN_DB_PREFIX."bank
|
||||
\param $date Date TMS op<EFBFBD>ration
|
||||
\param $date Date operation
|
||||
\param $oper 1,2,3,4...
|
||||
\param $label Descripton
|
||||
\param $amount Montant
|
||||
\param $num_chq Numero cheque ou virement
|
||||
\param $categorie Categorie optionnelle
|
||||
\param $user Utilisateur qui cr<EFBFBD>e
|
||||
\param $user User that create
|
||||
\param $emetteur Nom emetteur
|
||||
\param $banque Banque emettrice
|
||||
\return int Rowid de l'entr<EFBFBD>e ajout<EFBFBD>e, <0 si erreur
|
||||
\return int Rowid of added entry, <0 si erreur
|
||||
*/
|
||||
function addline($date, $oper, $label, $amount, $num_chq='', $categorie='', $user, $emetteur='',$banque='')
|
||||
{
|
||||
@ -257,8 +255,9 @@ class Account extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dolibarr_syslog("Account::addline ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->error();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,10 +76,11 @@ if ($action == 'add_paiement')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Effectue les vérifications des parametres
|
||||
if ($_POST['paiementid'] <= 0)
|
||||
{
|
||||
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('PaymentMode')).'</div>';
|
||||
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('PaymentMode')).'</div>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ if ($action == 'add_paiement')
|
||||
// d'un paiement
|
||||
if (! $_POST['accountid'])
|
||||
{
|
||||
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>';
|
||||
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -98,7 +99,7 @@ if ($action == 'add_paiement')
|
||||
\TODO A activer qd gestion avoir active et que creation facture fournisseur negative interdit
|
||||
if ($total <= 0)
|
||||
{
|
||||
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Amount')).'</div>';
|
||||
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Amount')).'</div>';
|
||||
$error++;
|
||||
}
|
||||
*/
|
||||
@ -110,7 +111,7 @@ if ($action == 'add_paiement')
|
||||
// Creation de la ligne paiement
|
||||
$paiement = new PaiementFourn($db);
|
||||
$paiement->datepaye = $datepaye;
|
||||
$paiement->amounts = $amounts; // Tableau de montant
|
||||
$paiement->amounts = $amounts; // Array of amounts
|
||||
$paiement->paiementid = $_POST['paiementid'];
|
||||
$paiement->num_paiement = $_POST['num_paiement'];
|
||||
$paiement->note = $_POST['comment'];
|
||||
@ -149,7 +150,7 @@ if ($action == 'add_paiement')
|
||||
DOL_URL_ROOT.'/fourn/paiement/fiche.php?id=',
|
||||
'(paiement)',
|
||||
'payment_supplier');
|
||||
$acc->add_url_line($bank_line_id,
|
||||
$acc->add_url_line($bank_line_id,
|
||||
$fac->fournisseur->id,
|
||||
DOL_URL_ROOT.'/fourn/fiche.php?socid=',
|
||||
$fac->fournisseur->nom,
|
||||
@ -164,7 +165,7 @@ if ($action == 'add_paiement')
|
||||
}
|
||||
else
|
||||
{
|
||||
$fiche_erreur_message = '<div class="error">'.$langs->trans("Error").'</div>';
|
||||
$mesg = '<div class="error">'.$langs->trans($paiement->error).'</div>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -190,9 +191,9 @@ llxHeader();
|
||||
|
||||
$html=new Form($db);
|
||||
|
||||
if ($fiche_erreur_message)
|
||||
if ($mesg)
|
||||
{
|
||||
print '<tr><td colspan="3" align="center">'.$fiche_erreur_message.'</td></tr>';
|
||||
print '<tr><td colspan="3" align="center">'.$mesg.'</td></tr>';
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'add_paiement')
|
||||
|
||||
@ -65,8 +65,8 @@ class PaiementFourn
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief R<EFBFBD>cup<EFBFBD>re l'objet paiement
|
||||
* \param id id du paiement a r<EFBFBD>cup<EFBFBD>rer
|
||||
* \brief Load payment object
|
||||
* \param id id paiement to get
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function fetch($id)
|
||||
@ -112,7 +112,7 @@ class PaiementFourn
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Creta payment in database
|
||||
* \brief Create payment in database
|
||||
* \param user Object of creating user
|
||||
* \return int id of created payment, < 0 if error
|
||||
*/
|
||||
@ -132,14 +132,18 @@ class PaiementFourn
|
||||
$this->total += $val;
|
||||
}
|
||||
$this->total = price2num($this->total);
|
||||
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ($this->total <> 0) // On accepte les montants n<EFBFBD>gatifs
|
||||
if ($this->total <> 0) // On accepte les montants negatifs
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author)';
|
||||
$sql .= ' VALUES (now(), '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')';
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (';
|
||||
$sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)';
|
||||
$sql.= ' VALUES (now(),';
|
||||
$sql.= ' '.$this->db->idate($this->datepaye).', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.', 0)';
|
||||
|
||||
dolibarr_syslog("PaiementFourn::create sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -162,7 +166,7 @@ class PaiementFourn
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('PaiementFourn::Create Montant non num<EFBFBD>rique');
|
||||
dolibarr_syslog('PaiementFourn::Create Montant non numerique',LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,12 +182,19 @@ class PaiementFourn
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('PaiementFourn::Create Erreur INSERT dans paiementfourn');
|
||||
$this->error=$this->db->lasterror();
|
||||
dolibarr_syslog('PaiementFourn::Create Error '.$this->error, LOG_ERR);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="ErrorTotalIsNull";
|
||||
dolibarr_syslog('PaiementFourn::Create Error '.$this->error, LOG_ERR);
|
||||
$error++;
|
||||
}
|
||||
|
||||
if ( $this->total <> 0 && $error == 0 ) // On accepte les montants n<>gatifs
|
||||
if ($this->total <> 0 && $error == 0) // On accepte les montants negatifs
|
||||
{
|
||||
$this->db->commit();
|
||||
dolibarr_syslog('PaiementFourn::Create Ok Total = '.$this->total);
|
||||
@ -192,7 +203,6 @@ class PaiementFourn
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dolibarr_syslog('PaiementFourn::Create Erreur');
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,5 +290,6 @@ create table llx_ecm_document
|
||||
private smallint DEFAULT 0
|
||||
) type=innodb;
|
||||
|
||||
ALTER TABLE llx_bank modify num_chq varchar(50);
|
||||
|
||||
ALTER TABLE llx_menu_const ADD UNIQUE KEY uk_menu_const(fk_menu, fk_constraint);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2000-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- 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
|
||||
@ -32,7 +32,7 @@ create table llx_bank
|
||||
fk_user_rappro integer,
|
||||
fk_type varchar(4), -- CB, Virement, cheque
|
||||
num_releve varchar(50),
|
||||
num_chq int,
|
||||
num_chq varchar(50),
|
||||
rappro tinyint default 0,
|
||||
note text,
|
||||
fk_bordereau integer DEFAULT 0,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user