From e2d451e0f09a305a1b33cb3871b744c729b4e520 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 29 Jan 2019 18:54:32 +0100 Subject: [PATCH] Fattura per conto terzi --- modules/anagrafiche/edit.php | 2 +- modules/fatture/actions.php | 2 +- modules/fatture/edit.php | 2 +- modules/fatture/variables.php | 3 +++ plugins/exportFE/src/FatturaElettronica.php | 14 +++++++++++--- plugins/sedi/edit.php | 2 +- update/2_4_6.sql | 5 ++++- 7 files changed, 22 insertions(+), 8 deletions(-) diff --git a/modules/anagrafiche/edit.php b/modules/anagrafiche/edit.php index c4fb10726..0c726c60d 100644 --- a/modules/anagrafiche/edit.php +++ b/modules/anagrafiche/edit.php @@ -152,7 +152,7 @@ if (!$cliente) {
- {[ "type": "select", "label": "", "name": "id_nazione", "values": "query=SELECT id AS id, nome AS descrizione FROM an_nazioni ORDER BY nome ASC", "value": "$id_nazione$" ]} + {[ "type": "select", "label": "", "name": "id_nazione", "values": "query=SELECT id AS id, CONCAT_WS(' - ', iso2, nome) AS descrizione FROM an_nazioni ORDER BY nome ASC", "value": "$id_nazione$" ]}
diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php index f6eee76f3..4ad1a8338 100644 --- a/modules/fatture/actions.php +++ b/modules/fatture/actions.php @@ -81,7 +81,7 @@ switch (post('op')) { 'idsede' => post('idsede'), 'idconto' => post('idconto'), 'split_payment' => post('split_payment') ?: 0, - + 'is_fattura_conto_terzi' => post('is_fattura_conto_terzi') ?: 0, 'n_colli' => post('n_colli'), 'tipo_resa' => post('tipo_resa'), 'bollo' => 0, diff --git a/modules/fatture/edit.php b/modules/fatture/edit.php index 501f2a3a4..c0458c973 100644 --- a/modules/fatture/edit.php +++ b/modules/fatture/edit.php @@ -124,7 +124,7 @@ if (empty($record['is_fiscale'])) { if ($dir == 'entrata') { ?> - {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "ajax-source": "clienti", "help": "", "value": "$idanagrafica$" ]} + {[ "type": "select", "label": "", "name": "idanagrafica", "required": 1, "ajax-source": "clienti", "help": "fetchOne('SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica = '.prepare(setting('Azienda predefinita')))['ragione_sociale']; ?>", "value": "$idanagrafica$" ]} diff --git a/modules/fatture/variables.php b/modules/fatture/variables.php index 2add53a0f..119afce29 100644 --- a/modules/fatture/variables.php +++ b/modules/fatture/variables.php @@ -7,6 +7,8 @@ $r = $dbo->fetchOne('SELECT co_documenti.*, (SELECT pec FROM zz_smtps WHERE zz_smtps.id='.prepare($template['id_smtp']).') AS is_pec FROM co_documenti INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica WHERE co_documenti.id='.prepare($id_record)); +$logo_azienda = str_replace(DOCROOT, ROOTDIR, App::filepath('templates/base|custom|/logo_azienda.jpg')); + // Variabili da sostituire return [ 'email' => $r['is_pec'] ? $r['pec'] : $r['email'], @@ -15,4 +17,5 @@ return [ 'numero' => empty($r['numero_esterno']) ? $r['numero'] : $r['numero_esterno'], 'note' => $r['note'], 'data' => Translator::dateToLocale($r['data']), + 'logo_azienda' => !empty($logo_azienda) ? '': '', ]; diff --git a/plugins/exportFE/src/FatturaElettronica.php b/plugins/exportFE/src/FatturaElettronica.php index d169702db..5be2f3a9b 100644 --- a/plugins/exportFE/src/FatturaElettronica.php +++ b/plugins/exportFE/src/FatturaElettronica.php @@ -483,9 +483,17 @@ class FatturaElettronica * @return array */ protected static function getCedentePrestatore($fattura) - { - $azienda = static::getAzienda(); - + { + + $documento = $fattura->getDocumento(); + + //Fattura per conto terzi + if ($documento['is_fattura_conto_terzi']){ + $azienda = $fattura->getCliente(); + }else{ + $azienda = static::getAzienda(); + } + $result = [ 'DatiAnagrafici' => static::getDatiAnagrafici($azienda, true), 'Sede' => static::getSede($azienda), diff --git a/plugins/sedi/edit.php b/plugins/sedi/edit.php index bf738ed3d..903544b20 100644 --- a/plugins/sedi/edit.php +++ b/plugins/sedi/edit.php @@ -55,7 +55,7 @@ echo '
- {[ "type": "select", "label": "'.tr('Nazione').'", "name": "id_nazione", "values": "query=SELECT `id`, `nome` AS `descrizione` FROM `an_nazioni` ORDER BY `descrizione` ASC", "value": "$id_nazione$" ]} + {[ "type": "select", "label": "'.tr('Nazione').'", "name": "id_nazione", "values": "query=SELECT `id`, CONCAT_WS(\' - \', `iso2`, `nome`) AS `descrizione` FROM `an_nazioni` ORDER BY `descrizione` ASC", "value": "$id_nazione$" ]}
diff --git a/update/2_4_6.sql b/update/2_4_6.sql index b981cbbda..403d354a4 100644 --- a/update/2_4_6.sql +++ b/update/2_4_6.sql @@ -54,4 +54,7 @@ ALTER TABLE `co_documenti` ADD `descrizione_stato_fe` TEXT NOT NULL AFTER `codic ALTER TABLE `co_documenti` ADD `data_stato_fe` TIMESTAMP NOT NULL AFTER `descrizione_stato_fe`; -- Rimozione iva eliminata -UPDATE `zz_settings` SET `tipo`='query=SELECT id, descrizione FROM `co_iva` WHERE deleted_at IS NULL ORDER BY descrizione ASC' WHERE `nome`='Iva predefinita'; \ No newline at end of file +UPDATE `zz_settings` SET `tipo`='query=SELECT id, descrizione FROM `co_iva` WHERE deleted_at IS NULL ORDER BY descrizione ASC' WHERE `nome`='Iva predefinita'; + +-- Flag fattura per conto terzi +ALTER TABLE `co_documenti` ADD `is_fattura_conto_terzi` BOOLEAN NOT NULL DEFAULT FALSE AFTER `split_payment`;