rs.ge 0.0.10 → 0.0.11

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.
data/README.md CHANGED
@@ -45,7 +45,7 @@ was_created = RS.create_service_user(params)
45
45
  - `su` — ახალი სერვისის მომხმარებლის სახელი;
46
46
  - `sp` — სერვისის მომხმარებლის პაროლი.
47
47
 
48
- ეს ბუნქცია აბრუნებს `boolean` ტიპის მნიშვნელობას: თუ მომხმარებელი შეიქმნა, ბრუნდება `true`, ხოლო `false` — წინააღმდეგ შემთხვევაში. თუ რატომ არ მოხდა მომხმარებლის გახსნა შეიძლება მხოლოდ ვივარაუდოდ: ამის შესახებ rs-ის სერვისი არანაირ პასუხს არ იძლევა.
48
+ ეს ფუნქცია აბრუნებს `boolean` ტიპის მნიშვნელობას: თუ მომხმარებელი შეიქმნა, ბრუნდება `true`, ხოლო `false` — წინააღმდეგ შემთხვევაში. თუ რატომ არ მოხდა მომხმარებლის გახსნა შეიძლება მხოლოდ ვივარაუდოდ: ამის შესახებ rs-ის სერვისი არანაირ პასუხს არ იძლევა.
49
49
 
50
50
  ძალაინ მნიშვნელოვანი ფუნქციაა `check_service_user`, რომელიც გარდა იმისა, რომ ამოწმებს ახლად შექმნილი მომხმარებლის სახელს და პაროლს, ასევე გაძლევთ შანსს გაიგოთ თქვენი ორგანიზაციის გადამხდელის ID. ამ ფუნქციის გამოძახება ასე გამოიყურება:
51
51
 
data/lib/rs.rb CHANGED
@@ -5,6 +5,7 @@ require 'rs/sys'
5
5
  require 'rs/dict'
6
6
  require 'rs/waybill'
7
7
  require 'rs/print'
8
+ require 'rs/invoice'
8
9
 
9
10
  module RS
10
11
  # ელქტრონული ზედნადების ფორმის WSDL მისამართი
@@ -13,6 +14,12 @@ module RS
13
14
  # ელექტრონული ა/ფ WSDL მისამართი
14
15
  INVOICE_SERVICE_URL = 'https://www.revenue.mof.ge/ntosservice/ntosservice.asmx?WSDL'
15
16
 
17
+ # მომხმარებელი, რომელიც შეგიძლიათ გამოიყენოთ ღია სერვისებში.
18
+ OPEN_SU = 'dimitri1979'
19
+
20
+ # პაროლის ღია მომხმარებლისთვის.
21
+ OPEN_SP = '123456'
22
+
16
23
  # შეცდომის კლასი
17
24
  class Error < RuntimeError
18
25
  end
@@ -33,6 +40,19 @@ module RS
33
40
  end
34
41
  end
35
42
 
43
+ # ამოწმებს პარამეტრების მნიშვნელობას su და sp
44
+ # და თუ ისინი არაა განსაზღვრული, მიანიჭებს ღია
45
+ # მომხმარებლის პარამეტრებს.
46
+ # ეს სასარგებლოა ისეთი მონაცემების მისაღებად,
47
+ # რომელიც არაა უშუალოდ დაკავშირებული ორგანიზაციის
48
+ # საქმიანობოსთან.
49
+ def self.ensure_open_user(params)
50
+ unless params.include? 'su'
51
+ params['su'] = OPEN_SU
52
+ params['sp'] = OPEN_SP
53
+ end
54
+ end
55
+
36
56
  # ამოწმებს, რომ მოცემულ პარამეტრებში ყველას მნიშვნელობა განსხვავდებოდეს <code>nil</code>-სგან.
37
57
  def self.validate_presence_of(params, *options)
38
58
  options.each do |opt|
data/lib/rs/dict.rb CHANGED
@@ -83,6 +83,7 @@ module RS
83
83
  # sp -- სერვისის მომხმარებლის პაროლი
84
84
  # normilize -- კი/არა, გამოიყენოს თუ არა სახელების ნორმალიზებული მნიშვნელობები (საწყისად ნორმალიზებულია)
85
85
  def self.get_excise_codes(params)
86
+ RS.ensure_open_user(params)
86
87
  RS.validate_presence_of(params, 'su', 'sp')
87
88
  client = RS.waybill_service
88
89
  response = client.request 'get_akciz_codes' do
@@ -110,6 +111,7 @@ module RS
110
111
  # su -- სერვისის მომხმარებლის სახელი
