Fix: Wrong error management when vat rate not defined.

This commit is contained in:
Laurent Destailleur 2009-11-17 23:01:16 +00:00
parent 6c5d4f283f
commit 7718fc03d7
6 changed files with 114 additions and 100 deletions

View File

@ -58,7 +58,7 @@ print '<div class="conteneur">'."\n";
print '<div class="conteneur_img_gauche">'."\n"; print '<div class="conteneur_img_gauche">'."\n";
print '<div class="conteneur_img_droite">'."\n"; print '<div class="conteneur_img_droite">'."\n";
print '<h1 class="entete"><span>CAISSE</span></h1>'."\n"; print '<h1 class="entete"><span>POINT OF SALE</span></h1>'."\n";
print '<div class="menu_principal">'."\n"; print '<div class="menu_principal">'."\n";
include_once('templates/menu.tpl.php'); include_once('templates/menu.tpl.php');

View File

@ -57,13 +57,12 @@ if ($conf->banque->enabled && (empty($conf_fkaccount_cash) || empty($conf_fkacco
{ {
$error.= '<div class="error">Setup of CashDesk module not complete. Bank account not defined</div>'; $error.= '<div class="error">Setup of CashDesk module not complete. Bank account not defined</div>';
} }
// TODO: ajouter gestion entrepot // If we setup stock module to ask movement on invoices, with must not work if required setup not finished.
/* if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_BILL && empty($conf_fkentrepot))
if ($conf->stock->enabled && empty($conf_fkentrepot))
{ {
$error.= '<div class="error">Setup of CashDesk module not complete. Warehouse not defined</div>'; $error.= '<div class="error">Setup of CashDesk module not complete. Warehouse (for stock decrease on invoice) is not defined</div>';
} }
*/
// Parametres d'affichage // Parametres d'affichage
$conf_taille_listes = 200; // Nombre max de lignes a afficher dans les listes $conf_taille_listes = 200; // Nombre max de lignes a afficher dans les listes
$conf_nbr_car_listes = 60; // Nombre max de caracteres par ligne dans les listes $conf_nbr_car_listes = 60; // Nombre max de caracteres par ligne dans les listes

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net> /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
* Copyright (C) 2008 Laurent Destailleur <eldy@uers.sourceforge.net> * Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -46,15 +46,13 @@ if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE))
$bankcheque->fetch($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE); $bankcheque->fetch($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE);
$bankchequeLink = $bankcheque->getNomUrl(1); $bankchequeLink = $bankcheque->getNomUrl(1);
} }
// TODO: ajouter gestion entrepot if (!empty($conf->global->CASHDESK_ID_WAREHOUSE) && $conf->stock->enabled)
/*
if (!empty($conf->global->CASHDESK_ID_WAREHOUSE))
{ {
$warehouse=new Entrepot($db); $warehouse=new Entrepot($db);
$warehouse->fetch($conf->global->CASHDESK_ID_WAREHOUSE); $warehouse->fetch($conf->global->CASHDESK_ID_WAREHOUSE);
$warehouseLink = $warehouse->getNomUrl(1); $warehouseLink = $warehouse->getNomUrl(1);
} }
*/
$langs->load("@cashdesk"); $langs->load("@cashdesk");
$langs->load("main"); $langs->load("main");
@ -67,14 +65,14 @@ print '<li class="menu_choix1"><a href="affIndex.php?menu=facturation&id=NOUV"><
print '<li class="menu_choix2"><a href=".."><span>'.$langs->trans("BackOffice").'</span></a></li>'; print '<li class="menu_choix2"><a href=".."><span>'.$langs->trans("BackOffice").'</span></a></li>';
print '<li class="menu_choix0">'.$langs->trans("User").' : '.$_SESSION['prenom'].' '.$_SESSION['nom'].' <a href="deconnexion.php">'.$logout.'</a><br>'; print '<li class="menu_choix0">'.$langs->trans("User").': '.$_SESSION['prenom'].' '.$_SESSION['nom'].' <a href="deconnexion.php">'.$logout.'</a><br>';
print $langs->trans("CashDeskThirdParty").' : '.$companyLink.'<br>'; print $langs->trans("CashDeskThirdParty").': '.$companyLink.'<br>';
print $langs->trans("CashDeskBankCash").' : '.$bankcashLink.'<br>'; print $langs->trans("CashDeskBankCash").': '.$bankcashLink.'<br>';
print $langs->trans("CashDeskBankCB").' : '.$bankcbLink.'<br>'; print $langs->trans("CashDeskBankCB").': '.$bankcbLink.'<br>';
print $langs->trans("CashDeskBankCheque").' : '.$bankchequeLink.'<br>'; print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.'<br>';
if ($conf->stock->enabled && $warehouse->id) // Disabled because warehouse->fetch disabled before if (!empty($conf->global->CASHDESK_ID_WAREHOUSE) && $conf->stock->enabled)
{ {
print $langs->trans("CashDeskWarehouse").' : '.$warehouseLink; print $langs->trans("CashDeskWarehouse").': '.$warehouseLink;
} }
print '</li></ul>'; print '</li></ul>';
print '</div>'; print '</div>';

