Fix: Possibilit de saisir des lignes avec montant ngatif (pour lignes de remises)

New: Gestion ajout automatique des lignes de remises
This commit is contained in:
Laurent Destailleur 2006-05-31 22:54:32 +00:00
parent 3007a54025
commit 71e9993766
8 changed files with 53 additions and 13 deletions

View File

@ -359,12 +359,24 @@ if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
}
if ($_POST['action'] == "adddiscount" && $user->rights->propale->creer)
{
$propal = new Propal($db);
$ret=$propal->fetch($_POST['propalid']);
if ($_POST["amount"])
{
// \todo a completer
// $propal->insert_discount($_POST["amount"]);
}
}
/*
* Ajout d'une ligne produit dans la propale
*/
if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
{
if ($_POST['qty'] && (($_POST['np_price']>=0 && $_POST['np_desc']) || $_POST['idprod']))
if ($_POST['qty'] && (($_POST['np_price']!=0 && $_POST['np_desc']) || $_POST['idprod']))
{
$propal = new Propal($db);
$ret=$propal->fetch($_POST['propalid']);
@ -602,14 +614,17 @@ if ($_GET['propalid'] > 0)
print '</tr>';
// Ligne info remises tiers
print '<tr><td>'.$langs->trans('Info').'</td><td colspan="5">';
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$societe->getCurrentDiscount();
print '. ';
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
print '.';
if ($absolute_discount)
{
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
print '.';
}
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
print '</td></tr>';
// Dates
@ -1257,7 +1272,7 @@ if ($_GET['propalid'] > 0)
// Valid
if ($propal->statut == 0)
{
if ($user->rights->propale->valider)
if ($user->rights->propale->valider && $propal->total_ttc > 0)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&amp;action=validate">'.$langs->trans('Validate').'</a>';
}

View File

@ -122,13 +122,13 @@ ExportDataset_invoice_1=Factures clients et lignes de facture
ProformaBill=Facture Proforma :
Reduction=Réduction
ReductionShort=Réduc.
GlobalDiscount=Remise globale
GlobalDiscount=Remise fixe
CreditNote=Avoir
CreditNotes=Avoirs
NewGlobalDiscount=Nouvelle remise
NewGlobalDiscount=Nouvelle remise fixe
NoteReason=Note/Motif
ReasonDiscount=Motif
AddGlobalDiscount=Ajouter remise
AddGlobalDiscount=Ajouter remise fixe
DiscountOfferedBy=Accordé par
DiscountStillRemaining=Remises absolues restant en cours
DiscountAlreadyCounted=Remises absolues déjà appliquées

View File

@ -136,6 +136,21 @@ class Propal
}
}
/**
* \brief Ajout d'un produit dans la proposition, en base
* \param idproduct Id du produit à ajouter
* \param qty Quantité
* \param remise_percent Remise relative effectuée sur le produit
* \param p_desc Descriptif optionnel
* \return int >0 si ok, <0 si ko
* \see add_product
*/
function insert_discount($idproduct, $qty, $remise_percent=0, $p_desc='')
{
}
/**
* \brief Ajout d'un produit dans la proposition, en base
* \param idproduct Id du produit à ajouter

View File

@ -90,10 +90,11 @@ ALTER TABLE llx_facture_fourn_det ADD INDEX idx_facture_fourn_det_fk_facture (fk
ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid);
ALTER TABLE llx_facturedet ADD COLUMN total_ht real after price;
ALTER TABLE llx_facturedet ADD COLUMN fk_remise_except integer NULL AFTER remise;
ALTER TABLE llx_facturedet ADD COLUMN total_ht real AFTER price;
ALTER TABLE llx_facturedet ADD COLUMN total_tva real;
ALTER TABLE llx_facturedet ADD COLUMN total_ttc real;
ALTER TABLE llx_facturedet ADD COLUMN info_bits integer DEFAULT 0 after date_end;
ALTER TABLE llx_facturedet ADD COLUMN info_bits integer DEFAULT 0 AFTER date_end;
ALTER TABLE llx_commande ADD INDEX idx_commande_fk_soc (fk_soc);
@ -202,8 +203,13 @@ ALTER TABLE llx_facture_rec ADD CONSTRAINT fk_facture_rec_fk_projet FORE
ALTER TABLE llx_facture_rec ADD UNIQUE INDEX idx_facture_rec_uk_titre (titre);
alter table llx_commandedet add column coef real;
alter table llx_propaldet add column coef real after price;
ALTER TABLE llx_commandedet ADD COLUMN fk_remise_except integer NULL AFTER remise;
ALTER TABLE llx_commandedet ADD COLUMN coef real;
ALTER TABLE llx_propaldet ADD COLUMN fk_remise_except integer NULL AFTER remise;
ALTER TABLE llx_propaldet ADD COLUMN coef real after price;
ALTER TABLE llx_contratdet ADD COLUMN fk_remise_except integer NULL AFTER remise;
create table llx_livraison
(

View File

@ -30,6 +30,7 @@ create table llx_commandedet
qty real, -- quantité
remise_percent real DEFAULT 0, -- pourcentage de remise
remise real DEFAULT 0, -- montant de la remise
fk_remise_except integer NULL, -- Lien vers table des remises fixes
subprice real, -- prix avant remise
price real, -- prix final
coef real, -- coefficient de marge

View File

@ -43,6 +43,7 @@ create table llx_contratdet
qty real, -- quantité
remise_percent real DEFAULT 0, -- pourcentage de remise
remise real DEFAULT 0, -- montant de la remise
fk_remise_except integer NULL, -- Lien vers table des remises fixes
subprice real, -- prix avant remise
price_ht real, -- prix final

View File

@ -30,6 +30,7 @@ create table llx_facturedet
qty real, -- Quantité (exemple 2)
remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%)
remise real DEFAULT 0, -- Montant calculé de la remise % sur PU HT (exemple 20)
fk_remise_except integer NULL, -- Lien vers table des remises fixes
subprice real, -- P.U. HT (exemple 100)
price real, -- P.U. HT apres remise % de ligne
total_ht real, -- Total HT de la ligne toute quantité et incluant remise ligne et globale

View File

@ -29,6 +29,7 @@ create table llx_propaldet
qty real, -- quantité
remise_percent real DEFAULT 0, -- pourcentage de remise
remise real DEFAULT 0, -- montant de la remise
fk_remise_except integer NULL, -- Lien vers table des remises fixes
subprice real, -- prix avant remise
price real, -- prix final
coef real, -- coefficient de marge