Fix conteggi consuntivi di preventivi e contratti

This commit is contained in:
Luca 2018-05-09 15:43:37 +02:00
parent 628c480c4a
commit a961e57b99
4 changed files with 12 additions and 8 deletions

View File

@ -268,13 +268,15 @@ if (!empty($rsi)) {
/*
Bilancio del contratto
*/
$rs = $dbo->fetchArray('SELECT SUM(subtotale) AS budget FROM co_righe2_contratti WHERE idcontratto='.prepare($id_record));
$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS budget FROM co_righe2_contratti WHERE idcontratto='.prepare($id_record));
$budget = $rs[0]['budget'];
$rs = $dbo->fetchArray("SELECT SUM(qta) AS totale_ore FROM `co_righe2_contratti` WHERE um='ore' AND idcontratto=".prepare($id_record));
$contratto_tot_ore = $rs[0]['totale_ore'];
$diff = floatval($budget) - floatval($totale);
$diff = sum($budget, -$totale_addebito);
if ($diff > 0) {
$bilancio = '<span class="text-success"><big>'.Translator::numberToLocale($diff).' &euro;</big></span>';
} elseif ($diff < 0) {

View File

@ -270,7 +270,7 @@ if (!empty($rsi)) {
/*
Bilancio del preventivo
*/
$diff = sum($budget, -$totale);
$diff = sum($budget, -$totale_addebito);
echo '
<div class="well text-center">

View File

@ -464,7 +464,7 @@ $imponibile = sum($imponibile);
$totale = $imponibile - $sconto;
$rs = $dbo->fetchArray('SELECT SUM(subtotale) as budget FROM `co_righe2_contratti` WHERE idcontratto = '.prepare($id_record));
$rs = $dbo->fetchArray('SELECT SUM(subtotale-sconto) as budget FROM `co_righe2_contratti` WHERE idcontratto = '.prepare($id_record));
$budget = $rs[0]['budget'];
$rs = $dbo->fetchArray("SELECT SUM(qta) AS totale_ore FROM `co_righe2_contratti` WHERE um='ore' AND idcontratto = ".prepare($id_record));

View File

@ -3,7 +3,7 @@
include_once __DIR__.'/../../core.php';
include_once $docroot.'/modules/interventi/modutil.php';
include_once $docroot.'/modules/preventivi/modutil.php';
$report_name = 'preventivo_'.$records[0]['numero'].'_cons.pdf';
echo '
@ -457,10 +457,12 @@ $imponibile = sum($imponibile);
$totale = $imponibile - $sconto;
$rs = $dbo->fetchArray('SELECT SUM(subtotale) as budget FROM `co_righe_preventivi` WHERE idpreventivo = '.prepare($id_record));
$budget = $rs[0]['budget'];
//$rs = $dbo->fetchArray('SELECT SUM(subtotale) as budget FROM `co_righe_preventivi` WHERE idpreventivo = '.prepare($id_record));
//$budget = $rs[0]['budget'];
$budget = get_imponibile_preventivo($id_record);
$rapporto = $budget - $totale;
$rapporto = floatval($budget) - floatval($totale);
// Totale imponibile
echo '