diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 58bc36a7328..a7d576fad63 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1936,8 +1936,13 @@ else
if ($object->paye) $resteapayer=0;
$resteapayeraffiche=$resteapayer;
- $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
- $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
+ //$filterabsolutediscount="fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ //$filtercreditnote="fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ $filterabsolutediscount="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')";
+ $filtercreditnote="fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
+
+ $absolute_discount=$soc->getAvailableDiscounts('',$filterabsolutediscount);
+ $absolute_creditnote=$soc->getAvailableDiscounts('',$filtercreditnote);
$absolute_discount=price2num($absolute_discount,'MT');
$absolute_creditnote=price2num($absolute_creditnote,'MT');
@@ -2233,9 +2238,8 @@ else
else
{
// Remise dispo de type remise fixe (not credit note)
- $filter='fk_facture_source IS NULL';
print '
';
- $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id',$soc->id, $absolute_discount, $filter, $resteapayer, ' - '.$addabsolutediscount);
+ $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' ('.$addabsolutediscount.')');
}
}
else
@@ -2265,9 +2269,8 @@ else
else
{
// Remise dispo de type avoir
- $filter='fk_facture_source IS NOT NULL';
if (! $absolute_discount) print '
';
- $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filter, $resteapayer);
+ $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer);
}
}
if (! $absolute_discount && ! $absolute_creditnote)
diff --git a/htdocs/compta/paiement/liste.php b/htdocs/compta/paiement/liste.php
index 99e9114f9b5..fa1961e81a8 100644
--- a/htdocs/compta/paiement/liste.php
+++ b/htdocs/compta/paiement/liste.php
@@ -90,13 +90,12 @@ else
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid AND s.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
}
$sql.= " WHERE p.fk_paiement = c.id";
- $sql.= " AND s.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid)
{
$sql.= " AND sc.fk_user = " .$user->id;
diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php
index 072f6341ba6..af711fe9af8 100644
--- a/htdocs/compta/stats/cabyuser.php
+++ b/htdocs/compta/stats/cabyuser.php
@@ -35,8 +35,8 @@ if (!$user->rights->compta->resultat->lire && !$user->rights->accounting->compta
accessforbidden();
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
-$modecompta = $conf->compta->mode;
-if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
+$modecompta = $conf->global->COMPTA_MODE;
+if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta");
$sortorder=isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
@@ -122,7 +122,10 @@ else {
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
-report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
+$moreparam=array();
+if (! empty($modecompta)) $moreparam['modecompta']=$modecompta;
+
+report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam);
// Charge tableau
@@ -137,7 +140,7 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2"; // Credit note
- //$sql.= " OR f.type = 3"; // We do not include deposit
+ $sql.= " OR f.type = 3"; // Deposit
$sql.= ")";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php
index df3264c50b4..d1e9507bc57 100644
--- a/htdocs/compta/stats/casoc.php
+++ b/htdocs/compta/stats/casoc.php
@@ -32,8 +32,8 @@ require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
$langs->load("companies");
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
-$modecompta = $conf->compta->mode;
-if ($_GET["modecompta"]) $modecompta=$_GET["modecompta"];
+$modecompta = $conf->global->COMPTA_MODE;
+if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta");
$sortorder=isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
@@ -125,7 +125,9 @@ else {
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
-report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink);
+$moreparam=array();
+if (! empty($modecompta)) $moreparam['modecompta']=$modecompta;
+report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink,$moreparam);
// Charge tableau
@@ -140,7 +142,7 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2"; // Credit note
- //$sql.= " OR f.type = 3"; // We do not include deposit
+ $sql.= " OR f.type = 3"; // Deposit
$sql.= ")";
$sql.= " AND f.fk_soc = s.rowid";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php
index 69743dba019..e5432a6c8b0 100644
--- a/htdocs/compta/stats/index.php
+++ b/htdocs/compta/stats/index.php
@@ -88,7 +88,7 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql.= " f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2"; // Credit note
- //$sql.= " OR f.type = 3"; // We do not include deposit
+ $sql.= " OR f.type = 3"; // Deposit
$sql.= ")";
} else {
/*
@@ -222,7 +222,7 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++)
if ($cum[$case])
{
$now_show_delta=1; // On a trouve le premier mois de la premiere annee generant du chiffre.
- print ''.price($cum[$case],1).'';
+ print ''.price($cum[$case],1).'';
}
else
{
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 264b97c62fa..0c3d33fcf4d 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1788,6 +1788,7 @@ class CommonObject
* TODO Move this into an output class file (htmlline.class.php)
* If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
+ *
* @param $action GET/POST action
* @param $line Selected object line to output
* @param $var Is it a an odd line
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index 91a35373b70..c8f29e297b7 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -344,7 +344,7 @@ class DiscountAbsolute
$sql.= " WHERE (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available
if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id;
if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id;
- if ($filter) $sql.=' AND '.$filter;
+ if ($filter) $sql.=' AND ('.$filter.')';
if ($maxvalue) $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue);
dol_syslog("DiscountAbsolute::getAvailableDiscounts sql=".$sql,LOG_DEBUG);
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 2bbad2fe9f1..c45632b1837 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2425,15 +2425,17 @@ class Form
/**
- * Show a select box with available absolute discounts
- * @param page Page URL where form is shown
- * @param selected Value pre-selected
- * @param htmlname Nom du formulaire select. Si none, non modifiable
- * @param socid Third party id
- * @param amount Total amount available
- * @param filter SQL filter on discounts
- * @param maxvalue Max value for lines that can be selected
- * @param more More string to add
+ * Show a select box with available absolute discounts
+ *
+ * @param string $page Page URL where form is shown
+ * @param int $selected Value pre-selected
+ * @param string $htmlname Nom du formulaire select. Si none, non modifiable
+ * @param int $socid Third party id
+ * @param float $amount Total amount available
+ * @param string $filter SQL filter on discounts
+ * @param int $maxvalue Max value for lines that can be selected
+ * @param string $more More string to add
+ * @return void
*/
function form_remise_dispo($page, $selected='', $htmlname='remise_id',$socid, $amount, $filter='', $maxvalue=0, $more='')
{
@@ -2445,20 +2447,20 @@ class Form
print '';
print '
| '; - if (! $filter || $filter=='fk_facture_source IS NULL') print $langs->trans("CompanyHasAbsoluteDiscount",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; + //if (! $filter || $filter=="fk_facture_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; // If we want deposit to be substracted to payments only and not to total of final invoice + if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; else print $langs->trans("CompanyHasCreditNote",price($amount),$langs->transnoentities("Currency".$conf->monnaie)).': '; // print $langs->trans("AvailableGlobalDiscounts").': '; $newfilter='fk_facture IS NULL AND fk_facture_line IS NULL'; // Remises disponibles - if ($filter) $newfilter.=' AND '.$filter; - $nbqualifiedlines=$this->select_remises('',$htmlname,$newfilter,$socid,$maxvalue); + if ($filter) $newfilter.=' AND ('.$filter.')'; + $nbqualifiedlines=$this->select_remises($selected,$htmlname,$newfilter,$socid,$maxvalue); print ' | '; print ''; if ($nbqualifiedlines > 0) { - print ' trans("UseCredit"); - print '" title="'.$langs->trans("UseCreditNoteInInvoicePayment").'">'; + print ' '; } if ($more) print $more; print ' | '; diff --git a/htdocs/core/tpl/freeproductline_view.tpl.php b/htdocs/core/tpl/freeproductline_view.tpl.php index 7f069c1cd09..97db83bd121 100644 --- a/htdocs/core/tpl/freeproductline_view.tpl.php +++ b/htdocs/core/tpl/freeproductline_view.tpl.php @@ -24,29 +24,47 @@info_bits & 2) == 2) { ?> - trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); ?> + trans("ShowReduc"),'reduc').' '; + if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); + //else $txt=$langs->trans("Discount"); + print $txt; + ?> - description) { - if ($line->description == '(CREDIT_NOTE)') { + description) + { + if ($line->description == '(CREDIT_NOTE)') + { $discount=new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); - echo ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); - } elseif ($line->description == '(DEPOSIT)') { + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } + elseif ($line->description == '(DEPOSIT)') + { $discount=new DiscountAbsolute($this->db); $discount->fetch($line->fk_remise_except); - echo ' - '.$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); - } else { - echo ' - '.dol_htmlentitiesbr($line->description,1,true); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); + // Add date of deposit + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; + } + else + { + echo ($txt?' - ':'').dol_htmlentitiesbr($line->description,1,true); } } - } else { + } + else + { if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); if ($type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); echo $text.' '.dol_htmlentitiesbr($line->description,1,true); // Show range print_date_range($line->date_start,$line->date_end); - } ?> + } + ?> | tva_tx,'%',$line->info_bits); ?> | diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 93e3b307c3a..55a81f77ef5 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -100,7 +100,7 @@ BillStatus=Invoice status BillStatusDraft=Draft (needs to be validated) BillStatusPaid=Paid BillStatusPaidBackOrConverted=Paid or converted into discount -BillStatusConverted=Converted into discount +BillStatusConverted=Paid (ready for final invoice) BillStatusCanceled=Abandoned BillStatusValidated=Validated (needs to be paid) BillStatusStarted=Started diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index fce01b756c9..1d05ab959d9 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -203,8 +203,8 @@ CustomerRelativeDiscountShort=Relative discount CustomerAbsoluteDiscountShort=Absolute discount CompanyHasRelativeDiscount=This customer has a default discount of %s%% CompanyHasNoRelativeDiscount=This customer has no relative discount by default -CompanyHasAbsoluteDiscount=This customer still has discount credits for %s %s -CompanyHasCreditNote=This customer still has credit notes or previous deposits for %s %s +CompanyHasAbsoluteDiscount=This customer still has discount credits or deposits for %s %s +CompanyHasCreditNote=This customer still has credit notes for %s %s CompanyHasNoAbsoluteDiscount=This customer has no discount credit available CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users) CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself) diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 0dde775326a..8eecc43201e 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -96,7 +96,7 @@ BillStatus=État de la facture BillStatusDraft=Brouillon (à valider) BillStatusPaid=Payée BillStatusPaidBackOrConverted=Remboursé ou converti en réduction -BillStatusConverted=Converti en réduction +BillStatusConverted=Payée BillStatusCanceled=Abandonnée BillStatusValidated=Validée (à payer) BillStatusStarted=Règlement commencé @@ -230,11 +230,16 @@ ReductionsShort=Réduc. Discount=Remise Discounts=Remises ShowDiscount=Visualiser l'avoir +ShowReduc=Visualiser la déduction RelativeDiscount=Remise relative -GlobalDiscount=Remise fixe +GlobalDiscount=Ligne de déduction CreditNote=Avoir CreditNotes=Avoirs -AddDiscount=Créer remise fixe +AddDiscount=Editer remises +AddRelativeDiscount=Créer remise relative +EditRelativeDiscount=Editer remise relative +AddGlobalDiscount=Créer ligne de déduction +EditGlobalDiscounts=Editer remises fixes AddCreditNote=Créer facture avoir Deposit=Acompte Deposits=Acomptes @@ -242,7 +247,7 @@ DiscountFromCreditNote=Remise issue de l'avoir %s DiscountFromDeposit=Paiements issue de l'acompte %s AbsoluteDiscountUse=Ce type de crédit ne peut s'utiliser que sur une facture non validée CreditNoteDepositUse=La facture doit être validée pour pouvoir utiliser ce type de crédit -NewGlobalDiscount=Nouvelle remise fixe +NewGlobalDiscount=Nouvelle ligne de déduction NewRelativeDiscount=Nouvelle remise relative NoteReason=Note/Motif ReasonDiscount=Motif @@ -340,6 +345,7 @@ LawApplicationPart2=les marchandises demeurent la propriété du LawApplicationPart3=vendeur jusqu'à complet encaissement de LawApplicationPart4=leurs prix. LimitedLiabilityCompanyCapital=SARL au Capital de +UseLine=Appliquer UseDiscount=Appliquer remise UseCredit=Utiliser crédit UseCreditNoteInInvoicePayment=Réduire le montant du reste à payer avec ce crédit diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 528514e8773..ecacf88a2d2 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -205,8 +205,8 @@ CustomerRelativeDiscountShort=Remise relative CustomerAbsoluteDiscountShort=Remise fixe CompanyHasRelativeDiscount=Ce client a une remise par défaut de %s%% CompanyHasNoRelativeDiscount=Ce client n'a pas de remise relative par défaut -CompanyHasAbsoluteDiscount=Ce client a %s %s de remises fixes disponibles -CompanyHasCreditNote=Ce client a %s %s d'avoirs/acomptes disponibles +CompanyHasAbsoluteDiscount=Ce client a %s %s de lignes de déduction disponibles (remises, acomptes...) +CompanyHasCreditNote=Ce client a %s %s d'avoirs disponibles CompanyHasNoAbsoluteDiscount=Ce client n'a pas ou plus de remise fixe disponible CustomerAbsoluteDiscountAllUsers=Remises fixes en cours (accordées par tout utilisateur) CustomerAbsoluteDiscountMy=Remises fixes en cours (accordées personnellement) diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php index 6786ac36a01..928b1bf5a1a 100644 --- a/htdocs/lib/pdf.lib.php +++ b/htdocs/lib/pdf.lib.php @@ -727,6 +727,14 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source); } + elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) + { + $discount=new DiscountAbsolute($db); + $discount->fetch($object->lines[$i]->fk_remise_except); + $libelleproduitservice=$outputlangs->transnoentities("DiscountFromDeposit",$discount->ref_facture_source); + // Add date of deposit + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; + } else { if ($idprod) diff --git a/htdocs/lib/report.lib.php b/htdocs/lib/report.lib.php index 50b1a83c83c..dc27a6c76dd 100644 --- a/htdocs/lib/report.lib.php +++ b/htdocs/lib/report.lib.php @@ -25,15 +25,17 @@ /** * Show header of a VAT report -* @param nom Name of report -* @param variante Link for alternate report -* @param period Period of report -* @param periodlink Link to switch period -* @param description Description -* @param builddate Date generation -* @param exportlink Link for export or '' +* +* @param $nom Name of report +* @param $variante Link for alternate report +* @param $period Period of report +* @param $periodlink Link to switch period +* @param $description Description +* @param $builddate Date generation +* @param $exportlink Link for export or '' +* @param $moreparam Array with list of params to add into form */ -function report_header($nom,$variante='',$period,$periodlink,$description,$builddate,$exportlink='') +function report_header($nom,$variante='',$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array()) { global $langs; @@ -45,6 +47,10 @@ function report_header($nom,$variante='',$period,$periodlink,$description,$build dol_fiche_head($head, $hselected, $societe->nom); print '