zugpferd 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb023a7256c9cf26f6688283b6204bbccc0f46f2a6c8f0bb8082c2b1db277151
4
- data.tar.gz: 00d5dc92b2d38a3744af4388017629d83b74b28241014448c75b684fb8de7c5c
3
+ metadata.gz: 97af66296e92817aef2f4f2fbea2e0ebb7170fb3856732a552ac32210a8e085f
4
+ data.tar.gz: cc23dea33a361b6fcfc93a52c0928a70bea18757cb2e022dbf123b142480383a
5
5
  SHA512:
6
- metadata.gz: 0b6313dfce9be63204e9c7317be9abfbd38c0a53c97e5a7960c4b4fab98421f7f5ec892af59457c4babcdc0ec811de4159f926ae8f443df5f1d417055eb3847f
7
- data.tar.gz: 449b38ee768cea1a0a5167f498c5b80a6bc3604bfe92967cabed4e51d230fe56b307dd88c5313886cb2b67d6b053932bf5f8e575b18385b781fd323f74d10fdf
6
+ metadata.gz: 79479ce622f08767f6ac5d3d63b5826ca3a3eef621d768005c417600f16b308856280e270a7188f49a03b3ff25f03ec0b169861570cde588fc72005d64a96b92
7
+ data.tar.gz: 31d343e25f7d8c5e9d2eb459f941b5a0f67d38169e8f264f66100382e8d11ace7e5f2bfb79497d5d0dbbf6f2097965078f7b9fd2ffb0903ae1a56c3c622bdc53
@@ -64,6 +64,7 @@ module Zugpferd
64
64
  legal_registration_id: "ram:SpecifiedLegalOrganization/ram:ID",
65
65
  legal_form: "ram:Description",
66
66
  vat_identifier: "ram:SpecifiedTaxRegistration/ram:ID[@schemeID='VA']",
67
+ tax_registration_identifier: "ram:SpecifiedTaxRegistration/ram:ID[@schemeID='FC']",
67
68
  electronic_address: "ram:URIUniversalCommunication/ram:URIID",
68
69
  }.freeze
69
70
 
@@ -58,7 +58,7 @@ module Zugpferd
58
58
  customization_id: text(root, INVOICE[:customization_id]),
59
59
  profile_id: text(root, INVOICE[:profile_id]),
60
60
  note: text(root, INVOICE[:note]),
61
- seller: build_party(root.at_xpath(SELLER, NS)),
61
+ seller: build_party(root.at_xpath(SELLER, NS), seller: true),
62
62
  buyer: build_party(root.at_xpath(BUYER, NS)),
63
63
  line_items: root.xpath(INVOICE_LINE, NS).map { |n| build_line_item(n) },
64
64
  allowance_charges: settlement ? build_allowance_charges(settlement) : [],
@@ -69,7 +69,8 @@ module Zugpferd
69
69
  )
70
70
  end
71
71
 
72
- def build_party(node)
72
+ # Seller-only terms are read only for the seller
73
+ def build_party(node, seller: false)
73
74
  return nil unless node
74
75
 
75
76
  party = Model::TradeParty.new(
@@ -77,8 +78,9 @@ module Zugpferd
77
78
  trading_name: text(node, PARTY[:trading_name]),
78
79
  identifier: text(node, PARTY[:identifier]),
79
80
  legal_registration_id: text(node, PARTY[:legal_registration_id]),
80
- legal_form: text(node, PARTY[:legal_form]),
81
+ legal_form: (text(node, PARTY[:legal_form]) if seller),
81
82
  vat_identifier: text(node, PARTY[:vat_identifier]),
83
+ tax_registration_identifier: (text(node, PARTY[:tax_registration_identifier]) if seller),
82
84
  electronic_address: text(node, PARTY[:electronic_address]),
83
85
  )
84
86
 
@@ -74,7 +74,7 @@ module Zugpferd
74
74
  def build_agreement(xml, doc)
75
75
  xml["ram"].ApplicableHeaderTradeAgreement do
76
76
  xml["ram"].BuyerReference doc.buyer_reference if doc.buyer_reference
77
- build_party(xml, "SellerTradeParty", doc.seller) if doc.seller
77
+ build_party(xml, "SellerTradeParty", doc.seller, seller: true) if doc.seller
78
78
  build_party(xml, "BuyerTradeParty", doc.buyer) if doc.buyer
79
79
  build_buyer_order_reference(xml, doc) if doc.purchase_order_reference
80
80
  end
@@ -86,7 +86,8 @@ module Zugpferd
86
86
  end
87
87
  end
88
88
 
89
- def build_party(xml, element_name, party)
89
+ # Seller-only terms are written only for the seller
90
+ def build_party(xml, element_name, party, seller: false)
90
91
  xml["ram"].send(element_name) do
91
92
  if party.identifier
92
93
  xml["ram"].ID party.identifier
@@ -94,7 +95,7 @@ module Zugpferd
94
95
 
95
96
  xml["ram"].Name party.name
96
97
 
97
- xml["ram"].Description party.legal_form if party.legal_form
98
+ xml["ram"].Description party.legal_form if seller && party.legal_form
98
99
 
99
100
  if party.legal_registration_id || party.trading_name
100
101
  xml["ram"].SpecifiedLegalOrganization do
@@ -120,6 +121,12 @@ module Zugpferd
120
121
  xml["ram"].ID(party.vat_identifier, schemeID: "VA")
121
122
  end
122
123
  end
124
+
125
+ if seller && party.tax_registration_identifier
126
+ xml["ram"].SpecifiedTaxRegistration do
127
+ xml["ram"].ID(party.tax_registration_identifier, schemeID: "FC")
128
+ end
129
+ end
123
130
  end