111
112
  # sp -- სერვისის მომხმარებლის პაროლი
112
113
  def self.get_waybill_types(params)
114
+ RS.ensure_open_user(params)
113
115
  RS.validate_presence_of(params, 'su', 'sp')
114
116
  client = RS.waybill_service
115
117
  response = client.request 'get_waybill_types' do
@@ -134,6 +136,7 @@ module RS
134
136
  # su -- სერვისის მომხმარებლის სახელი
135
137
  # sp -- სერვისის მომხმარებლის პაროლი
136
138
  def self.get_waybill_units(params)
139
+ RS.ensure_open_user(params)
137
140
  RS.validate_presence_of(params, 'su', 'sp')
138
141
  client = RS.waybill_service
139
142
  response = client.request 'get_waybill_units' do
@@ -158,6 +161,7 @@ module RS
158
161
  # su -- სერვისის მომხმარებლის სახელი
159
162
  # sp -- სერვისის მომხმარებლის პაროლი
160
163
  def self.get_transport_types(params)
164
+ RS.ensure_open_user(params)
161
165
  RS.validate_presence_of(params, 'su', 'sp')
162
166
  client = RS.waybill_service
163
167
  response = client.request 'get_trans_types' do
data/lib/rs/invoice.rb ADDED
@@ -0,0 +1,18 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module RS
4
+
5
+ # ქმნის ფაქტურას მოცემული ზედნადებისთვის.
6
+ #
7
+ # ზედნადებზე ფაქტურის გამოწერა ხდება მხოლოდ დახურულ მდგომარეობაში.
8
+ def self.save_waybill_invoice(waybill, params = {})
9
+ RS.validate_presence_of(params, 'su', 'sp')
10
+ client = RS.waybill_service
11
+ params2 = params.merge( 'waybill_id' => waybill.id, 'in_inv_id' => 0 )
12
+ response = client.request 'save_invoice' do |soap|
13
+ soap.body = params2
14
+ end
15
+ waybill.invoice_id = response[:save_invoice_response][:out_inv_id].to_i
16
+ end
17
+
18
+ end
data/lib/rs/sys.rb CHANGED
@@ -116,6 +116,7 @@ module RS
116
116
  # sp -- პაროლი
117
117
  # tin -- საიდენტიფიკაციო ნომერი
118
118
  def self.get_name_from_tin(params)
119
+ RS.ensure_open_user(params)
119
120
  RS.validate_presence_of(params, 'su', 'sp', 'tin')
120
121
  client = RS.waybill_service
121
122
  response = client.request 'get_name_from_tin' do
data/lib/rs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module RS
4
- VERSION = "0.0.10"
4
+ VERSION = '0.0.11'
5
5
  end
data/lib/rs/waybill.rb CHANGED
@@ -118,6 +118,7 @@ module RS
118
118
  attr_accessor :create_date, :start_date, :delivery_date, :activate_date
119
119
  attr_accessor :items
120
120
  attr_accessor :error_code
121
+ attr_accessor :invoice_id
121
122
 
122
123
  def to_xml(xml)
123
124
  xml.WAYBILL do |b|
@@ -377,7 +378,7 @@ module RS
377
378
  RS.validate_presence_of(params, 'waybill_id', 'su', 'sp')
378
379
  client = RS.waybill_service
379
380
  response = client.request 'get_waybill' do |soap|
380
- soap.body = params.merge({:order => ['su', 'sp', 'waybill_id']})
381
+ soap.body = params.merge({:order! => ['su', 'sp', 'waybill_id']})
381
382
  end
382
383
  #puts response.to_hash[:get_waybill_response][:get_waybill_result][:waybill]
383
384
  Waybill.init_from_hash(response.to_hash[:get_waybill_response][:get_waybill_result][:waybill])
@@ -0,0 +1,12 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+ require 'rs'
5
+
6
+ describe 'get name from TIN using open user' do
7
+ before(:all) do
8
+ @name = RS.get_name_from_tin('tin' => '02001000490')
9
+ end
10
+ subject { @name }
11
+ it { should == 'დიმიტრი ყურაშვილი' }
12
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+ require 'rs'
5
+
6
+ describe 'save invoice (only for closed waybill)' do
7
+ before(:all) do
8
+ @waybill = waybill_skeleton
9
+ RS.save_waybill(@waybill, RS.su_params)
10
+ RS.activate_waybill(RS.su_params.merge('waybill_id' => @waybill.id))
11
+ RS.close_waybill(RS.su_params.merge('waybill_id' => @waybill.id))
12
+ RS.save_waybill_invoice(@waybill, RS.su_params)
13
+ end
14
+ subject { @waybill }
15
+ its(:invoice_id) { should_not be_nil }
16
+ its(:invoice_id) { should > 0 }
17
+ end
@@ -143,4 +143,4 @@ describe 'validation with remote' do
143
143
  it("driver_tin is OK") { subject[:driver_tin].should be_nil }
