diff --git a/lib/secretariat/invoice.rb b/lib/secretariat/invoice.rb index 833114e..73c97ed 100644 --- a/lib/secretariat/invoice.rb +++ b/lib/secretariat/invoice.rb @@ -42,6 +42,7 @@ module Secretariat :due_amount, :paid_amount, :tax_calculation_method, + :notes, :attachments, keyword_init: true ) do @@ -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) @@ -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 diff --git a/test/invoice_test.rb b/test/invoice_test.rb index b425517..91ce0eb 100644 --- a/test/invoice_test.rb +++ b/test/invoice_test.rb @@ -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 @@ -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) @@ -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)