xrechnung 0.3.0 → 0.5.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 +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +18 -20
- data/Rakefile +8 -8
- data/lib/xrechnung/allowance_charge.rb +44 -4
- data/lib/xrechnung/currency.rb +1 -1
- data/lib/xrechnung/invoice_line.rb +7 -2
- data/lib/xrechnung/item.rb +25 -2
- data/lib/xrechnung/legal_monetary_total.rb +1 -1
- data/lib/xrechnung/party.rb +3 -1
- data/lib/xrechnung/party_identification.rb +9 -1
- data/lib/xrechnung/party_legal_entity.rb +1 -1
- data/lib/xrechnung/payee_party.rb +36 -0
- data/lib/xrechnung/payment_mandate.rb +29 -0
- data/lib/xrechnung/payment_means.rb +6 -0
- data/lib/xrechnung/price.rb +1 -3
- data/lib/xrechnung/quantity.rb +1 -2
- data/lib/xrechnung/tax_category.rb +6 -5
- data/lib/xrechnung/version.rb +1 -1
- data/lib/xrechnung.rb +72 -18
- data/xrechnung.gemspec +8 -8
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb9e44c799aaa06982ea5b1fde9dda518822ad63b88c0519f43a85f4bd29ab7d
|
4
|
+
data.tar.gz: e4e84a5c0bd1c7e049b2944c513c3ab8b682d750dbaadbf37f5169e75b716315
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 676b9a6e8140f39b2b12b64abf869c97cd6a5353e369e2d8d26e86d0e4242ad7c31141b084a351492b20b085901b3f891732fd4cc12ac497c4ac0e53b277ed66
|
7
|
+
data.tar.gz: 50e8c1b14ae64fae08567276627446a67ea3a70a4fda48e80a8ce96024c78b24331d9487677d1f18c5fb1fbb5f71c98b64769fbccb042d50271ee2b791037157
|
data/.github/workflows/rspec.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
xrechnung (0.
|
4
|
+
xrechnung (0.5.0)
|
5
5
|
builder (~> 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -15,45 +15,42 @@ GEM
|
|
15
15
|
csv
|
16
16
|
mini_mime (>= 1.0.0)
|
17
17
|
multi_xml (>= 0.5.2)
|
18
|
-
json (2.
|
18
|
+
json (2.9.0)
|
19
19
|
language_server-protocol (3.17.0.3)
|
20
20
|
mini_mime (1.1.5)
|
21
21
|
multi_xml (0.6.0)
|
22
|
-
parallel (1.
|
23
|
-
parser (3.3.
|
22
|
+
parallel (1.26.3)
|
23
|
+
parser (3.3.6.0)
|
24
24
|
ast (~> 2.4.1)
|
25
25
|
racc
|
26
|
-
racc (1.8.
|
26
|
+
racc (1.8.1)
|
27
27
|
rainbow (3.1.1)
|
28
28
|
rake (13.2.1)
|
29
|
-
regexp_parser (2.9.
|
30
|
-
rexml (3.3.1)
|
31
|
-
strscan
|
29
|
+
regexp_parser (2.9.3)
|
32
30
|
rspec (3.13.0)
|
33
31
|
rspec-core (~> 3.13.0)
|
34
32
|
rspec-expectations (~> 3.13.0)
|
35
33
|
rspec-mocks (~> 3.13.0)
|
36
|
-
rspec-core (3.13.
|
34
|
+
rspec-core (3.13.2)
|
37
35
|
rspec-support (~> 3.13.0)
|
38
|
-
rspec-expectations (3.13.
|
36
|
+
rspec-expectations (3.13.3)
|
39
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
38
|
rspec-support (~> 3.13.0)
|
41
|
-
rspec-mocks (3.13.
|
39
|
+
rspec-mocks (3.13.2)
|
42
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
41
|
rspec-support (~> 3.13.0)
|
44
|
-
rspec-support (3.13.
|
45
|
-
rubocop (1.
|
42
|
+
rspec-support (3.13.2)
|
43
|
+
rubocop (1.69.1)
|
46
44
|
json (~> 2.3)
|
47
45
|
language_server-protocol (>= 3.17.0)
|
48
46
|
parallel (~> 1.10)
|
49
47
|
parser (>= 3.3.0.2)
|
50
48
|
rainbow (>= 2.2.2, < 4.0)
|
51
|
-
regexp_parser (>=
|
52
|
-
|
53
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
49
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
50
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
54
51
|
ruby-progressbar (~> 1.7)
|
55
|
-
unicode-display_width (>= 2.4.0, <
|
56
|
-
rubocop-ast (1.
|
52
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
53
|
+
rubocop-ast (1.36.2)
|
57
54
|
parser (>= 3.3.1.0)
|
58
55
|
rubocop-capybara (2.21.0)
|
59
56
|
rubocop (~> 1.41)
|
@@ -68,8 +65,9 @@ GEM
|
|
68
65
|
rubocop (~> 1.61)
|
69
66
|
ruby-progressbar (1.13.0)
|
70
67
|
rubyzip (2.3.2)
|
71
|
-
|
72
|
-
|
68
|
+
unicode-display_width (3.1.2)
|
69
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
70
|
+
unicode-emoji (4.0.4)
|
73
71
|
|
74
72
|
PLATFORMS
|
75
73
|
ruby
|
data/Rakefile
CHANGED
@@ -4,19 +4,19 @@ require "rspec/core/rake_task"
|
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
|
-
task :
|
7
|
+
task default: :spec
|
8
8
|
|
9
9
|
namespace :validator do
|
10
10
|
VALIDATOR_SOURCES = {
|
11
|
-
tool:
|
12
|
-
filename: "validator/validationtool-1.
|
13
|
-
release_url: "https://github.com/itplr-kosit/validator/releases/download/v1.
|
11
|
+
tool: {
|
12
|
+
filename: "validator/validationtool-1.5.0-standalone.jar",
|
13
|
+
release_url: "https://github.com/itplr-kosit/validator/releases/download/v1.5.0/validator-1.5.0-distribution.zip",
|
14
14
|
},
|
15
15
|
scenarios: {
|
16
16
|
filename: "validator/scenarios.xml",
|
17
|
-
release_url: "https://github.com/itplr-kosit/validator-configuration-xrechnung/releases/download/release-
|
18
|
-
}
|
19
|
-
}
|
17
|
+
release_url: "https://github.com/itplr-kosit/validator-configuration-xrechnung/releases/download/release-2024-10-31/validator-configuration-xrechnung_3.0.2_2024-10-31.zip",
|
18
|
+
},
|
19
|
+
}.freeze
|
20
20
|
|
21
21
|
VALIDATOR_SOURCES.each do |_, v|
|
22
22
|
base = Pathname.new(__dir__).join("validator")
|
@@ -50,6 +50,6 @@ namespace :validator do
|
|
50
50
|
tool = VALIDATOR_SOURCES[:tool][:filename]
|
51
51
|
scenarios = VALIDATOR_SOURCES[:scenarios][:filename]
|
52
52
|
|
53
|
-
sh "java -jar #{tool} -s #{scenarios} --output-directory #{output} --html
|
53
|
+
sh "java -jar #{tool} -r validator -s #{scenarios} --output-directory #{output} --html #{fixtures}"
|
54
54
|
end
|
55
55
|
end
|
@@ -6,17 +6,39 @@ module Xrechnung
|
|
6
6
|
# @return [TrueClass, FalseClass]
|
7
7
|
member :charge_indicator, type: [TrueClass, FalseClass]
|
8
8
|
|
9
|
+
# @!attribute allowance_charge_reason_code
|
10
|
+
# @return [String]
|
11
|
+
member :allowance_charge_reason_code, type: Integer
|
12
|
+
|
13
|
+
# @!attribute allowance_charge_reason
|
14
|
+
# @return [String]
|
15
|
+
member :allowance_charge_reason, type: String
|
16
|
+
|
17
|
+
# @!attribute multiplier_factor_numeric
|
18
|
+
# @return [BigDecimal]
|
19
|
+
member :multiplier_factor_numeric, type: BigDecimal, transform_value: ->(v) { BigDecimal(v, 0) }
|
20
|
+
|
9
21
|
# @!attribute amount
|
10
22
|
# @return [Xrechnung::Currency]
|
11
23
|
member :amount, type: Xrechnung::Currency
|
12
24
|
|
13
25
|
# @!attribute base_amount
|
14
26
|
# @return [Xrechnung::Currency]
|
15
|
-
member :base_amount, type: Xrechnung::Currency
|
27
|
+
member :base_amount, type: Xrechnung::Currency, optional: true
|
28
|
+
|
29
|
+
# @!attribute tax_category
|
30
|
+
# @return [Xrechnung::TaxCategory]
|
31
|
+
member :tax_category, type: Xrechnung::TaxCategory
|
16
32
|
|
17
33
|
def initialize(**kwargs)
|
18
|
-
kwargs[:amount]
|
19
|
-
|
34
|
+
unless kwargs[:amount].is_a?(Currency)
|
35
|
+
kwargs[:amount] = Currency::EUR(kwargs[:amount])
|
36
|
+
end
|
37
|
+
|
38
|
+
unless kwargs[:base_amount].is_a?(Currency) || kwargs[:base_amount].nil?
|
39
|
+
kwargs[:base_amount] = Currency::EUR(kwargs[:base_amount])
|
40
|
+
end
|
41
|
+
|
20
42
|
super(**kwargs)
|
21
43
|
end
|
22
44
|
|
@@ -24,8 +46,26 @@ module Xrechnung
|
|
24
46
|
def to_xml(xml)
|
25
47
|
xml.cac :AllowanceCharge do
|
26
48
|
xml.cbc :ChargeIndicator, charge_indicator
|
49
|
+
|
50
|
+
if allowance_charge_reason_code
|
51
|
+
xml.cbc :AllowanceChargeReasonCode, allowance_charge_reason_code
|
52
|
+
end
|
53
|
+
|
54
|
+
if allowance_charge_reason
|
55
|
+
xml.cbc :AllowanceChargeReason, allowance_charge_reason
|
56
|
+
end
|
57
|
+
|
58
|
+
if multiplier_factor_numeric
|
59
|
+
xml.cbc :MultiplierFactorNumeric, format("%.2f", multiplier_factor_numeric)
|
60
|
+
end
|
61
|
+
|
27
62
|
xml.cbc :Amount, *amount.xml_args
|
28
|
-
|
63
|
+
|
64
|
+
if base_amount
|
65
|
+
xml.cbc :BaseAmount, *base_amount.xml_args
|
66
|
+
end
|
67
|
+
|
68
|
+
tax_category&.to_xml(xml)
|
29
69
|
end
|
30
70
|
end
|
31
71
|
end
|
data/lib/xrechnung/currency.rb
CHANGED
@@ -28,6 +28,10 @@ module Xrechnung
|
|
28
28
|
# @return [Xrechnung::Price]
|
29
29
|
member :price, type: Xrechnung::Price
|
30
30
|
|
31
|
+
# @!attribute allowance_charges
|
32
|
+
# @return [Array<Xrechnung::AllowanceCharge>]
|
33
|
+
member :allowance_charges, type: Array, default: []
|
34
|
+
|
31
35
|
def initialize(**kwargs)
|
32
36
|
unless kwargs[:line_extension_amount].is_a?(Currency)
|
33
37
|
kwargs[:line_extension_amount] = Currency::EUR(kwargs[:line_extension_amount])
|
@@ -42,8 +46,9 @@ module Xrechnung
|
|
42
46
|
xml.cbc :InvoicedQuantity, invoiced_quantity.amount_to_s, unitCode: invoiced_quantity.unit_code
|
43
47
|
xml.cbc :LineExtensionAmount, *line_extension_amount.xml_args
|
44
48
|
|
45
|
-
unless self.class.members[:invoice_period].optional && invoice_period.nil?
|
46
|
-
|
49
|
+
invoice_period&.to_xml(xml) unless self.class.members[:invoice_period].optional && invoice_period.nil?
|
50
|
+
allowance_charges.each do |allowance_charge|
|
51
|
+
allowance_charge.to_xml(xml)
|
47
52
|
end
|
48
53
|
item&.to_xml(xml)
|
49
54
|
price&.to_xml(xml)
|
data/lib/xrechnung/item.rb
CHANGED
@@ -14,6 +14,14 @@ module Xrechnung
|
|
14
14
|
# @return [Xrechnung::Id]
|
15
15
|
member :standard_item_identification_id, type: Xrechnung::Id, optional: true
|
16
16
|
|
17
|
+
# @!attribute buyers_item_identification_id
|
18
|
+
# @return [Xrechnung::Id]
|
19
|
+
member :buyers_item_identification_id, type: Xrechnung::Id, optional: true
|
20
|
+
|
21
|
+
# @!attribute sellers_item_identification_id
|
22
|
+
# @return [Xrechnung::Id]
|
23
|
+
member :sellers_item_identification_id, type: Xrechnung::Id, optional: true
|
24
|
+
|
17
25
|
# @!attribute commodity_classification
|
18
26
|
# @return [Xrechnung::TaxCategory]
|
19
27
|
member :commodity_classification, type: Xrechnung::TaxCategory
|
@@ -23,16 +31,31 @@ module Xrechnung
|
|
23
31
|
member :classified_tax_category, type: Xrechnung::TaxCategory
|
24
32
|
|
25
33
|
# noinspection RubyResolve
|
26
|
-
def to_xml(xml)
|
34
|
+
def to_xml(xml) # rubocop:disable Metrics
|
27
35
|
xml.cac :Item do
|
28
36
|
xml.cbc :Description, description
|
29
37
|
xml.cbc :Name, name
|
38
|
+
|
30
39
|
unless standard_item_identification_id.nil?
|
31
40
|
xml.cac :StandardItemIdentification do
|
32
41
|
xml.cbc :ID, standard_item_identification_id.id, schemeID: standard_item_identification_id.scheme_id
|
33
42
|
end
|
34
43
|
end
|
35
|
-
|
44
|
+
|
45
|
+
unless buyers_item_identification_id.nil?
|
46
|
+
xml.cac :BuyersItemIdentification do
|
47
|
+
xml.cbc :ID, buyers_item_identification_id.id
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
unless sellers_item_identification_id.nil?
|
52
|
+
xml.cac :SellersItemIdentification do
|
53
|
+
xml.cbc :ID, sellers_item_identification_id.id
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
xml.cac :CommodityClassification, commodity_classification unless commodity_classification.nil?
|
58
|
+
|
36
59
|
classified_tax_category&.to_xml(xml, root_tag_name: :ClassifiedTaxCategory)
|
37
60
|
end
|
38
61
|
end
|
@@ -43,7 +43,7 @@ module Xrechnung
|
|
43
43
|
self.class.members.each_key do |name|
|
44
44
|
next if self[name].nil?
|
45
45
|
|
46
|
-
xml.cbc :"#{name.to_s.split(
|
46
|
+
xml.cbc :"#{name.to_s.split('_').map(&:capitalize).join}", *self[name].xml_args
|
47
47
|
end
|
48
48
|
xml.target!
|
49
49
|
end
|
data/lib/xrechnung/party.rb
CHANGED
@@ -47,6 +47,9 @@ module Xrechnung
|
|
47
47
|
private
|
48
48
|
|
49
49
|
def party_body(xml)
|
50
|
+
xml.cbc :EndpointID, contact&.electronic_mail, schemeID: "EM" if contact&.electronic_mail
|
51
|
+
|
52
|
+
party_identification&.to_xml(xml)
|
50
53
|
unless name.nil? # if blank? -> empty name tag
|
51
54
|
xml.cac :PartyName do
|
52
55
|
if name == ""
|
@@ -56,7 +59,6 @@ module Xrechnung
|
|
56
59
|
end
|
57
60
|
end
|
58
61
|
end
|
59
|
-
party_identification&.to_xml(xml)
|
60
62
|
postal_address&.to_xml(xml)
|
61
63
|
party_tax_scheme&.to_xml(xml)
|
62
64
|
party_legal_entity&.to_xml(xml)
|
@@ -6,10 +6,18 @@ module Xrechnung
|
|
6
6
|
# @return [String]
|
7
7
|
member :id, type: String
|
8
8
|
|
9
|
+
# @!attribute scheme_id
|
10
|
+
# @return [String]
|
11
|
+
member :scheme_id, type: String, optional: true
|
12
|
+
|
9
13
|
# noinspection RubyResolve
|
10
14
|
def to_xml(xml)
|
11
15
|
xml.cac :PartyIdentification do
|
12
|
-
|
16
|
+
if scheme_id
|
17
|
+
xml.cbc :ID, id, schemeID: scheme_id
|
18
|
+
else
|
19
|
+
xml.cbc :ID, id
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
15
23
|
end
|
@@ -13,8 +13,8 @@ module Xrechnung
|
|
13
13
|
# noinspection RubyResolve
|
14
14
|
def to_xml(xml)
|
15
15
|
xml.cac :PartyLegalEntity do
|
16
|
-
xml.cbc(:CompanyID, company_id) unless company_id.nil?
|
17
16
|
xml.cbc :RegistrationName, registration_name
|
17
|
+
xml.cbc(:CompanyID, company_id) unless company_id.nil?
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Xrechnung
|
2
|
+
# <cac:PayeeParty>
|
3
|
+
# <cac:PartyIdentification>
|
4
|
+
# <cbc:ID schemeID="SEPA">FR932874294</cbc:ID>
|
5
|
+
# </cac:PartyIdentification>
|
6
|
+
# <cac:PartyName>
|
7
|
+
# <cbc:Name>Payee Name Ltd</cbc:Name>
|
8
|
+
# </cac:PartyName>
|
9
|
+
# </cac:PayeeParty>
|
10
|
+
class PayeeParty
|
11
|
+
include MemberContainer
|
12
|
+
|
13
|
+
# @!attribute id
|
14
|
+
# @return [String]
|
15
|
+
member :id, type: String
|
16
|
+
|
17
|
+
# @!attribute name
|
18
|
+
# @return [String]
|
19
|
+
member :name, type: String, optional: true
|
20
|
+
|
21
|
+
# noinspection RubyResolve
|
22
|
+
def to_xml(xml)
|
23
|
+
xml.cac :PayeeParty do
|
24
|
+
xml.cac :PartyIdentification do
|
25
|
+
xml.cbc :ID, id, schemeID: "SEPA"
|
26
|
+
end
|
27
|
+
|
28
|
+
if name
|
29
|
+
xml.cac :PartyName do
|
30
|
+
xml.cbc :Name, name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Xrechnung
|
2
|
+
# <cac:PaymentMandate>
|
3
|
+
# <cbc:ID>SEPA-MANDAT-123</cbc:ID>
|
4
|
+
# <cac:PayerFinancialAccount>
|
5
|
+
# <cbc:ID>DE02500105170137075030</cbc:ID>
|
6
|
+
# </cac:PayerFinancialAccount>
|
7
|
+
# </cac:PaymentMandate>
|
8
|
+
class PaymentMandate
|
9
|
+
include MemberContainer
|
10
|
+
|
11
|
+
# @!attribute id
|
12
|
+
# @return [String]
|
13
|
+
member :id, type: String
|
14
|
+
|
15
|
+
# @!attribute payer_financial_account_id
|
16
|
+
# @return [String]
|
17
|
+
member :payer_financial_account_id, type: String
|
18
|
+
|
19
|
+
# noinspection RubyResolve
|
20
|
+
def to_xml(xml)
|
21
|
+
xml.cac :PaymentMandate do
|
22
|
+
xml.cbc :ID, id
|
23
|
+
xml.cac :PayerFinancialAccount do
|
24
|
+
xml.cbc :ID, payer_financial_account_id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -20,10 +20,16 @@ module Xrechnung
|
|
20
20
|
# @return [Xrechnung::PayeeFinancialAccount]
|
21
21
|
member :payee_financial_account, type: Xrechnung::PayeeFinancialAccount
|
22
22
|
|
23
|
+
# @!attribute payment_mandate
|
24
|
+
# @return [Xrechnung::PaymentMandate]
|
25
|
+
member :payment_mandate, type: Xrechnung::PaymentMandate, optional: true
|
26
|
+
|
23
27
|
# noinspection RubyResolve
|
24
28
|
def to_xml(xml)
|
25
29
|
xml.cbc :PaymentMeansCode, payment_means_code
|
26
30
|
payee_financial_account&.to_xml(xml)
|
31
|
+
payment_mandate&.to_xml(xml)
|
32
|
+
xml.target!
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
data/lib/xrechnung/price.rb
CHANGED
@@ -15,9 +15,7 @@ module Xrechnung
|
|
15
15
|
member :allowance_charge, type: Xrechnung::AllowanceCharge
|
16
16
|
|
17
17
|
def initialize(**kwargs)
|
18
|
-
unless kwargs[:price_amount].is_a?(Currency)
|
19
|
-
kwargs[:price_amount] = Currency::EUR(kwargs[:price_amount])
|
20
|
-
end
|
18
|
+
kwargs[:price_amount] = Currency::EUR(kwargs[:price_amount]) unless kwargs[:price_amount].is_a?(Currency)
|
21
19
|
super(**kwargs)
|
22
20
|
end
|
23
21
|
|
data/lib/xrechnung/quantity.rb
CHANGED
@@ -23,7 +23,7 @@ module Xrechnung
|
|
23
23
|
|
24
24
|
# @!attribute percent
|
25
25
|
# @return [BigDecimal]
|
26
|
-
member :percent, type: BigDecimal, transform_value: ->(v) { BigDecimal(v, 0) }
|
26
|
+
member :percent, type: BigDecimal, transform_value: ->(v) { v.nil? ? nil : BigDecimal(v, 0) }
|
27
27
|
|
28
28
|
# @!attribute tax_scheme_id
|
29
29
|
# @return [String]
|
@@ -41,15 +41,16 @@ module Xrechnung
|
|
41
41
|
def to_xml(xml, root_tag_name: :TaxCategory)
|
42
42
|
xml.cac root_tag_name do
|
43
43
|
xml.cbc :ID, id
|
44
|
-
xml.cbc :Percent, format("%.2f", percent)
|
45
|
-
xml.cac :TaxScheme do
|
46
|
-
xml.cbc :ID, tax_scheme_id
|
47
|
-
end
|
44
|
+
xml.cbc :Percent, format("%.2f", percent) unless percent.nil?
|
48
45
|
|
49
46
|
unless tax_exemption_reason_code.nil?
|
50
47
|
xml.cbc :TaxExemptionReasonCode, tax_exemption_reason_code
|
51
48
|
xml.cbc :TaxExemptionReason, tax_exemption_reason
|
52
49
|
end
|
50
|
+
|
51
|
+
xml.cac :TaxScheme do
|
52
|
+
xml.cbc :ID, tax_scheme_id
|
53
|
+
end
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
data/lib/xrechnung/version.rb
CHANGED
data/lib/xrechnung.rb
CHANGED
@@ -11,6 +11,8 @@ require "xrechnung/party_tax_scheme"
|
|
11
11
|
require "xrechnung/postal_address"
|
12
12
|
require "xrechnung/party"
|
13
13
|
require "xrechnung/payee_financial_account"
|
14
|
+
require "xrechnung/payment_mandate"
|
15
|
+
require "xrechnung/payee_party"
|
14
16
|
require "xrechnung/payment_means"
|
15
17
|
require "xrechnung/tax_total"
|
16
18
|
require "xrechnung/tax_category"
|
@@ -30,6 +32,22 @@ module Xrechnung
|
|
30
32
|
class Document
|
31
33
|
include MemberContainer
|
32
34
|
|
35
|
+
# Default customization specs
|
36
|
+
DEFAULT_CUSTOMIZATION_ID = "urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0"
|
37
|
+
DEFAULT_PROFILE_ID = "urn:fdc:peppol.eu:2017:poacc:billing:01:1.0"
|
38
|
+
|
39
|
+
# Document customization identifier
|
40
|
+
#
|
41
|
+
# @!attribute customization_id
|
42
|
+
# @return [String]
|
43
|
+
member :customization_id, type: String, default: DEFAULT_CUSTOMIZATION_ID
|
44
|
+
|
45
|
+
# Document profile identifier
|
46
|
+
#
|
47
|
+
# @!attribute profile_id
|
48
|
+
# @return [String]
|
49
|
+
member :profile_id, type: String, default: DEFAULT_PROFILE_ID
|
50
|
+
|
33
51
|
# Invoice number BT-1
|
34
52
|
#
|
35
53
|
# Eine eindeutige Kennung der Rechnung, die diese im System des Verkäufers identifiziert.
|
@@ -101,7 +119,7 @@ module Xrechnung
|
|
101
119
|
#
|
102
120
|
# @!attribute purchase_order_reference
|
103
121
|
# @return [String]
|
104
|
-
member :purchase_order_reference, type: String
|
122
|
+
member :purchase_order_reference, type: String, optional: true
|
105
123
|
|
106
124
|
# Sales order reference BT-14
|
107
125
|
#
|
@@ -147,7 +165,7 @@ module Xrechnung
|
|
147
165
|
#
|
148
166
|
# @!attribute tax_currency_code
|
149
167
|
# @return [String]
|
150
|
-
member :tax_currency_code, type: String
|
168
|
+
member :tax_currency_code, type: String
|
151
169
|
|
152
170
|
# Buyer reference BT-10
|
153
171
|
#
|
@@ -179,7 +197,7 @@ module Xrechnung
|
|
179
197
|
#
|
180
198
|
# @!attribute contract_document_reference_id
|
181
199
|
# @return [String]
|
182
|
-
member :contract_document_reference_id, type: String
|
200
|
+
member :contract_document_reference_id, type: String, optional: true
|
183
201
|
|
184
202
|
# Project reference BT-11
|
185
203
|
#
|
@@ -187,7 +205,7 @@ module Xrechnung
|
|
187
205
|
#
|
188
206
|
# @!attribute project_reference_id
|
189
207
|
# @return [String]
|
190
|
-
member :project_reference_id, type: String
|
208
|
+
member :project_reference_id, type: String, optional: true
|
191
209
|
|
192
210
|
# SELLER TAX REPRESENTATIVE PARTY BG-11
|
193
211
|
#
|
@@ -207,6 +225,15 @@ module Xrechnung
|
|
207
225
|
# @return [Xrechnung::PaymentMeans]
|
208
226
|
member :payment_means, type: Xrechnung::PaymentMeans
|
209
227
|
|
228
|
+
# PAYEE PARTY BG-10
|
229
|
+
#
|
230
|
+
# A group of business terms providing information about the Payee, i.e. the role that receives
|
231
|
+
# the payment. Shall be used when the Payee is different from the Seller.
|
232
|
+
#
|
233
|
+
# @!attribute payee_party
|
234
|
+
# @return [Xrechnung::PayeeParty]
|
235
|
+
member :payee_party, type: Xrechnung::PayeeParty, optional: true
|
236
|
+
|
210
237
|
# Payment terms BT-20
|
211
238
|
#
|
212
239
|
# Eine Textbeschreibung der Zahlungsbedingungen, die für den fälligen Zahlungsbetrag gelten (einschließlich
|
@@ -245,6 +272,17 @@ module Xrechnung
|
|
245
272
|
# @return [Array]
|
246
273
|
member :invoice_lines, type: Array, default: []
|
247
274
|
|
275
|
+
# DOCUMENT LEVEL ALLOWANCES AND CHARGES BG-20, BG-21
|
276
|
+
#
|
277
|
+
# A group of business terms providing information about allowances
|
278
|
+
# applicable to the Invoice as a whole. A group of business terms providing
|
279
|
+
# information about charges and taxes other than VAT, applicable to the
|
280
|
+
# Invoice as a whole.
|
281
|
+
#
|
282
|
+
# @!attribute allowance_charges
|
283
|
+
# @return [Array]
|
284
|
+
member :allowance_charges, type: Array, default: []
|
285
|
+
|
248
286
|
def to_xml(indent: 2, target: "")
|
249
287
|
xml = Builder::XmlMarkup.new(indent: indent, target: target)
|
250
288
|
xml.instruct! :xml, version: "1.0", encoding: "UTF-8"
|
@@ -255,7 +293,8 @@ module Xrechnung
|
|
255
293
|
"xmlns:cbc" => "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
|
256
294
|
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
257
295
|
"xsi:schemaLocation" => "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd" do
|
258
|
-
xml.cbc :CustomizationID,
|
296
|
+
xml.cbc :CustomizationID, customization_id
|
297
|
+
xml.cbc :ProfileID, profile_id
|
259
298
|
xml.cbc :ID, id
|
260
299
|
xml.cbc :IssueDate, issue_date
|
261
300
|
xml.cbc :DueDate, due_date
|
@@ -267,17 +306,20 @@ module Xrechnung
|
|
267
306
|
|
268
307
|
xml.cbc :TaxPointDate, tax_point_date unless tax_point_date.nil?
|
269
308
|
xml.cbc :DocumentCurrencyCode, document_currency_code
|
270
|
-
xml.cbc :TaxCurrencyCode, tax_currency_code
|
309
|
+
xml.cbc :TaxCurrencyCode, tax_currency_code unless tax_currency_code.nil?
|
271
310
|
xml.cbc :BuyerReference, buyer_reference
|
272
311
|
|
273
|
-
unless self.class.members[:invoice_period].optional && invoice_period.nil?
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
312
|
+
invoice_period&.to_xml(xml) unless self.class.members[:invoice_period].optional && invoice_period.nil?
|
313
|
+
|
314
|
+
unless self.class.members[:purchase_order_reference].optional && purchase_order_reference.nil? &&
|
315
|
+
self.class.members[:sales_order_reference].optional && sales_order_reference.nil?
|
316
|
+
xml.cac :OrderReference do
|
317
|
+
unless self.class.members[:purchase_order_reference].optional && purchase_order_reference.nil?
|
318
|
+
xml.cbc :ID, purchase_order_reference
|
319
|
+
end
|
320
|
+
unless self.class.members[:sales_order_reference].optional && sales_order_reference.nil?
|
321
|
+
xml.cbc :SalesOrderID, sales_order_reference
|
322
|
+
end
|
281
323
|
end
|
282
324
|
end
|
283
325
|
|
@@ -287,12 +329,16 @@ module Xrechnung
|
|
287
329
|
end
|
288
330
|
end
|
289
331
|
|
290
|
-
|
291
|
-
xml.
|
332
|
+
unless self.class.members[:contract_document_reference_id].optional && contract_document_reference_id.nil?
|
333
|
+
xml.cac :ContractDocumentReference do
|
334
|
+
xml.cbc :ID, contract_document_reference_id
|
335
|
+
end
|
292
336
|
end
|
293
337
|
|
294
|
-
|
295
|
-
xml.
|
338
|
+
unless self.class.members[:project_reference_id].optional && project_reference_id.nil?
|
339
|
+
xml.cac :ProjectReference do
|
340
|
+
xml.cbc :ID, project_reference_id
|
341
|
+
end
|
296
342
|
end
|
297
343
|
|
298
344
|
xml.cac :AccountingSupplierParty do
|
@@ -313,10 +359,18 @@ module Xrechnung
|
|
313
359
|
payment_means&.to_xml(xml)
|
314
360
|
end
|
315
361
|
|
362
|
+
unless self.class.members[:payee_party].optional && payee_party.nil?
|
363
|
+
payee_party&.to_xml(xml)
|
364
|
+
end
|
365
|
+
|
316
366
|
xml.cac :PaymentTerms do
|
317
367
|
xml.cbc :Note, payment_terms_note
|
318
368
|
end
|
319
369
|
|
370
|
+
allowance_charges.each do |allowance_charge|
|
371
|
+
allowance_charge&.to_xml(xml)
|
372
|
+
end
|
373
|
+
|
320
374
|
xml.cac :TaxTotal do
|
321
375
|
tax_total&.to_xml(xml)
|
322
376
|
end
|
data/xrechnung.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "lib/xrechnung/version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "xrechnung"
|
@@ -6,19 +6,19 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ["Julian Kornberger"]
|
7
7
|
spec.email = ["jk+github@digineo.de"]
|
8
8
|
|
9
|
-
spec.summary
|
10
|
-
spec.homepage
|
11
|
-
spec.license
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
9
|
+
spec.summary = "Library to create invoices in the XRechnung format."
|
10
|
+
spec.homepage = "https://github.com/digineo/xrechnung"
|
11
|
+
spec.license = "MIT"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
13
13
|
|
14
|
-
spec.metadata["homepage_uri"]
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
15
|
spec.metadata["source_code_uri"] = "https://github.com/digineo/xrechnung"
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
18
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) {
|
20
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
-
|
21
|
+
}
|
22
22
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xrechnung
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Kornberger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -88,6 +88,8 @@ files:
|
|
88
88
|
- lib/xrechnung/party_legal_entity.rb
|
89
89
|
- lib/xrechnung/party_tax_scheme.rb
|
90
90
|
- lib/xrechnung/payee_financial_account.rb
|
91
|
+
- lib/xrechnung/payee_party.rb
|
92
|
+
- lib/xrechnung/payment_mandate.rb
|
91
93
|
- lib/xrechnung/payment_means.rb
|
92
94
|
- lib/xrechnung/postal_address.rb
|
93
95
|
- lib/xrechnung/price.rb
|
@@ -111,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
113
|
requirements:
|
112
114
|
- - ">="
|
113
115
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
116
|
+
version: 3.0.0
|
115
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
118
|
requirements:
|
117
119
|
- - ">="
|
118
120
|
- !ruby/object:Gem::Version
|
119
121
|
version: '0'
|
120
122
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.5.19
|
122
124
|
signing_key:
|
123
125
|
specification_version: 4
|
124
126
|
summary: Library to create invoices in the XRechnung format.
|