Skip to content

Commit

Permalink
Set default Regime Fiscale
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Sep 21, 2023
1 parent 036c6b7 commit 51f469f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions parties.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ func newCedentePrestatore(s *org.Party) *supplier {
IdPaese: s.TaxID.Country.String(),
IdCodice: s.TaxID.Code.String(),
},
Anagrafica: newAnagrafica(s),
RegimeFiscale: s.Ext[it.ExtKeySDIFiscalRegime].String(),
Anagrafica: newAnagrafica(s),
},
IscrizioneREA: newIscrizioneREA(s),
Contatti: newContatti(s),
}

if v, ok := s.Ext[it.ExtKeySDIFiscalRegime]; ok {
ns.DatiAnagrafici.RegimeFiscale = v.String()
} else {
ns.DatiAnagrafici.RegimeFiscale = "RF01"
}

if len(s.Addresses) > 0 {
ns.Sede = newAddress(s.Addresses[0])
}
Expand Down
12 changes: 12 additions & 0 deletions parties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ func TestPartiesSupplier(t *testing.T) {
assert.Equal(t, "50000.00", s.IscrizioneREA.CapitaleSociale)
assert.Equal(t, "LN", s.IscrizioneREA.StatoLiquidazione)
})

t.Run("should set the supplier default regime fiscale", func(t *testing.T) {
env := test.LoadTestFile("invoice-simple.json")
inv := env.Extract().(*bill.Invoice)
inv.Supplier.Ext = nil
doc, err := test.ConvertFromGOBL(env)
require.NoError(t, err)

s := doc.FatturaElettronicaHeader.CedentePrestatore

assert.Equal(t, "RF01", s.DatiAnagrafici.RegimeFiscale)
})
}

func TestPartiesCustomer(t *testing.T) {
Expand Down

0 comments on commit 51f469f

Please sign in to comment.