ubl 0.1.1 → 0.1.3
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/README.md +2 -2
- data/lib/ubl/builder.rb +33 -1
- data/lib/ubl/version.rb +1 -1
- data/lib/ubl.rb +3 -17
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d3674c799834fc218a997979a36b62a860aff2f08568f4b3e947a54ac693ec5
|
4
|
+
data.tar.gz: 827efecf61e25ae097ec832706ec5409e7893a202aac5d485e2e038c7af3caf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2df2c642ae9b96f7ccf9a46264eec67679d9fb70a044e846320aea5036f044d4899c04f49ca335182b3856042d967dce2898b850045f2a2785b4a7ff960c169
|
7
|
+
data.tar.gz: d0129370aa18020f080f0c71213ca9e1681a1d2900aa2ce9bb3081460de06a26feaaa8aa9c96c0d4ceca9470980ffa63d77a3ac9245499539acf8001a8598daa
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Ubl
|
4
4
|
|
5
|
-
Generate UBL (Universal Business Language) documents, such as invoices and credit notes, compliant with the Peppol network.
|
5
|
+
Generate and validate UBL (Universal Business Language) documents, such as invoices and credit notes, compliant with the Peppol network.
|
6
6
|
|
7
7
|
## installation
|
8
8
|
|
@@ -57,7 +57,7 @@ invoice = Ubl::Invoice.new("UBL_BE")
|
|
57
57
|
```
|
58
58
|
|
59
59
|
You can also validate the result.
|
60
|
-
You need Docker for the schematron validation.
|
60
|
+
You need Docker for the schematron validation. (https://github.com/roel4d/peppol_schematron)
|
61
61
|
With `schematron: false` you can disable this and only the xsd validation will run.
|
62
62
|
```ruby
|
63
63
|
Tempfile.create("invoice.xml") do |invoice_file|
|
data/lib/ubl/builder.rb
CHANGED
@@ -51,12 +51,20 @@ module Ubl
|
|
51
51
|
}
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
54
|
+
def add_payment_means(iban:, bic:)
|
55
|
+
@payment_means = {
|
56
|
+
iban: iban,
|
57
|
+
bic: bic
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_line(name:, quantity:, unit_price:, description: name, tax_rate: 21.0, unit: "ZZ")
|
55
62
|
line_extension_amount = (quantity * unit_price).round(2)
|
56
63
|
tax_amount = (line_extension_amount * (tax_rate / 100.0)).round(2)
|
57
64
|
|
58
65
|
@invoice_lines << {
|
59
66
|
id: (@invoice_lines.length + 1).to_s,
|
67
|
+
description: description,
|
60
68
|
name: name,
|
61
69
|
quantity: quantity,
|
62
70
|
unit: unit,
|
@@ -111,6 +119,15 @@ module Ubl
|
|
111
119
|
end
|
112
120
|
end
|
113
121
|
|
122
|
+
def build_content(xml)
|
123
|
+
build_party(xml, @supplier, "AccountingSupplierParty")
|
124
|
+
build_party(xml, @customer, "AccountingCustomerParty")
|
125
|
+
build_payment_means(xml)
|
126
|
+
build_tax_total(xml)
|
127
|
+
build_monetary_total(xml)
|
128
|
+
build_invoice_lines(xml)
|
129
|
+
end
|
130
|
+
|
114
131
|
def add_attachment(id, filename)
|
115
132
|
@attachments << {id: id, content:}
|
116
133
|
end
|
@@ -163,6 +180,7 @@ module Ubl
|
|
163
180
|
end
|
164
181
|
|
165
182
|
xml["cac"].Item do
|
183
|
+
xml["cbc"].Description line[:description]
|
166
184
|
xml["cbc"].Name line[:name]
|
167
185
|
xml["cac"].ClassifiedTaxCategory do
|
168
186
|
xml["cbc"].ID get_tax_category_id(line[:tax_rate])
|
@@ -252,5 +270,19 @@ module Ubl
|
|
252
270
|
xml["cbc"].PayableAmount(currencyID: @currency) { xml.text sprintf("%.2f", @legal_monetary_total) }
|
253
271
|
end
|
254
272
|
end
|
273
|
+
|
274
|
+
def build_payment_means(xml)
|
275
|
+
return unless @payment_means
|
276
|
+
|
277
|
+
xml["cac"].PaymentMeans do
|
278
|
+
xml["cbc"].PaymentMeansCode "1"
|
279
|
+
xml["cac"].PayeeFinancialAccount do
|
280
|
+
xml["cbc"].ID @payment_means[:iban]
|
281
|
+
xml["cac"].FinancialInstitutionBranch do
|
282
|
+
xml["cbc"].ID @payment_means[:bic]
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
255
287
|
end
|
256
288
|
end
|
data/lib/ubl/version.rb
CHANGED
data/lib/ubl.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative "ubl/builder"
|
|
2
2
|
require_relative "ubl/validate"
|
3
3
|
|
4
4
|
##
|
5
|
-
# Generate UBL (Universal Business Language) documents,
|
5
|
+
# Generate and validate UBL (Universal Business Language) documents,
|
6
6
|
# such as invoices and credit notes, compliant with the Peppol network.
|
7
7
|
module Ubl
|
8
8
|
class Invoice < UblBuilder
|
@@ -23,15 +23,8 @@ module Ubl
|
|
23
23
|
build_header(xml) do |xml|
|
24
24
|
xml["cbc"].InvoiceTypeCode "380"
|
25
25
|
end
|
26
|
-
|
27
26
|
build_document_reference(xml, "CommercialInvoice")
|
28
|
-
|
29
|
-
build_party(xml, @supplier, "AccountingSupplierParty")
|
30
|
-
build_party(xml, @customer, "AccountingCustomerParty")
|
31
|
-
|
32
|
-
build_tax_total(xml)
|
33
|
-
build_monetary_total(xml)
|
34
|
-
build_invoice_lines(xml)
|
27
|
+
build_content(xml)
|
35
28
|
end
|
36
29
|
end
|
37
30
|
builder.to_xml
|
@@ -56,15 +49,8 @@ module Ubl
|
|
56
49
|
build_header(xml) do |xml|
|
57
50
|
xml["cbc"].CreditNoteTypeCode "381"
|
58
51
|
end
|
59
|
-
|
60
52
|
build_document_reference(xml, "CreditNote")
|
61
|
-
|
62
|
-
build_party(xml, @supplier, "AccountingSupplierParty")
|
63
|
-
build_party(xml, @customer, "AccountingCustomerParty")
|
64
|
-
|
65
|
-
build_tax_total(xml)
|
66
|
-
build_monetary_total(xml)
|
67
|
-
build_invoice_lines(xml)
|
53
|
+
build_content(xml)
|
68
54
|
end
|
69
55
|
end
|
70
56
|
builder.to_xml
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ubl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- roel4d
|
@@ -51,8 +51,8 @@ dependencies:
|
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.1'
|
54
|
-
description: Generate UBL (Universal Business Language) documents, such
|
55
|
-
and credit notes, compliant with the Peppol network.
|
54
|
+
description: Generate and validate UBL (Universal Business Language) documents, such
|
55
|
+
as invoices and credit notes, compliant with the Peppol network.
|
56
56
|
email:
|
57
57
|
- roel4d@webding.org
|
58
58
|
executables: []
|
@@ -170,5 +170,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
requirements: []
|
171
171
|
rubygems_version: 3.6.7
|
172
172
|
specification_version: 4
|
173
|
-
summary: Generate UBL documents for Peppol
|
173
|
+
summary: Generate and validate UBL documents for Peppol
|
174
174
|
test_files: []
|