2018-09-24 18:10:16 +02:00
|
|
|
<?php
|
|
|
|
|
2018-11-30 15:33:25 +01:00
|
|
|
namespace Plugins\ImportFE;
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2018-12-29 12:03:22 +01:00
|
|
|
use Modules;
|
|
|
|
use Modules\Anagrafiche\Anagrafica;
|
|
|
|
use Modules\Anagrafiche\Nazione;
|
|
|
|
use Modules\Anagrafiche\Tipo as TipoAnagrafica;
|
2018-09-25 11:55:52 +02:00
|
|
|
use Modules\Articoli\Articolo as ArticoloOriginale;
|
2018-12-29 12:03:22 +01:00
|
|
|
use Modules\Fatture\Components\Articolo;
|
|
|
|
use Modules\Fatture\Components\Riga;
|
|
|
|
use Modules\Fatture\Fattura;
|
2018-09-24 18:10:16 +02:00
|
|
|
use Modules\Fatture\Stato as StatoFattura;
|
|
|
|
use Modules\Fatture\Tipo as TipoFattura;
|
2018-11-30 15:33:25 +01:00
|
|
|
use UnexpectedValueException;
|
2018-12-29 12:03:22 +01:00
|
|
|
use Uploads;
|
|
|
|
use Util\XML;
|
2018-09-24 18:10:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Classe per la gestione della fatturazione elettronica in XML.
|
|
|
|
*
|
|
|
|
* @since 2.4.2
|
|
|
|
*/
|
|
|
|
class FatturaElettronica
|
|
|
|
{
|
2018-11-30 15:33:25 +01:00
|
|
|
protected static $directory = null;
|
|
|
|
|
|
|
|
/** @var array Percorso del file XML */
|
|
|
|
protected $file = null;
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
/** @var array XML della fattura */
|
|
|
|
protected $xml = null;
|
|
|
|
|
|
|
|
/** @var Fattura Fattura collegata */
|
|
|
|
protected $fattura = null;
|
|
|
|
|
2018-11-30 15:33:25 +01:00
|
|
|
public function __construct($file)
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2018-11-30 15:33:25 +01:00
|
|
|
$this->file = static::getImportDirectory().'/'.$file;
|
2019-02-13 11:26:56 +01:00
|
|
|
|
|
|
|
if (ends_with($file, '.p7m')) {
|
|
|
|
$file = XML::decodeP7M($this->file);
|
|
|
|
|
|
|
|
if ($file !== false) {
|
|
|
|
delete($this->file);
|
|
|
|
|
|
|
|
$this->file = $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-07 10:56:49 +01:00
|
|
|
$this->xml = XML::readFile($this->file);
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2018-09-25 11:55:52 +02:00
|
|
|
// Individuazione fattura pre-esistente
|
|
|
|
$dati_generali = $this->getBody()['DatiGenerali']['DatiGeneraliDocumento'];
|
|
|
|
$data = $dati_generali['Data'];
|
|
|
|
$numero = $dati_generali['Numero'];
|
2018-11-30 15:33:25 +01:00
|
|
|
$progressivo_invio = $this->getHeader()['DatiTrasmissione']['ProgressivoInvio'];
|
2018-09-25 11:55:52 +02:00
|
|
|
|
|
|
|
$fattura = Fattura::where([
|
2018-11-30 15:33:25 +01:00
|
|
|
'progressivo_invio' => $progressivo_invio,
|
2018-12-07 10:56:49 +01:00
|
|
|
'numero_esterno' => $numero,
|
2018-09-25 11:55:52 +02:00
|
|
|
'data' => $data,
|
|
|
|
])->first();
|
|
|
|
|
|
|
|
if (!empty($fattura)) {
|
2018-11-30 15:33:25 +01:00
|
|
|
$this->delete();
|
|
|
|
|
|
|
|
throw new UnexpectedValueException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getImportDirectory()
|
|
|
|
{
|
|
|
|
if (!isset(self::$directory)) {
|
|
|
|
$module = Modules::get('Fatture di acquisto');
|
|
|
|
|
|
|
|
$plugin = $module->plugins->first(function ($value, $key) {
|
|
|
|
return $value->name = 'Fatturazione Elettronica';
|
|
|
|
});
|
|
|
|
|
|
|
|
self::$directory = DOCROOT.'/'.$plugin->upload_directory;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self::$directory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function store($filename, $content)
|
|
|
|
{
|
2018-12-12 17:26:25 +01:00
|
|
|
$directory = static::getImportDirectory();
|
|
|
|
$file = $directory.'/'.$filename;
|
2018-11-30 15:33:25 +01:00
|
|
|
|
2018-12-12 17:26:25 +01:00
|
|
|
directory($directory);
|
2018-11-30 15:33:25 +01:00
|
|
|
file_put_contents($file, $content);
|
|
|
|
|
|
|
|
return $filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function isValid($file)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
new static($file);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch (UnexpectedValueException $e) {
|
|
|
|
return false;
|
2018-09-25 11:55:52 +02:00
|
|
|
}
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getHeader()
|
|
|
|
{
|
|
|
|
return $this->xml['FatturaElettronicaHeader'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBody()
|
|
|
|
{
|
|
|
|
return $this->xml['FatturaElettronicaBody'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function createAnagrafica($xml, $type = 'Fornitore')
|
|
|
|
{
|
|
|
|
$database = database();
|
|
|
|
|
|
|
|
$where = [];
|
|
|
|
|
|
|
|
$partita_iva = $xml['DatiAnagrafici']['IdFiscaleIVA']['IdCodice'];
|
|
|
|
if (!empty($partita_iva)) {
|
|
|
|
$where[] = '`piva` = '.prepare($partita_iva);
|
|
|
|
}
|
|
|
|
|
|
|
|
$codice_fiscale = $xml['DatiAnagrafici']['CodiceFiscale'];
|
|
|
|
if (!empty($codice_fiscale)) {
|
|
|
|
$where[] = '`codice_fiscale` = '.prepare($codice_fiscale);
|
|
|
|
}
|
|
|
|
|
|
|
|
$id_anagrafica = $database->fetchOne('SELECT `an_anagrafiche`.`idanagrafica` FROM `an_anagrafiche`
|
|
|
|
INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_anagrafiche`.`idanagrafica` = `an_tipianagrafiche_anagrafiche`.`idanagrafica`
|
|
|
|
INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica` = `an_tipianagrafiche_anagrafiche`.`idtipoanagrafica`
|
|
|
|
WHERE `an_tipianagrafiche`.`descrizione` = '.prepare($type).' AND ('.implode(' OR ', $where).')')['idanagrafica'];
|
|
|
|
if (!empty($id_anagrafica)) {
|
2018-09-25 16:47:44 +02:00
|
|
|
return Anagrafica::find($id_anagrafica);
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$ragione_sociale = $xml['DatiAnagrafici']['Anagrafica']['Denominazione'] ?: $xml['DatiAnagrafici']['Anagrafica']['Nome'].' '.$xml['DatiAnagrafici']['Anagrafica']['Cognome'];
|
2019-01-02 14:15:16 +01:00
|
|
|
$anagrafica = Anagrafica::build($ragione_sociale, [
|
2018-09-25 16:47:44 +02:00
|
|
|
TipoAnagrafica::where('descrizione', 'Fornitore')->first()->id,
|
2018-09-24 18:10:16 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
// Informazioni sull'anagrafica
|
|
|
|
$REA = $xml['IscrizioneREA'];
|
|
|
|
if (!empty($REA)) {
|
2019-01-10 18:41:25 +01:00
|
|
|
if (!empty($REA['Ufficio']) and !empty($REA['NumeroREA'])) {
|
|
|
|
$anagrafica->codicerea = $REA['Ufficio'].'-'.$REA['NumeroREA'];
|
|
|
|
}
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
if (!empty($REA['CapitaleSociale'])) {
|
|
|
|
$anagrafica->capitale_sociale = $REA['CapitaleSociale'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$anagrafica->save();
|
|
|
|
|
|
|
|
// Informazioni sulla sede
|
|
|
|
$info = $xml['Sede'];
|
2018-11-09 11:34:27 +01:00
|
|
|
$sede = $anagrafica->sedeLegale;
|
2018-09-24 18:10:16 +02:00
|
|
|
|
|
|
|
if (!empty($partita_iva)) {
|
|
|
|
$sede->partita_iva = $partita_iva;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($codice_fiscale)) {
|
|
|
|
$sede->codice_fiscale = $codice_fiscale;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sede->indirizzo = $info['Indirizzo'];
|
|
|
|
$sede->cap = $info['CAP'];
|
|
|
|
$sede->citta = $info['Comune'];
|
|
|
|
$sede->indirizzo = $info['Indirizzo'];
|
|
|
|
$sede->nazione()->associate(Nazione::where('iso2', $info['Nazione'])->first());
|
|
|
|
if (!empty($info['Provincia'])) {
|
|
|
|
$sede->provincia = $info['Provincia'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$contatti = $xml['Contatti'];
|
|
|
|
if (!empty($contatti)) {
|
|
|
|
if (!empty($contatti['Telefono'])) {
|
|
|
|
$sede->telefono = $contatti['Telefono'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($contatti['Fax'])) {
|
|
|
|
$sede->fax = $contatti['Fax'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($contatti['email'])) {
|
|
|
|
$sede->email = $contatti['email'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$sede->save();
|
|
|
|
|
2018-10-04 17:25:42 +02:00
|
|
|
return $anagrafica;
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2018-09-25 11:55:52 +02:00
|
|
|
public function getRighe()
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2018-09-25 11:55:52 +02:00
|
|
|
$result = $this->getBody()['DatiBeniServizi']['DettaglioLinee'];
|
|
|
|
|
2018-09-25 16:47:44 +02:00
|
|
|
$result = isset($result[0]) ? $result : [$result];
|
2018-09-25 11:55:52 +02:00
|
|
|
|
|
|
|
return $result;
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2018-10-29 22:23:29 +01:00
|
|
|
public function saveRighe($articoli, $iva, $conto)
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2018-09-25 11:55:52 +02:00
|
|
|
$righe = $this->getRighe();
|
|
|
|
|
|
|
|
foreach ($righe as $key => $riga) {
|
|
|
|
$articolo = ArticoloOriginale::find($articoli[$key]);
|
|
|
|
|
|
|
|
if (!empty($articolo)) {
|
2019-01-02 14:15:16 +01:00
|
|
|
$obj = Articolo::build($this->getFattura(), $articolo);
|
2018-09-25 11:55:52 +02:00
|
|
|
} else {
|
2019-01-02 14:15:16 +01:00
|
|
|
$obj = Riga::build($this->getFattura());
|
2018-09-25 11:55:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$obj->descrizione = $riga['Descrizione'];
|
2018-09-26 16:28:02 +02:00
|
|
|
$obj->id_iva = $iva[$key];
|
2018-10-29 22:23:29 +01:00
|
|
|
$obj->idconto = $conto[$key];
|
2018-11-21 17:45:06 +01:00
|
|
|
$obj->prezzo_unitario_vendita = $riga['PrezzoUnitario'];
|
2018-10-04 17:37:28 +02:00
|
|
|
$obj->qta = $riga['Quantita'] ?: 1;
|
2018-09-26 16:28:02 +02:00
|
|
|
|
2018-09-25 16:47:44 +02:00
|
|
|
if (!empty($riga['UnitaMisura'])) {
|
|
|
|
$obj->um = $riga['UnitaMisura'];
|
|
|
|
}
|
2018-09-25 11:55:52 +02:00
|
|
|
|
2019-01-22 17:53:16 +01:00
|
|
|
$sconti = $riga['ScontoMaggiorazione'];
|
2019-02-12 11:42:48 +01:00
|
|
|
|
2019-01-22 17:53:16 +01:00
|
|
|
if (!empty($sconti)) {
|
2019-02-08 19:39:04 +01:00
|
|
|
if ($sconti['Percentuale'] || $sconti['Importo']) {
|
|
|
|
$tipo = !empty($sconti['Percentuale']) ? 'PRC' : 'EUR';
|
|
|
|
$unitario = $sconti['Percentuale'] ?: $sconti['Importo'];
|
2019-01-25 11:02:36 +01:00
|
|
|
|
|
|
|
//SConto o MaGgiorazione
|
2019-02-08 19:39:04 +01:00
|
|
|
$unitario = ($sconti['Tipo'] == 'SC') ? $unitario : -$unitario;
|
2019-01-25 11:02:36 +01:00
|
|
|
|
|
|
|
if (!empty($unitario)) {
|
|
|
|
$obj->sconto_unitario = $unitario;
|
|
|
|
$obj->tipo_sconto = $tipo;
|
|
|
|
}
|
|
|
|
}
|
2019-02-12 11:42:48 +01:00
|
|
|
|
2019-02-08 19:39:04 +01:00
|
|
|
// Sconti multipli
|
|
|
|
else {
|
|
|
|
$sconto = $sconti[0]['Percentuale'] ? $sconti[0]['Percentuale'] : $sconti['Percentuale'];
|
|
|
|
$tipo = !empty($sconto) ? 'PRC' : 'EUR';
|
|
|
|
|
|
|
|
$sconto_totale = 0;
|
|
|
|
if ($tipo == 'PRC') {
|
|
|
|
/**
|
2019-02-12 11:42:48 +01:00
|
|
|
* Trasformo un eventuale sconto percentuale combinato in più
|
|
|
|
* sconti:
|
|
|
|
* Esempio:
|
|
|
|
* 40% + 30% è uno sconto del 42%.
|
|
|
|
*/
|
2019-02-08 19:39:04 +01:00
|
|
|
$prezzo_intero = $riga['PrezzoUnitario'] * $riga['Quantita'];
|
|
|
|
$prezzo_scontato = $prezzo_intero;
|
|
|
|
|
|
|
|
foreach ($sconti as $scontor) {
|
|
|
|
$prezzo_scontato -= $prezzo_scontato / 100 * $scontor['Percentuale'];
|
|
|
|
}
|
2019-02-12 11:42:48 +01:00
|
|
|
|
2019-02-08 19:39:04 +01:00
|
|
|
// Ricavo la percentuale finale di sconto con una proporzione
|
2019-02-12 11:42:48 +01:00
|
|
|
$percentuale_totale = (1 - ($prezzo_scontato / $prezzo_intero)) * 100;
|
|
|
|
|
2019-02-08 19:39:04 +01:00
|
|
|
if (!empty($percentuale_totale)) {
|
|
|
|
$obj->sconto_unitario = $percentuale_totale;
|
|
|
|
$obj->tipo_sconto = $tipo;
|
|
|
|
}
|
2019-02-12 11:42:48 +01:00
|
|
|
} else {
|
2019-02-08 19:39:04 +01:00
|
|
|
// Combino gli sconti tra loro
|
|
|
|
foreach ($sconti as $sconto) {
|
|
|
|
$unitario = $sconto['Percentuale'] ?: $sconto['Importo'];
|
|
|
|
|
|
|
|
//Sconto o Maggiorazione
|
|
|
|
$unitario = ($sconto['Tipo'] == 'SC') ? $unitario : -$unitario;
|
|
|
|
|
|
|
|
$sconto_totale += $unitario;
|
|
|
|
}
|
2019-02-12 11:42:48 +01:00
|
|
|
|
2019-02-08 19:39:04 +01:00
|
|
|
if (!empty($unitario)) {
|
|
|
|
$obj->sconto_unitario = $sconto_totale;
|
|
|
|
$obj->tipo_sconto = $tipo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-25 11:02:36 +01:00
|
|
|
}
|
|
|
|
|
2018-09-25 11:55:52 +02:00
|
|
|
$obj->save();
|
|
|
|
}
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2018-09-25 11:55:52 +02:00
|
|
|
public function getAllegati()
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2018-09-25 11:55:52 +02:00
|
|
|
$result = $this->getBody()['Allegati'];
|
|
|
|
|
2018-09-25 16:47:44 +02:00
|
|
|
$result = isset($result[0]) ? $result : [$result];
|
2018-09-25 11:55:52 +02:00
|
|
|
|
2018-12-07 10:56:49 +01:00
|
|
|
return array_clean($result);
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2018-11-30 15:33:25 +01:00
|
|
|
public function saveAllegati()
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2018-09-25 11:55:52 +02:00
|
|
|
$allegati = $this->getAllegati();
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2018-09-25 16:47:44 +02:00
|
|
|
$module = Modules::get('Fatture di acquisto');
|
|
|
|
|
2018-11-30 15:33:25 +01:00
|
|
|
$info = [
|
|
|
|
'category' => tr('Fattura Elettronica'),
|
|
|
|
'id_module' => $module->id,
|
|
|
|
'id_record' => $this->fattura->id,
|
|
|
|
];
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
foreach ($allegati as $allegato) {
|
|
|
|
$content = base64_decode($allegato['Attachment']);
|
2018-12-12 17:54:31 +01:00
|
|
|
|
|
|
|
$extension = '';
|
|
|
|
if (!empty($allegato['FormatoAttachment'])) {
|
|
|
|
$extension = '.'.strtolower($allegato['FormatoAttachment']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$original = $allegato['NomeAttachment'].$extension;
|
2018-09-25 16:47:44 +02:00
|
|
|
$filename = Uploads::getName($original, [
|
|
|
|
'id_module' => $module['id'],
|
|
|
|
]);
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2018-11-30 15:33:25 +01:00
|
|
|
file_put_contents($module->upload_directory.'/'.$filename, $content);
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2018-11-30 15:33:25 +01:00
|
|
|
Uploads::register(array_merge($info, [
|
2018-09-25 16:47:44 +02:00
|
|
|
'filename' => $filename,
|
|
|
|
'original' => $original,
|
2018-11-30 15:33:25 +01:00
|
|
|
]));
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
2018-11-30 15:33:25 +01:00
|
|
|
|
|
|
|
// Registrazione XML come allegato
|
|
|
|
$filename = Uploads::upload($this->file, array_merge($info, [
|
|
|
|
'name' => tr('Fattura Elettronica'),
|
2018-12-07 10:56:49 +01:00
|
|
|
'original' => basename($this->file),
|
2018-11-30 15:33:25 +01:00
|
|
|
]));
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|
|
|
|
|
2018-09-25 11:55:52 +02:00
|
|
|
public function getFattura()
|
|
|
|
{
|
|
|
|
return $this->fattura;
|
|
|
|
}
|
|
|
|
|
2018-09-24 18:10:16 +02:00
|
|
|
/**
|
|
|
|
* Registra la fattura elettronica come fattura del gestionale.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
2019-01-10 18:41:25 +01:00
|
|
|
public function saveFattura($id_pagamento, $id_sezionale, $id_tipo)
|
2018-09-24 18:10:16 +02:00
|
|
|
{
|
2019-01-10 18:06:15 +01:00
|
|
|
$anagrafica = static::createAnagrafica($this->getHeader()['CedentePrestatore']);
|
2018-09-24 18:10:16 +02:00
|
|
|
|
|
|
|
$dati_generali = $this->getBody()['DatiGenerali']['DatiGeneraliDocumento'];
|
|
|
|
$data = $dati_generali['Data'];
|
2019-01-10 18:41:25 +01:00
|
|
|
|
2018-10-29 22:23:29 +01:00
|
|
|
$numero_esterno = $dati_generali['Numero'];
|
2018-11-30 15:33:25 +01:00
|
|
|
$progressivo_invio = $this->getHeader()['DatiTrasmissione']['ProgressivoInvio'];
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2019-01-10 18:41:25 +01:00
|
|
|
$tipo = TipoFattura::where('id', $id_tipo)->first();
|
2019-01-10 18:06:15 +01:00
|
|
|
|
2019-01-02 14:15:16 +01:00
|
|
|
$fattura = Fattura::build($anagrafica, $tipo, $data, $id_sezionale);
|
2018-09-25 11:55:52 +02:00
|
|
|
$this->fattura = $fattura;
|
2018-09-24 18:10:16 +02:00
|
|
|
|
2018-11-30 15:33:25 +01:00
|
|
|
$fattura->progressivo_invio = $progressivo_invio;
|
2018-10-29 22:23:29 +01:00
|
|
|
$fattura->numero_esterno = $numero_esterno;
|
2018-09-25 16:47:44 +02:00
|
|
|
$fattura->idpagamento = $id_pagamento;
|
2018-09-24 18:10:16 +02:00
|
|
|
|
|
|
|
$stato_documento = StatoFattura::where('descrizione', 'Emessa')->first();
|
|
|
|
$fattura->stato()->associate($stato_documento);
|
|
|
|
|
2018-09-25 11:55:52 +02:00
|
|
|
// Sconto globale
|
|
|
|
$sconto = $dati_generali['ScontoMaggiorazione'];
|
|
|
|
if (!empty($sconto)) {
|
|
|
|
$tipo = !empty($sconto['Percentuale']) ? 'PRC' : 'EUR';
|
|
|
|
$unitario = $sconto['Percentuale'] ?: $sconto['Importo'];
|
|
|
|
|
|
|
|
$unitario = ($sconto['Tipo'] == 'SC') ? $unitario : -$unitario;
|
|
|
|
|
|
|
|
$fattura->sconto_globale = $unitario;
|
|
|
|
$fattura->tipo_sconto_globale = $tipo;
|
|
|
|
}
|
|
|
|
|
2018-09-26 16:28:02 +02:00
|
|
|
// Ritenuta d'Acconto
|
|
|
|
$ritenuta = $dati_generali['DatiRitenuta'];
|
|
|
|
if (!empty($ritenuta)) {
|
|
|
|
$percentuale = $ritenuta['AliquotaRitenuta'];
|
|
|
|
$importo = $ritenuta['ImportoRitenuta'];
|
|
|
|
|
|
|
|
// TODO: salvare in fattura
|
|
|
|
}
|
|
|
|
|
2019-01-10 18:41:25 +01:00
|
|
|
$causali = $dati_generali['Causale'];
|
|
|
|
if (count($causali) > 0) {
|
|
|
|
foreach ($causali as $causale) {
|
|
|
|
$note .= $causale;
|
|
|
|
}
|
|
|
|
$fattura->note = $note;
|
|
|
|
}
|
|
|
|
|
2018-09-26 16:28:02 +02:00
|
|
|
// Bollo
|
|
|
|
$bollo = $dati_generali['DatiBollo'];
|
|
|
|
if (!empty($bollo)) {
|
|
|
|
$fattura->bollo = $bollo['ImportoBollo'];
|
|
|
|
}
|
|
|
|
|
2018-09-25 11:55:52 +02:00
|
|
|
$fattura->save();
|
2018-09-24 18:10:16 +02:00
|
|
|
|
|
|
|
return $fattura->id;
|
|
|
|
}
|
2018-11-30 15:33:25 +01:00
|
|
|
|
|
|
|
public function delete()
|
|
|
|
{
|
|
|
|
delete($this->file);
|
|
|
|
}
|
2018-09-24 18:10:16 +02:00
|
|
|
}
|