From 3eb36b0026d5427d356633c7891c61c1b1b312e2 Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Tue, 14 Feb 2023 12:15:02 +0100 Subject: [PATCH 1/7] Aggiunta impostazione per aggiornamento data emissione in base alla prima data disponibile --- modules/fatture/actions.php | 18 ++++++++++++++++-- update/2_4_40.sql | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php index 498b5c7d0..4d2dee8be 100755 --- a/modules/fatture/actions.php +++ b/modules/fatture/actions.php @@ -65,11 +65,27 @@ switch (post('op')) { case 'update': $stato = Stato::find(post('idstatodocumento')); $fattura->stato()->associate($stato); + $data = post('data'); $tipo = Tipo::find(post('idtipodocumento')); $fattura->tipo()->associate($tipo); + + if (setting('Imposta data emissione in base alla prima data disponibile') == 1) { + + $data_fattura_precedente = $dbo->fetchOne('SELECT max(data)as datamax FROM co_documenti WHERE idstatodocumento=3'); + + if ($stato->id == '3'){ + if ($data < $data_fattura_precedente['datamax']) { + $fattura->data = $data_fattura_precedente['datamax']; + $fattura->data_competenza = $data_fattura_precedente['datamax']; + } + } + } else { + $fattura->data = post('data'); + $fattura->data_competenza = post('data_competenza'); + } if ($dir == 'entrata') { $fattura->data_registrazione = post('data'); @@ -77,8 +93,6 @@ switch (post('op')) { $fattura->data_registrazione = post('data_registrazione'); } - $fattura->data_competenza = post('data_competenza'); - $fattura->numero_esterno = post('numero_esterno'); $fattura->note = post('note'); $fattura->note_aggiuntive = post('note_aggiuntive'); diff --git a/update/2_4_40.sql b/update/2_4_40.sql index 30f61e933..8cdfdeb1f 100644 --- a/update/2_4_40.sql +++ b/update/2_4_40.sql @@ -177,3 +177,6 @@ INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione` -- Aggiunta colonna KM in vista Attività INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `html_format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES ((SELECT id from zz_modules WHERE title = "Attività"), 'KM', 'sum(in_interventi_tecnici.km)', '29', '1', '0', '1', '0', NULL, NULL, '0', '1', '0'); + +-- Aggiunta impostazione data emissione automatica +INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, "Imposta data emissione in base alla prima data disponibile", '0', 'boolean', '1', 'Fatturazione', NULL, NULL); \ No newline at end of file From f7c05c4581be03eddfbe2db09df812306c9913eb Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Tue, 14 Feb 2023 12:23:52 +0100 Subject: [PATCH 2/7] fix minore --- update/2_4_40.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update/2_4_40.sql b/update/2_4_40.sql index 8cdfdeb1f..040ec071c 100644 --- a/update/2_4_40.sql +++ b/update/2_4_40.sql @@ -179,4 +179,4 @@ INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione` INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `html_format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES ((SELECT id from zz_modules WHERE title = "Attività"), 'KM', 'sum(in_interventi_tecnici.km)', '29', '1', '0', '1', '0', NULL, NULL, '0', '1', '0'); -- Aggiunta impostazione data emissione automatica -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, "Imposta data emissione in base alla prima data disponibile", '0', 'boolean', '1', 'Fatturazione', NULL, NULL); \ No newline at end of file +INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, "Imposta data emissione in base alla prima data disponibile", '0', 'boolean', '1', 'Fatturazione', NULL, 'Imposta data emissione del documento in ciclo attivo, in base alla prima data disponibile in relazione ai documenti già emessi'); \ No newline at end of file From b90e77b30582246af7614ac83d0b9a684dcf5c29 Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Tue, 14 Feb 2023 13:08:41 +0100 Subject: [PATCH 3/7] fix minore --- modules/fatture/actions.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php index 4d2dee8be..a229f3b63 100755 --- a/modules/fatture/actions.php +++ b/modules/fatture/actions.php @@ -72,13 +72,13 @@ switch (post('op')) { if (setting('Imposta data emissione in base alla prima data disponibile') == 1) { - - $data_fattura_precedente = $dbo->fetchOne('SELECT max(data)as datamax FROM co_documenti WHERE idstatodocumento=3'); - - if ($stato->id == '3'){ - if ($data < $data_fattura_precedente['datamax']) { - $fattura->data = $data_fattura_precedente['datamax']; - $fattura->data_competenza = $data_fattura_precedente['datamax']; + if ($dir == 'entrata') { + if ($stato->id == '3'){ + $data_fattura_precedente = $dbo->fetchOne('SELECT max(data)as datamax FROM co_documenti WHERE idstatodocumento=3'); + if ($data < $data_fattura_precedente['datamax']) { + $fattura->data = $data_fattura_precedente['datamax']; + $fattura->data_competenza = $data_fattura_precedente['datamax']; + } } } } else { From 1bb891f3b667371c2bf4e8afd9ae8fd033b48106 Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Tue, 14 Feb 2023 15:15:11 +0100 Subject: [PATCH 4/7] ottimizzazione codice --- modules/fatture/actions.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php index a229f3b63..42439cb19 100755 --- a/modules/fatture/actions.php +++ b/modules/fatture/actions.php @@ -19,6 +19,7 @@ include_once __DIR__.'/../../core.php'; +use Carbon\Carbon; use Modules\Anagrafiche\Anagrafica; use Modules\Anagrafiche\Tipo as TipoAnagrafica; use Modules\Articoli\Articolo as ArticoloOriginale; @@ -73,18 +74,25 @@ switch (post('op')) { if (setting('Imposta data emissione in base alla prima data disponibile') == 1) { if ($dir == 'entrata') { - if ($stato->id == '3'){ - $data_fattura_precedente = $dbo->fetchOne('SELECT max(data)as datamax FROM co_documenti WHERE idstatodocumento=3'); - if ($data < $data_fattura_precedente['datamax']) { + if ($stato->descrizione == 'Emessa'){ + $data_fattura_precedente = $dbo->fetchOne(' + SELECT + MAX(DATA) AS datamax + FROM + co_documenti + INNER JOIN co_statidocumento ON co_statidocumento.id = co_documenti.idstatodocumento + INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id + WHERE + co_statidocumento.descrizione = "Emessa" AND co_tipidocumento.dir="entrata"'); + if (Carbon::parse($data)->lessThan(Carbon::parse($data_fattura_precedente['datamax']))) { $fattura->data = $data_fattura_precedente['datamax']; $fattura->data_competenza = $data_fattura_precedente['datamax']; } } } } else { - - $fattura->data = post('data'); - $fattura->data_competenza = post('data_competenza'); + $fattura->data = post('data'); + $fattura->data_competenza = post('data_competenza'); } if ($dir == 'entrata') { From cabd93cc822f5e435e851de0775f65b909036b74 Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Tue, 14 Feb 2023 16:13:11 +0100 Subject: [PATCH 5/7] Ottimizzazione codice --- modules/fatture/actions.php | 33 ++++++++++++++------------------- modules/fatture/bulk.php | 25 +++++++++++++++++++++++++ update/2_4_40.sql | 2 +- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php index 42439cb19..0929bb15c 100755 --- a/modules/fatture/actions.php +++ b/modules/fatture/actions.php @@ -71,25 +71,20 @@ switch (post('op')) { $tipo = Tipo::find(post('idtipodocumento')); $fattura->tipo()->associate($tipo); - - if (setting('Imposta data emissione in base alla prima data disponibile') == 1) { - if ($dir == 'entrata') { - if ($stato->descrizione == 'Emessa'){ - $data_fattura_precedente = $dbo->fetchOne(' - SELECT - MAX(DATA) AS datamax - FROM - co_documenti - INNER JOIN co_statidocumento ON co_statidocumento.id = co_documenti.idstatodocumento - INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id - WHERE - co_statidocumento.descrizione = "Emessa" AND co_tipidocumento.dir="entrata"'); - if (Carbon::parse($data)->lessThan(Carbon::parse($data_fattura_precedente['datamax']))) { - $fattura->data = $data_fattura_precedente['datamax']; - $fattura->data_competenza = $data_fattura_precedente['datamax']; - } - } - } + $data_fattura_precedente = $dbo->fetchOne(' + SELECT + MAX(DATA) AS datamax + FROM + co_documenti + INNER JOIN co_statidocumento ON co_statidocumento.id = co_documenti.idstatodocumento + INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id + INNER JOIN zz_segments ON zz_segments.id = co_documenti.id_segment + WHERE + co_statidocumento.descrizione = "Emessa" AND co_tipidocumento.dir="entrata" AND co_documenti.id_segment='.$fattura->id_segment); + + if ((setting('Data emissione fattura automatica') == 1) && ($dir == 'entrata') && ($stato->descrizione == 'Emessa') && (Carbon::parse($data)->lessThan(Carbon::parse($data_fattura_precedente['datamax']))) && (!empty($data_fattura_precedente['datamax']))){ + $fattura->data = $data_fattura_precedente['datamax']; + $fattura->data_competenza = $data_fattura_precedente['datamax']; } else { $fattura->data = post('data'); $fattura->data_competenza = post('data_competenza'); diff --git a/modules/fatture/bulk.php b/modules/fatture/bulk.php index 6a69b8662..f0eb2590f 100755 --- a/modules/fatture/bulk.php +++ b/modules/fatture/bulk.php @@ -29,6 +29,7 @@ use Util\XML; use Util\Zip; use Modules\Fatture\Stato; use Plugins\ReceiptFE\Ricevuta; +use Carbon\Carbon; $anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita')); $stato_emessa = $dbo->selectOne('co_statidocumento', 'id', ['descrizione' => 'Emessa'])['id']; @@ -469,9 +470,33 @@ switch (post('op')) { ->get(); foreach ($fatture as $fattura) { + $data = $fattura->data; + $fattura = Fattura::find($fattura['id']); $stato_precedente = Stato::find($fattura->idstatodocumento); + $data_fattura_precedente = $dbo->fetchOne(' + SELECT + MAX(DATA) AS datamax + FROM + co_documenti + INNER JOIN co_statidocumento ON co_statidocumento.id = co_documenti.idstatodocumento + INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento = co_tipidocumento.id + INNER JOIN zz_segments ON zz_segments.id = co_documenti.id_segment + WHERE + co_statidocumento.descrizione = "Emessa" AND co_tipidocumento.dir="entrata" AND co_documenti.id_segment='.$fattura->id_segment); + + if ((setting('Data emissione fattura automatica') == 1) && ($dir == 'entrata') && (Carbon::parse($data)->lessThan(Carbon::parse($data_fattura_precedente['datamax']))) && (!empty($data_fattura_precedente['datamax']))){ + $fattura->data = $data_fattura_precedente['datamax']; + $fattura->data_competenza = $data_fattura_precedente['datamax']; + } + + if ($dir == 'entrata') { + $fattura->data_registrazione = post('data'); + } else { + $fattura->data_registrazione = post('data_registrazione'); + } + if ($stato_precedente->descrizione == 'Bozza' && $fattura->isFiscale()) { $fattura->stato()->associate($new_stato); $results = $fattura->save(); diff --git a/update/2_4_40.sql b/update/2_4_40.sql index 040ec071c..9985fba69 100644 --- a/update/2_4_40.sql +++ b/update/2_4_40.sql @@ -179,4 +179,4 @@ INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione` INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `html_format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES ((SELECT id from zz_modules WHERE title = "Attività"), 'KM', 'sum(in_interventi_tecnici.km)', '29', '1', '0', '1', '0', NULL, NULL, '0', '1', '0'); -- Aggiunta impostazione data emissione automatica -INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, "Imposta data emissione in base alla prima data disponibile", '0', 'boolean', '1', 'Fatturazione', NULL, 'Imposta data emissione del documento in ciclo attivo, in base alla prima data disponibile in relazione ai documenti già emessi'); \ No newline at end of file +INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES (NULL, "Data emissione fattura automatica", '0', 'boolean', '1', 'Fatturazione', NULL, "Impedisce l'emissione di fatture di vendita con data precedente alla data dell'ultima fattura emessa"); \ No newline at end of file From f9f00ee521d6fce946831f71c58b44620639b892 Mon Sep 17 00:00:00 2001 From: loviuz Date: Tue, 14 Feb 2023 23:43:30 +0100 Subject: [PATCH 6/7] Fix lingua datetime-picker --- gulpfile.js | 1 + src/App.php | 1 + 2 files changed, 2 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index ae9fe7d69..856a46387 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -365,6 +365,7 @@ function i18n() { return gulp.src([ config.nodeDirectory + '/**/{i18n,lang,locale,locales}/*.{js,json}', config.development + '/' + config.paths.js + '/i18n/**/*.{js,json}', + config.nodeDirectory + '/moment/min/locales.js', '!' + config.nodeDirectory + '/**/{src,plugins}/**', '!' + config.nodeDirectory + '/ckeditor4/**', '!' + config.nodeDirectory + '/summernote/**', diff --git a/src/App.php b/src/App.php index 13b0e9b8c..7cd07fa51 100755 --- a/src/App.php +++ b/src/App.php @@ -63,6 +63,7 @@ class App 'i18n/parsleyjs/|lang|.min.js', 'i18n/select2/|lang|.min.js', 'i18n/moment/|lang|.min.js', + 'i18n/locales.min.js', 'i18n/@fullcalendar/|lang|.min.js', ], ]; From 0c4881736859f7da12ec810075d74367b21aa8ba Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Wed, 15 Feb 2023 14:58:38 +0100 Subject: [PATCH 7/7] Fix #1170 --- modules/interventi/bulk.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/interventi/bulk.php b/modules/interventi/bulk.php index 0f66444b3..81422bf63 100755 --- a/modules/interventi/bulk.php +++ b/modules/interventi/bulk.php @@ -119,7 +119,7 @@ switch (post('op')) { // Se non c'è già una fattura appena creata per questo cliente, creo una fattura nuova if (empty($id_documento)) { if (!empty($accodare)) { - $documento = $dbo->fetchOne('SELECT co_documenti.id FROM co_documenti INNER JOIN co_statidocumento ON co_documenti.idstatodocumento = co_statidocumento.id WHERE co_statidocumento.descrizione = \'Bozza\' AND idanagrafica = '.prepare($id_anagrafica)); + $documento = $dbo->fetchOne('SELECT co_documenti.id FROM co_documenti INNER JOIN co_statidocumento ON co_documenti.idstatodocumento = co_statidocumento.id INNER JOIN co_tipidocumento ON co_tipidocumento.id = co_documenti.idtipodocumento INNER JOIN zz_segments ON zz_segments.id = co_documenti.id_segment WHERE co_statidocumento.descrizione = "Bozza" AND co_documenti.idanagrafica = '.$id_anagrafica.' AND co_tipidocumento.id='.$tipo_documento['id'].' AND co_documenti.id_segment = '.$id_segment); $id_documento = $documento['id']; $id_documento_cliente[$id_anagrafica] = $id_documento;