mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fixed bug #866: Standing order from an invoice suggests invoice total amount instead of remaining to pay
This commit is contained in:
parent
7d71be2227
commit
a9e63610ae
|
|
@ -26,6 +26,7 @@ English Dolibarr ChangeLog
|
|||
- Fix: [ bug #855 ] Holiday approval email in French
|
||||
- Fix: [ bug #856 ] (Holidays module) Mail error if destination user doesn't have an email
|
||||
- Fix: [ bug #857 ] Invoice created from shipment does not have the order discount
|
||||
- Fix: [ bug #866 ] Standing order from an invoice suggests invoice total amount instead of remaining to pay
|
||||
|
||||
|
||||
***** ChangeLog for 3.3.1 compared to 3.3 *****
|
||||
|
|
|
|||
|
|
@ -2701,10 +2701,21 @@ class Facture extends CommonInvoice
|
|||
{
|
||||
$now=dol_now();
|
||||
|
||||
$totalpaye = $this->getSommePaiement();
|
||||
$totalcreditnotes = $this->getSumCreditNotesUsed();
|
||||
$totaldeposits = $this->getSumDepositsUsed();
|
||||
//print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits;
|
||||
|
||||
// We can also use bcadd to avoid pb with floating points
|
||||
// For example print 239.2 - 229.3 - 9.9; does not return 0.
|
||||
//$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||
//$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||
$resteapayer = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande';
|
||||
$sql .= ' (fk_facture, amount, date_demande, fk_user_demande, code_banque, code_guichet, number, cle_rib)';
|
||||
$sql .= ' VALUES ('.$this->id;
|
||||
$sql .= ",'".price2num($this->total_ttc)."'";
|
||||
$sql .= ",'".price2num($resteapayer)."'";
|
||||
$sql .= ",".$this->db->idate($now).",".$user->id;
|
||||
$sql .= ",'".$soc->bank_account->code_banque."'";
|
||||
$sql .= ",'".$soc->bank_account->code_guichet."'";
|
||||
|
|
|
|||
|
|
@ -404,6 +404,15 @@ if ($object->id > 0)
|
|||
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($object->total_ttc).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->currency).'</td></tr>';
|
||||
|
||||
// We can also use bcadd to avoid pb with floating points
|
||||
// For example print 239.2 - 229.3 - 9.9; does not return 0.
|
||||
//$resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||
//$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
||||
$resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
|
||||
|
||||
print '<tr><td>'.$langs->trans('RemainderToPay').'</td><td align="right" colspan="2" nowrap>'.price($resteapayer).'</td>';
|
||||
print '<td>'.$langs->trans('Currency'.$conf->currency).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans('Status').'</td>';
|
||||
print '<td align="left" colspan="3">'.($object->getLibStatut(4,$totalpaye)).'</td></tr>';
|
||||
|
|
|
|||
|
|
@ -426,14 +426,14 @@ class BonPrelevement extends CommonObject
|
|||
$facs = array();
|
||||
$amounts = array();
|
||||
|
||||
$facs = $this->getListInvoices();
|
||||
$facs = $this->getListInvoices(1);
|
||||
|
||||
$num=count($facs);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$fac = new Facture($this->db);
|
||||
$fac->fetch($facs[$i]);
|
||||
$amounts[$fac->id] = $fac->total_ttc;
|
||||
$fac->fetch($facs[$i][0]);
|
||||
$amounts[$fac->id] = $facs[$i][1];
|
||||
$result = $fac->set_paid($user);
|
||||
}
|
||||
$paiement = new Paiement($this->db);
|
||||
|
|
@ -576,9 +576,10 @@ class BonPrelevement extends CommonObject
|
|||
/**
|
||||
* Get invoice list
|
||||
*
|
||||
* @param $amounts If you want to get the amount of the order for each invoice
|
||||
* @return array id of invoices
|
||||
*/
|
||||
private function getListInvoices()
|
||||
private function getListInvoices($amounts=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
|
@ -588,7 +589,7 @@ class BonPrelevement extends CommonObject
|
|||
* Renvoie toutes les factures presente
|
||||
* dans un bon de prelevement
|
||||
*/
|
||||
$sql = "SELECT fk_facture";
|
||||
$sql = "SELECT fk_facture, SUM(pl.amount)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."prelevement_facture as pf";
|
||||
|
|
@ -596,6 +597,7 @@ class BonPrelevement extends CommonObject
|
|||
$sql.= " AND pl.fk_prelevement_bons = p.rowid";
|
||||
$sql.= " AND p.rowid = ".$this->id;
|
||||
$sql.= " AND p.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY fk_facture";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
|
|
@ -608,7 +610,14 @@ class BonPrelevement extends CommonObject
|
|||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$arr[$i] = $row[0];
|
||||
if (!$amounts) $arr[$i] = $row[0];
|
||||
else
|
||||
{
|
||||
$arr[$i] = array(
|
||||
$row[0],
|
||||
$row[1]
|
||||
);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user