Skip to content

Commit

Permalink
Fixing nil check and ensuring invoice series included in number
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Jan 31, 2024
1 parent b99f8a1 commit 3925bd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion body.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion items.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3925bd6

Please sign in to comment.