Fix: Wrong error management when vat rate not defined.
This commit is contained in:
parent
6c5d4f283f
commit
7718fc03d7
@ -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');
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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>';
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
@ -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,93 +211,107 @@ 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)
|
||||||
|
|
||||||
$id = $invoice->id;
|
|
||||||
|
|
||||||
// Add the payment
|
|
||||||
$payment=new Paiement($db);
|
|
||||||
$payment->datepaye=$now;
|
|
||||||
$payment->bank_account=$conf_fkaccount;
|
|
||||||
$payment->amounts[$invoice->id]=$obj_facturation->prix_total_ttc();
|
|
||||||
$payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->num_facture();
|
|
||||||
$payment->paiementid=$invoice->mode_reglement_id;
|
|
||||||
$payment->num_paiement='';
|
|
||||||
|
|
||||||
$paiement_id = $payment->create($user);
|
|
||||||
if ($paiement_id > 0)
|
|
||||||
{
|
{
|
||||||
// Ajout d'une ecriture sur le compte bancaire
|
$resultvalid=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
|
||||||
if ($conf->banque->enabled)
|
|
||||||
|
$id = $invoice->id;
|
||||||
|
|
||||||
|
// Add the payment
|
||||||
|
$payment=new Paiement($db);
|
||||||
|
$payment->datepaye=$now;
|
||||||
|
$payment->bank_account=$conf_fkaccount;
|
||||||
|
$payment->amounts[$invoice->id]=$obj_facturation->prix_total_ttc();
|
||||||
|
$payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->num_facture();
|
||||||
|
$payment->paiementid=$invoice->mode_reglement_id;
|
||||||
|
$payment->num_paiement='';
|
||||||
|
|
||||||
|
$paiement_id = $payment->create($user);
|
||||||
|
if ($paiement_id > 0)
|
||||||
{
|
{
|
||||||
$bankaccountid=0;
|
// Ajout d'une ecriture sur le compte bancaire
|
||||||
if ( $obj_facturation->mode_reglement() == 'ESP' )
|
if ($conf->banque->enabled)
|
||||||
{
|
{
|
||||||
$bankaccountid=$conf_fkaccount_cash;
|
$bankaccountid=0;
|
||||||
}
|
if ( $obj_facturation->mode_reglement() == 'ESP' )
|
||||||
if ( $obj_facturation->mode_reglement() == 'CHQ' )
|
|
||||||
{
|
|
||||||
$bankaccountid=$conf_fkaccount_cheque;
|
|
||||||
}
|
|
||||||
if ( $obj_facturation->mode_reglement() == 'CB' )
|
|
||||||
{
|
|
||||||
$bankaccountid=$conf_fkaccount_cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($bankaccountid > 0)
|
|
||||||
{
|
|
||||||
// Insertion dans llx_bank
|
|
||||||
$label = "(CustomerInvoicePayment)";
|
|
||||||
$acc = new Account($db, $bankaccountid);
|
|
||||||
|
|
||||||
$bank_line_id = $acc->addline($payment->datepaye,
|
|
||||||
$payment->paiementid, // Payment mode id or code ("CHQ or VIR for example")
|
|
||||||
$label,
|
|
||||||
$obj_facturation->prix_total_ttc(),
|
|
||||||
$payment->num_paiement,
|
|
||||||
'',
|
|
||||||
$user,
|
|
||||||
'',
|
|
||||||
'');
|
|
||||||
|
|
||||||
// Mise a jour fk_bank dans llx_paiement.
|
|
||||||
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
|
||||||
if ($bank_line_id > 0)
|
|
||||||
{
|
{
|
||||||
$payment->update_fk_bank($bank_line_id);
|
$bankaccountid=$conf_fkaccount_cash;
|
||||||
// Mise a jour liens (pour chaque facture concernees par le paiement)
|
}
|
||||||
foreach ($payment->amounts as $key => $value)
|
if ( $obj_facturation->mode_reglement() == 'CHQ' )
|
||||||
|
{
|
||||||
|
$bankaccountid=$conf_fkaccount_cheque;
|
||||||
|
}
|
||||||
|
if ( $obj_facturation->mode_reglement() == 'CB' )
|
||||||
|
{
|
||||||
|
$bankaccountid=$conf_fkaccount_cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bankaccountid > 0)
|
||||||
|
{
|
||||||
|
// Insertion dans llx_bank
|
||||||
|
$label = "(CustomerInvoicePayment)";
|
||||||
|
$acc = new Account($db, $bankaccountid);
|
||||||
|
|
||||||
|
$bank_line_id = $acc->addline($payment->datepaye,
|
||||||
|
$payment->paiementid, // Payment mode id or code ("CHQ or VIR for example")
|
||||||
|
$label,
|
||||||
|
$obj_facturation->prix_total_ttc(),
|
||||||
|
$payment->num_paiement,
|
||||||
|
'',
|
||||||
|
$user,
|
||||||
|
'',
|
||||||
|
'');
|
||||||
|
|
||||||
|
// Mise a jour fk_bank dans llx_paiement.
|
||||||
|
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||||
|
if ($bank_line_id > 0)
|
||||||
{
|
{
|
||||||
$facid = $key;
|
$payment->update_fk_bank($bank_line_id);
|
||||||
$fac = new Facture($db);
|
// Mise a jour liens (pour chaque facture concernees par le paiement)
|
||||||
$fac->fetch($facid);
|
foreach ($payment->amounts as $key => $value)
|
||||||
$fac->fetch_client();
|
{
|
||||||
$acc->add_url_line($bank_line_id,
|
$facid = $key;
|
||||||
$paiement_id,
|
$fac = new Facture($db);
|
||||||
DOL_URL_ROOT.'/compta/paiement/fiche.php?id=',
|
$fac->fetch($facid);
|
||||||
'(paiement)',
|
$fac->fetch_client();
|
||||||
'payment');
|
$acc->add_url_line($bank_line_id,
|
||||||
$acc->add_url_line($bank_line_id,
|
$paiement_id,
|
||||||
$fac->client->id,
|
DOL_URL_ROOT.'/compta/paiement/fiche.php?id=',
|
||||||
DOL_URL_ROOT.'/compta/fiche.php?socid=',
|
'(paiement)',
|
||||||
$fac->client->nom,
|
'payment');
|
||||||
'company');
|
$acc->add_url_line($bank_line_id,
|
||||||
|
$fac->client->id,
|
||||||
|
DOL_URL_ROOT.'/compta/fiche.php?socid=',
|
||||||
|
$fac->client->nom,
|
||||||
|
'company');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user