Skip to content

Commit d7eda4a

Browse files
committed
add buyer#id (BT-46)
1 parent 186306b commit d7eda4a

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

lib/secretariat/trade_party.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ module Secretariat
1818
using ObjectExtensions
1919

2020
TradeParty = Struct.new('TradeParty',
21+
:id,
2122
:name, :street1, :street2, :city, :postal_code, :country_id, :vat_id, :global_id, :global_id_scheme_id, :tax_id,
2223
keyword_init: true,
2324
) do
2425
def to_xml(xml, exclude_tax: false, version: 2)
26+
if id
27+
xml['ram'].ID id # BT-46
28+
end
2529
if global_id.present? && global_id_scheme_id.present?
2630
xml['ram'].GlobalID(schemeID: global_id_scheme_id) do
2731
xml.text(global_id)

test/invoice_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def make_eu_invoice(tax_category: :REVERSECHARGE)
1515
vat_id: 'DE304755032'
1616
)
1717
buyer = TradeParty.new(
18+
id: 'Kunde 4711',
1819
name: 'Depfu inc',
1920
street1: 'Quickbornstr. 46',
2021
city: 'Hamburg',
@@ -367,6 +368,7 @@ def test_simple_eu_invoice_v2
367368
assert_match(/<ram:CategoryCode>AE<\/ram:CategoryCode>/, xml)
368369
assert_match(/<ram:ExemptionReason>Reverse Charge<\/ram:ExemptionReason>/, xml)
369370
assert_match(/<ram:RateApplicablePercent>/, xml)
371+
assert_match(%r{<ram:BuyerTradeParty>\s*<ram:ID>Kunde 4711</ram:ID>}, xml)
370372

371373
v = Validator.new(xml, version: 2)
372374
errors = v.validate_against_schema

0 commit comments

Comments
 (0)