Qual: Field for amount into pos module tmp table are same type than others amount

This commit is contained in:
Laurent Destailleur 2010-11-20 16:07:52 +00:00
parent 84ad4c0578
commit 832a389598
11 changed files with 85 additions and 54 deletions

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@ -30,7 +30,7 @@ require ('class/Facturation.class.php');
if ( $_GET['id'] == 'NOUV' )
{
unset($_SESSION['serObjFacturation']);
$db->query ('DELETE FROM '.MAIN_DB_PREFIX.'tmp_caisse');
$db->query ('DELETE FROM '.MAIN_DB_PREFIX.'pos_tmp');
}
// Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ...

View File

@ -126,7 +126,7 @@ class Facturation {
$montant_remise_ht = ($resultarray[6] - $resultarray[0]);
$this->montant_remise ($montant_remise_ht);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tmp_caisse (";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."pos_tmp (";
$sql.= "fk_article";
$sql.= ", qte";
$sql.= ", fk_tva";
@ -157,14 +157,14 @@ class Facturation {
}
/**
* Suppression du panier d'un article identifie par son id dans la table llx_tmp_caisse
* Suppression du panier d'un article identifie par son id dans la table llx_pos_tmp
* @param aArticle
*/
public function supprArticle($aArticle)
{
global $db;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tmp_caisse";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."pos_tmp";
$sql.= " WHERE id = ".$aArticle;
$sql.= " LIMIT 1";
@ -179,7 +179,7 @@ class Facturation {
{
global $db;
$res = $db->query ('SELECT remise, total_ht, total_ttc, taux FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
$res = $db->query ('SELECT remise, total_ht, total_ttc, taux FROM '.MAIN_DB_PREFIX.'pos_tmp as c
LEFT JOIN '.MAIN_DB_PREFIX.'c_tva as t ON c.fk_tva = t.rowid
ORDER BY id');

View File

@ -1,5 +1,5 @@
/* Copyright (C) 2007-2008 Jérémie Ollivier <jeremie.o@laposte.net>
/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.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
@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Calcul et affichage en temps réel des informations sur le produit en cours
// Calcul et affichage en temps reel des informations sur le produit en cours
function modif () {
var prix_unit = parseFloat ( document.getElementById('frmQte').txtPrixUnit.value );
@ -26,7 +26,7 @@ function modif () {
var remise = parseInt ( document.getElementById('frmQte').txtRemise.value );
var stock = document.getElementById('frmQte').txtStock.value;
// // On s'assure que la quantitée tapée ne dépasse pas le stock
// // On s'assure que la quantitee tapee ne depasse pas le stock
// if ( qte > stock ) {
//
// qte = stock;
@ -51,7 +51,7 @@ function modif () {
// Calcul du total HT, sans remise
var total_ht = Math.round ( (prix_unit * qte) * 100 ) / 100;
// Calcul du montant de la remise, après s'être assuré que cette dernière ne soit pas négative
// Calcul du montant de la remise, apres s'etre assure que cette derniere ne soit pas negative
if ( remise <= 0 ) {
document.getElementById('frmQte').txtRemise.value = 0;
@ -66,12 +66,12 @@ function modif () {
// Recalcul du montant total, avec la remise
var total = Math.round ( (total_ht - montant_remise) *100 ) / 100;
// Affichage du résultat dans le formulaire
// Affichage du resultat dans le formulaire
document.getElementById('frmQte').txtTotal.value = total.toFixed(2);
}
// Affecte la source de la requete (liste déroulante ou champ texte 'ref') au champ caché
// Affecte la source de la requete (liste deroulante ou champ texte 'ref') au champ cache
function setSource (aSrc) {
document.getElementById('frmFacturation').hdnSource.value = aSrc;
@ -79,7 +79,7 @@ function setSource (aSrc) {
}
// Vérification de la cohérence des informations saisies dans le formulaire de choix du nombre d'articles
// Verification de la coherence des informations saisies dans le formulaire de choix du nombre d'articles
function verifSaisie () {
if ( document.getElementById('frmQte').txtQte.value ) {
@ -95,7 +95,7 @@ function verifSaisie () {
}
// Vérification de la cohérence des informations saisies dans le formulaire de calcul de la différence
// Verification de la coherence des informations saisies dans le formulaire de calcul de la difference
function verifDifference () {
var du = parseFloat ( document.getElementById('frmDifference').txtDu.value );
@ -118,14 +118,14 @@ function verifDifference () {
}
// Affecte le moyen de paiement (ESP, CB ou CHQ) au champ caché en fonction du bouton cliqué
// Affecte le moyen de paiement (ESP, CB ou CHQ) au champ cache en fonction du bouton clique
function verifClic (aChoix) {
document.getElementById('frmDifference').hdnChoix.value = aChoix;
}
// Détermination du moyen de paiement, et validation du formulaire si les données sont cohérentes
// Determination du moyen de paiement, et validation du formulaire si les donnees sont coherentes
function verifReglement () {
var choix = document.getElementById('frmDifference').hdnChoix.value;

View File

@ -0,0 +1,32 @@
-- ===========================================================================
-- Copyright (C) 2010 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
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- 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$
-- ===========================================================================
CREATE TABLE llx_pos_tmp (
id integer NOT NULL auto_increment,
fk_article integer NOT NULL,
qte real NOT NULL,
fk_tva integer NOT NULL,
remise_percent real NOT NULL,
remise real NOT NULL,
total_ht double(24,8) NOT NULL,
total_tva double(24,8) NOT NULL,
total_ttc double(24,8) NOT NULL,
PRIMARY KEY (id)
) ENGINE=innodb;

View File

@ -1,18 +0,0 @@
-- --------------------------------------------------------
--
-- Structure de la table `llx_tmp_caisse`
--
CREATE TABLE llx_tmp_caisse (
id integer NOT NULL auto_increment,
fk_article integer NOT NULL,
qte integer NOT NULL,
fk_tva integer NOT NULL,
remise_percent integer NOT NULL,
remise float NOT NULL,
total_ht float NOT NULL,
total_ttc float NOT NULL,
PRIMARY KEY (id)
) ENGINE=innodb;

View File

@ -98,9 +98,13 @@ $Id$
<form id="frmQte" class="formulaire1" method="post" action="facturation_verif.php?action=ajout_article" onsubmit ="javascript: return verifSaisie();">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<table>
<tr><th class="label1"><?php echo $langs->trans("Qty"); ?></th>
<th class="label1"><?php echo $langs->trans("Stock"); ?></th>
<th class="label1"><?php echo $langs->trans("PriceUHT"); ?></th><th></th><th class="label1"><?php echo $langs->trans("VATRate"); ?></th><th class="label1"><?php echo $langs->trans("Discount"); ?> (%)</th><th class="label1"><?php echo $langs->trans("TotalHT"); ?></th></tr>
<tr><th><?php echo $langs->trans("Qty"); ?></th>
<th><?php echo $langs->trans("Stock"); ?></th>
<th><?php echo $langs->trans("PriceUHT"); ?></th>
<th></th>
<th ><?php echo $langs->trans("VATRate"); ?></th>
<th><?php echo $langs->trans("Discount"); ?> (%)</th>
<th><?php echo $langs->trans("TotalHT"); ?></th></tr>
<tr>
<td><input class="texte1" type="text" name="txtQte" value="1" onkeyup="javascript: modif();" onfocus="javascript: this.select();" /></td>
<!-- Affichage du stock pour l'article courant -->

View File

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<?php
// Recuperation du contenu de la vente
$request='SELECT id, ref, label, qte, price, remise_percent, remise, total_ht, total_ttc FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
$request='SELECT id, ref, label, qte, price, remise_percent, remise, total_ht, total_ttc FROM '.MAIN_DB_PREFIX.'pos_tmp as c
LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid
ORDER BY id';
dol_syslog($request);

View File

@ -116,7 +116,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Variables
$res = $db->query (
'SELECT id, ref, label, qte, price, remise_percent, remise, total_ht, total_ttc, tva_tx FROM '.MAIN_DB_PREFIX.'tmp_caisse as c
'SELECT id, ref, label, qte, price, remise_percent, remise, total_ht, total_ttc, tva_tx FROM '.MAIN_DB_PREFIX.'pos_tmp as c
LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON c.fk_article = p.rowid
ORDER BY id');

View File

@ -140,7 +140,7 @@ switch ( $_GET['action'] )
// Recuperation de la liste des articles du panier
$res=$db->query ('
SELECT fk_article, qte, fk_tva, remise_percent, remise, total_ht, total_ttc
FROM '.MAIN_DB_PREFIX.'tmp_caisse
FROM '.MAIN_DB_PREFIX.'pos_tmp
WHERE 1');
$ret=array(); $i=0;
while ( $tab = $db->fetch_array($res) )

View File

@ -53,9 +53,6 @@ ALTER TABLE llx_facturedet_rec ADD COLUMN rang integer DEFAULT 0 AFTER special_c
ALTER TABLE llx_actioncomm ADD COLUMN fk_supplier_order integer;
ALTER TABLE llx_actioncomm ADD COLUMN fk_supplier_invoice integer;
ALTER TABLE llx_tmp_caisse MODIFY fk_article integer NOT NULL;
ALTER TABLE llx_propaldet ADD COLUMN fk_parent_line integer NULL AFTER fk_propal;
ALTER TABLE llx_commandedet ADD COLUMN fk_parent_line integer NULL AFTER fk_commande;
ALTER TABLE llx_facturedet ADD COLUMN fk_parent_line integer NULL AFTER fk_facture;
@ -106,3 +103,19 @@ UPDATE llx_societe SET canvas = 'individual' WHERE canvas = 'individual@thirdpar
insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS','7','chaine','Tolérance de retard avant alerte (en jours) sur commandes fournisseurs non traitées',0);
ALTER TABLE llx_actioncomm ADD COLUMN fulldayevent smallint NOT NULL default 0 after priority;
-- Enhance POS module
DROP TABLE llx_tmp_caisse;
CREATE TABLE llx_pos_tmp (
id integer NOT NULL auto_increment,
fk_article integer NOT NULL,
qte real NOT NULL,
fk_tva integer NOT NULL,
remise_percent real NOT NULL,
remise real NOT NULL,
total_ht double(24,8) NOT NULL,
total_tva double(24,8) NOT NULL,
total_ttc double(24,8) NOT NULL,
PRIMARY KEY (id)
) ENGINE=innodb;

View File

@ -26,17 +26,17 @@
/**
* \brief Calculate totals (net, vat, ...) of a line.
* \param qty Quantity
* \param pu Unit price (HT or TTC selon price_base_type)
* \param remise_percent_ligne Discount for line
* \param txtva Vat rate
* \param txlocaltax1 Localtax1 rate (used for some countries only, like spain)
* \param txlocaltax2 Localtax2 rate (used for some countries only, like spain)
* \param remise_percent_global 0
* \param price_base_type HT=on calcule sur le HT, TTC=on calcule sur le TTC
* \param info_bits Miscellanous informations on line
* \return result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
* Calculate totals (net, vat, ...) of a line.
* @param qty Quantity
* @param pu Unit price (HT or TTC selon price_base_type)
* @param remise_percent_ligne Discount for line
* @param txtva Vat rate
* @param txlocaltax1 Localtax1 rate (used for some countries only, like spain)
* @param txlocaltax2 Localtax2 rate (used for some countries only, like spain)
* @param remise_percent_global 0
* @param price_base_type HT=on calcule sur le HT, TTC=on calcule sur le TTC
* @param info_bits Miscellanous informations on line
* @return result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount)
*/
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $txlocaltax1=0, $txlocaltax2=0, $remise_percent_global=0, $price_base_type='HT', $info_bits=0)
{