openstamanager/templates/liquidazione_iva/body.php

313 lines
10 KiB
PHP
Raw Normal View History

2020-10-13 17:50:37 +02:00
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright (C) DevCode s.r.l.
2020-10-13 17:50:37 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
$totale_iva_vendite = sum(array_column($iva_vendite, 'iva'));
$totale_subtotale_vendite = sum(array_column($iva_vendite, 'subtotale'));
$totale_iva_acquisti = sum(array_column($iva_acquisti, 'iva'));
$totale_subtotale_acquisti = sum(array_column($iva_acquisti, 'subtotale'));
$totale_iva_esigibile = sum(array_column($iva_vendite_esigibile, 'iva'));
$totale_iva_nonesigibile = sum(array_column($iva_vendite_nonesigibile, 'iva'));
$subtotale_iva_esigibile = sum(array_column($iva_vendite_esigibile, 'subtotale'));
$subtotale_iva_nonesigibile = sum(array_column($iva_vendite_nonesigibile, 'subtotale'));
$totale_iva_detraibile = sum(array_column($iva_acquisti_detraibile, 'iva'));
$totale_iva_nondetraibile = sum(array_column($iva_acquisti_nondetraibile, 'iva'));
$subtotale_iva_detraibile = sum(array_column($iva_acquisti_detraibile, 'subtotale'));
$subtotale_iva_nondetraibile = sum(array_column($iva_acquisti_nondetraibile, 'subtotale'));
$totale_iva_vendite_anno_precedente = sum(array_column($iva_vendite_anno_precedente, 'iva'));
$totale_iva_acquisti_anno_precedente = sum(array_column($iva_acquisti_anno_precedente, 'iva'));
$totale_iva_anno_precedente = $totale_iva_vendite_anno_precedente - $totale_iva_acquisti_anno_precedente;
$totale_iva_vendite_periodo_precedente = sum(array_column($iva_vendite_periodo_precedente, 'iva'));
$totale_iva_acquisti_periodo_precedente = sum(array_column($iva_acquisti_periodo_precedente, 'iva'));
$totale_iva_periodo_precedente = $totale_iva_vendite_periodo_precedente - $totale_iva_acquisti_periodo_precedente;
$totale_iva = $totale_iva_esigibile - $totale_iva_detraibile;
2020-10-16 08:31:10 +02:00
if ($periodo == 'Trimestrale' && $totale_iva > 0) {
2020-10-13 17:50:37 +02:00
$maggiorazione = $totale_iva * 0.01;
$totale_iva_maggiorata = $totale_iva + $maggiorazione;
}
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<h5 class="text-center">VENDITE</h5>
<table class="table table-condensed table-striped table-bordered">
<thead>
<tr>
<th width="15%">Aliquota</th>
<th width="15%">Natura IVA</th>
<th width="30%">Descrizione</th>
<th class="text-right" width="20%">Imponibile</th>
<th class="text-right" width="20%">Imposta</th>
</tr>
2021-01-19 17:09:19 +01:00
</thead>
<tbody>
2020-10-13 17:50:37 +02:00
<tr>
<th class="text-center" colspan="5">IVA ESIGIBILE DEL PERIODO</th>
2021-01-19 17:09:19 +01:00
</tr>';
2021-02-18 18:48:44 +01:00
2020-10-16 08:31:10 +02:00
foreach ($iva_vendite_esigibile as $record) {
2020-10-13 17:50:37 +02:00
echo '
<tr>
<td>'.round($record['aliquota']).'%</td>
<td>'.$record['cod_iva'].'</td>
<td>'.$record['descrizione'].'</td>
<td class=text-right>'.moneyFormat($record['subtotale']).'</td>
<td class=text-right>'.moneyFormat($record['iva']).'</td>
</tr>';
}
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<td colspan="2"></td>
<td>TOTALI</td>
<td class=text-right>'.moneyFormat($subtotale_iva_esigibile).'</td>
<td class=text-right>'.moneyFormat($totale_iva_esigibile).'</td>
</tr>
<tr>
<th class="text-center" colspan="5">IVA NON ESIGIBILE DEL PERIODO</th>
</tr>';
2020-10-16 08:31:10 +02:00
foreach ($iva_vendite_nonesigibile as $record) {
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<td>'.round($record['aliquota']).'%</td>
<td>'.$record['cod_iva'].'</td>
<td>'.$record['descrizione'].'</td>
<td class=text-right>'.moneyFormat($record['subtotale']).'</td>
<td class=text-right>'.moneyFormat($record['iva']).'</td>
</tr>';
}
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<td colspan="2"></td>
<td>TOTALI</td>
<td class=text-right>'.moneyFormat($subtotale_iva_nonesigibile).'</td>
<td class=text-right>'.moneyFormat($totale_iva_nonesigibile).'</td>
</tr>
<tr>
<th class="text-center" colspan="5">RIEPILOGO GENERALE IVA VENDITE</th>
</tr>';
2020-10-16 08:31:10 +02:00
foreach ($iva_vendite as $record) {
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<td>'.round($record['aliquota']).'%</td>
<td>'.$record['cod_iva'].'</td>
<td>'.$record['descrizione'].'</td>
<td class=text-right>'.moneyFormat($record['subtotale']).'</td>
<td class=text-right>'.moneyFormat($record['iva']).'</td>
</tr>';
}
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<th colspan="2"></th>
<th>TOTALE</th>
<th class=text-right>'.moneyFormat($totale_subtotale_vendite).'</th>
<th class=text-right>'.moneyFormat($totale_iva_vendite).'</th>
</tr>
</tbody>
</table>
<h5 class="text-center">ACQUISTI</h5>
<table class="table table-condensed table-striped table-bordered">
<thead>
<tr>
<th width="15%">Aliquota</th>
<th width="15%">Natura IVA</th>
<th width="30%">Descrizione</th>
<th class="text-right" width="20%">Imponibile</th>
<th class="text-right" width="20%">Imposta</th>
</tr>
2021-01-19 17:09:19 +01:00
</thead>
<tbody>
2020-10-13 17:50:37 +02:00
<tr>
<th class="text-center" colspan="5">IVA DETRAIBILE DEL PERIODO</th>
2021-01-19 17:09:19 +01:00
</tr>';
2020-10-13 17:50:37 +02:00
2020-10-16 08:31:10 +02:00
foreach ($iva_acquisti_detraibile as $record) {
2020-10-13 17:50:37 +02:00
echo '
<tr>
<td>'.round($record['aliquota']).'%</td>
<td>'.$record['cod_iva'].'</td>
<td>'.$record['descrizione'].'</td>
<td class=text-right>'.moneyFormat($record['subtotale']).'</td>
<td class=text-right>'.moneyFormat($record['iva']).'</td>
</tr>';
}
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<td colspan="2"></td>
<td>TOTALI</td>
<td class=text-right>'.moneyFormat($subtotale_iva_detraibile).'</td>
<td class=text-right>'.moneyFormat($totale_iva_detraibile).'</td>
</tr>
<tr>
<th class="text-center" colspan="5">IVA NON DETRAIBILE DEL PERIODO</th>
</tr>';
2020-10-16 08:31:10 +02:00
foreach ($iva_acquisti_nondetraibile as $record) {
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<td>'.round($record['aliquota']).'%</td>
<td>'.$record['cod_iva'].'</td>
<td>'.$record['descrizione'].'</td>
<td class=text-right>'.moneyFormat($record['subtotale']).'</td>
<td class=text-right>'.moneyFormat($record['iva']).'</td>
</tr>';
}
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<td colspan="2"></td>
<td>TOTALI</td>
<td class=text-right>'.moneyFormat($subtotale_iva_nondetraibile).'</td>
<td class=text-right>'.moneyFormat($totale_iva_nondetraibile).'</td>
</tr>
<tr>
<th class="text-center" colspan="5">RIEPILOGO GENERALE IVA ACQUISTI</th>
</tr>';
2020-10-16 08:31:10 +02:00
foreach ($iva_acquisti as $record) {
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<td>'.round($record['aliquota']).'%</td>
<td>'.$record['cod_iva'].'</td>
<td>'.$record['descrizione'].'</td>
<td class=text-right>'.moneyFormat($record['subtotale']).'</td>
<td class=text-right>'.moneyFormat($record['iva']).'</td>
</tr>';
}
2021-02-18 18:48:44 +01:00
echo '
2020-10-13 17:50:37 +02:00
<tr>
<th colspan="2"></th>
<th>TOTALE</th>
<th class=text-right>'.moneyFormat($totale_subtotale_acquisti).'</th>
<th class=text-right>'.moneyFormat($totale_iva_acquisti).'</th>
</tr>
</tbody>
</table>
<br>
<br>
<table class="table table-condensed table-striped table-bordered">
<thead>
<tr>
<th class="text-center" colspan="2">PROSPETTO RIEPILOGATIVO DI LIQUIDAZIONE I.V.A.</th>
<tr>
<th width="70%">DESCRIZIONE</th>
<th class="text-right" width="30%">IMPORTO</th>
</tr>
</thead>
<tbody>
<tr>';
2020-10-16 08:31:10 +02:00
if ($totale_iva_anno_precedente >= 0) {
2021-02-18 18:48:44 +01:00
echo ' <td>DEBITO ANNO PRECEDENTE</td>';
2020-10-16 08:31:10 +02:00
} else {
2021-02-18 18:48:44 +01:00
echo ' <td>CREDITO ANNO PRECEDENTE</td>';
2020-10-13 17:50:37 +02:00
}
2021-02-18 18:48:44 +01:00
echo '<td class=text-right>'.moneyFormat(abs($totale_iva_anno_precedente)).'</td>
2020-10-13 17:50:37 +02:00
</tr>
<tr>';
2020-10-16 08:31:10 +02:00
if ($totale_iva_periodo_precedente >= 0) {
2021-02-18 18:48:44 +01:00
echo ' <td>DEBITO PERIODO PRECEDENTE</td>';
2020-10-16 08:31:10 +02:00
} else {
2021-02-18 18:48:44 +01:00
echo ' <td>CREDITO PERIODO PRECEDENTE</td>';
2020-10-13 17:50:37 +02:00
}
2021-02-18 18:48:44 +01:00
echo ' <td class=text-right>'.moneyFormat(abs($totale_iva_periodo_precedente)).'</td>
2020-10-13 17:50:37 +02:00
</tr>
<tr>
<td>TOTALE IVA SU VENDITE ESIGIBILE</td>
<td class=text-right>'.moneyFormat($totale_iva_esigibile).'</td>
</tr>
<tr>
<td>TOTALE IVA OGGETTIVAMENTE NON A DEBITO SU VENDITE</td>
<td class=text-right>'.moneyFormat($totale_iva_nonesigibile).'</td>
</tr>
<tr>
<td>TOTALE IVA SU ACQUISTI DETRAIBILI</td>
<td class=text-right>'.moneyFormat($totale_iva_detraibile).'</td>
</tr>
<tr>
<td>TOTALE IVA OGGETTIVAMENTE INDETRAIBILI SU ACQUISTI</td>
<td class=text-right>'.moneyFormat($totale_iva_nondetraibile).'</td>
</tr>
<tr>
<td>TOTALE IVA DETRAIBILI</td>
<td class=text-right>'.moneyFormat($totale_iva_detraibile).'</td>
</tr>
<tr>
<td>VARIAZIONE DI IMPOSTA RELATIVE A PERIODI PRECEDENTI</td>
<td class=text-right></td>
</tr>
<tr>
<td>DI CUI INTERESSI PER RAVVEDIMENTO</td>
<td class=text-right></td>
</tr>
<tr>
<td>DI CUI INTERESSI PER MAGGIORAZIONE TRIMESTRALI</td>
<td class=text-right></td>
</tr>
<tr>
<td>CREDITO IVA COMPENSABILE</td>
<td class=text-right></td>
</tr>
<tr>';
2020-10-16 08:31:10 +02:00
if ($totale_iva >= 0) {
2021-02-18 18:48:44 +01:00
echo ' <td>IVA A DEBITO</td>';
2020-10-16 08:31:10 +02:00
} else {
2021-02-18 18:48:44 +01:00
echo ' <td>IVA A CREDITO</td>';
2020-10-13 17:50:37 +02:00
}
2021-02-18 18:48:44 +01:00
echo ' <td class=text-right>'.moneyFormat(abs($totale_iva)).'</td>
2020-10-13 17:50:37 +02:00
</tr>
<tr>
<td>CREDITO SPECIALE DI IMPOSTA</td>
<td class=text-right></td>
</tr>
<tr>
<td>MAGGIORAZIONE 1,00%</td>
<td class=text-right>'.moneyFormat($maggiorazione).'</td>
</tr>
<tr>
<td>IVA A DEBITO CON MAGGIORAZIONE</td>
<td class=text-right>'.moneyFormat($totale_iva_maggiorata).'</td>
</tr>
<tr>
<td>IMPORTO DA VERSARE</td>
<td class=text-right>'.moneyFormat($totale_iva_maggiorata).'</td>
</tr>
<tr>
<td>CREDITO INFRANNUALE DI IMPOSTA CHIESTO A RIMBORSO</td>
<td class=text-right></td>
</tr>
<tr>
<td>CREDITO INFRANNUALE DA UTILIZZARE IN COMPENSAZIONE</td>
<td class=text-right></td>
</tr>
</tbody>
2020-10-16 08:31:10 +02:00
</table>';