Skip to content

Commit

Permalink
PartyLegalEntity: added CompanyID.
Browse files Browse the repository at this point in the history
  • Loading branch information
stas authored and corny committed Jun 26, 2024
1 parent 7a4cc8b commit d56bf5f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/xrechnung/party_legal_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ module Xrechnung
class PartyLegalEntity
include MemberContainer

# @!attribute company_id
# @return [String]
member :company_id, type: String

# @!attribute registration_name
# @return [String]
member :registration_name, type: String

# noinspection RubyResolve
def to_xml(xml)
xml.cac :PartyLegalEntity do
xml.cbc(:CompanyID, company_id) unless company_id.nil?
xml.cbc :RegistrationName, registration_name
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/fixtures/ruby/party_legal_entity.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
def build_party_legal_entity
def build_party_legal_entity(company_id: nil)
Xrechnung::PartyLegalEntity.new(
company_id: company_id,
registration_name: "Harry Hirsch Holz- und Trockenbau",
)
end
1 change: 1 addition & 0 deletions spec/fixtures/scraps/party_legal_entity.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<cac:PartyLegalEntity>
<cbc:CompanyID>DE 214365879</cbc:CompanyID>
<cbc:RegistrationName>Harry Hirsch Holz- und Trockenbau</cbc:RegistrationName>
</cac:PartyLegalEntity>
5 changes: 4 additions & 1 deletion spec/xrechnung/party_legal_entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

RSpec.describe Xrechnung::PartyLegalEntity do
it "generates xml" do
expect_xml_eq_fixture(build_party_legal_entity, "party_legal_entity")
expect_xml_eq_fixture(
build_party_legal_entity(company_id: "DE 214365879"),
"party_legal_entity"
)
end
end

0 comments on commit d56bf5f

Please sign in to comment.