rs.ge 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module RS
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
@@ -101,11 +101,12 @@ module RS
101
101
  class Waybill
102
102
  TRANSPORTATION_PAID_BY_BUYER = 1
103
103
  TRANSPORTATION_PAID_BY_SELLER = 2
104
- STATUS_DELETED = -1
104
+ STATUS_DELETED = -1
105
+ STATUS_DEACTIVATED = -2
105
106
  STATUS_SAVED = 0
106
107
  STATUS_ACTIVE = 1
107
108
  STATUS_CLOSED = 2
108
- attr_accessor :id, :type, :status, :parent_id
109
+ attr_accessor :id, :type, :status, :parent_id, :number
109
110
  attr_accessor :seller_id # გამყიდველის უნიკალური კოდი
110
111
  attr_accessor :buyer_tin, :check_buyer_tin, :buyer_name
111
112
  attr_accessor :seller_info, :buyer_info # გამყიდველის/მყიდველის თანამდებობა, სახელი და გვარი
@@ -161,6 +162,7 @@ module RS
161
162
  waybill.id = hash[:id]
162
163
  waybill.type = hash[:type].to_i
163
164
  waybill.status = hash[:status].to_i
165
+ waybill.number = hash[:waybill_number]
164
166
  waybill.seller_id = hash[:seler_un_id].to_i
165
167
  waybill.buyer_tin = hash[:buyer_tin]
166
168
  waybill.check_buyer_tin = hash[:chek_buyer_tin].to_i == 1
@@ -229,7 +231,7 @@ module RS
229
231
 
230
232
  # მყიდველის შემოწმება
231
233
  def validate_buyer
232
- if self.buyer_tin.nil?
234
+ if self.buyer_tin.nil? or self.buyer_tin.strip.empty?
233
235
  RS.append_validation_error(@validation_errors, :buyer_tin, 'მყიდველის საიდენტიფიკაციო ნომერი განუსაზღვრელია')
234
236
  else
235
237
  if self.check_buyer_tin
@@ -396,6 +398,7 @@ module RS
396
398
  end
397
399
 
398
400
  # ზედნადების წაშლა.
401
+ # ეს მეთოდი არ გამოდგება აქტიური/დასრულებული ზედნადების წასაშლელად.
399
402
  #
400
403
  # გადაეცემა შემდეგი პარამეტრები:
401
404
  # waybill_id -- ზედნადების ID
@@ -413,4 +416,23 @@ module RS
413
416
  response.to_hash[:del_waybill_response][:del_waybill_result].to_i == 1
414
417
  end
415
418
 
419
+ # აქტიური/დასრულებული ზედნადების გაუქმება.
420
+ # ეს მეთოდი არ გამოდგება შენახული ზედნადების გასაუქმებლად.
421
+ #
422
+ # გადაეცემა შემდეგი პარამეტრები:
423
+ # waybill_id -- ზედნადების ID
424
+ # su -- სერვისის მომხმარებელი
425
+ # sp -- სერვისის მომხმარებლის პაროლი
426
+ #
427
+ # აბრუნებს <code>true</code> თუ წაიშალა.
428
+ def self.deactivate_waybill(params)
429
+ RS.validate_presence_of(params, 'waybill_id', 'su', 'sp')
430
+ client = RS.waybill_service
431
+ response = client.request 'ref_waybill' do |soap|
432
+ soap.body = params.merge({:order => ['su', 'sp', 'waybill_id']})
433
+ end
434
+ #puts response.to_hash
435
+ response.to_hash[:ref_waybill_response][:ref_waybill_result].to_i == 1
436
+ end
437
+
416
438
  end
