Merge pull request #202 from devcode-it/2.4

Merge branch '2.4' to master
This commit is contained in:
Luca 2018-03-27 16:06:13 +02:00 committed by GitHub
commit 7a074a06a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -778,13 +778,17 @@ function aggiorna_sconto($tables, $fields, $id_record, $options = [])
if (!empty($sconto[0]['sconto_globale'])) {
if ($sconto[0]['tipo_sconto_globale'] == 'PRC') {
$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS imponibile, SUM(iva) AS iva FROM (SELECT '.$tables['row'].'.subtotale, '.$tables['row'].'.sconto, '.$tables['row'].'.iva FROM '.$tables['row'].' WHERE '.$fields['row'].'='.prepare($id_record).') AS t');
$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS imponibile, SUM(iva) AS iva FROM (SELECT '.$tables['row'].'.subtotale, '.$tables['row'].'.sconto, '.$tables['row'].'.iva FROM '.$tables['row'].' WHERE '.$fields['row'].'='.prepare($id_record).') AS t');
$subtotale = $rs[0]['imponibile'];
$iva += $rs[0]['iva'] / 100 * $sconto[0]['sconto_globale'];
$subtotale = -$subtotale / 100 * $sconto[0]['sconto_globale'];
$descrizione = $descrizione.' '.Translator::numberToLocale($sconto[0]['sconto_globale']).'%';
$descrizione = $descrizione.' '.Translator::numberToLocale($sconto[0]['sconto_globale']).'%';
} else {
$rs = $dbo->fetchArray('SELECT SUM(subtotale - sconto) AS imponibile, SUM(iva) AS iva FROM (SELECT '.$tables['row'].'.subtotale, '.$tables['row'].'.sconto, '.$tables['row'].'.iva FROM '.$tables['row'].' WHERE '.$fields['row'].'='.prepare($id_record).') AS t');
$subtotale = $rs[0]['imponibile'];
$iva += $sconto[0]['sconto_globale'] * $rs[0]['iva'] / $subtotale;
$subtotale = -$sconto[0]['sconto_globale'];
}