View File

@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
</script> </script>
<p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture.php?facid=<?php echo $_GET['facid']; ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p> <p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture.php?facid=<?php echo $_GET['facid']; ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p>
<br>
<p><a class="lien1" href="#" onclick="Javascript: popupTicket(); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p> <p><a class="lien1" href="#" onclick="Javascript: popupTicket(); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p>
</div> </div>

View File

@ -82,9 +82,11 @@ switch ( $_GET['action'] )
case 'valide_facture': case 'valide_facture':
$now=dol_now('tzserver');
// Recuperation de la date et de l'heure // Recuperation de la date et de l'heure
$date = date ('Y-m-d'); $date = dol_print_date($now,'day');
$heure = date ('H:i:s'); $heure = dol_print_date($now,'hour');
$note = ''; $note = '';
if (! is_object($obj_facturation)) if (! is_object($obj_facturation))
@ -125,7 +127,6 @@ switch ( $_GET['action'] )
$error=0; $error=0;
$now=dol_now('tzserver');
$db->begin(); $db->begin();
@ -183,7 +184,8 @@ switch ( $_GET['action'] )
$invoiceline=new FactureLigne($db); $invoiceline=new FactureLigne($db);
$invoiceline->fk_product=$tab_liste[$i]['fk_article']; $invoiceline->fk_product=$tab_liste[$i]['fk_article'];
$invoiceline->desc=$tab_article['label']; $invoiceline->desc=$tab_article['label'];
$invoiceline->tva_tx=$tab_tva['taux']; $invoiceline->tva_tx=empty($tab_tva['taux'])?0:$tab_tva['taux']; // works even if vat_rate is ''
//$invoiceline->tva_tx=$tab_tva['taux'];
$invoiceline->qty=$tab_liste[$i]['qte']; $invoiceline->qty=$tab_liste[$i]['qte'];
$invoiceline->remise_percent=$tab_liste[$i]['remise_percent']; $invoiceline->remise_percent=$tab_liste[$i]['remise_percent'];
$invoiceline->price=$tab_article['price']; $invoiceline->price=$tab_article['price'];
@ -209,15 +211,24 @@ switch ( $_GET['action'] )
// Si paiement differe ... // Si paiement differe ...
if ( $obj_facturation->mode_reglement() == 'DIF' ) if ( $obj_facturation->mode_reglement() == 'DIF' )
{ {
$result=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiement_le())); $resultcreate=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiement_le()));
$result=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture()); if ($resultcreate > 0)
{
$resultvalid=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
}
else
{
$error++;
}
$id = $invoice->id; $id = $invoice->id;
} }
else else
{ {
$result=$invoice->create($user,0,0); $resultcreate=$invoice->create($user,0,0);
$result=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture()); if ($resultcreate > 0)
{
$resultvalid=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
$id = $invoice->id; $id = $invoice->id;
@ -302,6 +313,11 @@ switch ( $_GET['action'] )
$error++; $error++;
} }
} }
else
{
$error++;
}
}
if (! $error) if (! $error)
{ {
@ -311,7 +327,7 @@ switch ( $_GET['action'] )
else else
{ {
$db->rollback(); $db->rollback();
$redirection = 'affIndex.php?facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr $redirection = 'affIndex.php?facid='.$id.'&mesg=ErrorFailedToCreateInvoice'; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
} }
break; break;

View File

@ -20,7 +20,7 @@
* \defgroup pos Module points of sale * \defgroup pos Module points of sale
* \brief Module to manage points of sale * \brief Module to manage points of sale
* \version $Id$ * \version $Id$
*/ */
/** /**
* \file htdocs/includes/modules/modCashDesk.class.php * \file htdocs/includes/modules/modCashDesk.class.php
@ -72,7 +72,7 @@ class modCashDesk extends DolibarrModules
$this->config_page_url = array("cashdesk.php"); $this->config_page_url = array("cashdesk.php");
// Dependencies // Dependencies
$this->depends = array("modBanque","modFacture","modProduit","modStock"); // List of modules id that must be enabled if this module is enabled $this->depends = array("modBanque","modFacture","modProduit"); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled $this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(4,1); // Minimum version of PHP required by module $this->phpmin = array(4,1); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module