NEW: supplier credit notes: display supplier discounts in supplier order card
This commit is contained in:
parent
bd486e4cab
commit
905adab517
@ -2038,8 +2038,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
|
|
||||||
// Relative and absolute discounts
|
// Relative and absolute discounts
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
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
|
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
|
||||||
// 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
|
$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 {
|
} else {
|
||||||
$filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')";
|
$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
|
else
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
print '. ';
|
print '. ';
|
||||||
$absolute_discount = $soc->getAvailableDiscounts('', 'fk_facture_source IS NULL');
|
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
|
||||||
$absolute_creditnote = $soc->getAvailableDiscounts('', 'fk_facture_source IS NOT NULL');
|
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
|
||||||
$absolute_discount = price2num($absolute_discount, 'MT');
|
$absolute_discount = price2num($absolute_discount, 'MT');
|
||||||
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
||||||
if ($absolute_discount) {
|
if ($absolute_discount) {
|
||||||
|
|||||||
@ -1477,6 +1477,29 @@ if ($action=='create')
|
|||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
if ($societe->id > 0)
|
||||||
|
{
|
||||||
|
// Discounts for third party
|
||||||
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
|
if ($fourn->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>';
|
||||||
|
|
||||||
|
$absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1);
|
||||||
|
|
||||||
|
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
|
||||||
|
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
print ' <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')) . '">(' . $langs->trans("EditGlobalDiscounts") . ')</a>';
|
||||||
|
print '.';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Ref supplier
|
// Ref supplier
|
||||||
print '<tr><td>'.$langs->trans('RefSupplier').'</td><td><input name="refsupplier" type="text"></td>';
|
print '<tr><td>'.$langs->trans('RefSupplier').'</td><td><input name="refsupplier" type="text"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -1857,6 +1880,45 @@ elseif (! empty($object->id))
|
|||||||
print '<td>'.$author->getNomUrl(1, '', 0, 0, 0).'</td>';
|
print '<td>'.$author->getNomUrl(1, '', 0, 0, 0).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// 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 = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
||||||
|
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
||||||
|
$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>';
|
||||||
|
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 '<br>';
|
||||||
|
$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 '</td></tr>';
|
||||||
|
|
||||||
// Conditions de reglement par defaut
|
// Conditions de reglement par defaut
|
||||||
$langs->load('bills');
|
$langs->load('bills');
|
||||||
print '<tr><td class="nowrap">';
|
print '<tr><td class="nowrap">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user