Skip to content

Commit

Permalink
FIX: supplier credit notes: hide relative discounts until supported
Browse files Browse the repository at this point in the history
  • Loading branch information
ATM-Marc committed Feb 16, 2018
1 parent fa0c65e commit 924a9c3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
7 changes: 5 additions & 2 deletions htdocs/fourn/commande/card.php
Expand Up @@ -1479,6 +1479,7 @@

if ($societe->id > 0)
{
/* // TODO handle supplier relative discount
// Discounts for third party
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
if ($societe->remise_percent)
Expand All @@ -1488,7 +1489,7 @@
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
print '. ';
print '<br>';

*/
$absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1);

if ($absolute_discount)
Expand Down Expand Up @@ -1894,11 +1895,13 @@
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $societe->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';

print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
/* // TODO handle supplier relative discount
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');
Expand All @@ -1908,7 +1911,7 @@
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
} else {
// Remise dispo de type remise fixe (not credit note)
print '<br>';
// print '<br>';
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
}
}
Expand Down
19 changes: 11 additions & 8 deletions htdocs/fourn/facture/card.php
Expand Up @@ -1917,13 +1917,15 @@
{
// Discounts for third party
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
/* // TODO handle supplier relative discount
if ($societe->remise_percent)
print $langs->trans("CompanyHasRelativeDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $societe->remise_percent . '</a>');
else
print $langs->trans("CompanyHasNoRelativeDiscount");
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
print '. ';
print '<br>';
*/
if ($absolute_discount)
print $langs->trans("CompanyHasAbsoluteDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . '</a>', $langs->trans("Currency" . $conf->currency));
else
Expand Down Expand Up @@ -2417,23 +2419,24 @@

print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
print '</td><td>';
/* // TODO handle supplier relative discount
if ($societe->remise_percent)
print $langs->trans("CompanyHasRelativeDiscount", $societe->remise_percent);
else
print $langs->trans("CompanyHasNoRelativeDiscount");
// print ' ('.$addrelativediscount.')';
*/
// Is there is commercial discount or down payment available ?
if ($absolute_discount > 0) {
print '. ';
// print '. ';
if ($object->statut > 0 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
if ($object->statut == 0) {
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
print '. ';
} else {
if ($object->statut < 1 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
print '<br>' . $text . '.<br>';
print '<!--<br>-->' . $text . '.<br>';
} else {
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
$text2 = $langs->trans("AbsoluteDiscountUse");
Expand All @@ -2442,18 +2445,18 @@
}
} else {
// Discount available of type fixed amount (not credit note)
print '<br>';
// print '<br>';
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' (' . $addabsolutediscount . ')', 0, 1);
}
} else {
if ($absolute_creditnote > 0) // If not, link will be added later
{
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT)
print ' (' . $addabsolutediscount . ')<br>';
else
print '. ';
// else
// print '. ';
} else
print '. ';
print '. ';
}
// Is there credit notes availables ?
if ($absolute_creditnote > 0)
Expand All @@ -2468,7 +2471,7 @@
}
} else { // We can add a credit note on a down payment or standard invoice or situation invoice
// There is credit notes discounts available
if (! $absolute_discount) print '<br>';
// if (! $absolute_discount) print '<br>';
// $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, $resteapayer, '', 0, 1);
$more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')';
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, 1); // We allow credit note even if amount is higher
Expand Down
9 changes: 6 additions & 3 deletions htdocs/supplier_proposal/card.php
Expand Up @@ -1050,16 +1050,17 @@

if ($soc->id > 0)
{
/* // TODO handle supplier relative discount
// Discounts for third party
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
if ($fourn->remise_percent)
if ($soc->remise_percent)
print $langs->trans("CompanyHasRelativeDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $soc->remise_percent . '</a>');
else
print $langs->trans("CompanyHasNoRelativeDiscount");
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
print '. ';
print '<br>';

*/
$absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1);

if ($absolute_discount)
Expand Down Expand Up @@ -1424,11 +1425,13 @@
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';

print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
/* // TODO handle supplier relative discount
if ($soc->remise_percent)
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
else
print $langs->trans("CompanyHasNoRelativeDiscount");
print '. ';
*/
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1);
$absolute_discount = price2num($absolute_discount, 'MT');
Expand All @@ -1438,7 +1441,7 @@
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
} else {
// Remise dispo de type remise fixe (not credit note)
print '<br>';
// print '<br>';
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
}
}
Expand Down

0 comments on commit 924a9c3

Please sign in to comment.