mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-03-09 15:50:14 +01:00
Miglioramenti nella gestione dell'IVA
Aggiunta possibilità di specificare IVA di vendita e di acquisto predefinita per le anagrafiche. Aggiunto nuovo modulo per le Stampe contabili. Modifica nella gestione dei diritti di chiamata, ora applicati solo sulla prima sessione di lavoro della giornata (se questa viene eliminata, il diritto chiamata viene rimosso di conseguenza anche con altre sessioni presenti).
This commit is contained in:
parent
1256c2fea9
commit
1da2f8909f
@ -526,12 +526,13 @@ span.form-control {
|
||||
.main-header .logo {
|
||||
display: none;
|
||||
}
|
||||
/*
|
||||
.content-wrapper,
|
||||
.right-side,
|
||||
.left-side,
|
||||
.main-sidebar {
|
||||
padding-top: 50px;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@media screen and (max-width:1023px) {
|
||||
|
@ -52,9 +52,12 @@ if (Auth::check()) {
|
||||
'week' => tr('Settimana'),
|
||||
'month' => tr('Mese'),
|
||||
'today' => tr('Oggi'),
|
||||
'yesterday' => tr('Ieri'),
|
||||
'last7Days' => tr('Ultimi 7 giorni'),
|
||||
'last30Days' => tr('Ultimi 30 giorni'),
|
||||
'firstThreemester' => tr('I trimestre'),
|
||||
'secondThreemester' => tr('II trimestre'),
|
||||
'thirdThreemester' => tr('III trimestre'),
|
||||
'fourthThreemester' => tr('IV trimestre'),
|
||||
'firstSemester' => tr('I semestre'),
|
||||
'secondSemester' => tr('II semestre'),
|
||||
'thisMonth' => tr('Questo mese'),
|
||||
'lastMonth' => tr('Mese scorso'),
|
||||
'thisYear' => tr("Quest'anno"),
|
||||
@ -161,8 +164,12 @@ if (Auth::check()) {
|
||||
</a>
|
||||
|
||||
<div class="input-group btn-calendar pull-left">
|
||||
<button id="daterange" class="btn"><i class="fa fa-calendar" style="color:'.$calendar.'"></i> <i class="fa fa-caret-down"></i></button>
|
||||
</div>
|
||||
<button id="daterange" class="btn"><i class="fa fa-calendar" style="color:'.$calendar.'"></i> <i class="fa fa-caret-down"></i></button>
|
||||
<span class="hidden-xs" style="vertical-align:middle">
|
||||
'.Translator::dateToLocale($_SESSION['period_start']).' - '.Translator::dateToLocale($_SESSION['period_end']).'
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="right-menu" class="pull-right">
|
||||
<button onclick="window.print()" class="btn btn-sm btn-info tip" title="'.tr('Stampa').'">
|
||||
|
@ -45,9 +45,12 @@ $(document).ready(function () {
|
||||
// Calendario principale
|
||||
ranges = {};
|
||||
ranges[globals.translations.today] = [moment(), moment()];
|
||||
ranges[globals.translations.yesterday] = [moment().subtract(1, 'days'), moment().subtract(1, 'days')];
|
||||
ranges[globals.translations.last7Days] = [moment().subtract(6, 'days'), moment()];
|
||||
ranges[globals.translations.last30Days] = [moment().subtract(29, 'days'), moment()];
|
||||
ranges[globals.translations.firstThreemester] = [moment("01", "MM"), moment("03", "MM").endOf('month')];
|
||||
ranges[globals.translations.secondThreemester] = [moment("04", "MM"), moment("06", "MM").endOf('month')];
|
||||
ranges[globals.translations.thirdThreemester] = [moment("07", "MM"), moment("09", "MM").endOf('month')];
|
||||
ranges[globals.translations.fourthThreemester] = [moment("10", "MM"), moment("12", "MM").endOf('month')];
|
||||
ranges[globals.translations.firstSemester] = [moment("01", "MM"), moment("06", "MM").endOf('month')];
|
||||
ranges[globals.translations.secondSemester] = [moment("06", "MM"), moment("12", "MM").endOf('month')];
|
||||
ranges[globals.translations.thisMonth] = [moment().startOf('month'), moment().endOf('month')];
|
||||
ranges[globals.translations.lastMonth] = [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')];
|
||||
ranges[globals.translations.thisYear] = [moment().startOf('year'), moment().endOf('year')];
|
||||
|
@ -38,7 +38,8 @@ switch (post('op')) {
|
||||
'idpagamento_vendite' => $post['idpagamento_vendite'],
|
||||
'idlistino_acquisti' => $post['idlistino_acquisti'],
|
||||
'idlistino_vendite' => $post['idlistino_vendite'],
|
||||
'idiva' => $post['idiva'],
|
||||
'idiva_acquisti' => $post['idiva_acquisti'],
|
||||
'idiva_vendite' => $post['idiva_vendite'],
|
||||
'settore' => $post['settore'],
|
||||
'marche' => $post['marche'],
|
||||
'dipendenti' => $post['dipendenti'],
|
||||
|
@ -148,42 +148,46 @@ if ($cliente || $fornitore) {
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="row">
|
||||
<?php
|
||||
if ($fornitore) {
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Pagamento predefinito per acquisti'); ?>", "name": "idpagamento_acquisti", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC", "value": "$idpagamento_acquisti$" ]}
|
||||
{[ "type": "select", "label": "<?php echo tr('Pagamento predefinito (per acquisti)'); ?>", "name": "idpagamento_acquisti", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC", "value": "$idpagamento_acquisti$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Listino articoli (per acquisti)'); ?>", "name": "idlistino_acquisti", "values": "query=SELECT id, nome AS descrizione FROM mg_listini ORDER BY nome ASC", "value": "$idlistino_acquisti$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Iva predefinita (per acquisti)'); ?>", "name": "idiva_acquisti", "values": "query=SELECT id, descrizione FROM co_iva ORDER BY descrizione ASC", "value": "$idiva_acquisti$" ]}
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
if ($cliente) {
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Pagamento predefinito per vendite'); ?>", "name": "idpagamento_vendite", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC", "value": "$idpagamento_vendite$" ]}
|
||||
{[ "type": "select", "label": "<?php echo tr('Pagamento predefinito (per vendite)'); ?>", "name": "idpagamento_vendite", "values": "query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC", "value": "$idpagamento_vendite$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Listino articoli (per vendite)'); ?>", "name": "idlistino_vendite", "values": "query=SELECT id, nome AS descrizione FROM mg_listini ORDER BY nome ASC", "value": "$idlistino_vendite$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Iva predefinita (per vendite)'); ?>", "name": "idiva_vendite", "values": "query=SELECT id, descrizione FROM co_iva ORDER BY descrizione ASC", "value": "$idiva_vendite$" ]}
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
} ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Iva predefinita'); ?>", "name": "idiva", "values": "query=SELECT id, descrizione FROM co_iva ORDER BY descrizione ASC", "value": "$idiva$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
{[ "type": "select", "label": "<?php echo tr('Indirizzo di fatturazione'); ?>", "name": "idsede_fatturazione", "values": "query=SELECT id, CONCAT_WS(', ', nomesede, citta) AS descrizione FROM an_sedi WHERE idanagrafica='$id_record' UNION SELECT '0' AS id, 'Sede legale' AS descrizione ORDER BY descrizione", "value": "$idsede_fatturazione$" ]}
|
||||
</div>
|
||||
|
@ -55,14 +55,9 @@ echo '
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Nelle fatture di acquisto leggo l'iva di acquisto dal fornitore
|
||||
if ($dir == 'uscita') {
|
||||
$rsf = $dbo->fetchArray('SELECT idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $rsf[0]['idiva'];
|
||||
}
|
||||
|
||||
// Leggo l'iva predefinita dall'articolo e se non c'è leggo quella predefinita generica
|
||||
$idiva = $idiva ?: get_var('Iva predefinita');
|
||||
// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica
|
||||
$iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $iva[0]['idiva'] ?: get_var('Iva predefinita');
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
|
@ -376,32 +376,6 @@ switch (post('op')) {
|
||||
$costi_intervento = get_costi_intervento($idintervento);
|
||||
$prezzo = $costi_intervento['manodopera_scontato'] + $costi_intervento['viaggio_scontato'];
|
||||
|
||||
// Aggiunta sconto
|
||||
if (!empty($costi_intervento['sconto_globale'])) {
|
||||
$subtot = $costi_intervento['sconto_globale'];
|
||||
|
||||
// Calcolo iva
|
||||
$query = 'SELECT * FROM co_iva WHERE id='.prepare($idiva);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$desc_iva = $rs[0]['descrizione'];
|
||||
|
||||
$iva = ($subtot) / 100 * $rs[0]['percentuale'];
|
||||
$iva_indetraibile = $iva / 100 * $rs[0]['indetraibile'];
|
||||
|
||||
// Calcolo rivalsa inps
|
||||
$query = 'SELECT * FROM co_rivalsainps WHERE id='.prepare(get_var('Percentuale rivalsa INPS'));
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$rivalsainps = ($subtot) / 100 * $rs[0]['percentuale'];
|
||||
|
||||
// Calcolo ritenuta d'acconto
|
||||
$query = 'SELECT * FROM co_ritenutaacconto WHERE id='.prepare(get_var("Percentuale ritenuta d'acconto"));
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$ritenutaacconto = ($subtot + $rivalsainps) / 100 * $rs[0]['percentuale'];
|
||||
|
||||
$query = 'INSERT INTO co_righe_documenti(iddocumento, idintervento, idconto, idiva, desc_iva, iva, iva_indetraibile, descrizione, subtotale, qta, idrivalsainps, rivalsainps, idritenutaacconto, ritenutaacconto, `order`) VALUES('.prepare($id_record).', NULL, '.prepare($idconto).', '.prepare($idiva).', '.prepare($desc_iva).', '.prepare($iva).', '.prepare($iva_indetraibile).', '.prepare('Sconto '.$descrizione).', '.prepare($subtot).', 1, '.prepare(get_var('Percentuale rivalsa INPS')).', '.prepare($rivalsainps).', '.prepare(get_var("Percentuale ritenuta d'acconto")).', '.prepare($ritenutaacconto).', (SELECT IFNULL(MAX(`order`) + 1, 0) FROM co_righe_documenti AS t WHERE iddocumento='.prepare($id_record).'))';
|
||||
$dbo->query($query);
|
||||
}
|
||||
|
||||
// Calcolo iva
|
||||
$query = 'SELECT * FROM co_iva WHERE id='.prepare($idiva);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
@ -424,6 +398,32 @@ switch (post('op')) {
|
||||
// Aggiunta riga intervento sul documento
|
||||
$query = 'INSERT INTO co_righe_documenti(iddocumento, idintervento, idconto, idiva, desc_iva, iva, iva_indetraibile, descrizione, subtotale, um, qta, idrivalsainps, rivalsainps, idritenutaacconto, ritenutaacconto, `order`) VALUES('.prepare($id_record).', '.prepare($idintervento).', '.prepare($idconto).', '.prepare($idiva).', '.prepare($desc_iva).', '.prepare($iva).', '.prepare($iva_indetraibile).', '.prepare($descrizione).', '.prepare($subtot).", '-', ".prepare($qta).', '.prepare(get_var('Percentuale rivalsa INPS')).', '.prepare($rivalsainps).', '.prepare(get_var("Percentuale ritenuta d'acconto")).', '.prepare($ritenutaacconto).', (SELECT IFNULL(MAX(`order`) + 1, 0) FROM co_righe_documenti AS t WHERE iddocumento='.prepare($id_record).'))';
|
||||
if ($dbo->query($query)) {
|
||||
// Aggiunta sconto
|
||||
if (!empty($costi_intervento['sconto_globale'])) {
|
||||
$subtot = $costi_intervento['sconto_globale'];
|
||||
|
||||
// Calcolo iva
|
||||
$query = 'SELECT * FROM co_iva WHERE id='.prepare($idiva);
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$desc_iva = $rs[0]['descrizione'];
|
||||
|
||||
$iva = ($subtot) / 100 * $rs[0]['percentuale'];
|
||||
$iva_indetraibile = $iva / 100 * $rs[0]['indetraibile'];
|
||||
|
||||
// Calcolo rivalsa inps
|
||||
$query = 'SELECT * FROM co_rivalsainps WHERE id='.prepare(get_var('Percentuale rivalsa INPS'));
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$rivalsainps = ($subtot) / 100 * $rs[0]['percentuale'];
|
||||
|
||||
// Calcolo ritenuta d'acconto
|
||||
$query = 'SELECT * FROM co_ritenutaacconto WHERE id='.prepare(get_var("Percentuale ritenuta d'acconto"));
|
||||
$rs = $dbo->fetchArray($query);
|
||||
$ritenutaacconto = ($subtot + $rivalsainps) / 100 * $rs[0]['percentuale'];
|
||||
|
||||
$query = 'INSERT INTO co_righe_documenti(iddocumento, idintervento, idconto, idiva, desc_iva, iva, iva_indetraibile, descrizione, subtotale, qta, idrivalsainps, rivalsainps, idritenutaacconto, ritenutaacconto, `order`) VALUES('.prepare($id_record).', NULL, '.prepare($idconto).', '.prepare($idiva).', '.prepare($desc_iva).', '.prepare($iva).', '.prepare($iva_indetraibile).', '.prepare('Sconto '.$descrizione).', '.prepare($subtot).', 1, '.prepare(get_var('Percentuale rivalsa INPS')).', '.prepare($rivalsainps).', '.prepare(get_var("Percentuale ritenuta d'acconto")).', '.prepare($ritenutaacconto).', (SELECT IFNULL(MAX(`order`) + 1, 0) FROM co_righe_documenti AS t WHERE iddocumento='.prepare($id_record).'))';
|
||||
$dbo->query($query);
|
||||
}
|
||||
|
||||
// Ricalcolo inps, ritenuta e bollo
|
||||
if ($dir == 'entrata') {
|
||||
ricalcola_costiagg_fattura($id_record);
|
||||
|
@ -9,7 +9,6 @@ if ($module['name'] == 'Fatture di vendita') {
|
||||
$conti = 'conti-vendite';
|
||||
|
||||
$listino = 'idlistino_vendite';
|
||||
|
||||
} else {
|
||||
$dir = 'uscita';
|
||||
$conti = 'conti-acquisti';
|
||||
@ -64,14 +63,9 @@ echo '
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Nelle fatture di acquisto leggo l'iva di acquisto dal fornitore
|
||||
if ($dir == 'uscita') {
|
||||
$rsf = $dbo->fetchArray('SELECT idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $rsf[0]['idiva'];
|
||||
}
|
||||
|
||||
// Leggo l'iva predefinita dall'articolo e se non c'è leggo quella predefinita generica
|
||||
$idiva = $idiva ?: get_var('Iva predefinita');
|
||||
// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica
|
||||
$iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $iva[0]['idiva'] ?: get_var('Iva predefinita');
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
|
@ -63,14 +63,9 @@ if (get_var('Percentuale rivalsa INPS') != '' || get_var("Percentuale ritenuta d
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Nelle fatture di acquisto leggo l'iva di acquisto dal fornitore
|
||||
if ($dir == 'uscita') {
|
||||
$rsf = $dbo->fetchArray('SELECT idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva_predefinita = $rsf[0]['idiva'];
|
||||
}
|
||||
|
||||
// Leggo l'iva predefinita dall'articolo e se non c'è leggo quella predefinita generica
|
||||
$idiva = $idiva ?: get_var('Iva predefinita');
|
||||
// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica
|
||||
$iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $iva[0]['idiva'] ?: get_var('Iva predefinita');
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
|
@ -130,7 +130,7 @@ switch (post('op')) {
|
||||
'km' => $km,
|
||||
|
||||
'prezzo_ore_unitario' => $prezzo_ore_unitario,
|
||||
'prezzo_km_unitario' => $prezzo_km_unitari,
|
||||
'prezzo_km_unitario' => $prezzo_km_unitario,
|
||||
'prezzo_dirittochiamata' => $prezzo_dirittochiamata,
|
||||
'prezzo_ore_unitario_tecnico' => $prezzo_ore_unitario_tecnico,
|
||||
'prezzo_km_unitario_tecnico' => $prezzo_km_unitario_tecnico,
|
||||
|
@ -39,7 +39,7 @@ if ($user['gruppo'] == 'Tecnici') {
|
||||
$rss = $dbo->fetchArray('SELECT idtipointervento FROM in_interventi WHERE id='.prepare($id_record));
|
||||
$idtipointervento = $rs[0]['idtipointervento'];
|
||||
|
||||
$query = 'SELECT * FROM an_anagrafiche JOIN in_interventi_tecnici ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica WHERE deleted=0 AND idintervento='.prepare($id_record)." AND idanagrafica IN (SELECT idanagrafica FROM an_tipianagrafiche_anagrafiche WHERE idtipoanagrafica = (SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione = 'Tecnico')) ORDER BY ragione_sociale ASC, in_interventi_tecnici.orario_inizio ASC";
|
||||
$query = 'SELECT * FROM an_anagrafiche JOIN in_interventi_tecnici ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica WHERE deleted=0 AND idintervento='.prepare($id_record)." AND idanagrafica IN (SELECT idanagrafica FROM an_tipianagrafiche_anagrafiche WHERE idtipoanagrafica = (SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione = 'Tecnico')) ORDER BY ragione_sociale ASC, in_interventi_tecnici.orario_inizio ASC, in_interventi_tecnici.id ASC";
|
||||
$rs2 = $dbo->fetchArray($query);
|
||||
$prev_tecnico = '';
|
||||
|
||||
@ -49,9 +49,11 @@ if (!empty($rs2)) {
|
||||
|
||||
// Intestazione tecnico
|
||||
if ($prev_tecnico != $r['ragione_sociale']) {
|
||||
$prev_tecnico = $r['ragione_sociale'];
|
||||
|
||||
echo '
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover table-condensed '.$class_tecnico.'">
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th><i class="fa fa-user"></i> '.$r['ragione_sociale'].'</th>
|
||||
<th>'.tr('Orario inizio').'</th>
|
||||
@ -108,7 +110,7 @@ if (!empty($rs2)) {
|
||||
<input type="hidden" name="prezzo_dirittochiamata_tecnico['.$id.']" value="'.$costo_dirittochiamata_tecnico.'" />';
|
||||
|
||||
echo '
|
||||
<tr class="'.$class_tecnico.'">
|
||||
<tr>
|
||||
<td class="tecn_'.$r['idtecnico'].'">';
|
||||
|
||||
if ($rs[0]['stato'] != 'Fatturato') {
|
||||
|
@ -124,6 +124,13 @@ function add_tecnico($idintervento, $idtecnico, $inizio, $fine, $idcontratto)
|
||||
}
|
||||
}
|
||||
|
||||
// Azzeramento forzato del diritto di chiamata nel caso questa non sia la prima sessione dell'intervento per il giorno di inizio [Luca]
|
||||
$rs = $dbo->fetchArray('SELECT id FROM in_interventi_tecnici WHERE (DATE(orario_inizio)=DATE('.prepare($inizio).') OR DATE(orario_fine)=DATE('.prepare($inizio).')) AND idintervento='.prepare($idintervento));
|
||||
if (!empty($rs)) {
|
||||
$costo_dirittochiamata_tecnico = 0;
|
||||
$costo_dirittochiamata = 0;
|
||||
}
|
||||
|
||||
// Inserisco le ore dei tecnici nella tabella "in_interventi_tecnici"
|
||||
$dbo->insert('in_interventi_tecnici', [
|
||||
'idintervento' => $idintervento,
|
||||
|
@ -56,14 +56,9 @@ echo '
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
// Nelle fatture di acquisto leggo l'iva di acquisto dal fornitore
|
||||
if ($dir == 'uscita') {
|
||||
$rsf = $dbo->fetchArray('SELECT idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva_predefinita = $rsf[0]['idiva'];
|
||||
}
|
||||
|
||||
// Leggo l'iva predefinita dall'articolo e se non c'è leggo quella predefinita generica
|
||||
$idiva = $idiva ?: get_var('Iva predefinita');
|
||||
// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica
|
||||
$iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $iva[0]['idiva'] ?: get_var('Iva predefinita');
|
||||
|
||||
// Iva
|
||||
echo '
|
||||
|
@ -29,14 +29,9 @@ if (empty($idriga)) {
|
||||
$prezzo = 0;
|
||||
$sconto = 0;
|
||||
|
||||
// Nelle fatture di acquisto leggo l'iva di acquisto dal fornitore
|
||||
if ($dir == 'uscita') {
|
||||
$rsf = $dbo->fetchArray('SELECT idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $rsf[0]['idiva'];
|
||||
}
|
||||
|
||||
// Leggo l'iva predefinita dall'articolo e se non c'è leggo quella predefinita generica
|
||||
$idiva = $idiva ?: get_var('Iva predefinita');
|
||||
// Leggo l'iva predefinita per l'anagrafica e se non c'è leggo quella predefinita generica
|
||||
$iva = $dbo->fetchArray('SELECT idiva_'.($dir == 'uscita' ? 'acquisti' : 'vendite').' AS idiva FROM an_anagrafiche WHERE idanagrafica='.prepare($idanagrafica));
|
||||
$idiva = $iva[0]['idiva'] ?: get_var('Iva predefinita');
|
||||
} else {
|
||||
$op = 'editriga';
|
||||
$button = tr('Modifica');
|
||||
|
@ -64,15 +64,15 @@ if (!empty($rsi)) {
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['manodopera_costo']).'
|
||||
'.Translator::numberToLocale($int['manodopera_costo'] + $int['viaggio_costo']).'
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['manodopera_addebito']).'
|
||||
'.Translator::numberToLocale($int['manodopera_addebito'] + $int['viaggio_addebito']).'
|
||||
</td>
|
||||
|
||||
<td class="text-right">
|
||||
'.Translator::numberToLocale($int['manodopera_scontato']).'
|
||||
'.Translator::numberToLocale($int['manodopera_scontato'] + $int['viaggio_scontato']).'
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
@ -197,9 +197,9 @@ if (!empty($rsi)) {
|
||||
|
||||
$totale_ore += $int['ore'];
|
||||
$totale_km += $int['km'];
|
||||
$totale_costo += $int['manodopera_costo'];
|
||||
$totale_addebito += $int['manodopera_addebito'];
|
||||
$totale_scontato += $int['manodopera_scontato'];
|
||||
$totale_costo += $int['manodopera_costo'] + $int['viaggio_costo'];
|
||||
$totale_addebito += $int['manodopera_addebito'] + $int['viaggio_addebito'];
|
||||
$totale_scontato += $int['manodopera_scontato'] + $int['viaggio_scontato'];
|
||||
}
|
||||
|
||||
// Totali
|
||||
|
26
modules/stampe_contabili/edit.php
Normal file
26
modules/stampe_contabili/edit.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
echo '
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">'.tr('Registri iva').'</h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<a class="btn btn-primary btn-block" href="'.$rootdir.'/pdfgen.php?ptype=registro_iva&dir=entrata" target="_blank">
|
||||
<i class="fa fa-print"></i> '.tr('Stampa registro iva vendite').'
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<a class="btn btn-primary btn-block" href="'.$rootdir.'/pdfgen.php?ptype=registro_iva&dir=uscita" target="_blank">
|
||||
<i class="fa fa-print"></i> '.tr('Stampa registro iva acquisti').'
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
BIN
templates/registro_iva/logo_azienda.jpg
Normal file
BIN
templates/registro_iva/logo_azienda.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
154
templates/registro_iva/pdfgen.registro_iva.php
Normal file
154
templates/registro_iva/pdfgen.registro_iva.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
//carica report html
|
||||
$report = file_get_contents($docroot.'/templates/registro_iva/registroiva.html');
|
||||
$body = file_get_contents($docroot.'/templates/registro_iva/registroiva_body.html');
|
||||
|
||||
include_once __DIR__.'/../pdfgen_variables.php';
|
||||
|
||||
$dir = $_GET['dir'];
|
||||
$periodo = $_GET['periodo'];
|
||||
|
||||
$v_iva = [];
|
||||
$v_totale = [];
|
||||
|
||||
$totale_iva = 0;
|
||||
$totale_subtotale = 0;
|
||||
|
||||
$date_start = $_SESSION['period_start'];
|
||||
$date_end = $_SESSION['period_end'];
|
||||
|
||||
/*
|
||||
$periodo = explode('-', $periodo);
|
||||
|
||||
switch ($periodo[0]) {
|
||||
//anno
|
||||
case 'Y':
|
||||
$date_start = $periodo[2].'-01-01';
|
||||
$date_end = $periodo[2].'-12-31';
|
||||
break;
|
||||
//mese
|
||||
case 'M':
|
||||
$date_start = $periodo[2].'-'.$periodo[1].'-01';
|
||||
$date_end = date('Y-m-t', strtotime($date_start));
|
||||
break;
|
||||
//trimestre
|
||||
case 'T':
|
||||
$date_start = $periodo[2].'-'.$periodo[1].'-01';
|
||||
$date_end = date('Y-m-t', strtotime('+2 months', strtotime($date_start)));
|
||||
break;
|
||||
//semestre
|
||||
case 'S':
|
||||
$date_start = $periodo[2].'-'.$periodo[1].'-01';
|
||||
$date_end = date('Y-m-t', strtotime('+5 months', strtotime($date_start)));
|
||||
break;
|
||||
}*/
|
||||
|
||||
if ($dir == 'entrata') {
|
||||
$query = "SELECT *, SUM(subtotale-co_righe_documenti.sconto) AS subtotale, SUM(iva) AS iva, (SELECT ragione_sociale FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=co_documenti.idanagrafica) AS ragione_sociale FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE dir='entrata' AND co_documenti.data>='".$date_start."' AND co_documenti.data<='".$date_end."' GROUP BY co_documenti.id, co_righe_documenti.idiva";
|
||||
} elseif ($dir == 'uscita') {
|
||||
$query = "SELECT *, SUM(subtotale-co_righe_documenti.sconto) AS subtotale, SUM(iva) AS iva, (SELECT ragione_sociale FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=co_documenti.idanagrafica) AS ragione_sociale FROM co_documenti INNER JOIN co_righe_documenti ON co_documenti.id=co_righe_documenti.iddocumento INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE dir='uscita' AND co_documenti.data>='".$date_start."' AND co_documenti.data<='".$date_end."' GROUP BY co_documenti.id, co_righe_documenti.idiva";
|
||||
}
|
||||
|
||||
$rs = $dbo->fetchArray($query);
|
||||
|
||||
if ($dir == 'entrata') {
|
||||
$body .= "<span style='font-size:15pt; margin-left:6px;'><b>REGISTRO IVA VENDITA</b></span><br><br>";
|
||||
} elseif ($dir == 'uscita') {
|
||||
$body .= "<span style='font-size:15pt; margin-left:6px;'><b>REGISTRO IVA ACQUISTO</b></span><br><br>";
|
||||
}
|
||||
|
||||
$body .= "
|
||||
<table cellspacing='0' style='table-layout:fixed;'>
|
||||
<col width='40'><col width='100'><col width='100'><col width='362'><col width='160'><col width='90'><col width='90'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Prot.</th>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Data</th>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>N° Documento</th>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Causale<br>Ragione sociale</th>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Aliquota</th>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Imponibile</th>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Imposta</th>
|
||||
</tr>
|
||||
</thead>
|
||||
";
|
||||
|
||||
for ($i = 0; $i < sizeof($rs); ++$i) {
|
||||
$body .= '<tr>';
|
||||
if ($rs[$i]['numero'] == $rs[$i - 1]['numero']) {
|
||||
$body .= " <td class='first_cell cell-padded text-center'></td>";
|
||||
$body .= " <td class='table_cell cell-padded text-center'></td>";
|
||||
} else {
|
||||
$body .= " <td class='first_cell cell-padded text-center'>".$rs[$i]['numero'].'</td>';
|
||||
$body .= " <td class='table_cell cell-padded text-center'>".date('d/m/Y', strtotime($rs[$i]['data'])).'</td>';
|
||||
}
|
||||
$body .= " <td class='table_cell cell-padded text-center'>".$rs[$i]['numero_esterno'].'</td>';
|
||||
if ($dir == 'entrata') {
|
||||
$body .= "<td class='table_cell cell-padded'>
|
||||
Fattura di vendita<br>
|
||||
".$rs[$i]['ragione_sociale'].'
|
||||
</td>';
|
||||
} elseif ($dir == 'uscita') {
|
||||
$body .= "<td class='table_cell cell-padded'>
|
||||
Fattura di acquisto<br>
|
||||
".$rs[$i]['ragione_sociale'].'
|
||||
</td>';
|
||||
}
|
||||
$body .= " <td class='table_cell cell-padded'>".$rs[$i]['desc_iva'].'</td>';
|
||||
$body .= " <td class='table_cell cell-padded text-right'>".Translator::numberToLocale($rs[$i]['subtotale'], 2).' €</td>';
|
||||
$body .= " <td class='table_cell cell-padded text-right'>".Translator::numberToLocale($rs[$i]['iva'], 2).' €</td>';
|
||||
$body .= '</tr>';
|
||||
|
||||
$v_iva[$rs[$i]['desc_iva']] += $rs[$i]['iva'];
|
||||
$v_totale[$rs[$i]['desc_iva']] += $rs[$i]['subtotale'];
|
||||
|
||||
$totale_iva += $rs[$i]['iva'];
|
||||
$totale_subtotale += $rs[$i]['subtotale'];
|
||||
}
|
||||
|
||||
$body .= '
|
||||
</table>
|
||||
';
|
||||
|
||||
$body .= "<br><br><span style='font-size:12pt; margin-left:6px;'><b>RIEPILOGO IVA</b></span><br><br>";
|
||||
|
||||
$body .= "
|
||||
<table cellspacing='0' style='table-layout:fixed;'>
|
||||
<col width='140'><col width='90'><col width='90'>
|
||||
<tr>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Cod. IVA</th>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Imponibile</th>
|
||||
<th bgcolor='#dddddd' class='full_cell1 cell-padded'>Imposta</th>
|
||||
|
||||
</tr>
|
||||
";
|
||||
|
||||
foreach ($v_iva as $desc_iva => $tot_iva) {
|
||||
if ($desc_iva != '') {
|
||||
$body .= "<tr><td valign='top' class='first_cell cell-padded'>\n";
|
||||
$body .= $desc_iva."\n";
|
||||
$body .= "</td>\n";
|
||||
|
||||
$body .= "<td valign='top' align='right' class='table_cell cell-padded'>\n";
|
||||
$body .= Translator::numberToLocale($v_totale[$desc_iva], 2)." €\n";
|
||||
$body .= "</td>\n";
|
||||
|
||||
$body .= "<td valign='top' align='right' class='table_cell cell-padded'>\n";
|
||||
$body .= Translator::numberToLocale($v_iva[$desc_iva], 2)." €\n";
|
||||
$body .= "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
$body .= " <tr bgcolor='#dddddd'>
|
||||
<td class='full_cell1 cell-padded text-right'><b>TOTALE</b></td>
|
||||
<td class='full_cell1 cell-padded text-right'>".Translator::numberToLocale($totale_subtotale, 2)." €</td>
|
||||
<td class='full_cell1 cell-padded text-right'>".Translator::numberToLocale($totale_iva, 2).' €</td>
|
||||
</tr>';
|
||||
|
||||
$body .= '
|
||||
</table>
|
||||
';
|
||||
|
||||
$orientation = 'L';
|
||||
$report_name = 'registro_iva.pdf';
|
59
templates/registro_iva/registroiva.html
Normal file
59
templates/registro_iva/registroiva.html
Normal file
@ -0,0 +1,59 @@
|
||||
<style>
|
||||
<!--
|
||||
.table_values td{
|
||||
border: 1px solid #888;
|
||||
padding: 4px;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.table_values th{
|
||||
background: #abbfcb;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.first_cell{
|
||||
border-left: 1px solid #aaa;
|
||||
border-right: 1px solid #aaa;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.table_cell{
|
||||
border-bottom: 1px solid #aaa;
|
||||
border-right: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.full_cell1{
|
||||
border: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.full_cell{
|
||||
border-top: 1px solid #aaa;
|
||||
border-right: 1px solid #aaa;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.text-center{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.text-right{
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.b-right{
|
||||
border-right: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.b-bottom{
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
.cell-padded{
|
||||
padding: 4px;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
|
||||
<page backcolor="#ffffff" backtop="40mm" backbottom="5mm" backleft="0mm" backright="0mm" footer="" style="font-size: $font_size$">
|
||||
$body$
|
||||
</page>
|
25
templates/registro_iva/registroiva_body.html
Normal file
25
templates/registro_iva/registroiva_body.html
Normal file
@ -0,0 +1,25 @@
|
||||
<page_header>
|
||||
|
||||
<br>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width:215mm;" align="left">
|
||||
<big>
|
||||
<big><big><b>$f_ragionesociale$</b></big></big>
|
||||
<p style="margin-left:4px; font-size:11px; line-height:12px;">
|
||||
$f_indirizzo$
|
||||
$f_citta$
|
||||
$f_piva$
|
||||
$f_codicefiscale$
|
||||
$f_capsoc$
|
||||
$f_telefono$
|
||||
</p>
|
||||
</big>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<img src="$docroot$/templates/fatture/logo_azienda.jpg" alt="Logo" style="width:60mm;" border="0">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
</page_header>
|
@ -757,9 +757,6 @@ INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`,
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), '_link_record_', 'mg_movimenti.idarticolo', 7, 1, 0, 0, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Movimenti'), '_link_hash_', 'CONCAT(\'tab_\', (SELECT `id` FROM `zz_plugins` WHERE `name` = \'Movimenti\' AND idmodule_to = (SELECT `id` FROM `zz_modules` WHERE `name` = \'Articoli\')))', 7, 1, 0, 0, 1);
|
||||
|
||||
-- Impostazione dei titoli di default
|
||||
UPDATE `zz_modules` SET `title` = `name` WHERE `title` = '';
|
||||
|
||||
-- Aggiunta del campo di dicitura fissa per la fatturazione
|
||||
ALTER TABLE `co_iva` ADD `dicitura` varchar(255);
|
||||
|
||||
@ -773,6 +770,11 @@ ALTER TABLE `an_anagrafiche` CHANGE `idlistino` `idlistino_vendite` int(11), ADD
|
||||
UPDATE `an_anagrafiche` SET `idlistino_vendite` = NULL WHERE `idlistino_vendite` = 0;
|
||||
UPDATE `an_anagrafiche` SET `idlistino_acquisti` = `idlistino_vendite` WHERE `idlistino_vendite` IS NOT NULL;
|
||||
|
||||
-- Miglioramento della gestione dell'iva predefinita
|
||||
ALTER TABLE `an_anagrafiche` CHANGE `idiva` `idiva_vendite` int(11), ADD `idiva_acquisti` int(11) AFTER `idiva_vendite`;
|
||||
UPDATE `an_anagrafiche` SET `idiva_vendite` = NULL WHERE `idiva_vendite` = 0;
|
||||
UPDATE `an_anagrafiche` SET `idiva_acquisti` = `idiva_vendite` WHERE `idiva_vendite` IS NOT NULL;
|
||||
|
||||
-- Rimozione data_sla e ora_sla
|
||||
ALTER TABLE `in_interventi` DROP `data_sla`, DROP `ora_sla`;
|
||||
|
||||
@ -933,3 +935,10 @@ UPDATE `co_iva` SET `dicitura` = 'Operazione soggetta a reverse charge ex art. 1
|
||||
|
||||
-- Aggiunta campi in co_pagamenti per la selezione del conto di default
|
||||
ALTER TABLE `co_pagamenti` ADD `idconto_vendite` int(11), ADD `idconto_acquisti` int(11);
|
||||
|
||||
-- Aggiunta del modulo Stampe contabili
|
||||
INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Stampe contabili', 'stampe_contabili', 'custom', '', 'fa fa-angle-right', '2.3', '2.3', '1', 1, '1', '1');
|
||||
UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Stampe contabili' AND `t2`.`name` = 'Contabilità') SET `t1`.`parent` = `t2`.`id`;
|
||||
|
||||
-- Impostazione dei titoli di default
|
||||
UPDATE `zz_modules` SET `title` = `name` WHERE `title` = '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user