From 8f812f05c51636a17f1e4a1babc02c5f2ad8d369 Mon Sep 17 00:00:00 2001 From: Pek5892 Date: Fri, 28 Apr 2023 10:02:37 +0200 Subject: [PATCH] Fix riferimento fattura in vista Preventivi --- update/2_4_45.sql | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/update/2_4_45.sql b/update/2_4_45.sql index 54aeff63a..659691ae8 100644 --- a/update/2_4_45.sql +++ b/update/2_4_45.sql @@ -3,4 +3,25 @@ INSERT INTO `zz_imports` (`id`, `id_module`, `name`, `class`, `created_at`) VALU -- Modifica nomi colonne Totali UPDATE `zz_views` SET `name` = 'Totale documento' WHERE `name` = 'Totale ivato'; -UPDATE `zz_views` SET `name` = 'Imponibile' WHERE `name` = 'Totale'; \ No newline at end of file +UPDATE `zz_views` SET `name` = 'Imponibile' WHERE `name` = 'Totale'; + +-- Fix query Preventivi +UPDATE `zz_modules` SET `options` = " +SELECT + |select| +FROM + `co_preventivi` + LEFT JOIN `an_anagrafiche` ON `co_preventivi`.`idanagrafica` = `an_anagrafiche`.`idanagrafica` + LEFT JOIN `co_statipreventivi` ON `co_preventivi`.`idstato` = `co_statipreventivi`.`id` + LEFT JOIN (SELECT `idpreventivo`, SUM(`subtotale` - `sconto`) AS `totale_imponibile`, SUM(`subtotale` - `sconto` + `iva`) AS `totale` FROM `co_righe_preventivi` GROUP BY `idpreventivo`) AS righe ON `co_preventivi`.`id` = `righe`.`idpreventivo` + LEFT JOIN (SELECT `an_anagrafiche`.`idanagrafica`, `an_anagrafiche`.`ragione_sociale` AS nome FROM `an_anagrafiche`)AS agente ON `agente`.`idanagrafica`=`co_preventivi`.`idagente` + LEFT JOIN (SELECT GROUP_CONCAT(DISTINCT `co_documenti`.`numero_esterno` SEPARATOR ', ') AS `info`, `co_righe_documenti`.`original_document_id` AS `idpreventivo` FROM `co_documenti` INNER JOIN `co_righe_documenti` ON `co_documenti`.`id` = `co_righe_documenti`.`iddocumento` WHERE `original_document_type`='Modules\\\\Preventivi\\\\Preventivo' GROUP BY `idpreventivo`, `original_document_id`) AS `fattura` ON `fattura`.`idpreventivo` = `co_preventivi`.`id` +WHERE + 1=1 |segment(`co_preventivi`.`id_segment`)| |date_period(custom,'|period_start|' >= `data_bozza` AND '|period_start|' <= `data_conclusione`,'|period_end|' >= `data_bozza` AND '|period_end|' <= `data_conclusione`,`data_bozza` >= '|period_start|' AND `data_bozza` <= '|period_end|',`data_conclusione` >= '|period_start|' AND `data_conclusione` <= '|period_end|',`data_bozza` >= '|period_start|' AND `data_conclusione` = NULL)| AND `default_revision` = 1 +GROUP BY + `co_preventivi`.`id`, `fattura`.`info` +HAVING + 2=2 +ORDER BY + `co_preventivi`.`id` DESC" WHERE `name` = 'Preventivi'; +