secretariat 3.5.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 +22 -6
- 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 +4 -3
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,
|
@@ -42,6 +46,7 @@ module Secretariat
|
|
42
46
|
:due_amount,
|
43
47
|
:paid_amount,
|
44
48
|
:tax_calculation_method,
|
49
|
+
:notes,
|
45
50
|
:attachments,
|
46
51
|
keyword_init: true
|
47
52
|
) do
|
@@ -84,7 +89,7 @@ module Secretariat
|
|
84
89
|
taxes[line_item.tax_percent].base_amount += BigDecimal(line_item.net_amount) * line_item.quantity
|
85
90
|
end
|
86
91
|
end
|
87
|
-
|
92
|
+
|
88
93
|
if tax_calculation_method == :VERTICAL
|
89
94
|
taxes.values.map do |tax|
|
90
95
|
tax.tax_amount = (tax.base_amount * tax.tax_percent / 100).round(2)
|
@@ -200,8 +205,13 @@ module Secretariat
|
|
200
205
|
xml.text(issue_date.strftime("%Y%m%d"))
|
201
206
|
end
|
202
207
|
end
|
203
|
-
|
208
|
+
Array(self.notes).each do |note|
|
209
|
+
xml['ram'].IncludedNote do
|
210
|
+
xml['ram'].Content note
|
211
|
+
end
|
212
|
+
end
|
204
213
|
end
|
214
|
+
|
205
215
|
transaction = by_version(version, 'SpecifiedSupplyChainTradeTransaction', 'SupplyChainTradeTransaction')
|
206
216
|
xml['rsm'].send(transaction) do
|
207
217
|
|
@@ -250,16 +260,22 @@ module Secretariat
|
|
250
260
|
end
|
251
261
|
trade_settlement = by_version(version, 'ApplicableSupplyChainTradeSettlement', 'ApplicableHeaderTradeSettlement')
|
252
262
|
xml['ram'].send(trade_settlement) do
|
253
|
-
if payment_reference
|
263
|
+
if payment_reference.present?
|
254
264
|
xml['ram'].PaymentReference payment_reference
|
255
265
|
end
|
256
266
|
xml['ram'].InvoiceCurrencyCode currency_code
|
257
267
|
xml['ram'].SpecifiedTradeSettlementPaymentMeans do
|
258
268
|
xml['ram'].TypeCode payment_code
|
259
269
|
xml['ram'].Information payment_text
|
260
|
-
if payment_iban
|
270
|
+
if payment_iban || payment_payee_account_name
|
261
271
|
xml['ram'].PayeePartyCreditorFinancialAccount do
|
262
|
-
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
|
263
279
|
end
|
264
280
|
end
|
265
281
|
end
|
@@ -267,7 +283,7 @@ module Secretariat
|
|
267
283
|
xml['ram'].ApplicableTradeTax do
|
268
284
|
Helpers.currency_element(xml, 'ram', 'CalculatedAmount', tax.tax_amount, currency_code, add_currency: version == 1)
|
269
285
|
xml['ram'].TypeCode 'VAT'
|
270
|
-
if tax_reason_text
|
286
|
+
if tax_reason_text.present?
|
271
287
|
xml['ram'].ExemptionReason tax_reason_text
|
272
288
|
end
|
273
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
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 3.6
|
46
|
+
version: '3.6'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.6
|
53
|
+
version: '3.6'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: minitest
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|