Ciao a tutti,
a seguito del post di prima sulla visualizzazione della fattura che ho poi risolto,
ora sono in preda alla pratica del leggere il contenuto.
ho effettuato una buona parte del lavoro appoggiandomi ad una classe creata da me.
Public Class Fattura
Public Class Rootobject
Public Property FatturaElettronica As Fatturaelettronica
End Class
Public Class Fatturaelettronica
Public Property xmlns As String
Public Property xmlnsxsd As String
Public Property xmlnsxsi As String
Public Property versione As String
Public Property FatturaElettronicaHeader As Fatturaelettronicaheader
Public Property FatturaElettronicaBody As Fatturaelettronicabody
Public Property dsSignature As DsSignature
End Class
Public Class Fatturaelettronicaheader
Public Property DatiTrasmissione As Datitrasmissione
Public Property CedentePrestatore As Cedenteprestatore
Public Property CessionarioCommittente As Cessionariocommittente
End Class
Public Class Datitrasmissione
Public Property IdTrasmittente As Idtrasmittente
Public Property ProgressivoInvio As String
Public Property FormatoTrasmissione As String
Public Property CodiceDestinatario As String
End Class
Public Class Idtrasmittente
Public Property IdPaese As String
Public Property IdCodice As String
End Class
Public Class Cedenteprestatore
Public Property DatiAnagrafici As Datianagrafici
Public Property Sede As Sede
Public Property IscrizioneREA As Iscrizionerea
Public Property Contatti As Contatti
End Class
Public Class Datianagrafici
Public Property IdFiscaleIVA As Idfiscaleiva
Public Property Anagrafica As Anagrafica
Public Property RegimeFiscale As String
End Class
Public Class Idfiscaleiva
Public Property IdPaese As String
Public Property IdCodice As String
End Class
Public Class Anagrafica
Public Property Denominazione As String
End Class
Public Class Sede
Public Property Indirizzo As String
Public Property NumeroCivico As String
Public Property CAP As String
Public Property Comune As String
Public Property Provincia As String
Public Property Nazione As String
End Class
Public Class Iscrizionerea
Public Property Ufficio As String
Public Property NumeroREA As String
Public Property CapitaleSociale As String
Public Property StatoLiquidazione As String
End Class
Public Class Contatti
Public Property Telefono As String
Public Property Email As String
End Class
Public Class Cessionariocommittente
Public Property DatiAnagrafici As Datianagrafici1
Public Property Sede As Sede1
End Class
Public Class Datianagrafici1
Public Property IdFiscaleIVA As Idfiscaleiva1
Public Property Anagrafica As Anagrafica1
End Class
Public Class Idfiscaleiva1
Public Property IdPaese As String
Public Property IdCodice As String
End Class
Public Class Anagrafica1
Public Property Denominazione As String
End Class
Public Class Sede1
Public Property Indirizzo As String
Public Property CAP As String
Public Property Comune As String
Public Property Nazione As String
End Class
Public Class Fatturaelettronicabody
Public Property DatiGenerali As Datigenerali
Public Property DatiBeniServizi As Datibeniservizi
Public Property DatiPagamento As Datipagamento
Public Property Allegati As Allegati
End Class
Public Class Datigenerali
Public Property DatiGeneraliDocumento As Datigeneralidocumento
Public Property DatiOrdineAcquisto() As Datiordineacquisto
End Class
Public Class Datigeneralidocumento
Public Property TipoDocumento As String
Public Property Divisa As String
Public Property Data As String
Public Property Numero As String
Public Property ImportoTotaleDocumento As String
Public Property Arrotondamento As String
Public Property Causale As String
End Class
Public Class Datiordineacquisto
Public Property RiferimentoNumeroLinea As String
Public Property IdDocumento As String
End Class
Public Class Datibeniservizi
Public Property DettaglioLinee() As Dettagliolinee
Public Property DatiRiepilogo As Datiriepilogo
End Class
Public Class Datiriepilogo
Public Property AliquotaIVA As String
Public Property ImponibileImporto As String
Public Property Imposta As String
End Class
Public Class Dettagliolinee
Public Property NumeroLinea As String
Public Property Descrizione As String
Public Property Quantita As String
Public Property DataInizioPeriodo As String
Public Property DataFinePeriodo As String
Public Property PrezzoUnitario As String
Public Property PrezzoTotale As String
Public Property AliquotaIVA As String
Public Property AltriDatiGestionali As Object
End Class
Public Class Datipagamento
Public Property CondizioniPagamento As String
Public Property DettaglioPagamento As Dettagliopagamento
End Class
Public Class Dettagliopagamento
Public Property ModalitaPagamento As String
Public Property DataScadenzaPagamento As String
Public Property ImportoPagamento As String
Public Property IstitutoFinanziario As String
Public Property IBAN As String
Public Property BIC As String
End Class
Public Class Allegati
Public Property NomeAttachment As String
Public Property FormatoAttachment As String
Public Property Attachment As String
End Class
Public Class DsSignature
Public Property xmlnsds As String
Public Property Id As String
Public Property dsSignedInfo As DsSignedinfo
Public Property dsSignatureValue As String
Public Property dsKeyInfo As DsKeyinfo
Public Property dsObject As DsObject
End Class
Public Class DsSignedinfo
Public Property dsCanonicalizationMethod As DsCanonicalizationmethod
Public Property dsSignatureMethod As DsSignaturemethod
Public Property dsReference() As DsReference
End Class
Public Class DsCanonicalizationmethod
Public Property Algorithm As String
End Class
Public Class DsSignaturemethod
Public Property Algorithm As String
End Class
Public Class DsReference
Public Property Id As String
Public Property dsTransforms As DsTransforms
Public Property dsDigestMethod As DsDigestmethod
Public Property dsDigestValue As String
Public Property Type As String
Public Property URI As String
End Class
Public Class DsTransforms
Public Property dsTransform As Object
End Class
Public Class DsDigestmethod
Public Property Algorithm As String
End Class
Public Class DsKeyinfo
Public Property dsX509Data As DsX509data
End Class
Public Class DsX509data
Public Property dsX509Certificate As String
End Class
Public Class DsObject
Public Property xadesQualifyingProperties As XadesQualifyingproperties
End Class
Public Class XadesQualifyingproperties
Public Property xmlnsxades As String
Public Property Target As String
Public Property xadesSignedProperties As XadesSignedproperties
End Class
Public Class XadesSignedproperties
Public Property Id As String
Public Property xadesSignedSignatureProperties As XadesSignedsignatureproperties
Public Property xadesSignedDataObjectProperties As XadesSigneddataobjectproperties
End Class
Public Class XadesSignedsignatureproperties
Public Property xadesSigningTime As Date
Public Property xadesSigningCertificate As XadesSigningcertificate
End Class
Public Class XadesSigningcertificate
Public Property xadesCert As XadesCert
End Class
Public Class XadesCert
Public Property xadesCertDigest As XadesCertdigest
Public Property xadesIssuerSerial As XadesIssuerserial
End Class
Public Class XadesCertdigest
Public Property dsDigestMethod As DsDigestmethod1
Public Property dsDigestValue As String
End Class
Public Class DsDigestmethod1
Public Property Algorithm As String
End Class
Public Class XadesIssuerserial
Public Property dsX509IssuerName As String
Public Property dsX509SerialNumber As String
End Class
Public Class XadesSigneddataobjectproperties
Public Property xadesDataObjectFormat As XadesDataobjectformat
End Class
Public Class XadesDataobjectformat
Public Property ObjectReference As String
Public Property xadesMimeType As String
End Class
End Class
Per poi andare a ricreare qui nel button gli elementi.
If pathexplorer = "" Then
MsgBox("Select a Valid Invoice Before Start")
Exit Sub
End If
MsgBox(pathexplorer)
Dim PercorsoFile As String = pathexplorer
Dim fatturaElettronica As Fattura.FatturaElettronica = New Fattura.FatturaElettronica()
Dim serializzare As XmlSerializer = New XmlSerializer(GetType(Fattura.FatturaElettronica))
Dim readerLettura As StreamReader = New StreamReader(PercorsoFile)
fatturaElettronica = CType(serializzare.Deserialize(readerLettura), Fattura.FatturaElettronica)
readerLettura.Close()
Dim NomeFornitore As String = fatturaElettronica.FatturaElettronicaHeader.CedentePrestatore.DatiAnagrafici.Anagrafica.Denominazione
Dim totaleImporto As Decimal = fatturaElettronica.FatturaElettronicaBody.DatiGenerali.DatiGeneraliDocumento.ImportoTotaleDocumento
Dim numfattura As Integer = fatturaElettronica.FatturaElettronicaHeader.DatiTrasmissione.ProgressivoInvio
Dim piva As String = fatturaElettronica.FatturaElettronicaHeader.CedentePrestatore.DatiAnagrafici.IdFiscaleIVA.IdCodice
MsgBox("Fornitore : " & NomeFornitore & " totaleImporto " & totaleImporto & " num fatt " & numfattura & "p iva" & piva)
' Catch ex As Exception
' MessageBox.Show(ex.Message)
' End Try
End Sub
ma continua sempre e comunque a darmi errore
System.InvalidOperationException: 'There is an error in XML document (1, 56).'
InvalidOperationException: <FatturaElettronica xmlns='
http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2'> was not expected.
il char 56, corrispnonde a ns3:fatturaelettronica
<?xml version="1.0" encoding="UTF-8"?><ns3:FatturaElettronica xmlns:ns3="
http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2" xmlns:ns2="
http://www.w3.org/2000/09/xmldsi#" versione="FPR12">
idee, suggerimenti??
è due giorni che ci piango sopra..