FIX Mark credit note as available for credit note in other currency
This commit is contained in:
parent
75b875ae55
commit
07d1559802
@ -697,6 +697,7 @@ if (empty($reshook))
|
||||
$db->begin();
|
||||
|
||||
$amount_ht = $amount_tva = $amount_ttc = array();
|
||||
$multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
|
||||
|
||||
// Loop on each vat rate
|
||||
$i = 0;
|
||||
@ -710,7 +711,7 @@ if (empty($reshook))
|
||||
$multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht;
|
||||
$multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva;
|
||||
$multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc;
|
||||
$i ++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -251,11 +251,14 @@ if (empty($reshook))
|
||||
$paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
|
||||
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
|
||||
$paiement->paiementid = dol_getIdFromCode($db,GETPOST('paiementcode'),'c_paiement','code','id',1);
|
||||
$paiement->num_paiement = GETPOST('num_paiement');
|
||||
$paiement->note = GETPOST('comment');
|
||||
$paiement->num_paiement = GETPOST('num_paiement', 'alpha');
|
||||
$paiement->note = GETPOST('comment', 'alpha');
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Create payment and update this->multicurrency_amounts if this->amounts filled or
|
||||
// this->amounts if this->multicurrency_amounts filled.
|
||||
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices and regenerating documents
|
||||
if ($paiement_id < 0)
|
||||
{
|
||||
@ -280,7 +283,7 @@ if (empty($reshook))
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
// If payment dispatching on more than one invoice, we keep on summary page, otherwise jump on invoice card
|
||||
// If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card
|
||||
$invoiceid=0;
|
||||
foreach ($paiement->amounts as $key => $amount)
|
||||
{
|
||||
@ -632,7 +635,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
// Date
|
||||
print '<td align="center">'.dol_print_date($db->jdate($objp->df),'day')."</td>\n";
|
||||
|
||||
// Date Max Payment
|
||||
// Due date
|
||||
if ($objp->dlr > 0 )
|
||||
{
|
||||
print '<td align="center">';
|
||||
@ -647,7 +650,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><b>--</b></td>';
|
||||
print '<td align="center"></td>';
|
||||
}
|
||||
|
||||
// Currency
|
||||
@ -670,12 +673,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Multicurrency Price
|
||||
// Multicurrency remain to pay
|
||||
print '<td align="right">';
|
||||
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
print '<td class="right nowraponall">';
|
||||
|
||||
// Add remind multicurrency amount
|
||||
$namef = 'multicurrency_amount_'.$objp->facid;
|
||||
@ -687,12 +690,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'");
|
||||
print '<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.'" value="'.$_POST[$namef].'">';
|
||||
print '<input type=hidden class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
|
||||
print '<input type="text" size="8" class="multicurrency_amount" name="'.$namef.'" value="'.$_POST[$namef].'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" size="8" name="'.$namef.'_disabled" value="'.$_POST[$namef].'" disabled>';
|
||||
print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.$_POST[$namef].'" disabled>';
|
||||
print '<input type="hidden" name="'.$namef.'" value="'.$_POST[$namef].'">';
|
||||
}
|
||||
}
|
||||
@ -713,7 +716,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
//$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
|
||||
|
||||
// Amount
|
||||
print '<td align="right">';
|
||||
print '<td class="right nowraponall">';
|
||||
|
||||
// Add remind amount
|
||||
$namef = 'amount_'.$objp->facid;
|
||||
@ -723,12 +726,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'");
|
||||
print '<input type="text" class="maxwidth75 amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
|
||||
print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
|
||||
print '<input type="text" size="8" class="amount" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" size="8" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
|
||||
print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
|
||||
print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
|
||||
}
|
||||
print "</td>";
|
||||
@ -760,7 +763,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
{
|
||||
// Print total
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="2" align="left">'.$langs->trans('TotalTTC').'</td>';
|
||||
print '<td colspan="2" align="left">'.$langs->trans('TotalTTC').'</td><td></td>';
|
||||
if (!empty($conf->multicurrency->enabled)) {
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
|
||||
@ -365,6 +365,7 @@ class Paiement extends CommonObject
|
||||
if ($invoice->type == Facture::TYPE_DEPOSIT)
|
||||
{
|
||||
$amount_ht = $amount_tva = $amount_ttc = array();
|
||||
$multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
|
||||
|
||||
// Insert one discount by VAT rate category
|
||||
$discount = new DiscountAbsolute($this->db);
|
||||
@ -383,6 +384,9 @@ class Paiement extends CommonObject
|
||||
$amount_ht[$line->tva_tx] += $line->total_ht;
|
||||
$amount_tva[$line->tva_tx] += $line->total_tva;
|
||||
$amount_ttc[$line->tva_tx] += $line->total_ttc;
|
||||
$multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht;
|
||||
$multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva;
|
||||
$multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -391,6 +395,9 @@ class Paiement extends CommonObject
|
||||
$discount->amount_ht = abs($amount_ht[$tva_tx]);
|
||||
$discount->amount_tva = abs($amount_tva[$tva_tx]);
|
||||
$discount->amount_ttc = abs($amount_ttc[$tva_tx]);
|
||||
$discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]);
|
||||
$discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]);
|
||||
$discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]);
|
||||
$discount->tva_tx = abs($tva_tx);
|
||||
|
||||
$result = $discount->create($user);
|
||||
@ -1108,7 +1115,7 @@ class Paiement extends CommonObject
|
||||
/**
|
||||
* get the right way of payment
|
||||
*
|
||||
* @return string 'dolibarr' if standard comportment or paid in dolibarr currency, 'customer' if payment received from multicurrency inputs
|
||||
* @return string 'dolibarr' if standard comportment or paid in main currency, 'customer' if payment received from multicurrency inputs
|
||||
*/
|
||||
function getWay()
|
||||
{
|
||||
|
||||
@ -53,10 +53,13 @@ class DiscountAbsolute
|
||||
*/
|
||||
public $fk_soc;
|
||||
|
||||
public $discount_type; // 0 => customer discount, 1 => supplier discount
|
||||
public $amount_ht; //
|
||||
public $discount_type; // 0 => customer discount, 1 => supplier discount
|
||||
public $amount_ht; //
|
||||
public $amount_tva; //
|
||||
public $amount_ttc; //
|
||||
public $multicurrency_amount_ht;
|
||||
public $multicurrency_amount_tva;
|
||||
public $multicurrency_amount_ttc;
|
||||
public $tva_tx; // Vat rate
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user