rs.ge 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/README.md +23 -0
- data/Rakefile +12 -0
- data/lib/rs.rb +55 -0
- data/lib/rs/dict.rb +247 -0
- data/lib/rs/sys.rb +127 -0
- data/lib/rs/version.rb +4 -0
- data/lib/rs/waybill.rb +116 -0
- data/p1-soapui-project.xml +5505 -0
- data/rs.gemspec +26 -0
- data/spec/rs/dict_spec.rb +175 -0
- data/spec/rs/sys_spec.rb +69 -0
- data/spec/rs/waybill_spec.rb +84 -0
- data/spec/spec_helper.rb +50 -0
- data/test.rb +185 -0
- metadata +111 -0
data/rs.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rs.ge"
|
7
|
+
s.version = RS::VERSION
|
8
|
+
s.authors = ["Dimitri Kurashvili"]
|
9
|
+
s.email = ["dimitri@c12.ge"]
|
10
|
+
s.homepage = "http://c12.ge"
|
11
|
+
s.summary = %q{rs.ge web services}
|
12
|
+
s.description = %q{ruby client for rs.ge web services}
|
13
|
+
|
14
|
+
s.rubyforge_project = "rs"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency 'rspec', '~> 2'
|
22
|
+
s.add_development_dependency 'simplecov'
|
23
|
+
|
24
|
+
s.add_runtime_dependency 'savon'
|
25
|
+
s.add_runtime_dependency 'httpi'
|
26
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
# excise codes
|
5
|
+
|
6
|
+
describe 'getting excise codes' do
|
7
|
+
before(:all) do
|
8
|
+
@codes = RS.get_excise_codes(RS.su_params)
|
9
|
+
end
|
10
|
+
subject { @codes }
|
11
|
+
it { should_not be_nil }
|
12
|
+
it { should_not be_empty }
|
13
|
+
context "first code" do
|
14
|
+
subject {@codes.first}
|
15
|
+
it { should be_instance_of RS::ExciseCode }
|
16
|
+
its(:id) { should_not be_nil }
|
17
|
+
its(:name) { should_not be_nil }
|
18
|
+
its(:name) { should_not be_empty }
|
19
|
+
its(:code) { should_not be_empty }
|
20
|
+
its(:measure) { should_not be_nil }
|
21
|
+
its(:value) { should_not be_nil }
|
22
|
+
its(:value) { should > 0 }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'excise name normalization' do
|
27
|
+
context 'name (1234) _ msr _ (1)' do
|
28
|
+
subject { RS.normalize_excise_name('name (1234) _ msr _ (1)') }
|
29
|
+
it { should == 'name' }
|
30
|
+
end
|
31
|
+
context 'name (019048999) _ msr _ (1)' do
|
32
|
+
subject { RS.normalize_excise_name('name (019048999) _ msr _ (1)') }
|
33
|
+
it { should == 'name' }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# waybill types
|
38
|
+
|
39
|
+
describe 'getting waybill types' do
|
40
|
+
before(:all) do
|
41
|
+
@types = RS.get_waybill_types(RS.su_params)
|
42
|
+
end
|
43
|
+
subject { @types }
|
44
|
+
it { should_not be_nil }
|
45
|
+
it { should_not be_empty }
|
46
|
+
context 'first type' do
|
47
|
+
subject { @types.first }
|
48
|
+
it { should be_instance_of WaybillType }
|
49
|
+
its(:id) { should_not be_nil }
|
50
|
+
its(:name) { should_not be_nil }
|
51
|
+
its(:name) { should_not be_empty }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def waybill_type_creation_test(id)
|
56
|
+
context "WaybillType with ID=#{id}" do
|
57
|
+
subject { WaybillType.create_from_id(id) }
|
58
|
+
it { should be_instance_of WaybillType }
|
59
|
+
its(:id) { should == id }
|
60
|
+
its(:name) { should == WaybillType::NAMES[id]}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe WaybillType do
|
65
|
+
waybill_type_creation_test WaybillType::INNER
|
66
|
+
waybill_type_creation_test WaybillType::TRANSPORTATION
|
67
|
+
waybill_type_creation_test WaybillType::WITHOUT_TRANSPORTATION
|
68
|
+
waybill_type_creation_test WaybillType::DISTRIBUTION
|
69
|
+
waybill_type_creation_test WaybillType::RETURN
|
70
|
+
waybill_type_creation_test WaybillType::SUB_WAYBILL
|
71
|
+
end
|
72
|
+
|
73
|
+
# waybill units
|
74
|
+
|
75
|
+
describe 'getting waybill units' do
|
76
|
+
before(:all) do
|
77
|
+
@units = RS.get_waybill_units(RS.su_params)
|
78
|
+
end
|
79
|
+
subject { @units }
|
80
|
+
it { should_not be_nil }
|
81
|
+
it { should_not be_empty }
|
82
|
+
context 'first unit' do
|
83
|
+
subject{ @units.first }
|
84
|
+
it { should_not be_nil }
|
85
|
+
it { should be_instance_of WaybillUnit }
|
86
|
+
its(:id) { should_not be_nil }
|
87
|
+
its(:name) { should_not be_nil }
|
88
|
+
its(:name) { should_not be_empty }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# transport types
|
93
|
+
|
94
|
+
describe 'getting transport types' do
|
95
|
+
before(:all) do
|
96
|
+
@types = RS.get_transport_types(RS.su_params)
|
97
|
+
end
|
98
|
+
subject { @types }
|
99
|
+
it { should_not be_nil }
|
100
|
+
it { should_not be_empty }
|
101
|
+
context 'first type' do
|
102
|
+
subject { @types.first }
|
103
|
+
it { should_not be_nil }
|
104
|
+
it { should be_instance_of TransportType }
|
105
|
+
its(:id) { should_not be_nil }
|
106
|
+
its(:name) { should_not be_nil }
|
107
|
+
its(:name) { should_not be_empty }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# bar codes
|
112
|
+
|
113
|
+
describe 'save and delete bar code' do
|
114
|
+
before(:all) do
|
115
|
+
@resp = RS.save_bar_code(RS.su_params.merge('bar_code' => '001', 'prod_name' => 'Apple', 'unit_id' => 1, 'unit_name' => 'kg', 'excise_id' => nil))
|
116
|
+
end
|
117
|
+
subject { @resp }
|
118
|
+
it { should be_true }
|
119
|
+
context 'delete this bar code' do
|
120
|
+
before(:all) do
|
121
|
+
@resp_delete = RS.delete_bar_code(RS.su_params.merge('bar_code' => 'inv/1'))
|
122
|
+
end
|
123
|
+
subject { @resp_delete }
|
124
|
+
it { should be_true }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe 'get bar codes' do
|
129
|
+
before(:all) do
|
130
|
+
RS.save_bar_code(RS.su_params.merge({'bar_code' => 'TV1', 'prod_name' => 'tv set 1', 'unit_id' => RS::WaybillUnit::OTHERS, 'unit_name' => 'box'}))
|
131
|
+
RS.save_bar_code(RS.su_params.merge({'bar_code' => 'TV2', 'prod_name' => 'tv set 2', 'unit_id' => RS::WaybillUnit::OTHERS, 'unit_name' => 'box'}))
|
132
|
+
end
|
133
|
+
context "look up first code" do
|
134
|
+
before(:all) do
|
135
|
+
@codes = RS.get_bar_codes(RS.su_params.merge({'bar_code' => 'TV1'}))
|
136
|
+
end
|
137
|
+
subject { @codes }
|
138
|
+
it { should_not be_nil }
|
139
|
+
it { should_not be_empty }
|
140
|
+
its(:size) { should == 1 }
|
141
|
+
context 'TV1 bar code' do
|
142
|
+
subject { @codes.first }
|
143
|
+
it { should be_instance_of RS::BarCode }
|
144
|
+
its(:code) { should == 'TV1' }
|
145
|
+
its(:name) { should == 'tv set 1' }
|
146
|
+
its(:unit_id) { should == RS::WaybillUnit::OTHERS }
|
147
|
+
its(:excise_id) { should be_nil }
|
148
|
+
end
|
149
|
+
end
|
150
|
+
context "lookup both codes" do
|
151
|
+
before(:all) do
|
152
|
+
@codes = RS.get_bar_codes(RS.su_params.merge({'bar_code' => 'TV'}))
|
153
|
+
end
|
154
|
+
subject { @codes }
|
155
|
+
it { should_not be_nil }
|
156
|
+
it { should_not be_empty }
|
157
|
+
its(:size) { should == 2 }
|
158
|
+
context 'TV1 bar code' do
|
159
|
+
subject { @codes.first }
|
160
|
+
it { should be_instance_of RS::BarCode }
|
161
|
+
its(:code) { should == 'TV1' }
|
162
|
+
its(:name) { should == 'tv set 1' }
|
163
|
+
its(:unit_id) { should == RS::WaybillUnit::OTHERS }
|
164
|
+
its(:excise_id) { should be_nil }
|
165
|
+
end
|
166
|
+
context 'TV2 bar code' do
|
167
|
+
subject { @codes[1] }
|
168
|
+
it { should be_instance_of RS::BarCode }
|
169
|
+
its(:code) { should == 'TV2' }
|
170
|
+
its(:name) { should == 'tv set 2' }
|
171
|
+
its(:unit_id) { should == RS::WaybillUnit::OTHERS }
|
172
|
+
its(:excise_id) { should be_nil }
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
data/spec/rs/sys_spec.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
IP_PATTERN = /^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$/
|
5
|
+
|
6
|
+
describe 'what is my IP' do
|
7
|
+
before(:all) do
|
8
|
+
@ip = RS.what_is_my_ip
|
9
|
+
end
|
10
|
+
subject { @ip }
|
11
|
+
it { should match IP_PATTERN }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'get service users' do
|
15
|
+
before(:all) do
|
16
|
+
@org = RS::TEST_ORG1
|
17
|
+
@users = RS.get_service_users(RS.auth_params)
|
18
|
+
end
|
19
|
+
subject { @users }
|
20
|
+
it { should_not be_empty }
|
21
|
+
context 'one of the users' do
|
22
|
+
subject { @users.first }
|
23
|
+
it('should not have empty ID') { subject.id.should_not be_nil }
|
24
|
+
it('should not have empty USER_NAME') { subject.user_name.should_not be_nil }
|
25
|
+
it('should not have empty PAYER_ID') { subject.payer_id.should_not be_nil }
|
26
|
+
it('should have correct IP') { subject.ip.should match IP_PATTERN }
|
27
|
+
it('should have some NAME') { subject.name.should_not be_nil }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'check service user' do
|
32
|
+
before(:all) do
|
33
|
+
@user = RS.check_service_user(RS.su_params)
|
34
|
+
end
|
35
|
+
subject { @user }
|
36
|
+
it { should be_instance_of User }
|
37
|
+
its(:id) { should_not be_nil }
|
38
|
+
its(:payer_id) { should_not be_nil }
|
39
|
+
its(:user_name) { should_not be_nil }
|
40
|
+
its(:user_name) { should == RS::SU_NAME }
|
41
|
+
its(:name) { should be_nil }
|
42
|
+
its(:ip) { should be_nil }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'check service user with illegal password' do
|
46
|
+
before(:all) do
|
47
|
+
@user = RS.check_service_user('su' => RS::SU_NAME, 'sp' => 'someincorrectpassword')
|
48
|
+
end
|
49
|
+
subject { @user }
|
50
|
+
it { should be_nil }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'update service user' do
|
54
|
+
before(:all) do
|
55
|
+
@org = RS::TEST_ORG1
|
56
|
+
@ip = RS.what_is_my_ip
|
57
|
+
@resp = RS.update_service_user( RS.auth_params.merge(RS.su_params).merge({ 'ip' => @ip, 'name' => 'c12' }) )
|
58
|
+
end
|
59
|
+
subject { @resp }
|
60
|
+
it { should be_true }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'get name from TIN' do
|
64
|
+
before(:all) do
|
65
|
+
@name = RS.get_name_from_tin(RS.su_params.merge('tin' => '422430239'))
|
66
|
+
end
|
67
|
+
subject { @name }
|
68
|
+
it { should == 'შპს ც12' }
|
69
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
def waybill_skeleton(params = {})
|
5
|
+
waybill = RS::Waybill.new
|
6
|
+
waybill.id = params[:id]
|
7
|
+
waybill.type = params[:type] ? params[:type] : RS::WaybillType::TRANSPORTATION
|
8
|
+
waybill.status = params[:status] ? params[:status] : RS::Waybill::STATUS_START
|
9
|
+
waybill.seller_id = params[:seller_id] ? params[:seller_id] : 731937
|
10
|
+
waybill.buyer_tin = params[:buyer_tin] ? params[:buyer_tin] : '12345678910'
|
11
|
+
waybill.check_buyer_tin = params[:check_buyer_tin] ? params[:check_buyer_tin] : true
|
12
|
+
waybill.buyer_name = params[:buyer_name] ? params[:buyer_name] : 'სატესტო მყიდველი'
|
13
|
+
waybill.start_address = params[:start_address] ? params[:start_address] : 'თბილისი'
|
14
|
+
waybill.end_address = params[:end_address] ? params[:end_address] : 'სოხუმი'
|
15
|
+
waybill.transport_type_id = params[:transport_type] ? params[:transport_type] : RS::TransportType::VEHICLE
|
16
|
+
waybill.start_date = params[:start_date] ? params[:start_date] : Time.now
|
17
|
+
if waybill.transport_type_id == RS::TransportType::VEHICLE
|
18
|
+
waybill.car_number = params[:car_number] ? params[:car_number] : 'WDW842'
|
19
|
+
waybill.driver_name = params[:driver_name] ? params[:driver_name] : 'დიმიტრი ყურაშვილი'
|
20
|
+
waybill.driver_tin = params[:driver_tin] ? params[:driver_tin] : '02001000490'
|
21
|
+
else
|
22
|
+
waybill.car_number = params[:car_number]
|
23
|
+
waybill.driver_name = params[:driver_name]
|
24
|
+
waybill.driver_tin = params[:driver_tin]
|
25
|
+
end
|
26
|
+
|
27
|
+
if params[:items]
|
28
|
+
items = []
|
29
|
+
params[:items].each do |item|
|
30
|
+
item = WaybillItem.new
|
31
|
+
item.prod_name = item[:name]
|
32
|
+
item.unit_id = item[:unit_id]
|
33
|
+
item.unit_name = item[:unit_name]
|
34
|
+
item.quantity = item[:quantity]
|
35
|
+
item.price = item[:price]
|
36
|
+
item.bar_code = item[:code]
|
37
|
+
items << item
|
38
|
+
end
|
39
|
+
else
|
40
|
+
item = WaybillItem.new
|
41
|
+
item.prod_name = 'სატესტო საქონელი'
|
42
|
+
item.unit_id = 99
|
43
|
+
item.unit_name = 'ერთეული'
|
44
|
+
item.quantity = 2
|
45
|
+
item.price = 5
|
46
|
+
item.bar_code = '123'
|
47
|
+
items = [item]
|
48
|
+
end
|
49
|
+
waybill.items = items
|
50
|
+
|
51
|
+
waybill
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'save waybill' do
|
55
|
+
before(:all) do
|
56
|
+
@waybill = waybill_skeleton
|
57
|
+
RS.save_waybill(@waybill, RS.su_params)
|
58
|
+
end
|
59
|
+
subject { @waybill }
|
60
|
+
its(:status) { should == 0 }
|
61
|
+
its(:id) { should_not be_nil }
|
62
|
+
its(:id) { should > 0 }
|
63
|
+
its(:error_code) { should == 0 }
|
64
|
+
context 'items' do
|
65
|
+
subject { @waybill.items }
|
66
|
+
its(:size) { should == 1 }
|
67
|
+
context 'first item' do
|
68
|
+
subject { @waybill.items.first }
|
69
|
+
its(:id) { should_not be_nil }
|
70
|
+
its(:id) { should > 0 }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'save waybill with large production name' do
|
76
|
+
before(:all) do
|
77
|
+
@waybill = waybill_skeleton
|
78
|
+
@waybill.items[0].prod_name = '1234567890'*30 + '1' # 301 სიმბოლო შეცდომითია
|
79
|
+
RS.save_waybill(@waybill, RS.su_params)
|
80
|
+
end
|
81
|
+
subject { @waybill }
|
82
|
+
its(:error_code) { should == -1 }
|
83
|
+
its(:id) { should be_nil }
|
84
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
# Savon (SOAP client)
|
4
|
+
|
5
|
+
require 'savon'
|
6
|
+
|
7
|
+
HTTPI.log = false
|
8
|
+
Savon.log = false
|
9
|
+
|
10
|
+
# SimpleCov
|
11
|
+
|
12
|
+
require 'simplecov'
|
13
|
+
|
14
|
+
SimpleCov.start do
|
15
|
+
add_filter '/spec/'
|
16
|
+
end
|
17
|
+
|
18
|
+
# RSpec
|
19
|
+
|
20
|
+
require 'rspec'
|
21
|
+
require 'rs'
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.include(RSpec::Matchers)
|
25
|
+
end
|
26
|
+
|
27
|
+
# RS namespace is included by default
|
28
|
+
|
29
|
+
include RS
|
30
|
+
|
31
|
+
# Test organizations provided by RS.GE service
|
32
|
+
|
33
|
+
module RS
|
34
|
+
unless defined?(TEST_ORG1) and defined?(TEST_ORG2)
|
35
|
+
TEST_ORG1 = { :user => 'tbilisi', :password => '123456', :taxid => '206322102'}
|
36
|
+
TEST_ORG2 = { :user => 'satesto2', :password => '123456', :taxid => '12345678910'}
|
37
|
+
end
|
38
|
+
unless defined?(SU_NAME) and defined?(SU_PSWD)
|
39
|
+
SU_NAME = 'dimitri1979'
|
40
|
+
SU_PSWD = '123456'
|
41
|
+
end
|
42
|
+
def su_params
|
43
|
+
{'su' => SU_NAME, 'sp' => SU_PSWD}
|
44
|
+
end
|
45
|
+
def auth_params(org = 1)
|
46
|
+
u = org == 1 ? TEST_ORG1[:user] : TEST_ORG2[:user]
|
47
|
+
p = org == 2 ? TEST_ORG1[:password] : TEST_ORG2[:password]
|
48
|
+
{'user_name' => u, 'user_password' => p}
|
49
|
+
end
|
50
|
+
end
|
data/test.rb
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'savon'
|
3
|
+
|
4
|
+
client = Savon::Client.new 'http://services.rs.ge/WayBillService/WayBillService.asmx?WSDL'
|
5
|
+
|
6
|
+
wb = %Q{
|
7
|
+
<WAYBILL>
|
8
|
+
<SUB_WAYBILLS/>
|
9
|
+
<GOODS_LIST>
|
10
|
+
<GOODS>
|
11
|
+
<ID>0</ID>
|
12
|
+
<W_NAME>მწვანე ბარდა მარნეული 520გრ</W_NAME>
|
13
|
+
<UNIT_ID>2</UNIT_ID>
|
14
|
+
<UNIT_TXT>ცალი</UNIT_TXT>
|
15
|
+
<QUANTITY>1</QUANTITY>
|
16
|
+
<PRICE>2.09</PRICE>
|
17
|
+
<AMOUNT>2.09</AMOUNT>
|
18
|
+
<BAR_CODE>11</BAR_CODE>
|
19
|
+
<A_ID>0</A_ID>
|
20
|
+
</GOODS>
|
21
|
+
</GOODS_LIST>
|
22
|
+
<ID>0</ID>
|
23
|
+
<TYPE>5</TYPE>
|
24
|
+
<CREATE_DATE>2012-02-12T22:56:48</CREATE_DATE>
|
25
|
+
<BUYER_TIN>211336240</BUYER_TIN>
|
26
|
+
<CHEK_BUYER_TIN>0</CHEK_BUYER_TIN>
|
27
|
+
<BUYER_NAME>ნიკორა</BUYER_NAME>
|
28
|
+
<START_ADDRESS>ყანთელის 9</START_ADDRESS>
|
29
|
+
<END_ADDRESS>ჭავჭავაძის 24</END_ADDRESS>
|
30
|
+
<DRIVER_TIN>12345678910</DRIVER_TIN>
|
31
|
+
<CHEK_DRIVER_TIN>0</CHEK_DRIVER_TIN>
|
32
|
+
<DRIVER_NAME>დიმიტრი ობოლაშვილი</DRIVER_NAME>
|
33
|
+
<TRANSPORT_COAST>0</TRANSPORT_COAST>
|
34
|
+
<RECEPTION_INFO/>
|
35
|
+
<RECEIVER_INFO/>
|
36
|
+
<DELIVERY_DATE/>
|
37
|
+
<STATUS>1</STATUS>
|
38
|
+
<SELER_UN_ID>731937</SELER_UN_ID>
|
39
|
+
<ACTIVATE_DATE/>
|
40
|
+
<PAR_ID/>
|
41
|
+
<CAR_NUMBER>ABK852</CAR_NUMBER>
|
42
|
+
<BEGIN_DATE>2012-01-25T20:54:36</BEGIN_DATE>
|
43
|
+
<TRAN_COST_PAYER>0</TRAN_COST_PAYER>
|
44
|
+
<TRANS_ID>3</TRANS_ID>
|
45
|
+
<TRANS_TXT/>
|
46
|
+
<COMMENT/>
|
47
|
+
</WAYBILL>
|
48
|
+
}
|
49
|
+
|
50
|
+
#resp = client.request 'get_waybill' do
|
51
|
+
# soap.body = {'su'=>'dimitri1979','sp'=>'123456','waybill_id'=>'0000003171'}
|
52
|
+
#end
|
53
|
+
|
54
|
+
# resp = client.request 'SAVE_WAYBILL'.downcase do
|
55
|
+
# soap.body = {
|
56
|
+
# 'su' => 'dimitri1979',
|
57
|
+
# 'sp' => '123456',
|
58
|
+
# 'waybill!' => wb
|
59
|
+
# }
|
60
|
+
# end
|
61
|
+
|
62
|
+
#, :body => { 'waybill!' => '<a>Some XML</a>' }
|
63
|
+
|
64
|
+
# puts '-------------------'
|
65
|
+
# puts resp.to_hash
|
66
|
+
# puts '-------------------'
|
67
|
+
# puts resp.to_xml
|
68
|
+
|
69
|
+
body = { 'rs:save_waybill' => {'rs:su' => 'dimitri1979', 'rs:sp' => '123456', 'rs:waybill!' => wb }}
|
70
|
+
namespaces = { 'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/', 'xmlns:rs' => 'http://tempuri.org/' }
|
71
|
+
wb_xml = Gyoku.xml( {'saopenv:Envelope' => { 'saopenv:Header' => {}, 'saopenv:Body' => body }, :attributes! => {'saopenv:Envelope' => namespaces}} )
|
72
|
+
#puts wb_xml
|
73
|
+
#resp = client.request 'save_waybill' do
|
74
|
+
# soap.xml = %Q{<?xml version="1.0" encoding="utf-8"?>#{wb_xml}}
|
75
|
+
#end
|
76
|
+
|
77
|
+
# ეს არის ზედნადების ხაზი საქონლისთვის.
|
78
|
+
class WaybillItem
|
79
|
+
attr_accessor :id, :prod_name, :unit_id, :unit_name, :quantity, :price, :bar_code, :excise_id
|
80
|
+
attr_accessor :error_code, :status_code
|
81
|
+
|
82
|
+
# აბრუნებს ამ ხაზის XML წარმოდგენას.
|
83
|
+
# @param xml XML builder-ის კლასი
|
84
|
+
def to_xml(xml)
|
85
|
+
xml.GOODS do |b|
|
86
|
+
b.ID (self.id ? self.id : 0)
|
87
|
+
b.W_NAME self.prod_name
|
88
|
+
b.UNIT_ID self.unit_id
|
89
|
+
b.UNIT_TXT self.unit_name
|
90
|
+
b.QUANTITY self.quantity
|
91
|
+
b.PRICE self.price
|
92
|
+
b.AMOUNT self.quantity * self.price
|
93
|
+
b.BAR_CODE self.bar_code
|
94
|
+
b.A_ID (self.excise_id ? self.excise_id : 0)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# ეს არის ზედნადების კლასი.
|
100
|
+
class Waybill
|
101
|
+
TRANSPORTATION_PAID_BY_BUYER = 1
|
102
|
+
TRANSPORTATION_PAID_BY_SELLER = 2
|
103
|
+
STATUS_START = 0
|
104
|
+
STATUS_ACTIVE = 1
|
105
|
+
attr_accessor :id, :type, :status, :parent_id
|
106
|
+
attr_accessor :seller_id # გამყიდველის უნიკალური კოდი
|
107
|
+
attr_accessor :buyer_tin, :check_buyer_tin, :buyer_name
|
108
|
+
attr_accessor :seller_info, :buyer_info # გამყიდველის/მყიდველის თანამდებობა, სახელი და გვარი
|
109
|
+
attr_accessor :driver_tin, :check_driver_tin, :driver_name
|
110
|
+
attr_accessor :start_address, :end_address
|
111
|
+
attr_accessor :transportation_cost, :transportation_cost_payer, :transport_type_id, :transport_type_name, :car_number
|
112
|
+
attr_accessor :comment
|
113
|
+
attr_accessor :start_date, :delivery_date
|
114
|
+
attr_accessor :items
|
115
|
+
|
116
|
+
def to_xml(xml)
|
117
|
+
xml.WAYBILL do |b|
|
118
|
+
b.GOODS_LIST do |g|
|
119
|
+
(self.items || []).each do |item|
|
120
|
+
item.to_xml g
|
121
|
+
end
|
122
|
+
end
|
123
|
+
b.ID (self.id ? self.id : 0)
|
124
|
+
b.TYPE self.type
|
125
|
+
b.BUYER_TIN self.buyer_tin
|
126
|
+
b.CHEK_BUYER_TIN (self.check_buyer_tin ? 1 : 0)
|
127
|
+
b.BUYER_NAME self.buyer_name
|
128
|
+
b.START_ADDRESS self.start_address
|
129
|
+
b.END_ADDRESS self.end_address
|
130
|
+
b.DRIVER_TIN self.driver_tin
|
131
|
+
b.CHEK_DRIVER_TIN (self.check_driver_tin ? 1 : 0)
|
132
|
+
b.DRIVER_NAME self.driver_name
|
133
|
+
b.TRANSPORT_COAST (self.transportation_cost ? self.transportation_cost : 0)
|
134
|
+
b.RECEPTION_INFO self.seller_info
|
135
|
+
b.RECEIVER_INFO self.buyer_info
|
136
|
+
b.DELIVERY_DATE (self.delivery_date ? self.delivery_date.strftime('%Y-%m-%dT%H:%M:%S') : '')
|
137
|
+
b.STATUS self.status
|
138
|
+
b.SELER_UN_ID self.seller_id
|
139
|
+
b.PAR_ID (self.parent_id ? self.parent_id : '')
|
140
|
+
b.CAR_NUMBER self.car_number
|
141
|
+
b.BEGIN_DATE (self.start_date ? self.start_date.strftime('%Y-%m-%dT%H:%M:%S') : '')
|
142
|
+
b.TRANS_COST_PAYER (self.transportation_cost_payer ? self.transportation_cost_payer : Waybill::TRANSPORTATION_PAID_BY_BUYER)
|
143
|
+
b.TRANS_ID self.transport_type_id
|
144
|
+
b.TRANS_TXT self.transport_type_name
|
145
|
+
b.COMMENT self.comment
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
waybill = Waybill.new
|
151
|
+
waybill.type = 2
|
152
|
+
waybill.status = Waybill::STATUS_START
|
153
|
+
waybill.seller_id = 731937
|
154
|
+
waybill.buyer_tin = '12345678910'
|
155
|
+
waybill.check_buyer_tin = true
|
156
|
+
waybill.buyer_name = 'სატესტო ორგანიზაცია - 2'
|
157
|
+
waybill.start_address = 'Tbilisi'
|
158
|
+
waybill.end_address = 'Sokhumi'
|
159
|
+
waybill.transport_type_id = 1
|
160
|
+
waybill.driver_name = 'დიმიტრი ყურაშვილი'
|
161
|
+
waybill.car_number = 'WDW842'
|
162
|
+
waybill.driver_tin = '02001000490'
|
163
|
+
waybill.start_date = Time.now
|
164
|
+
|
165
|
+
item = WaybillItem.new
|
166
|
+
item.prod_name = 'კიტრი'
|
167
|
+
item.unit_id = 99
|
168
|
+
item.unit_name = 'კგ'
|
169
|
+
item.quantity = 10
|
170
|
+
item.price = 10
|
171
|
+
item.bar_code = '1234'
|
172
|
+
|
173
|
+
waybill.items = []
|
174
|
+
waybill.items << item
|
175
|
+
|
176
|
+
resp = client.request 'save_waybill' do |soap|
|
177
|
+
#xml = Builder::XmlMarkup.new
|
178
|
+
soap.body do |xml|
|
179
|
+
xml.ins0 :su, 'dimitri1979'
|
180
|
+
xml.ins0 :sp, '123456'
|
181
|
+
xml.ins0 :waybill do |b|
|
182
|
+
waybill.to_xml b
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|