saft 0.2.0 → 0.3.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/.rubocop.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/lib/saft/v2/html.rb +19 -11
- data/lib/saft/v2/norway.rb +33 -37
- data/lib/saft/v2/parse.rb +14 -8
- data/lib/saft/v2/scribe.rb +29 -17
- data/lib/saft/v2/types.rb +31 -25
- data/lib/saft/v2/xsd_validate.rb +4 -7
- data/lib/saft/version.rb +1 -1
- data/vendor/Norwegian_SAF-T_Financial_Schema_v_1.30.xsd +3360 -0
- data/vendor/norway/general_ledger_account_grouping_category_codes_income_statement_naeringsspesifikasjon.csv +528 -0
- metadata +9 -14
- data/.gemspec +0 -35
- data/vendor/SAF-T_Financial_Schema_NO_1.10.xsd +0 -3343
- data/vendor/norway/general_ledger_standard_accounts.xsd +0 -54
- data/vendor/norway/general_ledger_standard_accounts_2_character.csv +0 -75
- data/vendor/norway/general_ledger_standard_accounts_2_character.xml +0 -373
- data/vendor/norway/general_ledger_standard_accounts_4_character.csv +0 -747
- data/vendor/norway/general_ledger_standard_accounts_4_character.xml +0 -3733
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccf2f23f9b7847e33f6bf8ae683c5358272be99de2d244a99349e66cdca67f86
|
|
4
|
+
data.tar.gz: d3e94ebf8bf376f472a30a50bfed25c69ac17c8df713f82c088c87c33b73d4c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 257c2ec4f99fd5f5ac175be4cd1dbb0648a8e2e4cb63aa2e256b95b448fe60ebc8b0098c8214d242674e009f62584a769ac239e1427bd14e18a24e5c60d8c2d2
|
|
7
|
+
data.tar.gz: e277f97a70ffe3055ca523765e5983d15ad9f5e905b248ce7f562fa89944e5f761a1ee43d0a9a69565f1c64d6b2a3600022d0801b4ff01eff38489a8e4867d94
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/saft/v2/html.rb
CHANGED
|
@@ -200,7 +200,8 @@ module SAFT::V2
|
|
|
200
200
|
t.tr {
|
|
201
201
|
t.th("Id")
|
|
202
202
|
t.th("Description")
|
|
203
|
-
t.th("
|
|
203
|
+
t.th("GroupingCategory")
|
|
204
|
+
t.th("GroupingCode")
|
|
204
205
|
t.th("Opening balance")
|
|
205
206
|
t.th("Closing balance")
|
|
206
207
|
t.th("Rest")
|
|
@@ -208,20 +209,26 @@ module SAFT::V2
|
|
|
208
209
|
}
|
|
209
210
|
t.tbody {
|
|
210
211
|
@accounts.each do |account|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
#{
|
|
217
|
-
#{
|
|
212
|
+
category = SAFT::V2::Norway.grouping_category(account.grouping_code)
|
|
213
|
+
code_title = category_title = "Not found"
|
|
214
|
+
if category
|
|
215
|
+
code_title = <<~TEXT
|
|
216
|
+
Grouping code #{category.grouping_code}
|
|
217
|
+
#{category.code_description_en}
|
|
218
|
+
#{category.code_description_no}
|
|
219
|
+
TEXT
|
|
220
|
+
category_title = <<~TEXT
|
|
221
|
+
Grouping category #{category.grouping_category}
|
|
222
|
+
#{category.category_description_en}
|
|
223
|
+
#{category.category_description_no}
|
|
218
224
|
TEXT
|
|
219
225
|
end
|
|
220
226
|
|
|
221
227
|
t.tr {
|
|
222
228
|
t.td(account.account_id)
|
|
223
229
|
t.td(account.account_description)
|
|
224
|
-
t.td(account.
|
|
230
|
+
t.td(account.grouping_category, title: category_title)
|
|
231
|
+
t.td(account.grouping_code, title: code_title)
|
|
225
232
|
t.td {
|
|
226
233
|
t.div(class: "flex justify-between") {
|
|
227
234
|
if account.opening_debit_balance
|
|
@@ -257,7 +264,8 @@ module SAFT::V2
|
|
|
257
264
|
.except(
|
|
258
265
|
:account_id,
|
|
259
266
|
:account_description,
|
|
260
|
-
:
|
|
267
|
+
:grouping_category,
|
|
268
|
+
:grouping_code,
|
|
261
269
|
:opening_debit_balance,
|
|
262
270
|
:opening_credit_balance,
|
|
263
271
|
:closing_debit_balance,
|
|
@@ -542,7 +550,7 @@ module SAFT::V2
|
|
|
542
550
|
def title
|
|
543
551
|
<<~TEXT
|
|
544
552
|
#{account.account_id} #{account.account_description}
|
|
545
|
-
|
|
553
|
+
Grouping category and code #{account.grouping_category} / #{account.grouping_code}
|
|
546
554
|
opening balance #{HTML.format_big_decimal(account.opening_debit_balance || -account.opening_credit_balance)}
|
|
547
555
|
closing balance #{HTML.format_big_decimal(account.closing_debit_balance || -account.closing_credit_balance)}
|
|
548
556
|
TEXT
|
data/lib/saft/v2/norway.rb
CHANGED
|
@@ -36,13 +36,16 @@ module SAFT::V2::Norway
|
|
|
36
36
|
|
|
37
37
|
VatTaxCodes = Types::Array.of(VatTaxCode)
|
|
38
38
|
|
|
39
|
-
class
|
|
40
|
-
attribute :
|
|
41
|
-
attribute :
|
|
42
|
-
attribute :
|
|
39
|
+
class GroupingCategory < Dry::Struct
|
|
40
|
+
attribute :grouping_category, Types::String
|
|
41
|
+
attribute :category_description_no, Types::String
|
|
42
|
+
attribute :category_description_en, Types::String
|
|
43
|
+
attribute :grouping_code, Types::String
|
|
44
|
+
attribute :code_description_no, Types::String
|
|
45
|
+
attribute :code_description_en, Types::String
|
|
43
46
|
end
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
GroupingCategories = Types::Array.of(GroupingCategory)
|
|
46
49
|
|
|
47
50
|
def self.vat_codes
|
|
48
51
|
return @vat_codes if defined?(@vat_codes)
|
|
@@ -65,24 +68,22 @@ module SAFT::V2::Norway
|
|
|
65
68
|
@vat_codes = VatTaxCodes[vat_codes].freeze
|
|
66
69
|
end
|
|
67
70
|
|
|
68
|
-
def self.
|
|
69
|
-
return @
|
|
71
|
+
def self.grouping_categories
|
|
72
|
+
return @grouping_categories if defined?(@grouping_categories)
|
|
70
73
|
|
|
71
|
-
@
|
|
72
|
-
|
|
73
|
-
.each { @
|
|
74
|
-
general_ledger_accounts_4_digits
|
|
75
|
-
.each { @std_account_map[_1.number] = _1 }
|
|
74
|
+
@grouping_categories = {}
|
|
75
|
+
general_ledger_grouping_categories
|
|
76
|
+
.each { @grouping_categories[_1.grouping_code] = _1 }
|
|
76
77
|
|
|
77
|
-
@
|
|
78
|
+
@grouping_categories
|
|
78
79
|
end
|
|
79
80
|
|
|
80
|
-
def self.
|
|
81
|
-
|
|
81
|
+
def self.grouping_category(grouping_code)
|
|
82
|
+
grouping_categories[grouping_code]
|
|
82
83
|
end
|
|
83
84
|
|
|
84
|
-
def self.
|
|
85
|
-
|
|
85
|
+
def self.grouping_category!(grouping_code)
|
|
86
|
+
grouping_categories.fetch(grouping_code)
|
|
86
87
|
end
|
|
87
88
|
|
|
88
89
|
def self.vat_code_map
|
|
@@ -101,33 +102,28 @@ module SAFT::V2::Norway
|
|
|
101
102
|
vat_code_map.fetch(code)
|
|
102
103
|
end
|
|
103
104
|
|
|
104
|
-
def self.
|
|
105
|
-
return @
|
|
106
|
-
|
|
107
|
-
@general_ledger_accounts_2_digits = parse_general_ledger_accounts(
|
|
108
|
-
SAFT::V2::Norway::PATH + "general_ledger_standard_accounts_2_character.csv",
|
|
109
|
-
)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def self.general_ledger_accounts_4_digits
|
|
113
|
-
return @general_ledger_accounts_4_digits if defined?(@general_ledger_accounts_4_digits)
|
|
105
|
+
def self.general_ledger_grouping_categories
|
|
106
|
+
return @general_ledger_grouping_categories if defined?(@general_ledger_grouping_categories)
|
|
114
107
|
|
|
115
|
-
@
|
|
116
|
-
SAFT::V2::Norway::PATH + "
|
|
108
|
+
@general_ledger_grouping_categories = parse_general_ledger_grouping_catergories(
|
|
109
|
+
SAFT::V2::Norway::PATH + "general_ledger_account_grouping_category_codes_income_statement_naeringsspesifikasjon.csv",
|
|
117
110
|
)
|
|
118
111
|
end
|
|
119
112
|
|
|
120
|
-
def self.
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
def self.parse_general_ledger_grouping_catergories(path)
|
|
114
|
+
groupings = []
|
|
123
115
|
CSV.foreach(path, headers: true, col_sep: ";") do |row|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
|
|
117
|
+
groupings.push({
|
|
118
|
+
grouping_category: row["GroupingCategory"],
|
|
119
|
+
category_description_no: row["CategoryDescriptionNOB"],
|
|
120
|
+
category_description_en: row["CategoryDescriptionENG"],
|
|
121
|
+
grouping_code: row["GroupingCode"],
|
|
122
|
+
code_description_no: row["CodeDescriptionNOB"],
|
|
123
|
+
code_description_en: row["CodeDescriptionENG"],
|
|
128
124
|
})
|
|
129
125
|
end
|
|
130
126
|
|
|
131
|
-
|
|
127
|
+
GroupingCategories[groupings].freeze
|
|
132
128
|
end
|
|
133
129
|
end
|
data/lib/saft/v2/parse.rb
CHANGED
|
@@ -130,7 +130,8 @@ module SAFT::V2
|
|
|
130
130
|
{
|
|
131
131
|
analysis_type: xml.at_xpath("AnalysisType")&.content,
|
|
132
132
|
analysis_id: xml.at_xpath("AnalysisID")&.content,
|
|
133
|
-
|
|
133
|
+
debit_analysis_amount: parse(Types::AmountStructure, xml.at_xpath("DebitAnalysisAmount")),
|
|
134
|
+
credit_analysis_amount: parse(Types::AmountStructure, xml.at_xpath("CreditAnalysisAmount")),
|
|
134
135
|
}.compact
|
|
135
136
|
|
|
136
137
|
when Types::AnalysisPartyInfoStructure.name
|
|
@@ -147,7 +148,8 @@ module SAFT::V2
|
|
|
147
148
|
country: xml.at_xpath("Country")&.content,
|
|
148
149
|
tax_base: xml.at_xpath("TaxBase")&.content,
|
|
149
150
|
tax_base_description: xml.at_xpath("TaxBaseDescription")&.content,
|
|
150
|
-
|
|
151
|
+
debit_tax_amount: parse(Types::AmountStructure, xml.at_xpath("DebitTaxAmount")),
|
|
152
|
+
credit_tax_amount: parse(Types::AmountStructure, xml.at_xpath("CreditTaxAmount")),
|
|
151
153
|
tax_exemption_reason: xml.at_xpath("TaxExemptionReason")&.content,
|
|
152
154
|
tax_declaration_period: xml.at_xpath("TaxDeclarationPeriod")&.content,
|
|
153
155
|
}.compact
|
|
@@ -216,11 +218,7 @@ module SAFT::V2
|
|
|
216
218
|
**parse(Types::CompanyStructure, xml),
|
|
217
219
|
customer_id: xml.at_xpath("CustomerID")&.content,
|
|
218
220
|
self_billing_indicator: xml.at_xpath("SelfBillingIndicator")&.content,
|
|
219
|
-
|
|
220
|
-
opening_debit_balance: xml.at_xpath("OpeningDebitBalance")&.content,
|
|
221
|
-
opening_credit_balance: xml.at_xpath("OpeningCreditBalance")&.content,
|
|
222
|
-
closing_debit_balance: xml.at_xpath("ClosingDebitBalance")&.content,
|
|
223
|
-
closing_credit_balance: xml.at_xpath("ClosingCreditBalance")&.content,
|
|
221
|
+
balance_accounts: xml.xpath("BalanceAccount").map { |node| parse(Types::BalanceAccount, node) }.then { _1.empty? ? nil : _1 },
|
|
224
222
|
party_info: parse(Types::PartyInfoStructure, xml.at_xpath("PartyInfo")),
|
|
225
223
|
}.compact
|
|
226
224
|
|
|
@@ -229,12 +227,17 @@ module SAFT::V2
|
|
|
229
227
|
**parse(Types::CompanyStructure, xml),
|
|
230
228
|
supplier_id: xml.at_xpath("SupplierID")&.content,
|
|
231
229
|
self_billing_indicator: xml.at_xpath("SelfBillingIndicator")&.content,
|
|
230
|
+
balance_accounts: xml.xpath("BalanceAccount").map { |node| parse(Types::BalanceAccount, node) }.then { _1.empty? ? nil : _1 },
|
|
231
|
+
party_info: parse(Types::PartyInfoStructure, xml.at_xpath("PartyInfo")),
|
|
232
|
+
}.compact
|
|
233
|
+
|
|
234
|
+
when Types::BalanceAccount.name
|
|
235
|
+
{
|
|
232
236
|
account_id: xml.at_xpath("AccountID")&.content,
|
|
233
237
|
opening_debit_balance: xml.at_xpath("OpeningDebitBalance")&.content,
|
|
234
238
|
opening_credit_balance: xml.at_xpath("OpeningCreditBalance")&.content,
|
|
235
239
|
closing_debit_balance: xml.at_xpath("ClosingDebitBalance")&.content,
|
|
236
240
|
closing_credit_balance: xml.at_xpath("ClosingCreditBalance")&.content,
|
|
237
|
-
party_info: parse(Types::PartyInfoStructure, xml.at_xpath("PartyInfo")),
|
|
238
241
|
}.compact
|
|
239
242
|
|
|
240
243
|
when Types::TaxCodeDetails.name
|
|
@@ -320,11 +323,14 @@ module SAFT::V2
|
|
|
320
323
|
period_year: xml.at_xpath("PeriodYear")&.content,
|
|
321
324
|
transaction_date: xml.at_xpath("TransactionDate")&.content,
|
|
322
325
|
source_id: xml.at_xpath("SourceID")&.content,
|
|
326
|
+
voucher_type: xml.at_xpath("VoucherType")&.content,
|
|
327
|
+
voucher_description: xml.at_xpath("VoucherDescription")&.content,
|
|
323
328
|
transaction_type: xml.at_xpath("TransactionType")&.content,
|
|
324
329
|
description: xml.at_xpath("Description")&.content,
|
|
325
330
|
batch_id: xml.at_xpath("BatchID")&.content,
|
|
326
331
|
system_entry_date: xml.at_xpath("SystemEntryDate")&.content,
|
|
327
332
|
gl_posting_date: xml.at_xpath("GLPostingDate")&.content,
|
|
333
|
+
modification_date: xml.at_xpath("ModificationDate")&.content,
|
|
328
334
|
system_id: xml.at_xpath("SystemID")&.content,
|
|
329
335
|
lines: xml.xpath("Line").map { |node| parse(Types::Line, node) }.then { _1.empty? ? nil : _1 },
|
|
330
336
|
}.compact
|
data/lib/saft/v2/scribe.rb
CHANGED
|
@@ -62,7 +62,7 @@ module SAFT::V2
|
|
|
62
62
|
xml.SoftwareVersion(struct.software_version)
|
|
63
63
|
xml.Company { build(struct.company) }
|
|
64
64
|
xml.DefaultCurrencyCode(struct.default_currency_code)
|
|
65
|
-
xml.SelectionCriteria { build(struct.selection_criteria) }
|
|
65
|
+
xml.SelectionCriteria { build(struct.selection_criteria) }
|
|
66
66
|
xml.HeaderComment(struct.header_comment) if struct.header_comment
|
|
67
67
|
xml.TaxAccountingBasis(struct.tax_accounting_basis)
|
|
68
68
|
xml.TaxEntity(struct.tax_entity) if struct.tax_entity
|
|
@@ -73,22 +73,30 @@ module SAFT::V2
|
|
|
73
73
|
build_company_structure(struct)
|
|
74
74
|
xml.CustomerID(struct.customer_id)
|
|
75
75
|
xml.SelfBillingIndicator(struct.self_billing_indicator) if struct.self_billing_indicator
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
struct.balance_accounts.each do |balance|
|
|
77
|
+
xml.BalanceAccount {
|
|
78
|
+
xml.AccountID(balance.account_id) if balance.account_id
|
|
79
|
+
xml.OpeningDebitBalance(balance.opening_debit_balance.to_s("F")) if balance.opening_debit_balance
|
|
80
|
+
xml.OpeningCreditBalance(balance.opening_credit_balance.to_s("F")) if balance.opening_credit_balance
|
|
81
|
+
xml.ClosingDebitBalance(balance.closing_debit_balance.to_s("F")) if balance.closing_debit_balance
|
|
82
|
+
xml.ClosingCreditBalance(balance.closing_credit_balance.to_s("F")) if balance.closing_credit_balance
|
|
83
|
+
}
|
|
84
|
+
end
|
|
81
85
|
xml.PartyInfo { build(struct.party_info) } if struct.party_info
|
|
82
86
|
|
|
83
87
|
when Types::Supplier.name.split("::").last
|
|
84
88
|
build_company_structure(struct)
|
|
85
89
|
xml.SupplierID(struct.supplier_id)
|
|
86
90
|
xml.SelfBillingIndicator(struct.self_billing_indicator) if struct.self_billing_indicator
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
struct.balance_accounts.each do |balance|
|
|
92
|
+
xml.BalanceAccount {
|
|
93
|
+
xml.AccountID(balance.account_id) if balance.account_id
|
|
94
|
+
xml.OpeningDebitBalance(balance.opening_debit_balance.to_s("F")) if balance.opening_debit_balance
|
|
95
|
+
xml.OpeningCreditBalance(balance.opening_credit_balance.to_s("F")) if balance.opening_credit_balance
|
|
96
|
+
xml.ClosingDebitBalance(balance.closing_debit_balance.to_s("F")) if balance.closing_debit_balance
|
|
97
|
+
xml.ClosingCreditBalance(balance.closing_credit_balance.to_s("F")) if balance.closing_credit_balance
|
|
98
|
+
}
|
|
99
|
+
end
|
|
92
100
|
xml.PartyInfo { build(struct.party_info) } if struct.party_info
|
|
93
101
|
|
|
94
102
|
when Types::Owner.name.split("::").last
|
|
@@ -166,7 +174,8 @@ module SAFT::V2
|
|
|
166
174
|
when Types::AnalysisStructure.name.split("::").last
|
|
167
175
|
xml.AnalysisType(struct.analysis_type) if struct.analysis_type
|
|
168
176
|
xml.AnalysisID(struct.analysis_id) if struct.analysis_id
|
|
169
|
-
xml.
|
|
177
|
+
xml.DebitAnalysisAmount { build(struct.debit_analysis_amount) } if struct.debit_analysis_amount
|
|
178
|
+
xml.CreditAnalysisAmount { build(struct.credit_analysis_amount) } if struct.credit_analysis_amount
|
|
170
179
|
|
|
171
180
|
when Types::AnalysisPartyInfoStructure.name.split("::").last
|
|
172
181
|
xml.AnalysisType(struct.analysis_type)
|
|
@@ -179,7 +188,8 @@ module SAFT::V2
|
|
|
179
188
|
xml.Country(struct.country) if struct.country
|
|
180
189
|
xml.TaxBase(struct.tax_base.to_s("F")) if struct.tax_base
|
|
181
190
|
xml.TaxBaseDescription(struct.tax_base_description) if struct.tax_base_description
|
|
182
|
-
xml.
|
|
191
|
+
xml.DebitTaxAmount { build(struct.debit_tax_amount) } if struct.debit_tax_amount
|
|
192
|
+
xml.CreditTaxAmount { build(struct.credit_tax_amount) } if struct.credit_tax_amount
|
|
183
193
|
xml.TaxExemptionReason(struct.tax_exemption_reason) if struct.tax_exemption_reason
|
|
184
194
|
xml.TaxDeclarationPeriod(struct.tax_declaration_period) if struct.tax_declaration_period
|
|
185
195
|
|
|
@@ -216,15 +226,14 @@ module SAFT::V2
|
|
|
216
226
|
xml.SoftwareVersion(struct.software_version)
|
|
217
227
|
xml.Company { build(struct.company) }
|
|
218
228
|
xml.DefaultCurrencyCode(struct.default_currency_code)
|
|
219
|
-
xml.SelectionCriteria { build(struct.selection_criteria) }
|
|
229
|
+
xml.SelectionCriteria { build(struct.selection_criteria) }
|
|
220
230
|
xml.HeaderComment(struct.header_comment) if struct.header_comment
|
|
221
231
|
|
|
222
232
|
when Types::Account.name.split("::").last
|
|
223
233
|
xml.AccountID(struct.account_id)
|
|
224
234
|
xml.AccountDescription(struct.account_description)
|
|
225
|
-
xml.
|
|
226
|
-
xml.
|
|
227
|
-
xml.GroupingCode(struct.grouping_code) if struct.grouping_code
|
|
235
|
+
xml.GroupingCategory(struct.grouping_category)
|
|
236
|
+
xml.GroupingCode(struct.grouping_code)
|
|
228
237
|
xml.AccountType(struct.account_type)
|
|
229
238
|
xml.AccountCreationDate(struct.account_creation_date) if struct.account_creation_date
|
|
230
239
|
xml.OpeningDebitBalance(struct.opening_debit_balance.to_s("F")) if struct.opening_debit_balance
|
|
@@ -333,11 +342,14 @@ module SAFT::V2
|
|
|
333
342
|
xml.PeriodYear(struct.period_year) if struct.period_year
|
|
334
343
|
xml.TransactionDate(struct.transaction_date) if struct.transaction_date
|
|
335
344
|
xml.SourceID(struct.source_id) if struct.source_id
|
|
345
|
+
xml.VoucherType(struct.voucher_type) if struct.voucher_type
|
|
346
|
+
xml.VoucherDescription(struct.voucher_description) if struct.voucher_description
|
|
336
347
|
xml.TransactionType(struct.transaction_type) if struct.transaction_type
|
|
337
348
|
xml.Description(struct.description) if struct.description
|
|
338
349
|
xml.BatchID(struct.batch_id) if struct.batch_id
|
|
339
350
|
xml.SystemEntryDate(struct.system_entry_date) if struct.system_entry_date
|
|
340
351
|
xml.GLPostingDate(struct.gl_posting_date) if struct.gl_posting_date
|
|
352
|
+
xml.ModificationDate(struct.modification_date) if struct.modification_date
|
|
341
353
|
xml.SystemID(struct.system_id) if struct.system_id
|
|
342
354
|
struct.lines&.each do |line|
|
|
343
355
|
xml.Line { build(line) }
|
data/lib/saft/v2/types.rb
CHANGED
|
@@ -55,7 +55,8 @@ module SAFT::V2::Types
|
|
|
55
55
|
klass = Class.new(Dry::Struct) do
|
|
56
56
|
attribute(:analysis_type, base::SAFcodeType)
|
|
57
57
|
attribute(:analysis_id, base::SAFlongtextType)
|
|
58
|
-
attribute(:
|
|
58
|
+
attribute(:debit_analysis_amount, base::AmountStructure.optional.meta(omittable: true))
|
|
59
|
+
attribute(:credit_analysis_amount, base::AmountStructure.optional.meta(omittable: true))
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
base.const_set(:AnalysisStructure, klass)
|
|
@@ -69,12 +70,13 @@ module SAFT::V2::Types
|
|
|
69
70
|
|
|
70
71
|
klass = Class.new(Dry::Struct) do
|
|
71
72
|
attribute(:tax_type, base::SAFcodeType.optional.meta(omittable: true))
|
|
72
|
-
attribute(:tax_code, base::
|
|
73
|
+
attribute(:tax_code, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
73
74
|
attribute(:tax_percentage, Types::Decimal.optional.meta(omittable: true))
|
|
74
75
|
attribute(:country, base::ISOCountryCode.optional.meta(omittable: true))
|
|
75
76
|
attribute(:tax_base, Types::Decimal.optional.meta(omittable: true))
|
|
76
77
|
attribute(:tax_base_description, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
77
|
-
attribute(:
|
|
78
|
+
attribute(:debit_tax_amount, base::AmountStructure.optional.meta(omittable: true))
|
|
79
|
+
attribute(:credit_tax_amount, base::AmountStructure.optional.meta(omittable: true))
|
|
78
80
|
attribute(:tax_exemption_reason, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
79
81
|
attribute(:tax_declaration_period, base::SAFmiddle1textType.optional.meta(omittable: true))
|
|
80
82
|
end
|
|
@@ -143,13 +145,13 @@ module SAFT::V2::Types
|
|
|
143
145
|
base.const_set(:PartyInfoStructure, klass)
|
|
144
146
|
|
|
145
147
|
klass = Class.new(Dry::Struct) do
|
|
146
|
-
attribute(:street_name, base::
|
|
147
|
-
attribute(:number, base::
|
|
148
|
-
attribute(:additional_address_detail, base::
|
|
148
|
+
attribute(:street_name, base::SAFlongtextType.optional.meta(omittable: true))
|
|
149
|
+
attribute(:number, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
150
|
+
attribute(:additional_address_detail, base::SAFlongtextType.optional.meta(omittable: true))
|
|
149
151
|
attribute(:building, base::SAFmiddle1textType.optional.meta(omittable: true))
|
|
150
|
-
attribute(:city, base::
|
|
151
|
-
attribute(:postal_code, base::
|
|
152
|
-
attribute(:region, base::
|
|
152
|
+
attribute(:city, base::SAFlongtextType.optional.meta(omittable: true))
|
|
153
|
+
attribute(:postal_code, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
154
|
+
attribute(:region, base::SAFlongtextType.optional.meta(omittable: true))
|
|
153
155
|
attribute(:country, base::ISOCountryCode.optional.meta(omittable: true))
|
|
154
156
|
attribute(:address_type, base::AddressType.optional.meta(omittable: true))
|
|
155
157
|
end
|
|
@@ -192,7 +194,7 @@ module SAFT::V2::Types
|
|
|
192
194
|
|
|
193
195
|
klass = Class.new(Dry::Struct) do
|
|
194
196
|
attribute(:registration_number, base::SAFmiddle1textType.optional.meta(omittable: true))
|
|
195
|
-
attribute(:name, base::
|
|
197
|
+
attribute(:name, base::SAFlongtextType)
|
|
196
198
|
attribute(:addresses, Types::Array.of(base::AddressStructure))
|
|
197
199
|
attribute(:contacts, Types::Array.of(base::ContactInformationStructure).optional.meta(omittable: true))
|
|
198
200
|
attribute(:tax_registrations, Types::Array.of(base::TaxIDStructure).optional.meta(omittable: true))
|
|
@@ -203,7 +205,7 @@ module SAFT::V2::Types
|
|
|
203
205
|
|
|
204
206
|
klass = Class.new(base::CompanyStructure) do
|
|
205
207
|
attribute(:registration_number, base::SAFmiddle1textType)
|
|
206
|
-
attribute(:name, base::
|
|
208
|
+
attribute(:name, base::SAFlongtextType)
|
|
207
209
|
attribute(:addresses, Types::Array.of(base::AddressStructure))
|
|
208
210
|
attribute(:contacts, Types::Array.of(base::ContactInformationStructure))
|
|
209
211
|
attribute(:tax_registrations, Types::Array.of(base::TaxIDStructure).optional.meta(omittable: true))
|
|
@@ -223,7 +225,7 @@ module SAFT::V2::Types
|
|
|
223
225
|
attribute(:software_version, base::SAFshorttextType)
|
|
224
226
|
attribute(:company, base::CompanyHeaderStructure)
|
|
225
227
|
attribute(:default_currency_code, base::ISOCurrencyCode)
|
|
226
|
-
attribute(:selection_criteria, base::SelectionCriteriaStructure
|
|
228
|
+
attribute(:selection_criteria, base::SelectionCriteriaStructure)
|
|
227
229
|
attribute(:header_comment, base::SAFlongtextType.optional.meta(omittable: true))
|
|
228
230
|
end
|
|
229
231
|
|
|
@@ -232,7 +234,7 @@ module SAFT::V2::Types
|
|
|
232
234
|
klass = Class.new(base::HeaderStructure) do
|
|
233
235
|
attribute(:tax_accounting_basis, base::SAFshorttextType)
|
|
234
236
|
attribute(:tax_entity, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
235
|
-
attribute(:user_id, base::
|
|
237
|
+
attribute(:user_id, base::SAFlongtextType.optional.meta(omittable: true))
|
|
236
238
|
attribute(:audit_file_sender, base::CompanyStructure.optional.meta(omittable: true))
|
|
237
239
|
end
|
|
238
240
|
|
|
@@ -241,9 +243,8 @@ module SAFT::V2::Types
|
|
|
241
243
|
klass = Class.new(Dry::Struct) do
|
|
242
244
|
attribute(:account_id, base::SAFmiddle2textType)
|
|
243
245
|
attribute(:account_description, base::SAFlongtextType)
|
|
244
|
-
attribute(:
|
|
245
|
-
attribute(:
|
|
246
|
-
attribute(:grouping_code, base::SAFmiddle1textType.optional.meta(omittable: true))
|
|
246
|
+
attribute(:grouping_category, base::SAFlongtextType)
|
|
247
|
+
attribute(:grouping_code, base::SAFmiddle1textType)
|
|
247
248
|
attribute(:account_type, base::SAFshorttextType)
|
|
248
249
|
attribute(:account_creation_date, Types::Date.optional.meta(omittable: true))
|
|
249
250
|
attribute(:opening_debit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
@@ -254,14 +255,20 @@ module SAFT::V2::Types
|
|
|
254
255
|
|
|
255
256
|
base.const_set(:Account, klass)
|
|
256
257
|
|
|
257
|
-
klass = Class.new(
|
|
258
|
-
attribute(:customer_id, base::SAFmiddle1textType)
|
|
259
|
-
attribute(:self_billing_indicator, base::SAFcodeType.optional.meta(omittable: true))
|
|
258
|
+
klass = Class.new(Dry::Struct) do
|
|
260
259
|
attribute(:account_id, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
261
260
|
attribute(:opening_debit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
262
261
|
attribute(:opening_credit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
263
262
|
attribute(:closing_debit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
264
263
|
attribute(:closing_credit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
base.const_set(:BalanceAccount, klass)
|
|
267
|
+
|
|
268
|
+
klass = Class.new(base::CompanyStructure) do
|
|
269
|
+
attribute(:customer_id, base::SAFmiddle1textType)
|
|
270
|
+
attribute(:self_billing_indicator, base::SAFcodeType.optional.meta(omittable: true))
|
|
271
|
+
attribute(:balance_accounts, Types::Array.of(base::BalanceAccount))
|
|
265
272
|
attribute(:party_info, base::PartyInfoStructure.optional.meta(omittable: true))
|
|
266
273
|
end
|
|
267
274
|
|
|
@@ -270,18 +277,14 @@ module SAFT::V2::Types
|
|
|
270
277
|
klass = Class.new(base::CompanyStructure) do
|
|
271
278
|
attribute(:supplier_id, base::SAFmiddle1textType)
|
|
272
279
|
attribute(:self_billing_indicator, base::SAFcodeType.optional.meta(omittable: true))
|
|
273
|
-
attribute(:
|
|
274
|
-
attribute(:opening_debit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
275
|
-
attribute(:opening_credit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
276
|
-
attribute(:closing_debit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
277
|
-
attribute(:closing_credit_balance, base::SAFmonetaryType.optional.meta(omittable: true))
|
|
280
|
+
attribute(:balance_accounts, Types::Array.of(base::BalanceAccount))
|
|
278
281
|
attribute(:party_info, base::PartyInfoStructure.optional.meta(omittable: true))
|
|
279
282
|
end
|
|
280
283
|
|
|
281
284
|
base.const_set(:Supplier, klass)
|
|
282
285
|
|
|
283
286
|
klass = Class.new(Dry::Struct) do
|
|
284
|
-
attribute(:tax_code, base::
|
|
287
|
+
attribute(:tax_code, base::SAFmiddle2textType)
|
|
285
288
|
attribute(:effective_date, Types::Date.optional.meta(omittable: true))
|
|
286
289
|
attribute(:expiration_date, Types::Date.optional.meta(omittable: true))
|
|
287
290
|
attribute(:description, base::SAFlongtextType.optional.meta(omittable: true))
|
|
@@ -378,11 +381,14 @@ module SAFT::V2::Types
|
|
|
378
381
|
attribute(:period_year, Types::Integer)
|
|
379
382
|
attribute(:transaction_date, Types::Date)
|
|
380
383
|
attribute(:source_id, base::SAFmiddle1textType.optional.meta(omittable: true))
|
|
384
|
+
attribute(:voucher_type, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
385
|
+
attribute(:voucher_description, base::SAFmiddle2textType.optional.meta(omittable: true))
|
|
381
386
|
attribute(:transaction_type, base::SAFshorttextType.optional.meta(omittable: true))
|
|
382
387
|
attribute(:description, base::SAFlongtextType)
|
|
383
388
|
attribute(:batch_id, base::SAFmiddle1textType.optional.meta(omittable: true))
|
|
384
389
|
attribute(:system_entry_date, Types::Date)
|
|
385
390
|
attribute(:gl_posting_date, Types::Date)
|
|
391
|
+
attribute(:modification_date, Types::Date.optional.meta(omittable: true))
|
|
386
392
|
# ignored since xsd said "Not in use."
|
|
387
393
|
# attribute :CustomerID, base::SAFmiddle1textType.optional.meta(omittable: true)
|
|
388
394
|
# ignored since xsd said "Not in use."
|
data/lib/saft/v2/xsd_validate.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require "nokogiri"
|
|
4
4
|
require "pathname"
|
|
5
5
|
|
|
6
|
-
XSD_PATH = Pathname.new(__dir__) + ".." + ".." + ".." + "vendor" + "
|
|
6
|
+
XSD_PATH = Pathname.new(__dir__) + ".." + ".." + ".." + "vendor" + "Norwegian_SAF-T_Financial_Schema_v_1.30.xsd"
|
|
7
7
|
|
|
8
8
|
module SAFT::V2
|
|
9
9
|
class XsdValidate
|
|
@@ -17,12 +17,9 @@ module SAFT::V2
|
|
|
17
17
|
# https://nokogiri.org/rdoc/Nokogiri/XML/SyntaxError.html
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def valid?
|
|
21
|
-
|
|
22
|
-
end
|
|
20
|
+
def valid? = @xml_errors.none?
|
|
21
|
+
def invalid? = !valid?
|
|
23
22
|
|
|
24
|
-
def errors
|
|
25
|
-
@xml_errors
|
|
26
|
-
end
|
|
23
|
+
def errors = @xml_errors
|
|
27
24
|
end
|
|
28
25
|
end
|
data/lib/saft/version.rb
CHANGED