FIX: supplier credit notes: hide relative discounts until supported

This commit is contained in:
Marc de Lima Lucio 2018-02-16 12:30:32 +01:00
parent fa0c65e37e
commit 924a9c392c
3 changed files with 22 additions and 13 deletions

View File

@ -1479,6 +1479,7 @@ if ($action=='create')
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)
@ -1488,7 +1489,7 @@ if ($action=='create')
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)
@ -1894,11 +1895,13 @@ elseif (! empty($object->id))
$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');
@ -1908,7 +1911,7 @@ elseif (! empty($object->id))
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);
}
}

View File

@ -1917,6 +1917,7 @@ if ($action == 'create')
{
// 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
@ -1924,6 +1925,7 @@ if ($action == 'create')
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
@ -2417,15 +2419,16 @@ else
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));
@ -2433,7 +2436,7 @@ else
} 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");
@ -2442,7 +2445,7 @@ else
}
} 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 {
@ -2450,10 +2453,10 @@ else
{
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)
@ -2468,7 +2471,7 @@ else
}
} 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

View File

@ -1050,16 +1050,17 @@ if ($action == 'create')
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)
@ -1424,11 +1425,13 @@ if ($action == 'create')
$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');
@ -1438,7 +1441,7 @@ if ($action == 'create')
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);
}
}