144
144
  it("should have illegal buyer name") { subject[:buyer_name].should_not be_nil }
145
145
  it("buyer_tin is OK") { subject[:buyer_tin].should be_nil }
146
- end
146
+ end
data/spec/spec_helper.rb CHANGED
@@ -87,12 +87,12 @@ def waybill_skeleton(params = {})
87
87
  end
88
88
  else
89
89
  item = RS::WaybillItem.new
90
- item.prod_name = 'სატესტო საქონელი'
90
+ item.prod_name = 'ბალი ალუბალი წითელი'
91
91
  item.unit_id = 99
92
- item.unit_name = 'ერთეული'
93
- item.quantity = 2
92
+ item.unit_name = 'კილოგრამი'
93
+ item.quantity = 10
94
94
  item.price = 5
95
- item.bar_code = '123'
95
+ item.bar_code = '001'
96
96
  items = [item]
97
97
  end
98
98
  waybill.items = items
data/tmp/waybill.pdf CHANGED
@@ -173,7 +173,7 @@ S
173
173
  BT
174
174
  216.128 787.246 Td
175
175
  /F1.0 7 Tf
176
- <313320> Tj
176
+ <313420> Tj
177
177
  /F1.1 7 Tf
178
178
  <2d222e2f2b20> Tj
179
179
  /F1.0 7 Tf
@@ -243,7 +243,7 @@ S
243
243
  BT
244
244
  367.06 787.246 Td
245
245
  /F1.0 7 Tf
246
- <31353a3230> Tj
246
+ <31323a3432> Tj
247
247
  ET
248
248
 
249
249
  0.000 0.000 0.000 scn
@@ -6027,7 +6027,7 @@ S
6027
6027
  BT
6028
6028
  328.628 112.88399999999965 Td
6029
6029
  /F1.0 7 Tf
6030
- <313320> Tj
6030
+ <313420> Tj
6031
6031
  /F1.1 7 Tf
6032
6032
  <2d222e2f2b20> Tj
6033
6033
  /F1.0 7 Tf
@@ -6064,7 +6064,7 @@ S
6064
6064
  BT
6065
6065
  439.56 112.88399999999965 Td
6066
6066
  /F1.0 7 Tf
6067
- <31353a3230> Tj
6067
+ <31323a3432> Tj
6068
6068
  ET
6069
6069
 
6070
6070
  0.000 0.000 0.000 scn
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rs.ge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-13 00:00:00.000000000 Z
12
+ date: 2012-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &73474910 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '2'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *73474910
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: simplecov
27
- requirement: &73474710 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *73474710
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: savon
38
- requirement: &73474480 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *73474480
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: httpi
49
- requirement: &73474270 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *73474270
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: prawn
60
- requirement: &73474020 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0.12'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *73474020
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.12'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: c12-commons
71
- requirement: &73473810 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,7 +101,12 @@ dependencies:
76
101
  version: '0'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *73473810
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  description: ruby client for rs.ge web services
81
111
  email:
82
112
  - dimitri@c12.ge
@@ -92,15 +122,18 @@ files:
92
122
  - Rakefile
93
123
  - lib/rs.rb
94
124
  - lib/rs/dict.rb
125
+ - lib/rs/invoice.rb
95
126
  - lib/rs/print.rb
96
127
  - lib/rs/sys.rb
97
128
  - lib/rs/version.rb
98
129
  - lib/rs/waybill.rb
99
130
  - rs.gemspec
100
131
  - spec/rs/dict_spec.rb
132
+ - spec/rs/open_user.rb
101
133
  - spec/rs/pdf_spec.rb
102
134
  - spec/rs/sys_spec.rb
103
135
  - spec/rs/waybill_delete_spec.rb
136
+ - spec/rs/waybill_invoice_spec.rb
104
137
  - spec/rs/waybill_spec.rb
105
138
  - spec/rs/waybill_validation_spec.rb
106
139
  - spec/spec_helper.rb
@@ -126,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
159
  version: '0'
127
160
  requirements: []
128
161
  rubyforge_project: rs
129
- rubygems_version: 1.8.13
162
+ rubygems_version: 1.8.19
130
163
  signing_key:
131
164
  specification_version: 3
132
165
  summary: rs.ge web services