Skip to content

Commit

Permalink
Merge pull request #679 from link-it/feature/678-export-report-del-fl…
Browse files Browse the repository at this point in the history
…usso-di-rendicontazione_CSV

Issue(#678): Aggiunto export report del flusso di rendicontazione in …
  • Loading branch information
nardil committed Jan 26, 2024
2 parents 1a59300 + 8a7c546 commit c1b041a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export class AppComponent implements OnInit, AfterContentChecked, IModalDialog,
break;
case UtilService.URL_RENDICONTAZIONI+UtilService.URL_DETTAGLIO:
a.push({ label: 'Scarica flusso XML', type: UtilService.EXPORT_FLUSSO_XML });
a.push({ label: 'Scarica flusso CSV', type: UtilService.EXPORT_FLUSSO_CSV });
break;
case UtilService.URL_INCASSI+UtilService.URL_DETTAGLIO:
a.push({ label: 'Scarica resoconto', type: UtilService.EXPORT_INCASSO });
Expand Down Expand Up @@ -508,6 +509,9 @@ export class AppComponent implements OnInit, AfterContentChecked, IModalDialog,
case UtilService.EXPORT_INCASSO:
(_componentRef)?_componentRef.instance.exportData():null;
break;
case UtilService.EXPORT_FLUSSO_CSV:
(_componentRef)?_componentRef.instance.exportData('csv'):null;
break;
case UtilService.EXPORT_TRACCIATO_RICHIESTA:
case UtilService.EXPORT_TRACCIATO_AVVISI:
case UtilService.EXPORT_TRACCIATO_ESITO:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,18 @@ export class RendicontazioniViewComponent implements IModalDialog, IExport, Afte
return _std;
}

exportData() {
exportData(type: string = 'xml') {
switch (type) {
case 'xml':
this._exportDataXML();
break;
case 'csv':
this._exportDataCSV();
break;
}
}

_exportDataXML() {
this.gps.updateSpinner(true);
let urls: string[] = [];
let contents: string[] = [];
Expand Down Expand Up @@ -167,6 +178,68 @@ export class RendicontazioniViewComponent implements IModalDialog, IExport, Afte
}
}

_exportDataCSV() {
let _exportLabel = {
idFlusso: 'Id Flusso',
idPsp: 'Id Psp',
idDominio: 'Dominio',
iuv: 'IUV',
iur: 'IUR',
importo: 'Importo',
data: 'Data',
esito: 'Esito',
idPendenza: 'Id pendenza',
idTipoPendenza: 'Id tipo pendenza',
idVocePendenza: 'Id voce pendenza',
causale: 'Causale',
idSoggettoPagatore: 'Id debitore',
soggettoPagatore: 'Debitore anagrafica'
};

const _json: any = JSON.parse(JSON.stringify(this.json));
const _rendicontazioni: any[] = [];
this.json.rendicontazioni.forEach(rend => {
const rendicontazione: any = {};
rendicontazione[_exportLabel['idFlusso']] = _json.idFlusso ? _json.idFlusso : '';
rendicontazione[_exportLabel['idPsp']] = _json.idPsp ? _json.idPsp : '';
rendicontazione[_exportLabel['idDominio']] = _json.idDominio ? _json.idDominio : '';
rendicontazione[_exportLabel['iuv']] = rend.iuv || '';
rendicontazione[_exportLabel['iur']] = rend.iur || '';
rendicontazione[_exportLabel['importo']] = rend.importo || 0;
rendicontazione[_exportLabel['data']] = rend.data || '';
rendicontazione[_exportLabel['idPendenza']] = '';
rendicontazione[_exportLabel['idTipoPendenza']] = '';
rendicontazione[_exportLabel['idVocePendenza']] = '';
rendicontazione[_exportLabel['causale']] = '';
rendicontazione[_exportLabel['idSoggettoPagatore']] = '';
rendicontazione[_exportLabel['soggettoPagatore']] = '';
if (rend.riscossione && rend.riscossione.vocePendenza && rend.riscossione.vocePendenza.pendenza) {
rendicontazione[_exportLabel['idPendenza']] = rend.riscossione.vocePendenza.pendenza.idPendenza || '';
if (rend.riscossione.vocePendenza.pendenza.tipoPendenza) {
rendicontazione[_exportLabel['idTipoPendenza']] = rend.riscossione.vocePendenza.pendenza.tipoPendenza.idTipoPendenza || '';
}
rendicontazione[_exportLabel['idVocePendenza']] = rend.riscossione.vocePendenza.pendenza.idVocePendenza || '';
rendicontazione[_exportLabel['causale']] = rend.riscossione.vocePendenza.pendenza.causale || '';
if (rend.riscossione.vocePendenza.pendenza.soggettoPagatore) {
rendicontazione[_exportLabel['idSoggettoPagatore']] = rend.riscossione.vocePendenza.pendenza.soggettoPagatore.identificativo || '';
rendicontazione[_exportLabel['soggettoPagatore']] = rend.riscossione.vocePendenza.pendenza.soggettoPagatore.anagrafica || '';
}
}
_rendicontazioni.push(rendicontazione);
});

this.gps.updateSpinner(true);
const fileName = 'Flusso_' + _json.idFlusso.toString() + '_'+moment().format('DDMMYYYY_HHmmss') + '.csv';
const csvData: string = this.us.jsonToCsv('Rendicontazioni.csv', _rendicontazioni);
try {
const blob = new Blob([csvData], {type: "text/plain;charset=utf-8"});
FileSaver(blob, fileName);
} catch (e) {
this.us.alert('Si è verificato un errore non previsto durante la creazione del file.');
}
this.gps.updateSpinner(false);
}

refresh(mb: ModalBehavior) {}
save(responseService: BehaviorSubject<any>, mb: ModalBehavior) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,19 +396,19 @@ export class UtilService {
V1: 'V1',
V2: 'V2'
};

// MODELLO UNICO DA VERSIONE STAZIONE
public static MODELLO_UNICO_DA_VERSIONE: any = {
'V2': 'Si',
'V1': 'No'
};

// MODELLO UNICO BOOLEAN DA VERSIONE STAZIONE
public static MODELLO_UNICO_BOOLEAN_DA_VERSIONE: any = {
'V2': true,
'V1': false
};

// VERSIONE STAZIONE DA MODELLO UNICO BOOLEAN
public static VERSIONE_DA_MODELLO_UNICO_BOOLEAN: any = {
true: 'V2',
Expand Down Expand Up @@ -623,6 +623,7 @@ export class UtilService {
public static EXPORT_INCASSO: string = 'esporta_incasso';
public static EXPORT_RENDICONTAZIONI: string = 'esporta_rendicontazioni';
public static EXPORT_FLUSSO_XML: string = 'esporta_flusso_xml';
public static EXPORT_FLUSSO_CSV: string = 'esporta_flusso_csv';
public static EXPORT_TRACCIATO_RICHIESTA: string = 'esporta_tracciato_richiesta';
public static EXPORT_TRACCIATO_ESITO: string = 'esporta_tracciato_esito';
public static EXPORT_TRACCIATO_AVVISI: string = 'esporta_tracciato_avvisi';
Expand Down Expand Up @@ -1304,6 +1305,12 @@ export class UtilService {
_csv += this.jsonToCsvRows((index===0), _keys, _json);
});
break;
case 'Rendicontazioni.csv':
_keys = this._elaborateKeys(jsonData);
jsonData.forEach((_json, index) => {
_csv += this.jsonToCsvRows((index===0), _keys, _json);
});
break;
default:
}

Expand Down

0 comments on commit c1b041a

Please sign in to comment.