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_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";
|
||||
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>';
|
||||
}
|
||||
// TODO: ajouter gestion entrepot
|
||||
/*
|
||||
if ($conf->stock->enabled && empty($conf_fkentrepot))
|
||||
// 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))
|
||||
{
|
||||
$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
|
||||
$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
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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>
|
||||
*
|
||||
* 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);
|
||||
$bankchequeLink = $bankcheque->getNomUrl(1);
|
||||
}
|
||||
// TODO: ajouter gestion entrepot
|
||||
/*
|
||||
if (!empty($conf->global->CASHDESK_ID_WAREHOUSE))
|
||||
if (!empty($conf->global->CASHDESK_ID_WAREHOUSE) && $conf->stock->enabled)
|
||||
{
|
||||
$warehouse=new Entrepot($db);
|
||||
$warehouse->fetch($conf->global->CASHDESK_ID_WAREHOUSE);
|
||||
$warehouseLink = $warehouse->getNomUrl(1);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
$langs->load("@cashdesk");
|
||||
$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_choix0">'.$langs->trans("User").' : '.$_SESSION['prenom'].' '.$_SESSION['nom'].' <a href="deconnexion.php">'.$logout.'</a><br>';
|
||||
print $langs->trans("CashDeskThirdParty").' : '.$companyLink.'<br>';
|
||||
print $langs->trans("CashDeskBankCash").' : '.$bankcashLink.'<br>';
|
||||
print $langs->trans("CashDeskBankCB").' : '.$bankcbLink.'<br>';
|
||||
print $langs->trans("CashDeskBankCheque").' : '.$bankchequeLink.'<br>';
|
||||
if ($conf->stock->enabled && $warehouse->id) // Disabled because warehouse->fetch disabled before
|
||||
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("CashDeskBankCash").': '.$bankcashLink.'<br>';
|
||||
print $langs->trans("CashDeskBankCB").': '.$bankcbLink.'<br>';
|
||||
print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.'<br>';
|
||||
if (!empty($conf->global->CASHDESK_ID_WAREHOUSE) && $conf->stock->enabled)
|
||||
{
|
||||
print $langs->trans("CashDeskWarehouse").' : '.$warehouseLink;
|
||||
print $langs->trans("CashDeskWarehouse").': '.$warehouseLink;
|
||||
}
|
||||
print '</li></ul>';
|
||||
print '</div>';
|
||||
|
||||
@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
</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>
|
||||
<br>
|
||||
<p><a class="lien1" href="#" onclick="Javascript: popupTicket(); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p>
|
||||
|
||||
</div>
|
||||
|
||||
@ -81,10 +81,12 @@ switch ( $_GET['action'] )
|
||||
|
||||
|
||||
case 'valide_facture':
|
||||
|
||||
|
||||
$now=dol_now('tzserver');
|
||||
|
||||
// Recuperation de la date et de l'heure
|
||||
$date = date ('Y-m-d');
|
||||
$heure = date ('H:i:s');
|
||||
$date = dol_print_date($now,'day');
|
||||
$heure = dol_print_date($now,'hour');
|
||||
|
||||
$note = '';
|
||||
if (! is_object($obj_facturation))
|
||||
@ -125,7 +127,6 @@ switch ( $_GET['action'] )
|
||||
|
||||
|
||||
$error=0;
|
||||
$now=dol_now('tzserver');
|
||||
|
||||
|
||||
$db->begin();
|
||||
@ -183,7 +184,8 @@ switch ( $_GET['action'] )
|
||||
$invoiceline=new FactureLigne($db);
|
||||
$invoiceline->fk_product=$tab_liste[$i]['fk_article'];
|
||||
$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->remise_percent=$tab_liste[$i]['remise_percent'];
|
||||
$invoiceline->price=$tab_article['price'];
|
||||
@ -209,93 +211,107 @@ switch ( $_GET['action'] )
|
||||
// Si paiement differe ...
|
||||
if ( $obj_facturation->mode_reglement() == 'DIF' )
|
||||
{
|
||||
$result=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiement_le()));
|
||||
$result=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
|
||||
|
||||
$resultcreate=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiement_le()));
|
||||
if ($resultcreate > 0)
|
||||
{
|
||||
$resultvalid=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
$id = $invoice->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=$invoice->create($user,0,0);
|
||||
$result=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
|
||||
|
||||
$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)
|
||||
$resultcreate=$invoice->create($user,0,0);
|
||||
if ($resultcreate > 0)
|
||||
{
|
||||
// Ajout d'une ecriture sur le compte bancaire
|
||||
if ($conf->banque->enabled)
|
||||
$resultvalid=$invoice->set_valid($user,$conf_fksoc,$obj_facturation->num_facture());
|
||||
|
||||
$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;
|
||||
if ( $obj_facturation->mode_reglement() == 'ESP' )
|
||||
// Ajout d'une ecriture sur le compte bancaire
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
$bankaccountid=$conf_fkaccount_cash;
|
||||
}
|
||||
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)
|
||||
$bankaccountid=0;
|
||||
if ( $obj_facturation->mode_reglement() == 'ESP' )
|
||||
{
|
||||
$payment->update_fk_bank($bank_line_id);
|
||||
// Mise a jour liens (pour chaque facture concernees par le paiement)
|
||||
foreach ($payment->amounts as $key => $value)
|
||||
$bankaccountid=$conf_fkaccount_cash;
|
||||
}
|
||||
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;
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($facid);
|
||||
$fac->fetch_client();
|
||||
$acc->add_url_line($bank_line_id,
|
||||
$paiement_id,
|
||||
DOL_URL_ROOT.'/compta/paiement/fiche.php?id=',
|
||||
'(paiement)',
|
||||
'payment');
|
||||
$acc->add_url_line($bank_line_id,
|
||||
$fac->client->id,
|
||||
DOL_URL_ROOT.'/compta/fiche.php?socid=',
|
||||
$fac->client->nom,
|
||||
'company');
|
||||
$payment->update_fk_bank($bank_line_id);
|
||||
// Mise a jour liens (pour chaque facture concernees par le paiement)
|
||||
foreach ($payment->amounts as $key => $value)
|
||||
{
|
||||
$facid = $key;
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($facid);
|
||||
$fac->fetch_client();
|
||||
$acc->add_url_line($bank_line_id,
|
||||
$paiement_id,
|
||||
DOL_URL_ROOT.'/compta/paiement/fiche.php?id=',
|
||||
'(paiement)',
|
||||
'payment');
|
||||
$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
|
||||
{
|
||||
@ -311,7 +327,7 @@ switch ( $_GET['action'] )
|
||||
else
|
||||
{
|
||||
$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;
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* \defgroup pos Module points of sale
|
||||
* \brief Module to manage points of sale
|
||||
* \version $Id$
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/includes/modules/modCashDesk.class.php
|
||||
@ -72,7 +72,7 @@ class modCashDesk extends DolibarrModules
|
||||
$this->config_page_url = array("cashdesk.php");
|
||||
|
||||
// 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->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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user