client_bank_exchange 0.2.1 → 0.2.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 +4 -4
- data/lib/client_bank_exchange.rb +60 -42
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e125b29b3a88634eb45b8277850fc2e895b766
|
4
|
+
data.tar.gz: 5d3d4998c0e83e92bc35fe1b6416a360f14f21d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 552f39fc7231a4640b1c079ac5be386ee3ce3d9cdb40b1cb433640e78b470a0b3dcb1a0d64b31d8ba8f36195ad1588fbbdc38a092c3d7311feded4f108873505
|
7
|
+
data.tar.gz: f074e30a9327472a287805821835f8ad7ef3d25e7ad96365e481df3ab17be16bf2ef0e2c431a9a01f338e0c5a3365ea1de9c3cb24a5ab13a52cdfca675ed502e
|
data/lib/client_bank_exchange.rb
CHANGED
@@ -19,50 +19,11 @@ module ClientBankExchange
|
|
19
19
|
}
|
20
20
|
|
21
21
|
if content.start_with? '1CClientBankExchange'
|
22
|
-
|
23
|
-
[
|
24
|
-
:ВерсияФормата, :Кодировка,
|
25
|
-
:Отправитель, :Получатель,
|
26
|
-
:ДатаСоздания, :ВремяСоздания
|
27
|
-
].each do |key|
|
28
|
-
/#{key}=(.*)/.match(content) do |match|
|
29
|
-
result[:general][key] = match[1].strip
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
hash_value_to_date result[:general], :ДатаСоздания
|
34
|
-
hash_value_to_time result[:general], :ВремяСоздания
|
35
|
-
|
36
|
-
# parse remainings
|
37
|
-
/СекцияРасчСчет([\s\S]*?)\sКонецРасчСчет/.match(content) do |match|
|
38
|
-
# remainings properties (key=value)
|
39
|
-
match[1].scan(/(.*)=(.*)/) { |k, v| result[:remainings][k.to_sym] = v.strip }
|
40
|
-
|
41
|
-
# normalize
|
42
|
-
hash_value_to_date result[:remainings], :ДатаНачала
|
43
|
-
hash_value_to_date result[:remainings], :ДатаКонца
|
44
|
-
hash_value_to_d result[:remainings], :НачальныйОстаток
|
45
|
-
hash_value_to_d result[:remainings], :ВсегоПоступило
|
46
|
-
hash_value_to_d result[:remainings], :ВсегоСписано
|
47
|
-
hash_value_to_d result[:remainings], :КонечныйОстаток
|
48
|
-
end
|
49
|
-
|
50
|
-
# parse documents
|
51
|
-
regexp_document = /СекцияДокумент=(.*)\s([\s\S]*?)\sКонецДокумента/
|
52
|
-
result[:documents] = content.scan(regexp_document).map do |doc|
|
53
|
-
# document type
|
54
|
-
document = { СекцияДокумент: doc[0] }
|
55
|
-
|
56
|
-
# document properties (key=value)
|
57
|
-
doc[1].scan(/(.*)=(.*)/) { |k, v| document[k.to_sym] = v.strip }
|
22
|
+
result[:general] = general(content)
|
58
23
|
|
59
|
-
|
60
|
-
hash_value_to_i document, :Номер
|
61
|
-
hash_value_to_date document, :Дата
|
62
|
-
hash_value_to_d document, :Сумма
|
24
|
+
result[:remainings] = remainings(content)
|
63
25
|
|
64
|
-
|
65
|
-
end
|
26
|
+
result[:documents] = documents(content)
|
66
27
|
else
|
67
28
|
result[:errors] << 'Wrong format: 1CClientBankExchange not found'
|
68
29
|
end
|
@@ -71,6 +32,63 @@ module ClientBankExchange
|
|
71
32
|
end
|
72
33
|
|
73
34
|
private
|
35
|
+
|
36
|
+
def general content
|
37
|
+
result = {}
|
38
|
+
|
39
|
+
# parse general info (key=value)
|
40
|
+
[
|
41
|
+
:ВерсияФормата, :Кодировка,
|
42
|
+
:Отправитель, :Получатель,
|
43
|
+
:ДатаСоздания, :ВремяСоздания
|
44
|
+
].each do |key|
|
45
|
+
/#{key}=(.*)/.match(content) do |match|
|
46
|
+
result[key] = match[1].strip
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
hash_value_to_date result, :ДатаСоздания
|
51
|
+
hash_value_to_time result, :ВремяСоздания
|
52
|
+
|
53
|
+
result
|
54
|
+
end
|
55
|
+
|
56
|
+
def remainings content
|
57
|
+
result = {}
|
58
|
+
|
59
|
+
/СекцияРасчСчет([\s\S]*?)\sКонецРасчСчет/.match(content) do |match|
|
60
|
+
# remainings properties (key=value)
|
61
|
+
match[1].scan(/(.*)=(.*)/) { |k, v| result[k.to_sym] = v.strip }
|
62
|
+
|
63
|
+
# normalize
|
64
|
+
hash_value_to_date result, :ДатаНачала
|
65
|
+
hash_value_to_date result, :ДатаКонца
|
66
|
+
hash_value_to_d result, :НачальныйОстаток
|
67
|
+
hash_value_to_d result, :ВсегоПоступило
|
68
|
+
hash_value_to_d result, :ВсегоСписано
|
69
|
+
hash_value_to_d result, :КонечныйОстаток
|
70
|
+
end
|
71
|
+
|
72
|
+
result
|
73
|
+
end
|
74
|
+
|
75
|
+
def documents content
|
76
|
+
regexp_document = /СекцияДокумент=(.*)\s([\s\S]*?)\sКонецДокумента/
|
77
|
+
content.scan(regexp_document).map do |doc|
|
78
|
+
# document type
|
79
|
+
document = { СекцияДокумент: doc[0] }
|
80
|
+
|
81
|
+
# document properties (key=value)
|
82
|
+
doc[1].scan(/(.*)=(.*)/) { |k, v| document[k.to_sym] = v.strip }
|
83
|
+
|
84
|
+
# normalize
|
85
|
+
hash_value_to_i document, :Номер
|
86
|
+
hash_value_to_date document, :Дата
|
87
|
+
hash_value_to_d document, :Сумма
|
88
|
+
|
89
|
+
document
|
90
|
+
end
|
91
|
+
end
|
74
92
|
|
75
93
|
def hash_value_to_date hash, key
|
76
94
|
hash[key] = Date.parse(hash[key]) if hash[key]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client_bank_exchange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Zharikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Format specification: http://v8.1c.ru/edi/edi_stnd/100/101.htm'
|
14
14
|
email: andrey@zharikov.pro
|
@@ -37,9 +37,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
39
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.
|
40
|
+
rubygems_version: 2.4.6
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Import and export for 1CClientBankExchange v1.02 file format
|
44
44
|
test_files: []
|
45
|
-
has_rdoc:
|