Skip to content

Commit

Permalink
Adding Debit note back to spain
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Feb 2, 2024
1 parent 2294852 commit e039ee7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
59 changes: 52 additions & 7 deletions bill/invoice_correct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ import (
func TestInvoiceCorrect(t *testing.T) {
// Spanish Case (only corrective)

// debit note not supported in Spain
i := testInvoiceESForCorrection(t)
err := i.Correct(bill.Debit)
i := testInvoicePTForCorrection(t)
err := i.Correct(bill.Corrective)
require.Error(t, err)
assert.Contains(t, err.Error(), "invalid correction type: debit-note")
assert.Contains(t, err.Error(), "invalid correction type: corrective")

i = testInvoiceESForCorrection(t)
err = i.Correct(bill.Credit,
Expand Down Expand Up @@ -54,10 +53,10 @@ func TestInvoiceCorrect(t *testing.T) {
require.Error(t, err)
assert.Contains(t, err.Error(), "missing correction type")

i = testInvoiceESForCorrection(t)
err = i.Correct(bill.Debit, bill.WithReason("should fail"))
i = testInvoicePTForCorrection(t)
err = i.Correct(bill.Corrective, bill.WithReason("should fail"))
require.Error(t, err)
assert.Contains(t, err.Error(), "invalid correction type: debit-note")
assert.Contains(t, err.Error(), "invalid correction type: corrective")

i = testInvoiceESForCorrection(t)
err = i.Correct(
Expand Down Expand Up @@ -238,6 +237,52 @@ func testInvoiceESForCorrection(t *testing.T) *bill.Invoice {
return i
}

func testInvoicePTForCorrection(t *testing.T) *bill.Invoice {
t.Helper()
i := &bill.Invoice{
Series: "TEST",
Code: "123",
Tax: &bill.Tax{
PricesInclude: tax.CategoryVAT,
},
Supplier: &org.Party{
TaxID: &tax.Identity{
Country: l10n.PT,
Code: "545259045",
},
},
Customer: &org.Party{
TaxID: &tax.Identity{
Country: l10n.PT,
Code: "503504030",
},
},
IssueDate: cal.MakeDate(2022, 6, 13),
Lines: []*bill.Line{
{
Quantity: num.MakeAmount(10, 0),
Item: &org.Item{
Name: "Test Item",
Price: num.MakeAmount(10000, 2),
},
Taxes: tax.Set{
{
Category: "VAT",
Rate: "standard",
},
},
Discounts: []*bill.LineDiscount{
{
Reason: "Testing",
Percent: num.NewPercentage(10, 2),
},
},
},
},
}
return i
}

func testInvoiceFRForCorrection(t *testing.T) *bill.Invoice {
t.Helper()
i := &bill.Invoice{
Expand Down
1 change: 1 addition & 0 deletions regimes/es/es.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func New() *tax.Regime {
Types: []cbc.Key{
bill.InvoiceTypeCorrective,
bill.InvoiceTypeCreditNote,
bill.InvoiceTypeDebitNote,
},
Changes: correctionChangesList,
},
Expand Down

0 comments on commit e039ee7

Please sign in to comment.