Created
April 6, 2016 10:29
-
-
Save thesyncim/c9ce31eb71ba5b1c5a9f0bcc91758154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/xml" | |
"os" | |
) | |
func main(){ | |
file,err:=os.Open("saft.utf8.xml") | |
if err!=nil{ | |
panic(err) | |
} | |
defer file.Close() | |
decoder:=xml.NewDecoder(file) | |
var saft Saft | |
err=decoder.Decode(&saft) | |
if err!=nil{ | |
panic(err) | |
} | |
} | |
type Saft struct { | |
AuditFile struct { | |
Xsi string `xml:"xsi,attr"` | |
Header struct { | |
AuditFileVersion string `xml:"AuditFileVersion"` | |
CompanyID string `xml:"CompanyID"` | |
TaxRegistrationNumber string `xml:"TaxRegistrationNumber"` | |
TaxAccountingBasis string `xml:"TaxAccountingBasis"` | |
CompanyName string `xml:"CompanyName"` | |
BusinessName string `xml:"BusinessName"` | |
CompanyAddress struct { | |
BuildingNumber string `xml:"BuildingNumber"` | |
StreetName string `xml:"StreetName"` | |
AddressDetail string `xml:"AddressDetail"` | |
City string `xml:"City"` | |
PostalCode string `xml:"PostalCode"` | |
Region string `xml:"Region"` | |
Country string `xml:"Country"` | |
} `xml:"CompanyAddress"` | |
FiscalYear string `xml:"FiscalYear"` | |
StartDate string `xml:"StartDate"` | |
EndDate string `xml:"EndDate"` | |
CurrencyCode string `xml:"CurrencyCode"` | |
DateCreated string `xml:"DateCreated"` | |
TaxEntity string `xml:"TaxEntity"` | |
ProductCompanyTaxID string `xml:"ProductCompanyTaxID"` | |
SoftwareCertificateNumber string `xml:"SoftwareCertificateNumber"` | |
ProductID string `xml:"ProductID"` | |
ProductVersion string `xml:"ProductVersion"` | |
Telephone string `xml:"Telephone"` | |
Fax string `xml:"Fax"` | |
Email string `xml:"Email"` | |
Website string `xml:"Website"` | |
} `xml:"Header"` | |
MasterFiles struct { | |
Customer []struct { | |
CustomerID string `xml:"CustomerID"` | |
AccountID string `xml:"AccountID"` | |
CustomerTaxID string `xml:"CustomerTaxID"` | |
CompanyName string `xml:"CompanyName"` | |
BillingAddress struct { | |
AddressDetail string `xml:"AddressDetail"` | |
City string `xml:"City"` | |
PostalCode string `xml:"PostalCode"` | |
Country string `xml:"Country"` | |
} `xml:"BillingAddress"` | |
ShipToAddress struct { | |
AddressDetail string `xml:"AddressDetail"` | |
City string `xml:"City"` | |
PostalCode string `xml:"PostalCode"` | |
Country string `xml:"Country"` | |
} `xml:"ShipToAddress"` | |
SelfBillingIndicator string `xml:"SelfBillingIndicator"` | |
Telephone string `xml:"Telephone"` | |
Fax string `xml:"Fax"` | |
Email string `xml:"Email"` | |
Website string `xml:"Website"` | |
} `xml:"Customer"` | |
Product []struct { | |
ProductType string `xml:"ProductType"` | |
ProductCode string `xml:"ProductCode"` | |
ProductGroup string `xml:"ProductGroup"` | |
ProductDescription string `xml:"ProductDescription"` | |
ProductNumberCode string `xml:"ProductNumberCode"` | |
} `xml:"Product"` | |
TaxTable struct { | |
TaxTableEntry []struct { | |
TaxType string `xml:"TaxType"` | |
TaxCountryRegion string `xml:"TaxCountryRegion"` | |
TaxCode string `xml:"TaxCode"` | |
Description string `xml:"Description"` | |
TaxPercentage string `xml:"TaxPercentage"` | |
} `xml:"TaxTableEntry"` | |
} `xml:"TaxTable"` | |
} `xml:"MasterFiles"` | |
SourceDocuments struct { | |
SalesInvoices struct { | |
NumberOfEntries string `xml:"NumberOfEntries"` | |
TotalDebit string `xml:"TotalDebit"` | |
TotalCredit string `xml:"TotalCredit"` | |
Invoice []struct { | |
InvoiceNo string `xml:"InvoiceNo"` | |
DocumentStatus struct { | |
InvoiceStatus string `xml:"InvoiceStatus"` | |
InvoiceStatusDate string `xml:"InvoiceStatusDate"` | |
Reason string `xml:"Reason"` | |
SourceID string `xml:"SourceID"` | |
SourceBilling string `xml:"SourceBilling"` | |
} `xml:"DocumentStatus"` | |
Hash string `xml:"Hash"` | |
HashControl string `xml:"HashControl"` | |
Period string `xml:"Period"` | |
InvoiceDate string `xml:"InvoiceDate"` | |
InvoiceType string `xml:"InvoiceType"` | |
SpecialRegimes struct { | |
SelfBillingIndicator string `xml:"SelfBillingIndicator"` | |
CashVATSchemeIndicator string `xml:"CashVATSchemeIndicator"` | |
ThirdPartiesBillingIndicator string `xml:"ThirdPartiesBillingIndicator"` | |
} `xml:"SpecialRegimes"` | |
SourceID string `xml:"SourceID"` | |
SystemEntryDate string `xml:"SystemEntryDate"` | |
CustomerID string `xml:"CustomerID"` | |
ShipTo struct { | |
DeliveryDate string `xml:"DeliveryDate"` | |
Address struct { | |
AddressDetail string `xml:"AddressDetail"` | |
City string `xml:"City"` | |
PostalCode string `xml:"PostalCode"` | |
Country string `xml:"Country"` | |
} `xml:"Address"` | |
} `xml:"ShipTo"` | |
ShipFrom struct { | |
DeliveryDate string `xml:"DeliveryDate"` | |
Address struct { | |
AddressDetail string `xml:"AddressDetail"` | |
City string `xml:"City"` | |
PostalCode string `xml:"PostalCode"` | |
Country string `xml:"Country"` | |
} `xml:"Address"` | |
} `xml:"ShipFrom"` | |
MovementEndTime string `xml:"MovementEndTime"` | |
MovementStartTime string `xml:"MovementStartTime"` | |
Line []struct { | |
LineNumber string `xml:"LineNumber"` | |
ProductCode string `xml:"ProductCode"` | |
ProductDescription string `xml:"ProductDescription"` | |
Quantity string `xml:"Quantity"` | |
UnitOfMeasure string `xml:"UnitOfMeasure"` | |
UnitPrice string `xml:"UnitPrice"` | |
TaxPointDate string `xml:"TaxPointDate"` | |
Description string `xml:"Description"` | |
CreditAmount string `xml:"CreditAmount"` | |
Tax struct { | |
TaxType string `xml:"TaxType"` | |
TaxCountryRegion string `xml:"TaxCountryRegion"` | |
TaxCode string `xml:"TaxCode"` | |
TaxPercentage string `xml:"TaxPercentage"` | |
} `xml:"Tax"` | |
SettlementAmount string `xml:"SettlementAmount"` | |
} `xml:"Line"` | |
DocumentTotals struct { | |
TaxPayable string `xml:"TaxPayable"` | |
NetTotal string `xml:"NetTotal"` | |
GrossTotal string `xml:"GrossTotal"` | |
} `xml:"DocumentTotals"` | |
} `xml:"Invoice"` | |
} `xml:"SalesInvoices"` | |
MovementOfGoods struct { | |
NumberOfMovementLines string `xml:"NumberOfMovementLines"` | |
TotalQuantityIssued string `xml:"TotalQuantityIssued"` | |
StockMovement []struct { | |
DocumentNumber string `xml:"DocumentNumber"` | |
DocumentStatus struct { | |
MovementStatus string `xml:"MovementStatus"` | |
MovementStatusDate string `xml:"MovementStatusDate"` | |
Reason string `xml:"Reason"` | |
SourceID string `xml:"SourceID"` | |
SourceBilling string `xml:"SourceBilling"` | |
} `xml:"DocumentStatus"` | |
Hash string `xml:"Hash"` | |
HashControl string `xml:"HashControl"` | |
Period string `xml:"Period"` | |
MovementDate string `xml:"MovementDate"` | |
MovementType string `xml:"MovementType"` | |
SystemEntryDate string `xml:"SystemEntryDate"` | |
CustomerID string `xml:"CustomerID"` | |
SourceID string `xml:"SourceID"` | |
ShipTo struct { | |
DeliveryDate string `xml:"DeliveryDate"` | |
Address struct { | |
AddressDetail string `xml:"AddressDetail"` | |
City string `xml:"City"` | |
PostalCode string `xml:"PostalCode"` | |
Country string `xml:"Country"` | |
} `xml:"Address"` | |
} `xml:"ShipTo"` | |
ShipFrom struct { | |
DeliveryDate string `xml:"DeliveryDate"` | |
Address struct { | |
AddressDetail string `xml:"AddressDetail"` | |
City string `xml:"City"` | |
PostalCode string `xml:"PostalCode"` | |
Country string `xml:"Country"` | |
} `xml:"Address"` | |
} `xml:"ShipFrom"` | |
MovementEndTime string `xml:"MovementEndTime"` | |
MovementStartTime string `xml:"MovementStartTime"` | |
Line struct { | |
LineNumber string `xml:"LineNumber"` | |
ProductCode string `xml:"ProductCode"` | |
ProductDescription string `xml:"ProductDescription"` | |
Quantity string `xml:"Quantity"` | |
UnitOfMeasure string `xml:"UnitOfMeasure"` | |
UnitPrice string `xml:"UnitPrice"` | |
Description string `xml:"Description"` | |
DebitAmount string `xml:"DebitAmount"` | |
Tax struct { | |
TaxType string `xml:"TaxType"` | |
TaxCountryRegion string `xml:"TaxCountryRegion"` | |
TaxCode string `xml:"TaxCode"` | |
TaxPercentage string `xml:"TaxPercentage"` | |
} `xml:"Tax"` | |
SettlementAmount string `xml:"SettlementAmount"` | |
} `xml:"Line"` | |
DocumentTotals struct { | |
TaxPayable string `xml:"TaxPayable"` | |
NetTotal string `xml:"NetTotal"` | |
GrossTotal string `xml:"GrossTotal"` | |
} `xml:"DocumentTotals"` | |
} `xml:"StockMovement"` | |
} `xml:"MovementOfGoods"` | |
WorkingDocuments struct { | |
NumberOfEntries string `xml:"NumberOfEntries"` | |
TotalDebit string `xml:"TotalDebit"` | |
TotalCredit string `xml:"TotalCredit"` | |
WorkDocument []struct { | |
DocumentNumber string `xml:"DocumentNumber"` | |
DocumentStatus struct { | |
WorkStatus string `xml:"WorkStatus"` | |
WorkStatusDate string `xml:"WorkStatusDate"` | |
Reason string `xml:"Reason"` | |
SourceID string `xml:"SourceID"` | |
SourceBilling string `xml:"SourceBilling"` | |
} `xml:"DocumentStatus"` | |
Hash string `xml:"Hash"` | |
HashControl string `xml:"HashControl"` | |
Period string `xml:"Period"` | |
WorkDate string `xml:"WorkDate"` | |
WorkType string `xml:"WorkType"` | |
SourceID string `xml:"SourceID"` | |
SystemEntryDate string `xml:"SystemEntryDate"` | |
CustomerID string `xml:"CustomerID"` | |
Line struct { | |
LineNumber string `xml:"LineNumber"` | |
ProductCode string `xml:"ProductCode"` | |
ProductDescription string `xml:"ProductDescription"` | |
Quantity string `xml:"Quantity"` | |
UnitOfMeasure string `xml:"UnitOfMeasure"` | |
UnitPrice string `xml:"UnitPrice"` | |
TaxPointDate string `xml:"TaxPointDate"` | |
Description string `xml:"Description"` | |
DebitAmount string `xml:"DebitAmount"` | |
Tax struct { | |
TaxType string `xml:"TaxType"` | |
TaxCountryRegion string `xml:"TaxCountryRegion"` | |
TaxCode string `xml:"TaxCode"` | |
TaxPercentage string `xml:"TaxPercentage"` | |
} `xml:"Tax"` | |
SettlementAmount string `xml:"SettlementAmount"` | |
} `xml:"Line"` | |
DocumentTotals struct { | |
TaxPayable string `xml:"TaxPayable"` | |
NetTotal string `xml:"NetTotal"` | |
GrossTotal string `xml:"GrossTotal"` | |
} `xml:"DocumentTotals"` | |
} `xml:"WorkDocument"` | |
} `xml:"WorkingDocuments"` | |
Payments struct { | |
NumberOfEntries string `xml:"NumberOfEntries"` | |
TotalDebit string `xml:"TotalDebit"` | |
TotalCredit string `xml:"TotalCredit"` | |
Payment []struct { | |
PaymentRefNo string `xml:"PaymentRefNo"` | |
Period string `xml:"Period"` | |
TransactionDate string `xml:"TransactionDate"` | |
PaymentType string `xml:"PaymentType"` | |
Description string `xml:"Description"` | |
SystemID string `xml:"SystemID"` | |
DocumentStatus struct { | |
PaymentStatus string `xml:"PaymentStatus"` | |
PaymentStatusDate string `xml:"PaymentStatusDate"` | |
Reason string `xml:"Reason"` | |
SourceID string `xml:"SourceID"` | |
SourcePayment string `xml:"SourcePayment"` | |
} `xml:"DocumentStatus"` | |
PaymentMethod struct { | |
PaymentMechanism string `xml:"PaymentMechanism"` | |
PaymentAmount string `xml:"PaymentAmount"` | |
PaymentDate string `xml:"PaymentDate"` | |
} `xml:"PaymentMethod"` | |
SourceID string `xml:"SourceID"` | |
SystemEntryDate string `xml:"SystemEntryDate"` | |
CustomerID string `xml:"CustomerID"` | |
Line struct { | |
LineNumber string `xml:"LineNumber"` | |
SourceDocumentID struct { | |
OriginatingON string `xml:"OriginatingON"` | |
InvoiceDate string `xml:"InvoiceDate"` | |
Description string `xml:"Description"` | |
} `xml:"SourceDocumentID"` | |
SettlementAmount string `xml:"SettlementAmount"` | |
CreditAmount string `xml:"CreditAmount"` | |
} `xml:"Line"` | |
DocumentTotals struct { | |
TaxPayable string `xml:"TaxPayable"` | |
NetTotal string `xml:"NetTotal"` | |
GrossTotal string `xml:"GrossTotal"` | |
} `xml:"DocumentTotals"` | |
} `xml:"Payment"` | |
} `xml:"Payments"` | |
} `xml:"SourceDocuments"` | |
} `xml:"AuditFile"` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment