FIX: supplier credit notes: use MAIN_FEATURES_LEVEL
This commit is contained in:
parent
bcb39e57fb
commit
a4f2a2532d
@ -1477,7 +1477,7 @@ if ($action=='create')
|
|||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if ($societe->id > 0)
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $societe->id > 0)
|
||||||
{
|
{
|
||||||
/* // TODO handle supplier relative discount
|
/* // TODO handle supplier relative discount
|
||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
@ -1881,46 +1881,49 @@ 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 ($conf->global->MAIN_FEATURES_LEVEL > 0) {
|
||||||
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>';
|
// Relative and absolute discounts
|
||||||
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||||
$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>';
|
$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
|
||||||
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');
|
|
||||||
$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 {
|
} else {
|
||||||
// Remise dispo de type remise fixe (not credit note)
|
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (fk_invoice_supplier_source IS NOT NULL AND description LIKE '(DEPOSIT)%')";
|
||||||
// print '<br>';
|
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND description NOT LIKE '(DEPOSIT)%'";
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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>';
|
||||||
|
/* // 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');
|
||||||
|
$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>';
|
||||||
}
|
}
|
||||||
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');
|
||||||
|
|||||||
@ -1913,7 +1913,7 @@ if ($action == 'create')
|
|||||||
|
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
if ($societe->id > 0)
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $societe->id > 0)
|
||||||
{
|
{
|
||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
@ -2410,90 +2410,93 @@ else
|
|||||||
print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
|
print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Relative and absolute discounts
|
|
||||||
$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>';
|
|
||||||
$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
|
|
||||||
|
|
||||||
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 ($conf->global->MAIN_FEATURES_LEVEL > 0) {
|
||||||
if ($absolute_discount > 0) {
|
|
||||||
// print '. ';
|
// Relative and absolute discounts
|
||||||
if ($object->statut > 0 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_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>';
|
||||||
if ($object->statut == 0) {
|
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
$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 '. ';
|
$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
|
||||||
} else {
|
|
||||||
if ($object->statut < 1 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
|
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
|
||||||
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
print '</td><td>';
|
||||||
print '<!--<br>-->' . $text . '.<br>';
|
/* // 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 '. ';
|
||||||
|
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 {
|
} else {
|
||||||
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
if ($object->statut < 1 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
|
||||||
$text2 = $langs->trans("AbsoluteDiscountUse");
|
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
||||||
print $form->textwithpicto($text, $text2);
|
print '<!--<br>-->' . $text . '.<br>';
|
||||||
|
} else {
|
||||||
|
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
||||||
|
$text2 = $langs->trans("AbsoluteDiscountUse");
|
||||||
|
print $form->textwithpicto($text, $text2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Discount available of type fixed amount (not credit note)
|
||||||
|
// 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 {
|
} else {
|
||||||
// Discount available of type fixed amount (not credit note)
|
if ($absolute_creditnote > 0) // If not, link will be added later
|
||||||
// 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);
|
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 {
|
// Is there credit notes availables ?
|
||||||
if ($absolute_creditnote > 0) // If not, link will be added later
|
if ($absolute_creditnote > 0)
|
||||||
{
|
{
|
||||||
|
// If validated, we show link "add credit note to payment"
|
||||||
|
if ($object->statut != FactureFournisseur::STATUS_VALIDATED || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
|
||||||
|
if ($object->statut == 0 && $object->type != FactureFournisseur::TYPE_DEPOSIT) {
|
||||||
|
$text = $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency));
|
||||||
|
print $form->textwithpicto($text, $langs->trans("CreditNoteDepositUse"));
|
||||||
|
} else {
|
||||||
|
print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
|
||||||
|
}
|
||||||
|
} 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>';
|
||||||
|
// $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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $absolute_discount && ! $absolute_creditnote) {
|
||||||
|
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT)
|
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT)
|
||||||
print ' (' . $addabsolutediscount . ')<br>';
|
print ' (' . $addabsolutediscount . ')<br>';
|
||||||
// else
|
else
|
||||||
// print '. ';
|
print '. ';
|
||||||
} else
|
|
||||||
print '. ';
|
|
||||||
}
|
|
||||||
// Is there credit notes availables ?
|
|
||||||
if ($absolute_creditnote > 0)
|
|
||||||
{
|
|
||||||
// If validated, we show link "add credit note to payment"
|
|
||||||
if ($object->statut != FactureFournisseur::STATUS_VALIDATED || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
|
|
||||||
if ($object->statut == 0 && $object->type != FactureFournisseur::TYPE_DEPOSIT) {
|
|
||||||
$text = $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
print $form->textwithpicto($text, $langs->trans("CreditNoteDepositUse"));
|
|
||||||
} else {
|
|
||||||
print $langs->trans("CompanyHasCreditNote", price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
|
|
||||||
}
|
|
||||||
} 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>';
|
|
||||||
// $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
|
|
||||||
}
|
}
|
||||||
}
|
// if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
|
||||||
if (! $absolute_discount && ! $absolute_creditnote) {
|
// {
|
||||||
print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
// if (! $absolute_discount && ! $absolute_creditnote) print '<br>';
|
||||||
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT)
|
// print ' - ';
|
||||||
print ' (' . $addabsolutediscount . ')<br>';
|
// print $addabsolutediscount;
|
||||||
else
|
// print ' - '.$addcreditnote; // We disbale link to credit note
|
||||||
print '. ';
|
// }
|
||||||
}
|
print '</td></tr>';
|
||||||
// if ($object->statut == 0 && $object->type != 2 && $object->type != 3)
|
}
|
||||||
// {
|
|
||||||
// if (! $absolute_discount && ! $absolute_creditnote) print '<br>';
|
|
||||||
// print ' - ';
|
|
||||||
// print $addabsolutediscount;
|
|
||||||
// print ' - '.$addcreditnote; // We disbale link to credit note
|
|
||||||
// }
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$form->editfieldkey("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).'</td>';
|
print '<td>'.$form->editfieldkey("Label",'label',$object->label,$object,($user->rights->fournisseur->facture->creer)).'</td>';
|
||||||
@ -2852,37 +2855,39 @@ else
|
|||||||
$creditnoteamount = 0;
|
$creditnoteamount = 0;
|
||||||
$depositamount = 0;
|
$depositamount = 0;
|
||||||
|
|
||||||
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
if($conf->global->MAIN_FEATURES_LEVEL > 0) {
|
||||||
$sql .= " re.description, re.fk_invoice_supplier_source";
|
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re";
|
$sql .= " re.description, re.fk_invoice_supplier_source";
|
||||||
$sql .= " WHERE fk_invoice_supplier = " . $object->id;
|
$sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re";
|
||||||
$resql = $db->query($sql);
|
$sql .= " WHERE fk_invoice_supplier = " . $object->id;
|
||||||
if ($resql) {
|
$resql = $db->query($sql);
|
||||||
$num = $db->num_rows($resql);
|
if ($resql) {
|
||||||
$i = 0;
|
$num = $db->num_rows($resql);
|
||||||
$invoice = new FactureFournisseur($db);
|
$i = 0;
|
||||||
while ($i < $num) {
|
$invoice = new FactureFournisseur($db);
|
||||||
$obj = $db->fetch_object($resql);
|
while ($i < $num) {
|
||||||
$invoice->fetch($obj->fk_invoice_supplier_source);
|
$obj = $db->fetch_object($resql);
|
||||||
print '<tr><td colspan="' . $nbcols . '" align="right">';
|
$invoice->fetch($obj->fk_invoice_supplier_source);
|
||||||
if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
|
print '<tr><td colspan="' . $nbcols . '" align="right">';
|
||||||
print $langs->trans("CreditNote") . ' ';
|
if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
|
||||||
if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT)
|
print $langs->trans("CreditNote") . ' ';
|
||||||
print $langs->trans("Deposit") . ' ';
|
if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT)
|
||||||
print $invoice->getNomUrl(0);
|
print $langs->trans("Deposit") . ' ';
|
||||||
print ' :</td>';
|
print $invoice->getNomUrl(0);
|
||||||
print '<td align="right">' . price($obj->amount_ttc) . '</td>';
|
print ' :</td>';
|
||||||
print '<td align="right">';
|
print '<td align="right">' . price($obj->amount_ttc) . '</td>';
|
||||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&action=unlinkdiscount&discountid=' . $obj->rowid . '">' . img_delete() . '</a>';
|
print '<td align="right">';
|
||||||
print '</td></tr>';
|
print '<a href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&action=unlinkdiscount&discountid=' . $obj->rowid . '">' . img_delete() . '</a>';
|
||||||
$i ++;
|
print '</td></tr>';
|
||||||
if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
|
$i ++;
|
||||||
$creditnoteamount += $obj->amount_ttc;
|
if ($invoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
|
||||||
if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT)
|
$creditnoteamount += $obj->amount_ttc;
|
||||||
$depositamount += $obj->amount_ttc;
|
if ($invoice->type == FactureFournisseur::TYPE_DEPOSIT)
|
||||||
|
$depositamount += $obj->amount_ttc;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3097,7 +3102,7 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reverse back money or convert to reduction
|
// Reverse back money or convert to reduction
|
||||||
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT || $object->type == FactureFournisseur::TYPE_STANDARD) {
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT || $object->type == FactureFournisseur::TYPE_STANDARD)) {
|
||||||
// For credit note only
|
// For credit note only
|
||||||
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0)
|
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1048,11 +1048,11 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
print '</tr>' . "\n";
|
print '</tr>' . "\n";
|
||||||
|
|
||||||
if ($soc->id > 0)
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $soc->id > 0)
|
||||||
{
|
{
|
||||||
/* // TODO handle supplier relative discount
|
|
||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
|
/* // TODO handle supplier relative discount
|
||||||
if ($soc->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>');
|
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
|
else
|
||||||
@ -1411,46 +1411,49 @@ if ($action == 'create')
|
|||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Relative and absolute discounts
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
|
||||||
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=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
// Relative and absolute discounts
|
||||||
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||||
$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>';
|
$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
|
||||||
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');
|
|
||||||
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
|
||||||
if ($absolute_discount) {
|
|
||||||
if ($object->statut > SupplierProposal::STATUS_DRAFT) {
|
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
|
||||||
} else {
|
} else {
|
||||||
// Remise dispo de type remise fixe (not credit note)
|
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (fk_invoice_supplier_source IS NOT NULL AND description LIKE '(DEPOSIT)%')";
|
||||||
// print '<br>';
|
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND description NOT LIKE '(DEPOSIT)%'";
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
||||||
|
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->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=' . $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');
|
||||||
|
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
|
||||||
|
if ($absolute_discount) {
|
||||||
|
if ($object->statut > SupplierProposal::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', $soc->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>';
|
||||||
}
|
}
|
||||||
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>';
|
|
||||||
|
|
||||||
// Payment term
|
// Payment term
|
||||||
print '<tr><td class="titlefield">';
|
print '<tr><td class="titlefield">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user