@@ -0,0 +1,63 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'spec_helper'
3
+ require 'rs'
4
+
5
+ describe 'create waybill, activate it, then deactivate' do
6
+ before(:all) do
7
+ @waybill = waybill_skeleton
8
+ RS.save_waybill(@waybill, RS.su_params)
9
+ end
10
+ subject { @waybill }
11
+ it { should_not be_nil }
12
+ its(:id) { should_not be_nil }
13
+ its(:status) { should == RS::Waybill::STATUS_SAVED }
14
+ context 'activate waybill' do
15
+ before(:all) do
16
+ params = RS.su_params.merge('waybill_id' => @waybill.id)
17
+ RS.activate_waybill(params)
18
+ @waybill = RS.get_waybill(params)
19
+ end
20
+ subject { @waybill }
21
+ its(:status) { should == RS::Waybill::STATUS_ACTIVE }
22
+ end
23
+ context 'now deactivate waybill' do
24
+ before(:all) do
25
+ params = RS.su_params.merge('waybill_id' => @waybill.id)
26
+ #RS.close_waybill(params)
27
+ RS.deactivate_waybill(params)
28
+ @waybill = RS.get_waybill(params)
29
+ end
30
+ subject { @waybill }
31
+ its(:status) { should == RS::Waybill::STATUS_DEACTIVATED }
32
+ end
33
+ end
34
+
35
+ describe 'create waybill, activate and close it, then try to deactivate' do
36
+ before(:all) do
37
+ @waybill = waybill_skeleton
38
+ RS.save_waybill(@waybill, RS.su_params)
39
+ end
40
+ subject { @waybill }
41
+ it { should_not be_nil }
42
+ its(:id) { should_not be_nil }
43
+ its(:status) { should == RS::Waybill::STATUS_SAVED }
44
+ context 'activate and close waybill' do
45
+ before(:all) do
46
+ params = RS.su_params.merge('waybill_id' => @waybill.id)
47
+ RS.activate_waybill(params)
48
+ RS.close_waybill(params)
49
+ @waybill = RS.get_waybill(params)
50
+ end
51
+ subject { @waybill }
52
+ its(:status) { should == RS::Waybill::STATUS_CLOSED }
53
+ end
54
+ context 'could not deactivate closed waybill !!' do
55
+ before(:all) do
56
+ params = RS.su_params.merge('waybill_id' => @waybill.id)
57
+ RS.deactivate_waybill(params)
58
+ @waybill = RS.get_waybill(params)
59
+ end
60
+ subject { @waybill }
61
+ its(:status) { should == RS::Waybill::STATUS_CLOSED }
62
+ end
63
+ end
@@ -56,60 +56,6 @@ describe 'Corporate TIN validation' do
56
56
  validate_corporate_tin('12345678A', false)
57
57
  end
58
58
 
59
- def waybill_skeleton(params = {})
60
- waybill = RS::Waybill.new
61
- waybill.id = params[:id]
62
- waybill.type = params[:type] || RS::WaybillType::TRANSPORTATION
63
- waybill.status = params[:status] || RS::Waybill::STATUS_SAVED
64
- waybill.seller_id = params[:seller_id] || 731937
65
- waybill.buyer_tin = params[:buyer_tin] || '12345678910'
66
- waybill.check_buyer_tin = params[:check_buyer_tin] ? params[:check_buyer_tin] : true
67
- waybill.buyer_name = params[:buyer_name] || 'სატესტო მყიდველი'
68
- waybill.start_address = params[:start_address] || 'თბილისი'
69
- waybill.end_address = params[:end_address] || 'სოხუმი'
70
- waybill.transport_type_id = params[:transport_type] || RS::TransportType::VEHICLE
71
- waybill.start_date = params[:start_date] || Time.now
72
- waybill.comment = params[:comment] #|| 'comment'
73
- if waybill.transport_type_id == RS::TransportType::VEHICLE
74
- waybill.car_number = params[:car_number] || 'WDW842'
75
- waybill.driver_name = params[:driver_name] || 'დიმიტრი ყურაშვილი'
76
- waybill.driver_tin = params[:driver_tin] || '02001000490'
77
- waybill.check_driver_tin = params[:check_driver_tin].nil? ? false : params[:check_driver_tin]
78
- else
79
- waybill.car_number = params[:car_number]
80
- waybill.driver_name = params[:driver_name]
81
- waybill.driver_tin = params[:driver_tin]
82
- waybill.check_driver_tin = params[:check_driver_tin]
83
- end
84
- waybill.transportation_cost = params[:transportation_cost] || 0
85
-
86
- if params[:items]
87
- items = []
88
- params[:items].each do |item|
89
- item = RS::WaybillItem.new
90
- item.prod_name = item[:name]
91
- item.unit_id = item[:unit_id]
92
- item.unit_name = item[:unit_name]
93
- item.quantity = item[:quantity]
94
- item.price = item[:price]
95
- item.bar_code = item[:code]
96
- items << item
97
- end
98
- else
99
- item = RS::WaybillItem.new
100
- item.prod_name = 'სატესტო საქონელი'
101
- item.unit_id = 99
102
- item.unit_name = 'ერთეული'
103
- item.quantity = 2
104
- item.price = 5
105
- item.bar_code = '123'
106
- items = [item]
107
- end
108
- waybill.items = items
109
-
110
- waybill
111
- end
112
-
113
59
  describe 'save waybill' do
114
60
  before(:all) do
115
61
  @waybill = waybill_skeleton
@@ -44,3 +44,57 @@ module RS
44
44
  {'user_name' => u, 'user_password' => p}
45
45
  end
46
46
  end
