|
@@ -725,14 +725,14 @@ if (empty($reshook)) {
|
|
|
|
|
|
while ($i < $num) {
|
|
while ($i < $num) {
|
|
$objp = $db->fetch_object($result);
|
|
$objp = $db->fetch_object($result);
|
|
- $totalpaye += $objp->amount;
|
|
|
|
|
|
+ $totalpaid += $objp->amount;
|
|
$i++;
|
|
$i++;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
dol_print_error($db, '');
|
|
dol_print_error($db, '');
|
|
}
|
|
}
|
|
|
|
|
|
- $resteapayer = $object->total_ttc - $totalpaye;
|
|
|
|
|
|
+ $resteapayer = $object->total_ttc - $totalpaid;
|
|
|
|
|
|
// We check that invlice lines are transferred into accountancy
|
|
// We check that invlice lines are transferred into accountancy
|
|
$ventilExportCompta = $object->getVentilExportCompta();
|
|
$ventilExportCompta = $object->getVentilExportCompta();
|
|
@@ -1255,10 +1255,10 @@ if (empty($reshook)) {
|
|
|
|
|
|
if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) {
|
|
if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) {
|
|
if ($facture_source->fetch($object->fk_facture_source) > 0) {
|
|
if ($facture_source->fetch($object->fk_facture_source) > 0) {
|
|
- $totalpaye = $facture_source->getSommePaiement();
|
|
|
|
|
|
+ $totalpaid = $facture_source->getSommePaiement();
|
|
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
|
|
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
|
|
$totaldeposits = $facture_source->getSumDepositsUsed();
|
|
$totaldeposits = $facture_source->getSumDepositsUsed();
|
|
- $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits);
|
|
|
|
|
|
+ $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
|
|
|
|
|
|
$object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 1, 0, 0, 0, 0, 0, '', '', 'TTC');
|
|
$object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 1, 0, 0, 0, 0, 0, '', '', 'TTC');
|
|
}
|
|
}
|
|
@@ -3899,24 +3899,24 @@ if ($action == 'create') {
|
|
}
|
|
}
|
|
$selleruserevenustamp = $mysoc->useRevenueStamp();
|
|
$selleruserevenustamp = $mysoc->useRevenueStamp();
|
|
|
|
|
|
- $totalpaye = $object->getSommePaiement();
|
|
|
|
|
|
+ $totalpaid = $object->getSommePaiement();
|
|
$totalcreditnotes = $object->getSumCreditNotesUsed();
|
|
$totalcreditnotes = $object->getSumCreditNotesUsed();
|
|
$totaldeposits = $object->getSumDepositsUsed();
|
|
$totaldeposits = $object->getSumDepositsUsed();
|
|
- //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits."
|
|
|
|
|
|
+ //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits."
|
|
// selleruserrevenuestamp=".$selleruserevenustamp;
|
|
// selleruserrevenuestamp=".$selleruserevenustamp;
|
|
|
|
|
|
// We can also use bcadd to avoid pb with floating points
|
|
// We can also use bcadd to avoid pb with floating points
|
|
// For example print 239.2 - 229.3 - 9.9; does not return 0.
|
|
// 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($object->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT);
|
|
// $resteapayer=bcadd($resteapayer,$totalavoir,$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');
|
|
|
|
|
|
+ $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT');
|
|
|
|
|
|
// Multicurrency
|
|
// Multicurrency
|
|
if (!empty($conf->multicurrency->enabled)) {
|
|
if (!empty($conf->multicurrency->enabled)) {
|
|
- $multicurrency_totalpaye = $object->getSommePaiement(1);
|
|
|
|
|
|
+ $multicurrency_totalpaid = $object->getSommePaiement(1);
|
|
$multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1);
|
|
$multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1);
|
|
$multicurrency_totaldeposits = $object->getSumDepositsUsed(1);
|
|
$multicurrency_totaldeposits = $object->getSumDepositsUsed(1);
|
|
- $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT');
|
|
|
|
|
|
+ $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT');
|
|
// Code to fix case of corrupted data
|
|
// Code to fix case of corrupted data
|
|
if ($resteapayer == 0 && $multicurrency_resteapayer != 0) {
|
|
if ($resteapayer == 0 && $multicurrency_resteapayer != 0) {
|
|
$resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT');
|
|
$resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT');
|
|
@@ -4317,7 +4317,7 @@ if ($action == 'create') {
|
|
}
|
|
}
|
|
$morehtmlref .= '</div>';
|
|
$morehtmlref .= '</div>';
|
|
|
|
|
|
- $object->totalpaid = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
|
|
|
|
|
|
+ $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
|
|
|
|
|
|
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '');
|
|
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '');
|
|
|
|
|
|
@@ -4926,7 +4926,7 @@ if ($action == 'create') {
|
|
$total_next_ht = $total_next_ttc = 0;
|
|
$total_next_ht = $total_next_ttc = 0;
|
|
|
|
|
|
foreach ($object->tab_next_situation_invoice as $next_invoice) {
|
|
foreach ($object->tab_next_situation_invoice as $next_invoice) {
|
|
- $totalpaye = $next_invoice->getSommePaiement();
|
|
|
|
|
|
+ $totalpaid = $next_invoice->getSommePaiement();
|
|
$total_next_ht += $next_invoice->total_ht;
|
|
$total_next_ht += $next_invoice->total_ht;
|
|
$total_next_ttc += $next_invoice->total_ttc;
|
|
$total_next_ttc += $next_invoice->total_ttc;
|
|
|
|
|
|
@@ -4939,7 +4939,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_ht).'</span></td>';
|
|
print '<td class="right"><span class="amount">'.price($next_invoice->total_ttc).'</span></td>';
|
|
print '<td class="right"><span class="amount">'.price($next_invoice->total_ttc).'</span></td>';
|
|
- print '<td class="right">'.$next_invoice->getLibStatut(3, $totalpaye).'</td>';
|
|
|
|
|
|
+ print '<td class="right">'.$next_invoice->getLibStatut(3, $totalpaid).'</td>';
|
|
print '</tr>';
|
|
print '</tr>';
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5072,7 +5072,7 @@ if ($action == 'create') {
|
|
} else {
|
|
} else {
|
|
print $langs->trans('AlreadyPaid');
|
|
print $langs->trans('AlreadyPaid');
|
|
}
|
|
}
|
|
- print '</span></td><td class="right'.(($totalpaye > 0) ? ' amountalreadypaid' : '').'">'.price($totalpaye).'</td><td> </td></tr>';
|
|
|
|
|
|
+ print '</span></td><td class="right'.(($totalpaid > 0) ? ' amountalreadypaid' : '').'">'.price($totalpaid).'</td><td> </td></tr>';
|
|
|
|
|
|
$resteapayeraffiche = $resteapayer;
|
|
$resteapayeraffiche = $resteapayer;
|
|
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
|
|
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
|
|
@@ -5125,7 +5125,7 @@ if ($action == 'create') {
|
|
print '<span class="opacitymedium">';
|
|
print '<span class="opacitymedium">';
|
|
print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1);
|
|
print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1);
|
|
print '</span>';
|
|
print '</span>';
|
|
- print '</td><td class="right"><span class="amount">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).'</span></td><td> </td></tr>';
|
|
|
|
|
|
+ print '</td><td class="right"><span class="amount">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).'</span></td><td> </td></tr>';
|
|
$resteapayeraffiche = 0;
|
|
$resteapayeraffiche = 0;
|
|
$cssforamountpaymentcomplete = 'amountpaymentneutral';
|
|
$cssforamountpaymentcomplete = 'amountpaymentneutral';
|
|
}
|
|
}
|
|
@@ -5135,7 +5135,7 @@ if ($action == 'create') {
|
|
print '<span class="opacitymedium">';
|
|
print '<span class="opacitymedium">';
|
|
print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1);
|
|
print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1);
|
|
print '</span>';
|
|
print '</span>';
|
|
- print '</td><td class="right">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).'</td><td> </td></tr>';
|
|
|
|
|
|
+ print '</td><td class="right">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).'</td><td> </td></tr>';
|
|
// $resteapayeraffiche=0;
|
|
// $resteapayeraffiche=0;
|
|
$cssforamountpaymentcomplete = 'amountpaymentneutral';
|
|
$cssforamountpaymentcomplete = 'amountpaymentneutral';
|
|
}
|
|
}
|
|
@@ -5145,7 +5145,7 @@ if ($action == 'create') {
|
|
print '<span class="opacitymedium">';
|
|
print '<span class="opacitymedium">';
|
|
print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1);
|
|
print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1);
|
|
print '</span>';
|
|
print '</span>';
|
|
- print '</td><td class="right"><span class="amount">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).'</span></td><td> </td></tr>';
|
|
|
|
|
|
+ print '</td><td class="right"><span class="amount">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).'</span></td><td> </td></tr>';
|
|
$resteapayeraffiche = 0;
|
|
$resteapayeraffiche = 0;
|
|
$cssforamountpaymentcomplete = 'amountpaymentneutral';
|
|
$cssforamountpaymentcomplete = 'amountpaymentneutral';
|
|
}
|
|
}
|
|
@@ -5159,7 +5159,7 @@ if ($action == 'create') {
|
|
print '<span class="opacitymedium">';
|
|
print '<span class="opacitymedium">';
|
|
print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1);
|
|
print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1);
|
|
print '</span>';
|
|
print '</span>';
|
|
- print '</td><td class="right"><span class="amount">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).'</span></td><td> </td></tr>';
|
|
|
|
|
|
+ print '</td><td class="right"><span class="amount">'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).'</span></td><td> </td></tr>';
|
|
$resteapayeraffiche = 0;
|
|
$resteapayeraffiche = 0;
|
|
$cssforamountpaymentcomplete = 'amountpaymentneutral';
|
|
$cssforamountpaymentcomplete = 'amountpaymentneutral';
|
|
}
|
|
}
|
|
@@ -5220,7 +5220,7 @@ if ($action == 'create') {
|
|
// Total already paid back
|
|
// Total already paid back
|
|
print '<tr><td colspan="'.$nbcols.'" class="right">';
|
|
print '<tr><td colspan="'.$nbcols.'" class="right">';
|
|
print '<span class="opacitymedium">'.$langs->trans('AlreadyPaidBack').'</span>';
|
|
print '<span class="opacitymedium">'.$langs->trans('AlreadyPaidBack').'</span>';
|
|
- print '</td><td class="right"><span class="amount">'.price($sign * $totalpaye).'</span></td><td> </td></tr>';
|
|
|
|
|
|
+ print '</td><td class="right"><span class="amount">'.price($sign * $totalpaid).'</span></td><td> </td></tr>';
|
|
|
|
|
|
// Billed
|
|
// Billed
|
|
print '<tr><td colspan="'.$nbcols.'" class="right"><span class="opacitymedium">'.$langs->trans("Billed").'</span></td><td class="right">'.price($sign * $object->total_ttc).'</td><td> </td></tr>';
|
|
print '<tr><td colspan="'.$nbcols.'" class="right"><span class="opacitymedium">'.$langs->trans("Billed").'</span></td><td class="right">'.price($sign * $object->total_ttc).'</td><td> </td></tr>';
|
|
@@ -5498,8 +5498,8 @@ if ($action == 'create') {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- $sumofpayment = $totalpaye;
|
|
|
|
- $sumofpaymentall = $totalpaye + $totalcreditnotes + $totaldeposits;
|
|
|
|
|
|
+ $sumofpayment = $totalpaid;
|
|
|
|
+ $sumofpaymentall = $totalpaid + $totalcreditnotes + $totaldeposits;
|
|
|
|
|
|
// Reverse back money or convert to reduction
|
|
// Reverse back money or convert to reduction
|
|
if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) {
|
|
if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) {
|
|
@@ -5551,7 +5551,7 @@ if ($action == 'create') {
|
|
|
|
|
|
// Classify 'closed not completely paid' (possible if validated and not yet filed paid)
|
|
// Classify 'closed not completely paid' (possible if validated and not yet filed paid)
|
|
if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID) || $resteapayer != $object->total_ttc) && $usercanissuepayment) {
|
|
if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID) || $resteapayer != $object->total_ttc) && $usercanissuepayment) {
|
|
- if ($totalpaye > 0 || $totalcreditnotes > 0) {
|
|
|
|
|
|
+ if ($totalpaid > 0 || $totalcreditnotes > 0) {
|
|
// If one payment or one credit note was linked to this invoice
|
|
// If one payment or one credit note was linked to this invoice
|
|
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid">'.$langs->trans('ClassifyPaidPartially').'</a>';
|
|
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid">'.$langs->trans('ClassifyPaidPartially').'</a>';
|
|
} else {
|
|
} else {
|
|
@@ -5575,7 +5575,7 @@ if ($action == 'create') {
|
|
// For situation invoice with excess received
|
|
// For situation invoice with excess received
|
|
if ($object->statut > Facture::STATUS_DRAFT
|
|
if ($object->statut > Facture::STATUS_DRAFT
|
|
&& $object->type == Facture::TYPE_SITUATION
|
|
&& $object->type == Facture::TYPE_SITUATION
|
|
- && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0
|
|
|
|
|
|
+ && ($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits) > 0
|
|
&& $usercancreate
|
|
&& $usercancreate
|
|
&& !$objectidnext
|
|
&& !$objectidnext
|
|
&& $object->is_last_in_cycle()
|
|
&& $object->is_last_in_cycle()
|