diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 322caca9ab2..8148324961c 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -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++;
}
}
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index ef9e7f81f43..201e42e0af2 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -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 '
'.dol_print_date($db->jdate($objp->df),'day')." | \n";
- // Date Max Payment
+ // Due date
if ($objp->dlr > 0 )
{
print '';
@@ -647,7 +650,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
}
else
{
- print ' | -- | ';
+ print ' | ';
}
// Currency
@@ -670,12 +673,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
}
print '';
- // Multicurrency Price
+ // Multicurrency remain to pay
print '';
if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay);
print ' | ';
- print '';
+ print ' | ';
// 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 '';
print '';
- print '';
}
else
{
- print '';
+ print '';
print '';
}
}
@@ -713,7 +716,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
//$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
// Amount
- print ' | ';
+ print ' | ';
// 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 '';
print '';
- print '';
}
else
{
- print '';
+ print '';
print '';
}
print " | ";
@@ -760,7 +763,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
{
// Print total
print '';
- print '| '.$langs->trans('TotalTTC').' | ';
+ print ''.$langs->trans('TotalTTC').' | | ';
if (!empty($conf->multicurrency->enabled)) {
print ' | ';
print ' | ';
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index e17ae65750f..c3126aecee0 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -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()
{
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index 26a5dfe9fb1..af81e68f7e1 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -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
/**