@@ -638,6 +650,42 @@ if (empty($record['deleted_at'])) {
$("#lat").val(result.geometry.location.lat());
$("#lng").val(result.geometry.location.lng());
});
+
+ /* Campo nome e cognome*/
+ if ($('#ragione_sociale').val()!='' && $('#ragione_sociale').val() != $('#nome').val()+' '+$('#cognome').val()){
+ $('#nome').prop('disabled', true);
+ $('#cognome').prop('disabled', true);
+ };
+
+ if ($('#nome').val()!='' && $('#cognome').val()!=''){
+ $('#ragione_sociale').prop('disabled', true);
+ $("#ragione_sociale").attr('required', false);
+ };
+
+ $('#nome, #cognome').keyup(function(){
+ if ($('#nome').val() =='' && $('#cognome').val() =='' ){
+ $('#ragione_sociale').prop('disabled', false);
+ $("#ragione_sociale").attr('required', true);
+ }else{
+
+ $('#ragione_sociale').prop('disabled', true);
+ $("#ragione_sociale").attr('required', false);
+ }
+ });
+
+ $('#ragione_sociale').keyup(function(){
+
+ if ($(this).val()!=''){
+ $('#nome').prop('disabled', true);
+ $('#cognome').prop('disabled', true);
+ $("#ragione_sociale").attr('required', true);
+ }else{
+ $('#nome').prop('disabled', false);
+ $('#cognome').prop('disabled', false);
+ $("#ragione_sociale").attr('required', false);
+ }
+ });
+
});
diff --git a/plugins/exportFE/edit.php b/plugins/exportFE/edit.php
index 71ac16725..c59459fd2 100644
--- a/plugins/exportFE/edit.php
+++ b/plugins/exportFE/edit.php
@@ -22,7 +22,7 @@ if (!empty($fattura_pa)) {
// Campi obbligatori per il pagamento
$pagamento = $database->fetchOne('SELECT * FROM `co_pagamenti` WHERE `id` = '.prepare($record['idpagamento']));
$fields = [
- 'codice_modalita_pagamento_fe' => 'Codice di pagamento FE',
+ 'codice_modalita_pagamento_fe' => 'Codice modalità pagamento FE',
];
$missing = [];
@@ -35,7 +35,7 @@ foreach ($fields as $key => $name) {
if (!empty($missing) && !$generated) {
echo '
-
'.tr('Prima di procedere alla generazione della fattura elettronica completa i seguenti campi del tipo di pagamento: _FIELDS_', [
+
'.tr('Prima di procedere alla generazione della fattura elettronica completa i seguenti campi per il Pagamento: _FIELDS_', [
'_FIELDS_' => ''.implode(', ', $missing).'',
]).'
';
diff --git a/plugins/exportFE/src/FatturaElettronica.php b/plugins/exportFE/src/FatturaElettronica.php
index d4c6bba00..ca2237c0f 100644
--- a/plugins/exportFE/src/FatturaElettronica.php
+++ b/plugins/exportFE/src/FatturaElettronica.php
@@ -621,6 +621,23 @@ class FatturaElettronica
return $this->cliente;
}
+
+ /**
+ * Restituisce le informazioni sull'anagrafica dell'intermediario.
+ *
+ * @return array
+ */
+ public function getIntermediario()
+ {
+ if (empty($this->intermediario)) {
+ $intermediario = static::getAnagrafica(setting('Terzo intermediario'));
+ $this->intermediario = $intermediario;
+ }
+
+ return $this->intermediario;
+ }
+
+
/**
* Restituisce le informazioni riguardanti un anagrafica sulla base dell'identificativo fornito.
@@ -823,7 +840,7 @@ class FatturaElettronica
public function getFilename($new = false)
{
$azienda = static::getAzienda();
- $prefix = 'IT'.(empty($azienda['piva']) ? $azienda['codice_fiscale'] : $azienda['piva']);
+ $prefix = 'IT'.(!empty($azienda['codice_fiscale']) ? $azienda['codice_fiscale'] : $azienda['piva']);
if (empty($this->documento['progressivo_invio']) || !empty($new)) {
$database = database();
@@ -904,7 +921,7 @@ class FatturaElettronica
$result = [
'IdTrasmittente' => [
'IdPaese' => $azienda['nazione'],
- 'IdCodice' => (!empty($azienda['piva'])) ? $azienda['piva'] : $azienda['codice_fiscale'],
+ 'IdCodice' => (!empty($azienda['codice_fiscale'])) ? $azienda['codice_fiscale'] : $azienda['piva'],
],
'ProgressivoInvio' => $documento['progressivo_invio'],
'FormatoTrasmissione' => ($cliente['tipo'] == 'Ente pubblico') ? 'FPA12' : 'FPR12',
@@ -940,10 +957,12 @@ class FatturaElettronica
// Partita IVA (obbligatoria se presente)
if (!empty($anagrafica['piva'])) {
- $result['IdFiscaleIVA'] = [
- 'IdPaese' => $anagrafica['nazione'],
- 'IdCodice' => $anagrafica['piva'],
- ];
+
+ if (!empty($anagrafica['nazione']))
+ $result['IdFiscaleIVA']['IdPaese'] = $anagrafica['nazione'];
+
+ $result['IdFiscaleIVA']['IdCodice'] = $anagrafica['piva'];
+
}
// Codice fiscale
@@ -1043,7 +1062,7 @@ class FatturaElettronica
}
/**
- * Restituisce l'array responsabile per la generazione del tag CessionarioCommittente.
+ * Restituisce l'array responsabile per la generazione del tag CessionarioCommittente (1.4).
*
* @return array
*/
@@ -1058,6 +1077,24 @@ class FatturaElettronica
return $result;
}
+
+
+ /**
+ * Restituisce l'array responsabile per la generazione del tag TerzoIntermediarioOSoggettoEmittente (1.5).
+ *
+ * @return array
+ */
+ protected static function getTerzoIntermediarioOSoggettoEmittente($fattura)
+ {
+ $intermediario = $fattura->getIntermediario();
+
+ $result = [
+ 'DatiAnagrafici' => static::getDatiAnagrafici($intermediario),
+ ];
+
+ return $result;
+ }
+
/**
* Restituisce l'array responsabile per la generazione del tag DatiGeneraliDocumento.
@@ -1412,7 +1449,10 @@ class FatturaElettronica
}
if (empty($percentuale)) {
- $dettaglio['Natura'] = $iva['codice_natura_fe'];
+ //Controllo aggiuntivo codice_natura_fe per evitare che venga riportato il tag vuoto
+ if (!empty($iva['codice_natura_fe'])){
+ $dettaglio['Natura'] = $iva['codice_natura_fe'];
+ }
}
if (!empty($riga['riferimento_amministrazione'])) {
@@ -1611,6 +1651,12 @@ class FatturaElettronica
'CedentePrestatore' => static::getCedentePrestatore($fattura),
'CessionarioCommittente' => static::getCessionarioCommittente($fattura),
];
+
+ //Terzo Intermediario o Soggetto Emittente
+ if (!empty(setting('Terzo intermediario'))){
+ $result['TerzoIntermediarioOSoggettoEmittente'] = static::getTerzoIntermediarioOSoggettoEmittente($fattura);
+ $result['SoggettoEmittente'] = 'TZ';
+ }
return $result;
}
diff --git a/update/2_4_5.sql b/update/2_4_5.sql
index caf58fe02..8e14cf590 100644
--- a/update/2_4_5.sql
+++ b/update/2_4_5.sql
@@ -38,4 +38,17 @@ UPDATE `an_sedi` SET `provincia` = UPPER(provincia);
-- Colonna Codice Modalità (Pagamenti)
-INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default` ) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Pagamenti'), 'Codice Modalità', 'codice_modalita_pagamento_fe', 2, 1, 0, 0, NULL, NULL, 1, 0, 0);
\ No newline at end of file
+INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default` ) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Pagamenti'), 'Codice Modalità', 'codice_modalita_pagamento_fe', 2, 1, 0, 0, NULL, NULL, 1, 0, 0);
+
+
+-- Impostazione "Anagrafica del terzo intermediario"
+INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`) VALUES (NULL, 'Terzo intermediario', '', 'query=SELECT `an_anagrafiche`.`idanagrafica` AS ''id'', `ragione_sociale` AS ''descrizione'' FROM `an_anagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `an_tipianagrafiche_anagrafiche`.`idanagrafica` WHERE `idtipoanagrafica` = (SELECT `idtipoanagrafica` FROM `an_tipianagrafiche` WHERE `descrizione` = ''Fornitore'') AND `deleted_at` IS NULL', '1', 'Fatturazione Elettronica');
+
+-- Aggiungo campi nome e cognome
+ALTER TABLE `an_anagrafiche` CHANGE `nome_cognome` `nome` VARCHAR(255) NOT NULL;
+ALTER TABLE `an_anagrafiche` ADD `cognome` VARCHAR(255) NOT NULL AFTER `nome`;
+
+
+-- Colonna Rif. fattura (Prima nota)
+INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `search_inside`, `order_by`, `visible`, `summable`, `default` ) VALUES (NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Prima nota'), 'Rif. fattura', 'IF((iddocumento != ''),(SELECT numero_esterno FROM co_documenti WHERE id = iddocumento), ''-'')', 2, 1, 0, 0, NULL, NULL, 1, 0, 0);
+