Skip to content

Commit

Permalink
FIX Split of credit note into discount page generates records not
Browse files Browse the repository at this point in the history
correctly recognised as credit note.
  • Loading branch information
eldy committed May 30, 2016
1 parent 89cb122 commit 460d7ce
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions htdocs/comm/remx.php
Expand Up @@ -341,22 +341,22 @@
$var = !$var;
print "<tr ".$bc[$var].">";
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if ($obj->description == '(CREDIT_NOTE)')
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print $langs->trans("CreditNote").' '.$facturestatic->getNomURl(1);
print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif ($obj->description == '(DEPOSIT)')
elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print $langs->trans("InvoiceDeposit").' '.$facturestatic->getNomURl(1);
print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
else
Expand Down Expand Up @@ -500,22 +500,22 @@
$var = !$var;
print "<tr ".$bc[$var].">";
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if ($obj->description == '(CREDIT_NOTE)')
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print $langs->trans("CreditNote").' '.$facturestatic->getNomURl(1);
print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif ($obj->description == '(DEPOSIT)')
elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print $langs->trans("InvoiceDeposit").' '.$facturestatic->getNomURl(1);
print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
else
Expand Down
4 changes: 2 additions & 2 deletions htdocs/commande/card.php
Expand Up @@ -1900,8 +1900,8 @@
// 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='(DEPOSIT)')";
$filtercreditnote = "fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
$filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')";
$filtercreditnote = "fk_facture_source IS NOT NULL AND description NOT LIKE '(DEPOSIT)%'";
}

// Relative and absolute discounts
Expand Down
10 changes: 5 additions & 5 deletions htdocs/compta/facture.php
Expand Up @@ -2563,8 +2563,8 @@
$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='(DEPOSIT)')";
$filtercreditnote = "fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
$filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')";
$filtercreditnote = "fk_facture_source IS NOT NULL AND description NOT LIKE '(DEPOSIT)%'";
}

$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
Expand Down Expand Up @@ -2982,9 +2982,9 @@
// Remise dispo de type avoir
if (! $absolute_discount)
print '<br>';
// $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote,
// $filtercreditnote, $resteapayer);
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0); // We allow credit note even if amount is higher
// $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, $resteapayer
$more=' ('.$addcreditnote.')';
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $soc->id, $absolute_creditnote, $filtercreditnote, 0, $more); // We allow credit note even if amount is higher
}
}
if (! $absolute_discount && ! $absolute_creditnote) {
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -1128,8 +1128,8 @@ function select_remises($selected, $htmlname, $filter, $socid, $maxvalue=0)
{
$obj = $this->db->fetch_object($resql);
$desc=dol_trunc($obj->description,40);
if ($desc=='(CREDIT_NOTE)') $desc=$langs->trans("CreditNote");
if ($desc=='(DEPOSIT)') $desc=$langs->trans("Deposit");
if (preg_match('/\(CREDIT_NOTE\)/', $desc)) $desc=preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $desc);
if (preg_match('/\(DEPOSIT\)/', $desc)) $desc=preg_replace('/\(DEPOSIT\)/', $langs->trans("Deposit"), $desc);

$selectstring='';
if ($selected > 0 && $selected == $obj->rowid) $selectstring=' selected';
Expand Down Expand Up @@ -3762,7 +3762,7 @@ function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter
}
else
{
if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)).': ';
if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)).': ';
else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)).': ';
}
$newfilter='fk_facture IS NULL AND fk_facture_line IS NULL'; // Remises disponibles
Expand All @@ -3773,7 +3773,7 @@ function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter
if ($nbqualifiedlines > 0)
{
print ' &nbsp; <input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("UseLine")).'"';
if ($filter && $filter != "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description='(DEPOSIT)')") print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
if ($filter && $filter != "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND description LIKE '(DEPOSIT)%')") print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
print '>';
}
if ($more) print $more;
Expand Down

0 comments on commit 460d7ce

Please sign in to comment.