Skip to content
Permalink
Browse files

FIX Mark credit note as available for credit note in other currency

Conflicts:
	htdocs/compta/paiement.php
	htdocs/core/class/discount.class.php
  • Loading branch information...
eldy committed Feb 18, 2019
1 parent c0b22e8 commit ad7b8371dae4868273fb12645129a15654d35bfe
@@ -688,6 +688,7 @@
$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;
@@ -701,7 +702,7 @@
$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++;
}
}
@@ -250,11 +250,14 @@
$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)
{
@@ -279,7 +282,7 @@
{
$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)
{
@@ -649,12 +652,12 @@ function callForResult(imgId)
}
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;
@@ -666,12 +669,12 @@ function callForResult(imgId)
{
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].'">';
}
}
@@ -692,7 +695,7 @@ function callForResult(imgId)
//$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;
@@ -702,12 +705,12 @@ function callForResult(imgId)
{
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>";
@@ -292,6 +292,7 @@ function create($user, $closepaidinvoices=0)
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);
@@ -310,6 +311,9 @@ function create($user, $closepaidinvoices=0)
$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++;
}
}
@@ -318,6 +322,9 @@ function create($user, $closepaidinvoices=0)
$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);
@@ -995,7 +1002,7 @@ function getNextNumRef($soc,$mode='next')
/**
* 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()
{
@@ -33,10 +33,14 @@ class DiscountAbsolute
public $id; // Id discount
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
public $fk_user; // Id utilisateur qui accorde la remise
public $description; // Description libre

0 comments on commit ad7b837

Please sign in to comment.
You can’t perform that action at this time.