ubl 0.1.1 → 0.1.2

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: 5c951c7c837dfd7a900976e605a78832e0bf2bfd15733c4877f045df4bf0214e
4
- data.tar.gz: bceb1d66414fe51ae67db3c15ad0e60f6e127834dfc7f587781f9464a430364c
3
+ metadata.gz: 07e7d21d74c69ab965fe5a9968fd7404629079233b2fd6554e7fac2f51aff5e6
4
+ data.tar.gz: e13d2459ed88883a5206449565fb665bee8a59a097bbccf489c975be4ace1489
5
5
  SHA512:
6
- metadata.gz: f94eccdd50a880d39a67ab3fcfa102ff6115792fc06f94c6fc0c9702797902e3975e75c532d0512ee4ea9c58f05042b07cb2419703a5955be3cf19dabd30ffb3
7
- data.tar.gz: 3ced736e13ab314f47aea124fdea03188512b659e8f1579500d60a4ddf3d11a1f32f2b52573e54bc526c9494d50e9ca692818f1d8c1afbc0bc8570e2fc2a7d09
6
+ metadata.gz: 02d979487d2aafb9c96ab9ce923cb19f1821fd8850f8766a584ff0b5f06f86d5993747c0378c1eff62ef701518fe40876915d2234477f52bcb8e4c41660ef6f1
7
+ data.tar.gz: 73a22110aa073edce5165461c9883ec1796d92e5ded7b320de8c0de220d82f6755f2407e74fe9bd43dd95f545ca19390e78e1e3d17d518fdb8db284a1ae9f2c8
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,6 +51,13 @@ module Ubl
51
51
  }
52
52
  end
53
53
 
54
+ def add_payment_means(iban:, bic:)
55
+ @payment_means = {
56
+ iban: iban,
57
+ bic: bic
58
+ }
59
+ end
60
+
54
61
  def add_line(name:, quantity:, unit_price:, 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)
@@ -111,6 +118,15 @@ module Ubl
111
118
  end
112
119
  end
113
120
 
121
+ def build_content(xml)
122
+ build_party(xml, @supplier, "AccountingSupplierParty")
123
+ build_party(xml, @customer, "AccountingCustomerParty")
124
+ build_payment_means(xml)
125
+ build_tax_total(xml)
126
+ build_monetary_total(xml)
127
+ build_invoice_lines(xml)
128
+ end
129
+
114
130
  def add_attachment(id, filename)
115
131
  @attachments << {id: id, content:}
116
132
  end
@@ -252,5 +268,19 @@ module Ubl
252
268
  xml["cbc"].PayableAmount(currencyID: @currency) { xml.text sprintf("%.2f", @legal_monetary_total) }
253
269
  end
254
270
  end
271
+
272
+ def build_payment_means(xml)
273
+ return unless @payment_means
274
+
275
+ xml["cac"].PaymentMeans do
276
+ xml["cbc"].PaymentMeansCode "1"
277
+ xml["cac"].PayeeFinancialAccount do
278
+ xml["cbc"].ID @payment_means[:iban]
279
+ xml["cac"].FinancialInstitutionBranch do
280
+ xml["cbc"].ID @payment_means[:bic]
281
+ end
282
+ end
283
+ end
284
+ end
255
285
  end
256
286
  end
data/lib/ubl/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ubl
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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.1
4
+ version: 0.1.2
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 as invoices
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: []