Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/secretariat/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Secretariat
:due_amount,
:paid_amount,
:tax_calculation_method,
:notes,
:attachments,
keyword_init: true
) do
Expand Down Expand Up @@ -84,7 +85,7 @@ def taxes
taxes[line_item.tax_percent].base_amount += BigDecimal(line_item.net_amount) * line_item.quantity
end
end

if tax_calculation_method == :VERTICAL
taxes.values.map do |tax|
tax.tax_amount = (tax.base_amount * tax.tax_percent / 100).round(2)
Expand Down Expand Up @@ -200,8 +201,13 @@ def to_xml(version: 1, validate: true)
xml.text(issue_date.strftime("%Y%m%d"))
end
end

Array(self.notes).each do |note|
xml['ram'].IncludedNote do
xml['ram'].Content note
end
end
end

transaction = by_version(version, 'SpecifiedSupplyChainTradeTransaction', 'SupplyChainTradeTransaction')
xml['rsm'].send(transaction) do

Expand Down
7 changes: 4 additions & 3 deletions test/invoice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def make_eu_invoice(tax_category: :REVERSECHARGE)
grand_total_amount: BigDecimal('29'),
due_amount: 0,
paid_amount: 29,
payment_due_date: Date.today + 14
payment_due_date: Date.today + 14,
notes: "This is a test invoice",
)
end

Expand Down Expand Up @@ -401,7 +402,7 @@ def test_simple_foreign_invoice_v2_taxexpempt
rescue ValidationError => e
puts e.errors
end

def test_simple_foreign_invoice_v2_untaxed
begin
xml = make_foreign_invoice(tax_category: :UNTAXEDSERVICE).to_xml(version: 2)
Expand Down Expand Up @@ -561,7 +562,7 @@ def test_de_multiple_taxes_invoice_against_schematron_2
end
assert_equal [], errors
end

def test_negative_de_invoice_against_schematron_1
xml = make_negative_de_invoice.to_xml(version: 1)
v = Validator.new(xml, version: 1)
Expand Down