secretariat 3.6.0 → 3.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 +4 -4
- data/lib/secretariat/invoice.rb +14 -4
- data/lib/secretariat/object_extensions.rb +14 -0
- data/lib/secretariat/trade_party.rb +6 -4
- data/lib/secretariat/version.rb +1 -1
- data/lib/secretariat.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7614825461a1901faaa9bd3e72fc6fdbde345acc68fdfff7c7649d5e9af56bd5
|
4
|
+
data.tar.gz: 73ec613205ee0a40046c521baec838c4f2eb1fcbd15f12fccd0ec35d21071811
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ffff8d3135aae3aab1d2c71737b1bc80ce588748c3b3350218629673c1295126f9bcdbd17986c2da6f78a5f4bb51493df85bb32ec2bd3ebf16a7bd692200172
|
7
|
+
data.tar.gz: 84ae46ef3f826f9af23ff62c4e8484bc003cb8e665d3edbb5c55468d8782d445d35b82afc892679cd6effa4782ed4178471902287267896fb33770c6b708ea9a
|
data/lib/secretariat/invoice.rb
CHANGED
@@ -17,6 +17,8 @@ limitations under the License.
|
|
17
17
|
require 'bigdecimal'
|
18
18
|
|
19
19
|
module Secretariat
|
20
|
+
using ObjectExtensions
|
21
|
+
|
20
22
|
Invoice = Struct.new("Invoice",
|
21
23
|
:id,
|
22
24
|
:issue_date,
|
@@ -33,6 +35,8 @@ module Secretariat
|
|
33
35
|
:payment_terms_text,
|
34
36
|
:payment_due_date,
|
35
37
|
:payment_iban,
|
38
|
+
:payment_bic,
|
39
|
+
:payment_payee_account_name,
|
36
40
|
:tax_category,
|
37
41
|
:tax_percent,
|
38
42
|
:tax_amount,
|
@@ -256,16 +260,22 @@ module Secretariat
|
|
256
260
|
end
|
257
261
|
trade_settlement = by_version(version, 'ApplicableSupplyChainTradeSettlement', 'ApplicableHeaderTradeSettlement')
|
258
262
|
xml['ram'].send(trade_settlement) do
|
259
|
-
if payment_reference
|
263
|
+
if payment_reference.present?
|
260
264
|
xml['ram'].PaymentReference payment_reference
|
261
265
|
end
|
262
266
|
xml['ram'].InvoiceCurrencyCode currency_code
|
263
267
|
xml['ram'].SpecifiedTradeSettlementPaymentMeans do
|
264
268
|
xml['ram'].TypeCode payment_code
|
265
269
|
xml['ram'].Information payment_text
|
266
|
-
if payment_iban
|
270
|
+
if payment_iban || payment_payee_account_name
|
267
271
|
xml['ram'].PayeePartyCreditorFinancialAccount do
|
268
|
-
xml['ram'].IBANID payment_iban
|
272
|
+
xml['ram'].IBANID payment_iban if payment_iban
|
273
|
+
xml['ram'].AccountName payment_payee_account_name if payment_payee_account_name
|
274
|
+
end
|
275
|
+
end
|
276
|
+
if payment_bic
|
277
|
+
xml['ram'].PayeeSpecifiedCreditorFinancialInstitution do
|
278
|
+
xml['ram'].BICID payment_bic
|
269
279
|
end
|
270
280
|
end
|
271
281
|
end
|
@@ -273,7 +283,7 @@ module Secretariat
|
|
273
283
|
xml['ram'].ApplicableTradeTax do
|
274
284
|
Helpers.currency_element(xml, 'ram', 'CalculatedAmount', tax.tax_amount, currency_code, add_currency: version == 1)
|
275
285
|
xml['ram'].TypeCode 'VAT'
|
276
|
-
if tax_reason_text
|
286
|
+
if tax_reason_text.present?
|
277
287
|
xml['ram'].ExemptionReason tax_reason_text
|
278
288
|
end
|
279
289
|
Helpers.currency_element(xml, 'ram', 'BasisAmount', tax.base_amount, currency_code, add_currency: version == 1)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Secretariat
|
2
|
+
module ObjectExtensions
|
3
|
+
refine Object do
|
4
|
+
# Copied from activesupport/lib/active_support/core_ext/object/blank.rb, line 18
|
5
|
+
def blank?
|
6
|
+
respond_to?(:empty?) ? !!empty? : !self
|
7
|
+
end
|
8
|
+
|
9
|
+
def present?
|
10
|
+
!blank?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -15,12 +15,14 @@ limitations under the License.
|
|
15
15
|
=end
|
16
16
|
|
17
17
|
module Secretariat
|
18
|
+
using ObjectExtensions
|
19
|
+
|
18
20
|
TradeParty = Struct.new('TradeParty',
|
19
21
|
:name, :street1, :street2, :city, :postal_code, :country_id, :vat_id, :global_id, :global_id_scheme_id, :tax_id,
|
20
22
|
keyword_init: true,
|
21
23
|
) do
|
22
24
|
def to_xml(xml, exclude_tax: false, version: 2)
|
23
|
-
if global_id &&
|
25
|
+
if global_id.present? && global_id_scheme_id.present?
|
24
26
|
xml['ram'].GlobalID(schemeID: global_id_scheme_id) do
|
25
27
|
xml.text(global_id)
|
26
28
|
end
|
@@ -29,19 +31,19 @@ module Secretariat
|
|
29
31
|
xml['ram'].PostalTradeAddress do
|
30
32
|
xml['ram'].PostcodeCode postal_code
|
31
33
|
xml['ram'].LineOne street1
|
32
|
-
if street2
|
34
|
+
if street2.present?
|
33
35
|
xml['ram'].LineTwo street2
|
34
36
|
end
|
35
37
|
xml['ram'].CityName city
|
36
38
|
xml['ram'].CountryID country_id
|
37
39
|
end
|
38
|
-
if !exclude_tax && vat_id
|
40
|
+
if !exclude_tax && vat_id.present?
|
39
41
|
xml['ram'].SpecifiedTaxRegistration do
|
40
42
|
xml['ram'].ID(schemeID: 'VA') do
|
41
43
|
xml.text(vat_id)
|
42
44
|
end
|
43
45
|
end
|
44
|
-
elsif tax_id
|
46
|
+
elsif tax_id.present?
|
45
47
|
xml['ram'].SpecifiedTaxRegistration do
|
46
48
|
xml['ram'].ID(schemeID: 'FC') do
|
47
49
|
xml.text(tax_id)
|
data/lib/secretariat/version.rb
CHANGED
data/lib/secretariat.rb
CHANGED
@@ -15,6 +15,7 @@ limitations under the License.
|
|
15
15
|
=end
|
16
16
|
|
17
17
|
require_relative 'secretariat/version'
|
18
|
+
require_relative 'secretariat/object_extensions'
|
18
19
|
require_relative 'secretariat/constants'
|
19
20
|
require_relative 'secretariat/helpers'
|
20
21
|
require_relative 'secretariat/versioner'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secretariat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Krutisch
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/secretariat/helpers.rb
|
108
108
|
- lib/secretariat/invoice.rb
|
109
109
|
- lib/secretariat/line_item.rb
|
110
|
+
- lib/secretariat/object_extensions.rb
|
110
111
|
- lib/secretariat/tax.rb
|
111
112
|
- lib/secretariat/trade_party.rb
|
112
113
|
- lib/secretariat/validation_error.rb
|