124
131
  end
125
132
 
@@ -10,14 +10,16 @@ module Zugpferd
10
10
  # @return [String, nil] BT-28/BT-45 Trading name
11
11
  # @return [String, nil] BT-29/BT-46 Party identifier
12
12
  # @return [String, nil] BT-30/BT-47 Legal registration identifier
13
- # @return [String, nil] BT-33 Company legal form
13
+ # @return [String, nil] BT-33 Company legal form (seller only)
14
14
  # @return [String, nil] BT-31/BT-48 VAT identifier
15
+ # @return [String, nil] BT-32 Seller tax registration identifier (seller only)
15
16
  # @return [String, nil] BT-34/BT-49 Electronic address
16
17
  # @return [String, nil] BT-34-1/BT-49-1 Electronic address scheme
17
18
  # @return [PostalAddress, nil] BG-5/BG-8 Postal address
18
19
  # @return [Contact, nil] BG-6/BG-9 Contact information
19
20
  attr_accessor :name, :trading_name, :identifier,
20
21
  :legal_registration_id, :legal_form, :vat_identifier,
22
+ :tax_registration_identifier,
21
23
  :electronic_address, :electronic_address_scheme,
22
24
  :postal_address, :contact
23
25
 
@@ -63,6 +63,7 @@ module Zugpferd
63
63
  legal_registration_id: "cac:PartyLegalEntity/cbc:CompanyID",
64
64
  legal_form: "cac:PartyLegalEntity/cbc:CompanyLegalForm",
65
65
  vat_identifier: "cac:PartyTaxScheme[cac:TaxScheme/cbc:ID='VAT']/cbc:CompanyID",
66
+ tax_registration_identifier: "cac:PartyTaxScheme[cac:TaxScheme/cbc:ID!='VAT']/cbc:CompanyID",
66
67
  electronic_address: "cbc:EndpointID",
67
68
  }.freeze
68
69
 
@@ -51,7 +51,7 @@ module Zugpferd
51
51
  customization_id: text(root, INVOICE[:customization_id]),
52
52
  profile_id: text(root, INVOICE[:profile_id]),
53
53
  note: text(root, INVOICE[:note]),
54
- seller: build_party(root.at_xpath(SELLER, @ns)),
54
+ seller: build_party(root.at_xpath(SELLER, @ns), seller: true),
55
55
  buyer: build_party(root.at_xpath(BUYER, @ns)),
56
56
  line_items: root.xpath(line_element, @ns).map { |n| build_line_item(n) },
57
57
  allowance_charges: root.xpath(ALLOWANCE_CHARGE, @ns).map { |n| build_allowance_charge(n) },
@@ -62,7 +62,8 @@ module Zugpferd
62
62
  )
63
63
  end
64
64
 
65
- def build_party(node)
65
+ # Seller-only terms are read only for the seller
66
+ def build_party(node, seller: false)
66
67
  return nil unless node
67
68
 
68
69
  party = Model::TradeParty.new(
@@ -70,8 +71,9 @@ module Zugpferd
70
71
  trading_name: text(node, PARTY[:trading_name]),
71
72
  identifier: text(node, PARTY[:identifier]),
72
73
  legal_registration_id: text(node, PARTY[:legal_registration_id]),
73
- legal_form: text(node, PARTY[:legal_form]),
74
+ legal_form: (text(node, PARTY[:legal_form]) if seller),
74
75
  vat_identifier: text(node, PARTY[:vat_identifier]),
76
+ tax_registration_identifier: (text(node, PARTY[:tax_registration_identifier]) if seller),
75
77
  electronic_address: text(node, PARTY[:electronic_address]),
76
78
  )
77
79
 
@@ -68,7 +68,7 @@ module Zugpferd
68
68
  def build_supplier(xml, party, payment_instructions = nil)
69
69
  xml["cac"].AccountingSupplierParty do
70
70
  build_party(xml, party,
71
- creditor_reference_id: payment_instructions&.creditor_reference_id)
71
+ creditor_reference_id: payment_instructions&.creditor_reference_id, seller: true)
72
72
  end
73
73
  end
74
74
 
@@ -78,7 +78,8 @@ module Zugpferd
78
78
  end
79
79
  end
80
80
 
81
- def build_party(xml, party, creditor_reference_id: nil)
81
+ # Seller-only terms are written only for the seller
82
+ def build_party(xml, party, creditor_reference_id: nil, seller: false)
82
83
  xml["cac"].Party do
83
84
  if party.electronic_address
84
85
  attrs = {}
@@ -115,10 +116,19 @@ module Zugpferd
115
116
  end
116
117
  end
117
118
 
119
+ if seller && party.tax_registration_identifier
120
+ xml["cac"].PartyTaxScheme do
121
+ xml["cbc"].CompanyID party.tax_registration_identifier
122
+ xml["cac"].TaxScheme do
123
+ xml["cbc"].ID "FC"
124
+ end
125
+ end
126
+ end
127
+
118
128
  xml["cac"].PartyLegalEntity do
119
129
  xml["cbc"].RegistrationName party.name
120
130
  xml["cbc"].CompanyID party.legal_registration_id if party.legal_registration_id
121
- xml["cbc"].CompanyLegalForm party.legal_form if party.legal_form
131
+ xml["cbc"].CompanyLegalForm party.legal_form if seller && party.legal_form
122
132
  end
123
133
 
124
134
  build_contact(xml, party.contact) if party.contact
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zugpferd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Zeitler