47
+
48
+ def waybill_skeleton(params = {})
49
+ waybill = RS::Waybill.new
50
+ waybill.id = params[:id]
51
+ waybill.type = params[:type] || RS::WaybillType::TRANSPORTATION
52
+ waybill.status = params[:status] || RS::Waybill::STATUS_SAVED
53
+ waybill.seller_id = params[:seller_id] || 731937
54
+ waybill.buyer_tin = params[:buyer_tin] || '12345678910'
55
+ waybill.check_buyer_tin = params[:check_buyer_tin] ? params[:check_buyer_tin] : true
56
+ waybill.buyer_name = params[:buyer_name] || 'სატესტო მყიდველი'
57
+ waybill.start_address = params[:start_address] || 'თბილისი'
58
+ waybill.end_address = params[:end_address] || 'სოხუმი'
59
+ waybill.transport_type_id = params[:transport_type] || RS::TransportType::VEHICLE
60
+ waybill.start_date = params[:start_date] || Time.now
61
+ waybill.comment = params[:comment] #|| 'comment'
62
+ if waybill.transport_type_id == RS::TransportType::VEHICLE
63
+ waybill.car_number = params[:car_number] || 'WDW842'
64
+ waybill.driver_name = params[:driver_name] || 'დიმიტრი ყურაშვილი'
65
+ waybill.driver_tin = params[:driver_tin] || '02001000490'
66
+ waybill.check_driver_tin = params[:check_driver_tin].nil? ? false : params[:check_driver_tin]
67
+ else
68
+ waybill.car_number = params[:car_number]
69
+ waybill.driver_name = params[:driver_name]
70
+ waybill.driver_tin = params[:driver_tin]
71
+ waybill.check_driver_tin = params[:check_driver_tin]
72
+ end
73
+ waybill.transportation_cost = params[:transportation_cost] || 0
74
+
75
+ if params[:items]
76
+ items = []
77
+ params[:items].each do |item|
78
+ item = RS::WaybillItem.new
79
+ item.prod_name = item[:name]
80
+ item.unit_id = item[:unit_id]
81
+ item.unit_name = item[:unit_name]
82
+ item.quantity = item[:quantity]
83
+ item.price = item[:price]
84
+ item.bar_code = item[:code]
85
+ items << item
86
+ end
87
+ else
88
+ item = RS::WaybillItem.new
89
+ item.prod_name = 'სატესტო საქონელი'
90
+ item.unit_id = 99
91
+ item.unit_name = 'ერთეული'
92
+ item.quantity = 2
93
+ item.price = 5
94
+ item.bar_code = '123'
95
+ items = [item]
96
+ end
97
+ waybill.items = items
98
+
99
+ waybill
100
+ end
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.6
4
+ version: 0.0.7
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-02-26 00:00:00.000000000 Z
12
+ date: 2012-02-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70270712827600 !ruby/object:Gem::Requirement
16
+ requirement: &77932080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70270712827600
24
+ version_requirements: *77932080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simplecov
27
- requirement: &70270712827180 !ruby/object:Gem::Requirement
27
+ requirement: &77931660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70270712827180
35
+ version_requirements: *77931660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: savon
38
- requirement: &70270712826660 !ruby/object:Gem::Requirement
38
+ requirement: &77931170 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70270712826660
46
+ version_requirements: *77931170
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: httpi
49
- requirement: &70270712826220 !ruby/object:Gem::Requirement
49
+ requirement: &77930650 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70270712826220
57
+ version_requirements: *77930650
58
58
  description: ruby client for rs.ge web services
59
59
  email:
60
60
  - dimitri@c12.ge
@@ -76,6 +76,7 @@ files:
76
76
  - rs.gemspec
77
77
  - spec/rs/dict_spec.rb
78
78
  - spec/rs/sys_spec.rb
79
+ - spec/rs/waybill_delete_spec.rb
79
80
  - spec/rs/waybill_spec.rb
80
81
  - spec/rs/waybill_validation_spec.rb
81
82
  - spec/spec_helper.rb
@@ -100,14 +101,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
101
  version: '0'
101
102
  requirements: []
102
103
  rubyforge_project: rs
103
- rubygems_version: 1.8.15
104
+ rubygems_version: 1.8.13
104
105
  signing_key:
105
106
  specification_version: 3
106
107
  summary: rs.ge web services
107
- test_files:
108
- - spec/rs/dict_spec.rb
109
- - spec/rs/sys_spec.rb
110
- - spec/rs/waybill_spec.rb
111
- - spec/rs/waybill_validation_spec.rb
112
- - spec/spec_helper.rb
108
+ test_files: []
113
109
  has_rdoc: