From 905adab5176331c11b9936e06f8815723a06a272 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Fri, 16 Feb 2018 11:23:59 +0100 Subject: [PATCH] NEW: supplier credit notes: display supplier discounts in supplier order card --- htdocs/commande/card.php | 7 ++-- htdocs/fourn/commande/card.php | 62 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6e1d411d55e..a56dc6cd5ac 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2038,8 +2038,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Relative and absolute discounts if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final - // invoice + $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 } else { $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')"; @@ -2056,8 +2055,8 @@ if ($action == 'create' && $user->rights->commande->creer) else print $langs->trans("CompanyHasNoRelativeDiscount"); print '. '; - $absolute_discount = $soc->getAvailableDiscounts('', 'fk_facture_source IS NULL'); - $absolute_creditnote = $soc->getAvailableDiscounts('', 'fk_facture_source IS NOT NULL'); + $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); + $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); $absolute_discount = price2num($absolute_discount, 'MT'); $absolute_creditnote = price2num($absolute_creditnote, 'MT'); if ($absolute_discount) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 81ea1a0f951..5c632530a8e 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1477,6 +1477,29 @@ if ($action=='create') } print ''; + if ($societe->id > 0) + { + // Discounts for third party + print '' . $langs->trans('Discounts') . ''; + if ($fourn->remise_percent) + print $langs->trans("CompanyHasRelativeDiscount", '' . $societe->remise_percent . ''); + else + print $langs->trans("CompanyHasNoRelativeDiscount"); + print ' (' . $langs->trans("EditRelativeDiscount") . ')'; + print '. '; + print '
'; + + $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); + + if ($absolute_discount) + print $langs->trans("CompanyHasAbsoluteDiscount", '' . price($absolute_discount) . '', $langs->trans("Currency" . $conf->currency)); + else + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print ' (' . $langs->trans("EditGlobalDiscounts") . ')'; + print '.'; + print ''; + } + // Ref supplier print ''.$langs->trans('RefSupplier').''; print ''; @@ -1857,6 +1880,45 @@ elseif (! empty($object->id)) print ''.$author->getNomUrl(1, '', 0, 0, 0).''; print ''; + // Relative and absolute discounts + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + } else { + $filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (fk_invoice_supplier_source IS NOT NULL AND description LIKE '(DEPOSIT)%')"; + $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND description NOT LIKE '(DEPOSIT)%'"; + } + + $addrelativediscount = '' . $langs->trans("EditRelativeDiscounts") . ''; + $addabsolutediscount = '' . $langs->trans("EditGlobalDiscounts") . ''; + $addcreditnote = '' . $langs->trans("AddCreditNote") . ''; + + print '' . $langs->trans('Discounts') . ''; + if ($societe->remise_percent) + print $langs->trans("CompanyHasRelativeDiscount", $societe->remise_percent); + else + print $langs->trans("CompanyHasNoRelativeDiscount"); + print '. '; + $absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1); + $absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); + if ($absolute_discount) { + if ($object->statut > CommandeFournisseur::STATUS_DRAFT) { + print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)); + } else { + // Remise dispo de type remise fixe (not credit note) + print '
'; + $form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1); + } + } + if ($absolute_creditnote) { + print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '. '; + } + if (! $absolute_discount && ! $absolute_creditnote) + print $langs->trans("CompanyHasNoAbsoluteDiscount") . '.'; + print ''; + // Conditions de reglement par defaut $langs->load('bills'); print '';