zugpferd 0.3.0 → 0.9.1
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 +4 -4
- data/bin/setup-schemas +186 -0
- data/lib/zugpferd/cii/mapping.rb +37 -1
- data/lib/zugpferd/cii/reader.rb +57 -10
- data/lib/zugpferd/cii/writer.rb +103 -4
- data/lib/zugpferd/model/billing_document.rb +16 -2
- data/lib/zugpferd/model/line_item.rb +4 -1
- data/lib/zugpferd/model/payment_instructions.rb +3 -2
- data/lib/zugpferd/model/postal_address.rb +6 -6
- data/lib/zugpferd/model/preceding_invoice.rb +17 -0
- data/lib/zugpferd/model/price.rb +2 -1
- data/lib/zugpferd/model/trade_party.rb +3 -1
- data/lib/zugpferd/pdf/catalog_af.ps +21 -0
- data/lib/zugpferd/pdf/embedder.rb +6 -0
- data/lib/zugpferd/pdf/extractor.rb +318 -0
- data/lib/zugpferd/pdf.rb +1 -0
- data/lib/zugpferd/ubl/mapping.rb +47 -1
- data/lib/zugpferd/ubl/reader.rb +40 -4
- data/lib/zugpferd/ubl/writer.rb +99 -14
- data/lib/zugpferd/validation/pdf_validator.rb +11 -7
- data/lib/zugpferd/validation/schema_validator.rb +4 -4
- data/lib/zugpferd.rb +5 -4
- metadata +9 -9
data/lib/zugpferd/ubl/reader.rb
CHANGED
|
@@ -30,33 +30,45 @@ module Zugpferd
|
|
|
30
30
|
def build_invoice(root)
|
|
31
31
|
type_code_element = @credit_note ? "cbc:CreditNoteTypeCode" : INVOICE[:type_code]
|
|
32
32
|
line_element = @credit_note ? "cac:CreditNoteLine" : INVOICE_LINE
|
|
33
|
+
due_date_element = @credit_note ? CREDIT_NOTE_DUE_DATE : INVOICE[:due_date]
|
|
33
34
|
|
|
34
35
|
model_class = @credit_note ? Model::CreditNote : Model::Invoice
|
|
35
36
|
|
|
36
37
|
delivery_node = root.at_xpath(DELIVERY, @ns)
|
|
38
|
+
period_node = root.at_xpath(INVOICE_PERIOD, @ns)
|
|
37
39
|
|
|
38
40
|
model_class.new(
|
|
39
41
|
number: text(root, INVOICE[:number]),
|
|
40
42
|
issue_date: parse_date(text(root, INVOICE[:issue_date])),
|
|
41
|
-
due_date: parse_date(text(root,
|
|
43
|
+
due_date: parse_date(text(root, due_date_element)),
|
|
42
44
|
delivery_date: delivery_node ? parse_date(text(delivery_node, DELIVERY_DATE)) : nil,
|
|
45
|
+
deliver_to_address: build_deliver_to_address(delivery_node),
|
|
46
|
+
invoicing_period_start_date: period_node ? parse_date(text(period_node, INVOICE_PERIOD_FIELDS[:start_date])) : nil,
|
|
47
|
+
invoicing_period_end_date: period_node ? parse_date(text(period_node, INVOICE_PERIOD_FIELDS[:end_date])) : nil,
|
|
43
48
|
type_code: text(root, type_code_element),
|
|
44
49
|
currency_code: text(root, INVOICE[:currency_code]),
|
|
45
50
|
buyer_reference: text(root, INVOICE[:buyer_reference]),
|
|
51
|
+
buyer_accounting_reference: text(root, INVOICE[:buyer_accounting_reference]),
|
|
52
|
+
purchase_order_reference: purchase_order_reference(root),
|
|
53
|
+
seller_order_reference: text(root, SALES_ORDER_REFERENCE),
|
|
54
|
+
contract_reference: text(root, CONTRACT_REFERENCE),
|
|
55
|
+
project_reference: text(root, @credit_note ? CREDIT_NOTE_PROJECT_REFERENCE : PROJECT_REFERENCE),
|
|
46
56
|
customization_id: text(root, INVOICE[:customization_id]),
|
|
47
57
|
profile_id: text(root, INVOICE[:profile_id]),
|
|
48
58
|
note: text(root, INVOICE[:note]),
|
|
49
|
-
seller: build_party(root.at_xpath(SELLER, @ns)),
|
|
59
|
+
seller: build_party(root.at_xpath(SELLER, @ns), seller: true),
|
|
50
60
|
buyer: build_party(root.at_xpath(BUYER, @ns)),
|
|
51
61
|
line_items: root.xpath(line_element, @ns).map { |n| build_line_item(n) },
|
|
52
62
|
allowance_charges: root.xpath(ALLOWANCE_CHARGE, @ns).map { |n| build_allowance_charge(n) },
|
|
63
|
+
preceding_invoices: root.xpath(PRECEDING_INVOICE, @ns).map { |n| build_preceding_invoice(n) },
|
|
53
64
|
tax_breakdown: build_tax_breakdown(root.at_xpath(TAX_TOTAL, @ns)),
|
|
54
65
|
monetary_totals: build_monetary_totals(root.at_xpath(MONETARY_TOTAL, @ns)),
|
|
55
66
|
payment_instructions: build_payment_instructions(root),
|
|
56
67
|
)
|
|
57
68
|
end
|
|
58
69
|
|
|
59
|
-
|
|
70
|
+
# Seller-only terms are read only for the seller
|
|
71
|
+
def build_party(node, seller: false)
|
|
60
72
|
return nil unless node
|
|
61
73
|
|
|
62
74
|
party = Model::TradeParty.new(
|
|
@@ -64,8 +76,9 @@ module Zugpferd
|
|
|
64
76
|
trading_name: text(node, PARTY[:trading_name]),
|
|
65
77
|
identifier: text(node, PARTY[:identifier]),
|
|
66
78
|
legal_registration_id: text(node, PARTY[:legal_registration_id]),
|
|
67
|
-
legal_form: text(node, PARTY[:legal_form]),
|
|
79
|
+
legal_form: (text(node, PARTY[:legal_form]) if seller),
|
|
68
80
|
vat_identifier: text(node, PARTY[:vat_identifier]),
|
|
81
|
+
tax_registration_identifier: (text(node, PARTY[:tax_registration_identifier]) if seller),
|
|
69
82
|
electronic_address: text(node, PARTY[:electronic_address]),
|
|
70
83
|
)
|
|
71
84
|
|
|
@@ -90,6 +103,11 @@ module Zugpferd
|
|
|
90
103
|
)
|
|
91
104
|
end
|
|
92
105
|
|
|
106
|
+
def build_deliver_to_address(delivery_node)
|
|
107
|
+
addr_node = delivery_node&.at_xpath(DELIVER_TO_ADDRESS, @ns)
|
|
108
|
+
build_postal_address(addr_node) if addr_node
|
|
109
|
+
end
|
|
110
|
+
|
|
93
111
|
def build_contact(node)
|
|
94
112
|
Model::Contact.new(
|
|
95
113
|
name: text(node, CONTACT_FIELDS[:name]),
|
|
@@ -111,6 +129,7 @@ module Zugpferd
|
|
|
111
129
|
payment_means_code: text(means_node, PAYMENT[:payment_means_code]),
|
|
112
130
|
payment_id: text(means_node, PAYMENT[:payment_id]),
|
|
113
131
|
account_id: text(means_node, PAYMENT[:account_id]),
|
|
132
|
+
account_name: text(means_node, PAYMENT[:account_name]),
|
|
114
133
|
card_account_id: text(means_node, PAYMENT[:card_account_id]),
|
|
115
134
|
card_network_id: text(means_node, PAYMENT[:card_network_id]),
|
|
116
135
|
card_holder_name: text(means_node, PAYMENT[:card_holder_name]),
|
|
@@ -165,6 +184,7 @@ module Zugpferd
|
|
|
165
184
|
def build_line_item(node)
|
|
166
185
|
item_node = node.at_xpath(ITEM, @ns)
|
|
167
186
|
price_node = node.at_xpath(PRICE, @ns)
|
|
187
|
+
period_node = node.at_xpath(LINE_PERIOD, @ns)
|
|
168
188
|
|
|
169
189
|
quantity_element = @credit_note ? "cbc:CreditedQuantity" : LINE[:invoiced_quantity]
|
|
170
190
|
unit_code_element = @credit_note ? "cbc:CreditedQuantity/@unitCode" : LINE[:unit_code]
|
|
@@ -175,6 +195,8 @@ module Zugpferd
|
|
|
175
195
|
unit_code: node.at_xpath(unit_code_element, @ns)&.text,
|
|
176
196
|
line_extension_amount: text(node, LINE[:line_extension_amount]),
|
|
177
197
|
note: text(node, LINE[:note]),
|
|
198
|
+
period_start_date: period_node ? parse_date(text(period_node, LINE_PERIOD_FIELDS[:start_date])) : nil,
|
|
199
|
+
period_end_date: period_node ? parse_date(text(period_node, LINE_PERIOD_FIELDS[:end_date])) : nil,
|
|
178
200
|
item: build_item(item_node),
|
|
179
201
|
price: build_price(price_node),
|
|
180
202
|
)
|
|
@@ -197,6 +219,15 @@ module Zugpferd
|
|
|
197
219
|
|
|
198
220
|
Model::Price.new(
|
|
199
221
|
amount: text(node, PRICE_FIELDS[:amount]),
|
|
222
|
+
base_quantity: parse_decimal(text(node, PRICE_FIELDS[:base_quantity])),
|
|
223
|
+
base_quantity_unit_code: node.at_xpath(PRICE_FIELDS[:base_quantity_unit_code], @ns)&.text,
|
|
224
|
+
)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def build_preceding_invoice(node)
|
|
228
|
+
Model::PrecedingInvoice.new(
|
|
229
|
+
number: text(node, PRECEDING_INVOICE_FIELDS[:number]),
|
|
230
|
+
issue_date: parse_date(text(node, PRECEDING_INVOICE_FIELDS[:issue_date])),
|
|
200
231
|
)
|
|
201
232
|
end
|
|
202
233
|
|
|
@@ -215,6 +246,11 @@ module Zugpferd
|
|
|
215
246
|
)
|
|
216
247
|
end
|
|
217
248
|
|
|
249
|
+
def purchase_order_reference(root)
|
|
250
|
+
ref = text(root, ORDER_REFERENCE)
|
|
251
|
+
ref unless ref == ORDER_REFERENCE_NOT_APPLICABLE
|
|
252
|
+
end
|
|
253
|
+
|
|
218
254
|
def text(node, xpath)
|
|
219
255
|
node.at_xpath(xpath, @ns)&.text
|
|
220
256
|
end
|
data/lib/zugpferd/ubl/writer.rb
CHANGED
|
@@ -41,7 +41,7 @@ module Zugpferd
|
|
|
41
41
|
xml["cbc"].ProfileID doc.profile_id if doc.profile_id
|
|
42
42
|
xml["cbc"].ID doc.number
|
|
43
43
|
xml["cbc"].IssueDate doc.issue_date.to_s
|
|
44
|
-
xml["cbc"].DueDate doc.due_date.to_s if doc.due_date
|
|
44
|
+
xml["cbc"].DueDate doc.due_date.to_s if doc.due_date && !@credit_note
|
|
45
45
|
if @credit_note
|
|
46
46
|
xml["cbc"].CreditNoteTypeCode doc.type_code
|
|
47
47
|
else
|
|
@@ -49,12 +49,24 @@ module Zugpferd
|
|
|
49
49
|
end
|
|
50
50
|
xml["cbc"].Note doc.note if doc.note
|
|
51
51
|
xml["cbc"].DocumentCurrencyCode doc.currency_code
|
|
52
|
+
xml["cbc"].AccountingCost doc.buyer_accounting_reference if doc.buyer_accounting_reference
|
|
52
53
|
xml["cbc"].BuyerReference doc.buyer_reference if doc.buyer_reference
|
|
54
|
+
build_invoice_period(xml, doc) if doc.invoicing_period_start_date || doc.invoicing_period_end_date
|
|
55
|
+
build_order_reference(xml, doc) if doc.purchase_order_reference || doc.seller_order_reference
|
|
56
|
+
doc.preceding_invoices.each { |pi| build_preceding_invoice(xml, pi) }
|
|
57
|
+
|
|
58
|
+
if doc.contract_reference
|
|
59
|
+
xml["cac"].ContractDocumentReference do
|
|
60
|
+
xml["cbc"].ID doc.contract_reference
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
build_project_reference(xml, doc.project_reference) if doc.project_reference
|
|
53
65
|
|
|
54
66
|
build_supplier(xml, doc.seller, doc.payment_instructions) if doc.seller
|
|
55
67
|
build_customer(xml, doc.buyer) if doc.buyer
|
|
56
|
-
build_delivery(xml, doc) if doc.delivery_date
|
|
57
|
-
build_payment_means(xml, doc.payment_instructions) if doc.payment_instructions
|
|
68
|
+
build_delivery(xml, doc) if doc.delivery_date || doc.deliver_to_address
|
|
69
|
+
build_payment_means(xml, doc.payment_instructions, doc.due_date) if doc.payment_instructions
|
|
58
70
|
build_payment_terms(xml, doc.payment_instructions) if doc.payment_instructions&.note
|
|
59
71
|
doc.allowance_charges.each { |ac| build_allowance_charge(xml, ac, doc.currency_code) }
|
|
60
72
|
build_tax_total(xml, doc.tax_breakdown) if doc.tax_breakdown
|
|
@@ -65,7 +77,7 @@ module Zugpferd
|
|
|
65
77
|
def build_supplier(xml, party, payment_instructions = nil)
|
|
66
78
|
xml["cac"].AccountingSupplierParty do
|
|
67
79
|
build_party(xml, party,
|
|
68
|
-
creditor_reference_id: payment_instructions&.creditor_reference_id)
|
|
80
|
+
creditor_reference_id: payment_instructions&.creditor_reference_id, seller: true)
|
|
69
81
|
end
|
|
70
82
|
end
|
|
71
83
|
|
|
@@ -75,7 +87,8 @@ module Zugpferd
|
|
|
75
87
|
end
|
|
76
88
|
end
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
# Seller-only terms are written only for the seller
|
|
91
|
+
def build_party(xml, party, creditor_reference_id: nil, seller: false)
|
|
79
92
|
xml["cac"].Party do
|
|
80
93
|
if party.electronic_address
|
|
81
94
|
attrs = {}
|
|
@@ -112,10 +125,19 @@ module Zugpferd
|
|
|
112
125
|
end
|
|
113
126
|
end
|
|
114
127
|
|
|
128
|
+
if seller && party.tax_registration_identifier
|
|
129
|
+
xml["cac"].PartyTaxScheme do
|
|
130
|
+
xml["cbc"].CompanyID party.tax_registration_identifier
|
|
131
|
+
xml["cac"].TaxScheme do
|
|
132
|
+
xml["cbc"].ID "FC"
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
115
137
|
xml["cac"].PartyLegalEntity do
|
|
116
138
|
xml["cbc"].RegistrationName party.name
|
|
117
139
|
xml["cbc"].CompanyID party.legal_registration_id if party.legal_registration_id
|
|
118
|
-
xml["cbc"].CompanyLegalForm party.legal_form if party.legal_form
|
|
140
|
+
xml["cbc"].CompanyLegalForm party.legal_form if seller && party.legal_form
|
|
119
141
|
end
|
|
120
142
|
|
|
121
143
|
build_contact(xml, party.contact) if party.contact
|
|
@@ -124,12 +146,16 @@ module Zugpferd
|
|
|
124
146
|
|
|
125
147
|
def build_postal_address(xml, addr)
|
|
126
148
|
xml["cac"].PostalAddress do
|
|
127
|
-
xml
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
149
|
+
build_address_fields(xml, addr)
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def build_address_fields(xml, addr)
|
|
154
|
+
xml["cbc"].StreetName addr.street_name if addr.street_name
|
|
155
|
+
xml["cbc"].CityName addr.city_name if addr.city_name
|
|
156
|
+
xml["cbc"].PostalZone addr.postal_zone if addr.postal_zone
|
|
157
|
+
xml["cac"].Country do
|
|
158
|
+
xml["cbc"].IdentificationCode addr.country_code
|
|
133
159
|
end
|
|
134
160
|
end
|
|
135
161
|
|
|
@@ -141,15 +167,60 @@ module Zugpferd
|
|
|
141
167
|
end
|
|
142
168
|
end
|
|
143
169
|
|
|
170
|
+
def build_invoice_period(xml, doc)
|
|
171
|
+
xml["cac"].InvoicePeriod do
|
|
172
|
+
xml["cbc"].StartDate doc.invoicing_period_start_date.to_s if doc.invoicing_period_start_date
|
|
173
|
+
xml["cbc"].EndDate doc.invoicing_period_end_date.to_s if doc.invoicing_period_end_date
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def build_project_reference(xml, project_reference)
|
|
178
|
+
if @credit_note
|
|
179
|
+
xml["cac"].AdditionalDocumentReference do
|
|
180
|
+
xml["cbc"].ID project_reference
|
|
181
|
+
xml["cbc"].DocumentTypeCode PROJECT_REFERENCE_TYPE_CODE
|
|
182
|
+
end
|
|
183
|
+
else
|
|
184
|
+
xml["cac"].ProjectReference do
|
|
185
|
+
xml["cbc"].ID project_reference
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def build_order_reference(xml, doc)
|
|
191
|
+
xml["cac"].OrderReference do
|
|
192
|
+
xml["cbc"].ID doc.purchase_order_reference || ORDER_REFERENCE_NOT_APPLICABLE
|
|
193
|
+
xml["cbc"].SalesOrderID doc.seller_order_reference if doc.seller_order_reference
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def build_preceding_invoice(xml, preceding)
|
|
198
|
+
xml["cac"].BillingReference do
|
|
199
|
+
xml["cac"].InvoiceDocumentReference do
|
|
200
|
+
xml["cbc"].ID preceding.number
|
|
201
|
+
xml["cbc"].IssueDate preceding.issue_date.to_s if preceding.issue_date
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
144
206
|
def build_delivery(xml, doc)
|
|
145
207
|
xml["cac"].Delivery do
|
|
146
|
-
xml["cbc"].ActualDeliveryDate doc.delivery_date.to_s
|
|
208
|
+
xml["cbc"].ActualDeliveryDate doc.delivery_date.to_s if doc.delivery_date
|
|
209
|
+
if doc.deliver_to_address
|
|
210
|
+
xml["cac"].DeliveryLocation do
|
|
211
|
+
xml["cac"].Address do
|
|
212
|
+
build_address_fields(xml, doc.deliver_to_address)
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
end
|
|
147
216
|
end
|
|
148
217
|
end
|
|
149
218
|
|
|
150
|
-
|
|
219
|
+
# A credit note has no cbc:DueDate, BT-9 is written as PaymentDueDate instead.
|
|
220
|
+
def build_payment_means(xml, payment, due_date = nil)
|
|
151
221
|
xml["cac"].PaymentMeans do
|
|
152
222
|
xml["cbc"].PaymentMeansCode payment.payment_means_code
|
|
223
|
+
xml["cbc"].PaymentDueDate due_date.to_s if @credit_note && due_date
|
|
153
224
|
xml["cbc"].PaymentID payment.payment_id if payment.payment_id
|
|
154
225
|
if payment.card_account_id
|
|
155
226
|
xml["cac"].CardAccount do
|
|
@@ -161,6 +232,7 @@ module Zugpferd
|
|
|
161
232
|
if payment.account_id
|
|
162
233
|
xml["cac"].PayeeFinancialAccount do
|
|
163
234
|
xml["cbc"].ID payment.account_id
|
|
235
|
+
xml["cbc"].Name payment.account_name if payment.account_name
|
|
164
236
|
end
|
|
165
237
|
end
|
|
166
238
|
if payment.mandate_reference
|
|
@@ -266,11 +338,19 @@ module Zugpferd
|
|
|
266
338
|
unitCode: line.unit_code)
|
|
267
339
|
xml["cbc"].LineExtensionAmount(format_decimal(line.line_extension_amount),
|
|
268
340
|
currencyID: currency_code)
|
|
341
|
+
build_line_period(xml, line) if line.period_start_date || line.period_end_date
|
|
269
342
|
build_item(xml, line.item) if line.item
|
|
270
343
|
build_price(xml, line.price, currency_code) if line.price
|
|
271
344
|
end
|
|
272
345
|
end
|
|
273
346
|
|
|
347
|
+
def build_line_period(xml, line)
|
|
348
|
+
xml["cac"].InvoicePeriod do
|
|
349
|
+
xml["cbc"].StartDate line.period_start_date.to_s if line.period_start_date
|
|
350
|
+
xml["cbc"].EndDate line.period_end_date.to_s if line.period_end_date
|
|
351
|
+
end
|
|
352
|
+
end
|
|
353
|
+
|
|
274
354
|
def build_item(xml, item)
|
|
275
355
|
xml["cac"].Item do
|
|
276
356
|
xml["cbc"].Description item.description if item.description
|
|
@@ -295,6 +375,11 @@ module Zugpferd
|
|
|
295
375
|
def build_price(xml, price, currency_code)
|
|
296
376
|
xml["cac"].Price do
|
|
297
377
|
xml["cbc"].PriceAmount(format_decimal(price.amount), currencyID: currency_code)
|
|
378
|
+
if price.base_quantity
|
|
379
|
+
attrs = {}
|
|
380
|
+
attrs[:unitCode] = price.base_quantity_unit_code if price.base_quantity_unit_code
|
|
381
|
+
xml["cbc"].BaseQuantity(format_decimal(price.base_quantity), attrs)
|
|
382
|
+
end
|
|
298
383
|
end
|
|
299
384
|
end
|
|
300
385
|
|
|
@@ -38,7 +38,8 @@ module Zugpferd
|
|
|
38
38
|
uri = URI("#{@base_uri}/api/info")
|
|
39
39
|
response = Net::HTTP.get_response(uri)
|
|
40
40
|
response.code == "200"
|
|
41
|
-
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError, Net::OpenTimeout
|
|
41
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError, Net::OpenTimeout,
|
|
42
|
+
EOFError, Errno::ECONNRESET, Net::ReadTimeout
|
|
42
43
|
false
|
|
43
44
|
end
|
|
44
45
|
|
|
@@ -65,18 +66,21 @@ module Zugpferd
|
|
|
65
66
|
end
|
|
66
67
|
|
|
67
68
|
data = JSON.parse(response.body)
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
# veraPDF 1.30 returns validationResult as a list. A single object,
|
|
70
|
+
# the shape this method used to expect, is still accepted.
|
|
71
|
+
results = data.dig("report", "jobs", 0, "validationResult")
|
|
72
|
+
results = [results] if results.is_a?(Hash)
|
|
73
|
+
results = Array(results)
|
|
70
74
|
|
|
71
|
-
compliant =
|
|
72
|
-
failures = extract_failures(
|
|
75
|
+
compliant = results.any? && results.all? { |r| r["compliant"] == true }
|
|
76
|
+
failures = results.flat_map { |r| extract_failures(r) }
|
|
73
77
|
|
|
74
78
|
Result.new(compliant: compliant, failures: failures)
|
|
75
79
|
end
|
|
76
80
|
|
|
77
81
|
def extract_failures(validation)
|
|
78
|
-
details = validation["details"] ||
|
|
79
|
-
rules = details["
|
|
82
|
+
details = validation["details"] || {}
|
|
83
|
+
rules = details["ruleSummaries"] || []
|
|
80
84
|
|
|
81
85
|
rules.select { |r| r["status"] == "failed" }.map do |rule|
|
|
82
86
|
{
|
|
@@ -35,10 +35,10 @@ module Zugpferd
|
|
|
35
35
|
|
|
36
36
|
def load_schema(key)
|
|
37
37
|
@schema_cache[key] ||= begin
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
# The document URL lets Nokogiri resolve relative imports without
|
|
39
|
+
# changing the working directory of the whole process.
|
|
40
|
+
path = File.expand_path(XSD_PATHS.fetch(key), @schemas_path)
|
|
41
|
+
Nokogiri::XML::Schema.from_document(Nokogiri::XML(File.read(path), path))
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
end
|
data/lib/zugpferd.rb
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
module Zugpferd
|
|
2
|
+
class Error < StandardError; end
|
|
3
|
+
end
|
|
4
|
+
|
|
1
5
|
require_relative "zugpferd/model/billing_document"
|
|
2
6
|
require_relative "zugpferd/model/invoice"
|
|
3
7
|
require_relative "zugpferd/model/credit_note"
|
|
@@ -16,11 +20,8 @@ require_relative "zugpferd/model/tax_breakdown"
|
|
|
16
20
|
require_relative "zugpferd/model/tax_subtotal"
|
|
17
21
|
require_relative "zugpferd/model/payment_instructions"
|
|
18
22
|
require_relative "zugpferd/model/allowance_charge"
|
|
23
|
+
require_relative "zugpferd/model/preceding_invoice"
|
|
19
24
|
require_relative "zugpferd/ubl/reader"
|
|
20
25
|
require_relative "zugpferd/ubl/writer"
|
|
21
26
|
require_relative "zugpferd/cii/reader"
|
|
22
27
|
require_relative "zugpferd/cii/writer"
|
|
23
|
-
|
|
24
|
-
module Zugpferd
|
|
25
|
-
class Error < StandardError; end
|
|
26
|
-
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zugpferd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Zeitler
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: nokogiri
|
|
@@ -28,14 +27,14 @@ dependencies:
|
|
|
28
27
|
name: bigdecimal
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - ">="
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
32
|
version: '3.1'
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- - "
|
|
37
|
+
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '3.1'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
@@ -70,11 +69,11 @@ description: Read, write and convert XRechnung and ZUGFeRD electronic invoices (
|
|
|
70
69
|
according to EN 16931. Supports UBL 2.1 and UN/CEFACT CII syntaxes with dedicated
|
|
71
70
|
classes for Invoice, Credit Note, Corrected Invoice, Self-billed Invoice, Partial
|
|
72
71
|
Invoice and Prepayment Invoice.
|
|
73
|
-
email:
|
|
74
72
|
executables: []
|
|
75
73
|
extensions: []
|
|
76
74
|
extra_rdoc_files: []
|
|
77
75
|
files:
|
|
76
|
+
- bin/setup-schemas
|
|
78
77
|
- lib/zugpferd.rb
|
|
79
78
|
- lib/zugpferd/cii/mapping.rb
|
|
80
79
|
- lib/zugpferd/cii/reader.rb
|
|
@@ -91,6 +90,7 @@ files:
|
|
|
91
90
|
- lib/zugpferd/model/partial_invoice.rb
|
|
92
91
|
- lib/zugpferd/model/payment_instructions.rb
|
|
93
92
|
- lib/zugpferd/model/postal_address.rb
|
|
93
|
+
- lib/zugpferd/model/preceding_invoice.rb
|
|
94
94
|
- lib/zugpferd/model/prepayment_invoice.rb
|
|
95
95
|
- lib/zugpferd/model/price.rb
|
|
96
96
|
- lib/zugpferd/model/self_billed_invoice.rb
|
|
@@ -98,7 +98,9 @@ files:
|
|
|
98
98
|
- lib/zugpferd/model/tax_subtotal.rb
|
|
99
99
|
- lib/zugpferd/model/trade_party.rb
|
|
100
100
|
- lib/zugpferd/pdf.rb
|
|
101
|
+
- lib/zugpferd/pdf/catalog_af.ps
|
|
101
102
|
- lib/zugpferd/pdf/embedder.rb
|
|
103
|
+
- lib/zugpferd/pdf/extractor.rb
|
|
102
104
|
- lib/zugpferd/ubl/mapping.rb
|
|
103
105
|
- lib/zugpferd/ubl/reader.rb
|
|
104
106
|
- lib/zugpferd/ubl/writer.rb
|
|
@@ -118,7 +120,6 @@ metadata:
|
|
|
118
120
|
changelog_uri: https://github.com/alexzeitler/zugpferd/blob/master/CHANGELOG.md
|
|
119
121
|
documentation_uri: https://www.rubydoc.info/gems/zugpferd
|
|
120
122
|
bug_tracker_uri: https://github.com/alexzeitler/zugpferd/issues
|
|
121
|
-
post_install_message:
|
|
122
123
|
rdoc_options: []
|
|
123
124
|
require_paths:
|
|
124
125
|
- lib
|
|
@@ -133,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
134
|
- !ruby/object:Gem::Version
|
|
134
135
|
version: '0'
|
|
135
136
|
requirements: []
|
|
136
|
-
rubygems_version: 3.
|
|
137
|
-
signing_key:
|
|
137
|
+
rubygems_version: 3.6.9
|
|
138
138
|
specification_version: 4
|
|
139
139
|
summary: XRechnung & ZUGFeRD e-invoicing library for Ruby (UBL + CII)
|
|
140
140
|
test_files: []
|