From 3925bd66947c356864d18a725a683f87cc9ea68c Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Wed, 31 Jan 2024 21:21:24 +0000 Subject: [PATCH] Fixing nil check and ensuring invoice series included in number --- body.go | 7 ++++++- items.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/body.go b/body.go index f7e1ff3..5db0e15 100644 --- a/body.go +++ b/body.go @@ -98,12 +98,17 @@ func newDatiGenerali(inv *bill.Invoice) (*datiGenerali, error) { return nil, errors.New("simplified invoices are not currently supported") } + code := inv.Code + if inv.Series != "" { + code = fmt.Sprintf("%s-%s", inv.Series, inv.Code) + } + return &datiGenerali{ DatiGeneraliDocumento: &datiGeneraliDocumento{ TipoDocumento: codeTipoDocumento, Divisa: string(inv.Currency), Data: inv.IssueDate.String(), - Numero: inv.Code, + Numero: code, DatiRitenuta: dr, DatiBollo: newDatiBollo(inv.Charges), ImportoTotaleDocumento: formatAmount(&inv.Totals.Payable), diff --git a/items.go b/items.go index 6b19138..c6ae0b5 100644 --- a/items.go +++ b/items.go @@ -55,7 +55,7 @@ func generateLineDetails(inv *bill.Invoice) []*dettaglioLinee { PrezzoTotale: formatAmount(&line.Sum), ScontoMaggiorazione: extractLinePriceAdjustments(line), } - if len(line.Taxes) > 0 { + if line.Taxes != nil && len(line.Taxes) > 0 { vatTax := line.Taxes.Get(tax.CategoryVAT) if vatTax != nil { d.AliquotaIVA = formatPercentage(vatTax.Percent)