mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Try more complete fix for #31117
This commit is contained in:
parent
ef42231dc3
commit
90f49fbd83
|
|
@ -5176,9 +5176,13 @@ if ($action == 'create') {
|
|||
|
||||
$current_situation_counter = array();
|
||||
foreach ($object->tab_previous_situation_invoice as $prev_invoice) {
|
||||
$tmptotalpaidforthisinvoice = $prev_invoice->getSommePaiement();
|
||||
$tmptotalallpayments = $prev_invoice->getSommePaiement(0);
|
||||
$tmptotalallpayments += $prev_invoice->getSumDepositsUsed(0);
|
||||
$tmptotalallpayments += $prev_invoice->getSumCreditNotesUsed(0);
|
||||
|
||||
$total_prev_ht += $prev_invoice->total_ht;
|
||||
$total_prev_ttc += $prev_invoice->total_ttc;
|
||||
|
||||
$current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ? -1 : 1) * $prev_invoice->situation_counter;
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$prev_invoice->getNomUrl(1).'</td>';
|
||||
|
|
@ -5189,17 +5193,22 @@ if ($action == 'create') {
|
|||
}
|
||||
print '<td class="right"><span class="amount">'.price($prev_invoice->total_ht).'</span></td>';
|
||||
print '<td class="right"><span class="amount">'.price($prev_invoice->total_ttc).'</span></td>';
|
||||
print '<td class="right">'.$prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice).'</td>';
|
||||
print '<td class="right">'.$prev_invoice->getLibStatut(3, $tmptotalallpayments).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
$totalallpayments = $object->getSommePaiement(0);
|
||||
$totalallpayments += $object->getSumCreditNotesUsed(0);
|
||||
$totalallpayments += $object->getSumDepositsUsed(0);
|
||||
|
||||
$total_global_ht += $total_prev_ht;
|
||||
$total_global_ttc += $total_prev_ttc;
|
||||
$total_global_ht += $object->total_ht;
|
||||
$total_global_ttc += $object->total_ttc;
|
||||
|
||||
$current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE) ? -1 : 1) * $object->situation_counter;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$object->getNomUrl(1).'</td>';
|
||||
print '<td></td>';
|
||||
|
|
@ -5209,7 +5218,7 @@ if ($action == 'create') {
|
|||
}
|
||||
print '<td class="right"><span class="amount">'.price($object->total_ht).'</span></td>';
|
||||
print '<td class="right"><span class="amount">'.price($object->total_ttc).'</span></td>';
|
||||
print '<td class="right">'.$object->getLibStatut(3, $object->getSommePaiement()).'</td>';
|
||||
print '<td class="right">'.$object->getLibStatut(3, $totalallpayments).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
|
@ -5251,7 +5260,10 @@ if ($action == 'create') {
|
|||
$total_next_ht = $total_next_ttc = 0;
|
||||
|
||||
foreach ($object->tab_next_situation_invoice as $next_invoice) {
|
||||
$totalpaid = $next_invoice->getSommePaiement();
|
||||
$totalpaid = $next_invoice->getSommePaiement(0);
|
||||
$totalcreditnotes = $next_invoice->getSumCreditNotesUsed(0);
|
||||
$totaldeposits = $next_invoice->getSumDepositsUsed(0);
|
||||
|
||||
$total_next_ht += $next_invoice->total_ht;
|
||||
$total_next_ttc += $next_invoice->total_ttc;
|
||||
|
||||
|
|
@ -5264,7 +5276,7 @@ if ($action == 'create') {
|
|||
}
|
||||
print '<td class="right"><span class="amount">'.price($next_invoice->total_ht).'</span></td>';
|
||||
print '<td class="right"><span class="amount">'.price($next_invoice->total_ttc).'</span></td>';
|
||||
print '<td class="right">'.$next_invoice->getLibStatut(3, $totalpaid).'</td>';
|
||||
print '<td class="right">'.$next_invoice->getLibStatut(3, $totalpaid + $totalcreditnotes + $totaldeposits).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1979,11 +1979,16 @@ class Facture extends CommonInvoice
|
|||
|
||||
// Complete datas
|
||||
if (!empty($params['fromajaxtooltip']) && !isset($this->totalpaid)) {
|
||||
// Load the totalpaid field
|
||||
$this->totalpaid = $this->getSommePaiement(0);
|
||||
}
|
||||
if (isset($this->status) && isset($this->totalpaid)) {
|
||||
$datas['picto'] .= ' '.$this->getLibStatut(5, $this->totalpaid);
|
||||
if (!empty($params['fromajaxtooltip']) && !isset($this->totalcreditnotes)) {
|
||||
$this->totalcreditnotes = $this->getSumCreditNotesUsed(0);
|
||||
}
|
||||
if (!empty($params['fromajaxtooltip']) && !isset($this->totaldeposits)) {
|
||||
$this->totaldeposits = $this->getSumDepositsUsed(0);
|
||||
}
|
||||
if (isset($this->status) && isset($this->totalpaid) && isset($this->totalcreditnotes) && isset($this->totaldeposits)) {
|
||||
$datas['picto'] .= ' '.$this->getLibStatut(5, $this->totalpaid + $this->totalcreditnotes + $this->totaldeposits);
|
||||
}
|
||||
if ($moretitle) {
|
||||
$datas['picto'] .= ' - '.$moretitle;
|
||||
|
|
|
|||
|
|
@ -442,8 +442,8 @@ if ($action == 'makepayment_confirm' && $user->hasRight('facture', 'paiement'))
|
|||
$paiementAmount = $facture->getSommePaiement();
|
||||
$totalcreditnotes = $facture->getSumCreditNotesUsed();
|
||||
$totaldeposits = $facture->getSumDepositsUsed();
|
||||
$totalpay = $paiementAmount + $totalcreditnotes + $totaldeposits;
|
||||
$remaintopay = price2num($facture->total_ttc - $totalpay);
|
||||
$totalallpayments = $paiementAmount + $totalcreditnotes + $totaldeposits;
|
||||
$remaintopay = price2num($facture->total_ttc - $totalallpayments);
|
||||
|
||||
// hook to finalize the remaining amount, considering e.g. cash discount agreements
|
||||
$parameters = array('remaintopay' => $remaintopay);
|
||||
|
|
@ -1917,7 +1917,7 @@ if ($num > 0) {
|
|||
$totalarray['val']['f.total_localtax1'] = 0;
|
||||
$totalarray['val']['f.total_localtax1'] = 0;
|
||||
$totalarray['val']['f.total_ttc'] = 0;
|
||||
$totalarray['val']['totalam'] = 0;
|
||||
$totalarray['val']['dynamount_payed'] = 0;
|
||||
$totalarray['val']['rtp'] = 0;
|
||||
|
||||
$typenArray = $formcompany->typent_array(1);
|
||||
|
|
@ -2002,15 +2002,15 @@ if ($num > 0) {
|
|||
$paiement = $facturestatic->getSommePaiement();
|
||||
$totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
|
||||
$totaldeposits = $facturestatic->getSumDepositsUsed();
|
||||
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
|
||||
$remaintopay = $obj->total_ttc - $totalpay;
|
||||
$totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
|
||||
$remaintopay = $obj->total_ttc - $totalallpayments;
|
||||
|
||||
$multicurrency_paiement = $facturestatic->getSommePaiement(1);
|
||||
$multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
|
||||
$multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
|
||||
|
||||
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
|
||||
$remaintopay = price2num($facturestatic->total_ttc - $totalpay);
|
||||
$totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
|
||||
$remaintopay = price2num($facturestatic->total_ttc - $totalallpayments);
|
||||
|
||||
$multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
|
||||
$multicurrency_remaintopay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
|
||||
|
|
@ -2022,7 +2022,7 @@ if ($num > 0) {
|
|||
if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consumed
|
||||
$remaincreditnote = $discount->getAvailableDiscounts($companystatic, '', 'rc.fk_facture_source='.$facturestatic->id);
|
||||
$remaintopay = -$remaincreditnote;
|
||||
$totalpay = price2num($facturestatic->total_ttc - $remaintopay);
|
||||
$totalallpayments = price2num($facturestatic->total_ttc - $remaintopay);
|
||||
$multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic, '', 'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
|
||||
$multicurrency_remaintopay = -$multicurrency_remaincreditnote;
|
||||
$multicurrency_totalpay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
|
||||
|
|
@ -2030,6 +2030,8 @@ if ($num > 0) {
|
|||
|
||||
$facturestatic->alreadypaid = $paiement;
|
||||
$facturestatic->totalpaid = $paiement;
|
||||
$facturestatic->totalcreditnotes = $totalcreditnotes;
|
||||
$facturestatic->totaldeposits = $totaldeposits;
|
||||
|
||||
$marginInfo = array();
|
||||
if ($with_margin_info) {
|
||||
|
|
@ -2510,14 +2512,14 @@ if ($num > 0) {
|
|||
}
|
||||
|
||||
if (!empty($arrayfields['dynamount_payed']['checked'])) {
|
||||
print '<td class="right nowraponall amount">'.(!empty($totalpay) ? price($totalpay, 0, $langs) : ' ').'</td>'; // TODO Use a denormalized field
|
||||
print '<td class="right nowraponall amount">'.(!empty($totalallpayments) ? price($totalallpayments, 0, $langs) : ' ').'</td>'; // TODO Use a denormalized field
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!$i) {
|
||||
$totalarray['pos'][$totalarray['nbfield']] = 'totalam';
|
||||
$totalarray['pos'][$totalarray['nbfield']] = 'dynamount_payed';
|
||||
}
|
||||
$totalarray['val']['totalam'] += $totalpay;
|
||||
$totalarray['val']['dynamount_payed'] += $totalallpayments;
|
||||
}
|
||||
|
||||
// Pending amount
|
||||
|
|
@ -2715,7 +2717,7 @@ if ($num > 0) {
|
|||
// Status
|
||||
if (!empty($arrayfields['f.fk_statut']['checked'])) {
|
||||
print '<td class="nowrap center">';
|
||||
print $facturestatic->getLibStatut(5, $paiement);
|
||||
print $facturestatic->getLibStatut(5, $totalallpayments);
|
||||
print "</td>";
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
|
|
|
|||
|
|
@ -88,11 +88,21 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
|||
|
||||
print '</td>';
|
||||
print '<td class="linkedcol-statut right">';
|
||||
$totalallpayments = 0;
|
||||
$totalcalculated = false;
|
||||
if (method_exists($objectlink, 'getSommePaiement')) {
|
||||
print $objectlink->getLibStatut(3, $objectlink->getSommePaiement());
|
||||
} else {
|
||||
print $objectlink->getLibStatut(3);
|
||||
$totalcalculated = true;
|
||||
$totalallpayments += $objectlink->getSommePaiement();
|
||||
}
|
||||
if (method_exists($objectlink, 'getSumDepositsUsed')) {
|
||||
$totalcalculated = true;
|
||||
$totalallpayments += $objectlink->getSumDepositsUsed();
|
||||
}
|
||||
if (method_exists($objectlink, 'getSumCreditNotesUsed')) {
|
||||
$totalcalculated = true;
|
||||
$totalallpayments += $objectlink->getSumCreditNotesUsed();
|
||||
}
|
||||
print $objectlink->getLibStatut(3, ($totalcalculated ? $totalallpayments : -1));
|
||||
print '</td>';
|
||||
print '<td class="linkedcol-action right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&token='.newToken().'&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
|
||||
print "</tr>\n";
|
||||
|
|
|
|||
|
|
@ -379,9 +379,14 @@ if ((isModEnabled('fournisseur') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMO
|
|||
}
|
||||
print '<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).'</span></td>';
|
||||
print '<td class="right" title="'.dol_escape_htmltag($langs->trans("DateModificationShort").' : '.dol_print_date($db->jdate($obj->tms), 'dayhour', 'tzuserrel')).'">'.dol_print_date($db->jdate($obj->tms), 'day', 'tzuserrel').'</td>';
|
||||
|
||||
$alreadypaid = $facstatic->getSommePaiement();
|
||||
$alreadypaid += $facstatic->getSumCreditNotesUsed();
|
||||
$alreadypaid += $facstatic->getSumDepositsUsed();
|
||||
|
||||
print '<td>'.$facstatic->getLibStatut(3, $alreadypaid).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$total_ht += $obj->total_ht;
|
||||
$total_ttc += $obj->total_ttc;
|
||||
$totalam += $obj->am;
|
||||
|
|
|
|||
|
|
@ -1324,7 +1324,7 @@ class Paiement extends CommonObject
|
|||
$facturestatic = new Facture($this->db);
|
||||
foreach ($arraybill as $billid) {
|
||||
$facturestatic->fetch($billid);
|
||||
$label .= '<br> '.$facturestatic->getNomUrl(1, '', 0, 0, '', 1).' '.$facturestatic->getLibStatut(2, 1);
|
||||
$label .= '<br> '.$facturestatic->getNomUrl(1, '', 0, 0, '', 1).' '.$facturestatic->getLibStatut(2, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ print '</span></td></tr></table></div><br>';
|
|||
/*
|
||||
* Invoices waiting for withdraw
|
||||
*/
|
||||
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
|
||||
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut as status, f.paye, f.type,";
|
||||
$sql .= " pfd.date_demande, pfd.amount,";
|
||||
$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
|
||||
|
|
@ -141,10 +141,14 @@ if ($resql) {
|
|||
|
||||
$invoicestatic->id = $obj->rowid;
|
||||
$invoicestatic->ref = $obj->ref;
|
||||
$invoicestatic->statut = $obj->fk_statut;
|
||||
$invoicestatic->statut = $obj->status;
|
||||
$invoicestatic->status = $obj->status;
|
||||
$invoicestatic->paye = $obj->paye;
|
||||
$invoicestatic->type = $obj->type;
|
||||
$alreadypayed = $invoicestatic->getSommePaiement();
|
||||
|
||||
$totalallpayments = $invoicestatic->getSommePaiement(0);
|
||||
$totalallpayments += $invoicestatic->getSumCreditNotesUsed(0);
|
||||
$totalallpayments += $invoicestatic->getSumDepositsUsed(0);
|
||||
|
||||
$thirdpartystatic->id = $obj->socid;
|
||||
$thirdpartystatic->name = $obj->name;
|
||||
|
|
@ -177,7 +181,7 @@ if ($resql) {
|
|||
print '</td>';
|
||||
|
||||
print '<td class="right">';
|
||||
print $invoicestatic->getLibStatut(3, $alreadypayed);
|
||||
print $invoicestatic->getLibStatut(3, $totalallpayments);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,10 @@ if ($id > 0) {
|
|||
print $fac->error."<br>";
|
||||
continue;
|
||||
}
|
||||
$totalpaid = $fac->getSommePaiement();
|
||||
|
||||
$alreadypaid = $fac->getSommePaiement();
|
||||
$alreadypaid += $fac->getSumDepositsUsed();
|
||||
$alreadypaid += $fac->getSumCreditNotesUsed();
|
||||
|
||||
$userstatic->id = $objf->userid;
|
||||
$userstatic->login = $objf->login;
|
||||
|
|
@ -173,7 +176,7 @@ if ($id > 0) {
|
|||
'date' => $fac->date,
|
||||
'datefieldforsort' => $fac->date.'-'.$fac->ref,
|
||||
'link' => $fac->getNomUrl(1),
|
||||
'status' => $fac->getLibStatut(2, $totalpaid),
|
||||
'status' => $fac->getLibStatut(2, $alreadypaid),
|
||||
'amount' => $fac->total_ttc,
|
||||
'author' => $userstatic->getLoginUrl(1)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -745,7 +745,10 @@ while ($i < $imaxinloop) {
|
|||
}
|
||||
|
||||
if (!empty($arrayfields['t.status']['checked'])) {
|
||||
print '<td class="nowrap right">' . $tva_static->getLibStatut(5, $obj->alreadypayed) . '</td>';
|
||||
$totalallpayments = $obj->alreadypayed;
|
||||
// TODO Add deposit and credit notes
|
||||
|
||||
print '<td class="nowrap right">' . $tva_static->getLibStatut(5, $totalallpayments) . '</td>';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ abstract class CommonInvoice extends CommonObject
|
|||
|
||||
/**
|
||||
* Return amount of payments already done. This must include ONLY the record into the payment table.
|
||||
* Payments dones using discounts, credit notes, etc are not included.
|
||||
* Payments done using discounts, credit notes, etc are not included.
|
||||
*
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount. -1=Return both.
|
||||
* @return float|int|array Amount of payment already done, <0 and set ->error if KO
|
||||
|
|
|
|||
|
|
@ -769,14 +769,14 @@ abstract class CommonObject
|
|||
public $sendtoid;
|
||||
|
||||
/**
|
||||
* @var float Amount already paid from getSommePaiement() (used to show correct status)
|
||||
* @deprecated Use $totalpaid instead
|
||||
* @var float Amount already paid from getSommePaiement() + getSumCreditNotesUsed() + getSumDepositsUsed() (used to show correct status)
|
||||
* @see $totalpaid
|
||||
*/
|
||||
private $alreadypaid;
|
||||
public $alreadypaid;
|
||||
|
||||
/**
|
||||
* @var float Amount already paid from getSommePaiement() (used to show correct status)
|
||||
* @var float Amount already paid from getSommePaiement()
|
||||
* @see $alreadpaid
|
||||
*/
|
||||
public $totalpaid;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user