rs.ge 0.0.17 → 0.1.0.beta1
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/lib/rs.rb +5 -71
- data/lib/rs/models/waybill_unit.rb +21 -0
- data/lib/rs/requests/base_request.rb +20 -0
- data/lib/rs/requests/waybill_unit_request.rb +44 -0
- data/lib/rs/version.rb +1 -2
- data/rs.gemspec +3 -5
- data/spec/requests/waybill_units_spec.rb +24 -0
- data/spec/spec_helper.rb +3 -85
- metadata +14 -42
- data/lib/rs/car.rb +0 -6
- data/lib/rs/dict.rb +0 -259
- data/lib/rs/invoice.rb +0 -18
- data/lib/rs/print.rb +0 -331
- data/lib/rs/sys.rb +0 -128
- data/lib/rs/waybill.rb +0 -483
- data/problems.md +0 -1
- data/spec/rs/car_spec.rb +0 -25
- data/spec/rs/dict_spec.rb +0 -181
- data/spec/rs/open_user.rb +0 -12
- data/spec/rs/pdf_spec.rb +0 -21
- data/spec/rs/sys_spec.rb +0 -77
- data/spec/rs/waybill_delete_spec.rb +0 -63
- data/spec/rs/waybill_invoice_spec.rb +0 -19
- data/spec/rs/waybill_spec.rb +0 -205
- data/spec/rs/waybill_validation_spec.rb +0 -149
data/lib/rs.rb
CHANGED
@@ -1,76 +1,10 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
require 'savon'
|
3
3
|
require 'rs/version'
|
4
|
-
require 'rs/sys'
|
5
|
-
require 'rs/dict'
|
6
|
-
require 'rs/waybill'
|
7
|
-
require 'rs/print'
|
8
|
-
require 'rs/invoice'
|
9
|
-
require 'rs/car'
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
WAYBILL_SERVICE_URL = 'http://services.rs.ge/WayBillService/WayBillService.asmx?WSDL'
|
5
|
+
# models
|
6
|
+
require 'rs/models/waybill_unit'
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# მომხმარებელი, რომელიც შეგიძლიათ გამოიყენოთ ღია სერვისებში.
|
19
|
-
OPEN_SU = 'dimitri1979'
|
20
|
-
|
21
|
-
# პაროლის ღია მომხმარებლისთვის.
|
22
|
-
OPEN_SP = '123456'
|
23
|
-
|
24
|
-
# შეცდომის კლასი
|
25
|
-
class Error < RuntimeError
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
# ელექტრონული ზედნადების SOAP კლიენტის მიღება
|
31
|
-
def self.waybill_service
|
32
|
-
Savon::Client.new do
|
33
|
-
wsdl.document = WAYBILL_SERVICE_URL
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# ანგარიშ-ფაქტურის SOAP კლიენტის მიღება
|
38
|
-
def self.invoice_service
|
39
|
-
Savon::Client.new do
|
40
|
-
wsdl.document = INVOICE_SERVICE_URL
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# ამოწმებს პარამეტრების მნიშვნელობას su და sp
|
45
|
-
# და თუ ისინი არაა განსაზღვრული, მიანიჭებს ღია
|
46
|
-
# მომხმარებლის პარამეტრებს.
|
47
|
-
# ეს სასარგებლოა ისეთი მონაცემების მისაღებად,
|
48
|
-
# რომელიც არაა უშუალოდ დაკავშირებული ორგანიზაციის
|
49
|
-
# საქმიანობოსთან.
|
50
|
-
def self.ensure_open_user(params)
|
51
|
-
unless params['su']
|
52
|
-
params['su'] = OPEN_SU
|
53
|
-
params['sp'] = OPEN_SP
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# ამოწმებს, რომ მოცემულ პარამეტრებში ყველას მნიშვნელობა განსხვავდებოდეს <code>nil</code>-სგან.
|
58
|
-
def self.validate_presence_of(params, *options)
|
59
|
-
options.each do |opt|
|
60
|
-
val = params[opt.to_s]
|
61
|
-
raise RS::Error.new("#{opt.to_s} required") if val.nil? or (val.instance_of? String and val.strip.empty?)
|
62
|
-
end if options
|
63
|
-
end
|
64
|
-
|
65
|
-
# უზრუნველყოფს <code>nil</code> მნიშვნელობების სწორად ჩაწერას.
|
66
|
-
def self.prepare_params(params)
|
67
|
-
attributes = {}
|
68
|
-
params.each do |k, v|
|
69
|
-
if v.nil?
|
70
|
-
params.delete k
|
71
|
-
attributes[k] = {'xsi:nil' => true}
|
72
|
-
end
|
73
|
-
end
|
74
|
-
params['attributes!'] = attributes unless attributes.empty?
|
75
|
-
end
|
76
|
-
end
|
8
|
+
# requests
|
9
|
+
require 'rs/requests/base_request'
|
10
|
+
require 'rs/requests/waybill_unit_request'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
# WaybillUnit is a unit which is used to describe production quantities in waybill.
|
4
|
+
#
|
5
|
+
# The Revenue Service of Georgia provides us with standard set of units,
|
6
|
+
# which can be obtained using RS.waybill_units method call.
|
7
|
+
#
|
8
|
+
# One special unit, is the unit which describes all units which were not included
|
9
|
+
# in the Revenue Service list. Identification number for this special unit is
|
10
|
+
# stored in contant RS::WaybillUnit::OTHERS.
|
11
|
+
class RS::WaybillUnit
|
12
|
+
# Unit ID.
|
13
|
+
attr_accessor :id
|
14
|
+
|
15
|
+
# Unit name,
|
16
|
+
attr_accessor :name
|
17
|
+
|
18
|
+
# Identification number for the unit, which were not included in
|
19
|
+
# the Revenue Service list of units.
|
20
|
+
OTHERS = 99
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'savon'
|
3
|
+
|
4
|
+
# This class is the base for other request classes.
|
5
|
+
#
|
6
|
+
class RS::BaseRequest
|
7
|
+
# Waybill service WSDL location.
|
8
|
+
WAYBILL_SERVICE_URL = 'http://services.rs.ge/WayBillService/WayBillService.asmx?WSDL'
|
9
|
+
|
10
|
+
# Getting Savon client.
|
11
|
+
def waybill_client
|
12
|
+
Savon::Client.new { wsdl.document = WAYBILL_SERVICE_URL }
|
13
|
+
end
|
14
|
+
|
15
|
+
# Validates presence of specified keys in the #{params} hash.
|
16
|
+
def validate_presence_of(params, *keys)
|
17
|
+
diff = keys - params.keys
|
18
|
+
raise ArgumentError, "The following parameter(s) not specified: #{diff.to_s[1..-2]}" unless diff.empty?
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module RS
|
5
|
+
# Request object, used for processing waybill units.
|
6
|
+
#
|
7
|
+
# Use RS.unit or RS.units call to access instance of this class.
|
8
|
+
class WaybillUnitRequest < BaseRequest
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
# Returns all units.
|
12
|
+
def all(opts = {})
|
13
|
+
validate_presence_of(opts, :su, :sp)
|
14
|
+
response = waybill_client.request 'get_waybill_units' do
|
15
|
+
soap.body = { 'su' => opts[:su], 'sp' => opts[:sp] }
|
16
|
+
end
|
17
|
+
extract_units_from_response(response)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def extract_units_from_response(response)
|
23
|
+
units = []
|
24
|
+
units_hash = response.to_hash[:get_waybill_units_response][:get_waybill_units_result][:waybill_units][:waybill_unit]
|
25
|
+
units_hash.each do |hash|
|
26
|
+
unit = WaybillUnit.new
|
27
|
+
unit.id = hash[:id].to_i
|
28
|
+
unit.name = hash[:name]
|
29
|
+
units << unit
|
30
|
+
end
|
31
|
+
units
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns the instance of WaybillUnitRequest class.
|
37
|
+
def self.units
|
38
|
+
RS::WaybillUnitRequest.instance
|
39
|
+
end
|
40
|
+
|
41
|
+
class << self
|
42
|
+
alias_method :unit, :units
|
43
|
+
end
|
44
|
+
end
|
data/lib/rs/version.rb
CHANGED
data/rs.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require
|
3
|
+
require 'rs/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "rs.ge"
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["dimitri@c12.ge"]
|
10
10
|
s.homepage = "http://c12.ge"
|
11
11
|
s.summary = %q{rs.ge web services}
|
12
|
-
s.description = %q{
|
12
|
+
s.description = %q{Ruby client for rs.ge web services}
|
13
13
|
|
14
14
|
s.rubyforge_project = "rs"
|
15
15
|
|
@@ -19,10 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_development_dependency 'rspec', '~> 2'
|
22
|
-
s.add_development_dependency 'simplecov'
|
23
|
-
|
24
22
|
s.add_runtime_dependency 'savon'
|
25
23
|
s.add_runtime_dependency 'httpi'
|
26
24
|
s.add_runtime_dependency 'prawn', '~>0.12'
|
27
25
|
s.add_runtime_dependency 'c12-commons', '~> 0.0.5'
|
28
|
-
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'getting waybill units' do
|
5
|
+
before(:all) do
|
6
|
+
@units = RS.units.all(SU_PARAMS)
|
7
|
+
end
|
8
|
+
subject { @units }
|
9
|
+
it { should_not be_nil }
|
10
|
+
it { should_not be_empty }
|
11
|
+
context 'first unit' do
|
12
|
+
subject { @units.first }
|
13
|
+
it { should be_instance_of RS::WaybillUnit }
|
14
|
+
its(:id) { should_not be_nil }
|
15
|
+
its(:name) { should_not be_nil }
|
16
|
+
end
|
17
|
+
context 'last unit' do
|
18
|
+
subject { @units.last }
|
19
|
+
it { should be_instance_of RS::WaybillUnit }
|
20
|
+
its(:id) { should_not be_nil }
|
21
|
+
its(:id) { should == RS::WaybillUnit::OTHERS }
|
22
|
+
its(:name) { should_not be_nil }
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,97 +7,15 @@ require 'savon'
|
|
7
7
|
HTTPI.log = false
|
8
8
|
Savon.log = false
|
9
9
|
|
10
|
-
# SimpleCov
|
11
|
-
|
12
|
-
require 'simplecov'
|
13
|
-
|
14
|
-
SimpleCov.start do
|
15
|
-
add_filter '/spec/'
|
16
|
-
end
|
17
|
-
|
18
10
|
# RSpec
|
19
11
|
|
20
|
-
require 'rspec'
|
21
12
|
require 'rs'
|
13
|
+
require 'rspec'
|
22
14
|
|
23
15
|
RSpec.configure do |config|
|
24
16
|
config.include(RSpec::Matchers)
|
25
17
|
end
|
26
18
|
|
27
|
-
# Test
|
19
|
+
# Test user parameters.
|
28
20
|
|
29
|
-
|
30
|
-
unless defined?(TEST_ORG1) and defined?(TEST_ORG2)
|
31
|
-
TEST_ORG1 = { :user => 'tbilisi', :password => '123456', :taxid => '206322102'}
|
32
|
-
TEST_ORG2 = { :user => 'satesto2', :password => '123456', :taxid => '12345678910'}
|
33
|
-
end
|
34
|
-
unless defined?(SU_NAME) and defined?(SU_PSWD)
|
35
|
-
SU_NAME = 'dimitri1979'
|
36
|
-
SU_PSWD = '123456'
|
37
|
-
end
|
38
|
-
def self.su_params
|
39
|
-
{'su' => SU_NAME, 'sp' => SU_PSWD}
|
40
|
-
end
|
41
|
-
def self.auth_params(org = 1)
|
42
|
-
u = org == 1 ? TEST_ORG1[:user] : TEST_ORG2[:user]
|
43
|
-
p = org == 2 ? TEST_ORG1[:password] : TEST_ORG2[:password]
|
44
|
-
{'user_name' => u, 'user_password' => p}
|
45
|
-
end
|
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_id] || 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
|
-
waybill.transportation_cost_payer =params[:transportation_cost_payer] || RS::Waybill::TRANSPORTATION_PAID_BY_BUYER
|
75
|
-
|
76
|
-
if params[:items]
|
77
|
-
items = []
|
78
|
-
params[:items].each do |it|
|
79
|
-
item = RS::WaybillItem.new
|
80
|
-
item.prod_name = it[:name]
|
81
|
-
item.unit_id = it[:unit_id]
|
82
|
-
item.unit_name = it[:unit_name]
|
83
|
-
item.quantity = it[:quantity]
|
84
|
-
item.price = it[:price]
|
85
|
-
item.bar_code = it[:code]
|
86
|
-
item.vat_type = it[:vat_type]
|
87
|
-
items << item
|
88
|
-
end
|
89
|
-
else
|
90
|
-
item = RS::WaybillItem.new
|
91
|
-
item.prod_name = 'ბალი ალუბალი წითელი'
|
92
|
-
item.unit_id = 99
|
93
|
-
item.unit_name = 'კილოგრამი'
|
94
|
-
item.quantity = 10
|
95
|
-
item.price = 3
|
96
|
-
item.bar_code = '001'
|
97
|
-
item.vat_type = RS::Waybill::VAT_COMMON
|
98
|
-
items = [item]
|
99
|
-
end
|
100
|
-
waybill.items = items
|
101
|
-
|
102
|
-
waybill
|
103
|
-
end
|
21
|
+
SU_PARAMS = {:su => 'dimitri1979', :sp => '123456'}
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs.ge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0.beta1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dimitri Kurashvili
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -27,22 +27,6 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '2'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: simplecov
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
30
|
- !ruby/object:Gem::Dependency
|
47
31
|
name: savon
|
48
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,7 +91,7 @@ dependencies:
|
|
107
91
|
- - ~>
|
108
92
|
- !ruby/object:Gem::Version
|
109
93
|
version: 0.0.5
|
110
|
-
description:
|
94
|
+
description: Ruby client for rs.ge web services
|
111
95
|
email:
|
112
96
|
- dimitri@c12.ge
|
113
97
|
executables: []
|
@@ -121,26 +105,13 @@ files:
|
|
121
105
|
- README.md
|
122
106
|
- Rakefile
|
123
107
|
- lib/rs.rb
|
124
|
-
- lib/rs/
|
125
|
-
- lib/rs/
|
126
|
-
- lib/rs/
|
127
|
-
- lib/rs/print.rb
|
128
|
-
- lib/rs/sys.rb
|
108
|
+
- lib/rs/models/waybill_unit.rb
|
109
|
+
- lib/rs/requests/base_request.rb
|
110
|
+
- lib/rs/requests/waybill_unit_request.rb
|
129
111
|
- lib/rs/version.rb
|
130
|
-
- lib/rs/waybill.rb
|
131
|
-
- problems.md
|
132
112
|
- rs.gemspec
|
133
|
-
- spec/
|
134
|
-
- spec/rs/dict_spec.rb
|
135
|
-
- spec/rs/open_user.rb
|
136
|
-
- spec/rs/pdf_spec.rb
|
137
|
-
- spec/rs/sys_spec.rb
|
138
|
-
- spec/rs/waybill_delete_spec.rb
|
139
|
-
- spec/rs/waybill_invoice_spec.rb
|
140
|
-
- spec/rs/waybill_spec.rb
|
141
|
-
- spec/rs/waybill_validation_spec.rb
|
113
|
+
- spec/requests/waybill_units_spec.rb
|
142
114
|
- spec/spec_helper.rb
|
143
|
-
- tmp/waybill.pdf
|
144
115
|
homepage: http://c12.ge
|
145
116
|
licenses: []
|
146
117
|
post_install_message:
|
@@ -156,14 +127,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
128
|
none: false
|
158
129
|
requirements:
|
159
|
-
- - ! '
|
130
|
+
- - ! '>'
|
160
131
|
- !ruby/object:Gem::Version
|
161
|
-
version:
|
132
|
+
version: 1.3.1
|
162
133
|
requirements: []
|
163
134
|
rubyforge_project: rs
|
164
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.23
|
165
136
|
signing_key:
|
166
137
|
specification_version: 3
|
167
138
|
summary: rs.ge web services
|
168
|
-
test_files:
|
169
|
-
|
139
|
+
test_files:
|
140
|
+
- spec/requests/waybill_units_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
data/lib/rs/car.rb
DELETED
data/lib/rs/dict.rb
DELETED
@@ -1,259 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
module RS
|
4
|
-
|
5
|
-
# ეს არის აქციზის კოდის აღმწერი კლასი.
|
6
|
-
class ExciseCode
|
7
|
-
# name -- აქციზის დასახელება
|
8
|
-
# measure -- ზომის ერთეული
|
9
|
-
# code -- აქციზის კოდი
|
10
|
-
# value -- აქციზის განაკვეთი
|
11
|
-
attr_accessor :id, :name, :measure, :code, :value
|
12
|
-
end
|
13
|
-
|
14
|
-
# ეს არის ზედნადების ტიპის კლასი.
|
15
|
-
class WaybillType
|
16
|
-
INNER = 1
|
17
|
-
TRANSPORTATION = 2
|
18
|
-
WITHOUT_TRANSPORTATION = 3
|
19
|
-
DISTRIBUTION = 4
|
20
|
-
RETURN = 5
|
21
|
-
SUB_WAYBILL = 6
|
22
|
-
NAMES = {
|
23
|
-
INNER => 'შიდა გადაზიდვა', TRANSPORTATION => 'ტრანსპორტირებით', WITHOUT_TRANSPORTATION => 'ტრანსპორტირების გარეშე',
|
24
|
-
DISTRIBUTION => 'დისტრიბუცია', RETURN => 'უკან დაბრუნება', SUB_WAYBILL => 'ქვე-ზედნადები'
|
25
|
-
}
|
26
|
-
attr_accessor :id, :name
|
27
|
-
def self.create_from_id(id)
|
28
|
-
type = WaybillType.new
|
29
|
-
type.id = id
|
30
|
-
type.name = NAMES[id]
|
31
|
-
type
|
32
|
-
end
|
33
|
-
def self.all_types
|
34
|
-
[]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# ზედნადების ერთეულების განსაზღვრა.
|
39
|
-
class WaybillUnit
|
40
|
-
attr_accessor :id, :name
|
41
|
-
|
42
|
-
# ეს კოდი შეესაბამება ზომის ერთეულს 'სხვა'.
|
43
|
-
OTHERS = 99
|
44
|
-
end
|
45
|
-
|
46
|
-
# ტრანსპორტირების ტიპი
|
47
|
-
class TransportType
|
48
|
-
VEHICLE = 1
|
49
|
-
RAILWAY = 2
|
50
|
-
AIR = 3
|
51
|
-
TRAILER = 5
|
52
|
-
OTHERS = 4
|
53
|
-
NAMES = { VEHICLE => 'საავტომობილო', RAILWAY => 'სარკინიგზო', AIR => 'საავიაციო', TRAILER => 'მისაბმელი', OTHERS => 'სხვა' }
|
54
|
-
|
55
|
-
attr_accessor :id, :name
|
56
|
-
|
57
|
-
def self.create_from_id(id)
|
58
|
-
type = TransportType.new
|
59
|
-
type.id = id
|
60
|
-
type.name = NAMES[id]
|
61
|
-
type
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# შტრიხკოდის აღმწერი კლასი
|
66
|
-
class BarCode
|
67
|
-
attr_accessor :code, :name, :unit_id, :unit_name, :excise_id
|
68
|
-
end
|
69
|
-
|
70
|
-
protected
|
71
|
-
|
72
|
-
def self.normalize_excise_name(name)
|
73
|
-
index = name =~ /\([0-9]*\)/
|
74
|
-
index ? name[0..index-1].strip : name
|
75
|
-
end
|
76
|
-
|
77
|
-
public
|
78
|
-
|
79
|
-
# აქციზის კოდების სიის მიღება.
|
80
|
-
#
|
81
|
-
# უნდა გადაეცეს შემდეგი პარამეტრები:
|
82
|
-
#
|
83
|
-
# su -- სერვისის მომხმარებლის სახელი
|
84
|
-
# sp -- სერვისის მომხმარებლის პაროლი
|
85
|
-
# normilize -- კი/არა, გამოიყენოს თუ არა სახელების ნორმალიზებული მნიშვნელობები (საწყისად ნორმალიზებულია)
|
86
|
-
def self.get_excise_codes(params)
|
87
|
-
RS.ensure_open_user(params)
|
88
|
-
RS.validate_presence_of(params, 'su', 'sp')
|
89
|
-
client = RS.waybill_service
|
90
|
-
response = client.request 'get_akciz_codes' do
|
91
|
-
soap.body = params
|
92
|
-
end
|
93
|
-
normalize = params['normilize'] || true
|
94
|
-
codes_hash = response.to_hash[:get_akciz_codes_response][:get_akciz_codes_result][:akciz_codes][:akciz_code]
|
95
|
-
codes = []
|
96
|
-
codes_hash.each do |hash|
|
97
|
-
code = ExciseCode.new
|
98
|
-
code.id = hash[:id]
|
99
|
-
code.name = normalize ? normalize_excise_name(hash[:title]) : hash([:title])
|
100
|
-
code.measure = hash[:measurement]
|
101
|
-
code.code = hash[:sakon_kodi]
|
102
|
-
code.value = hash[:akcis_ganakv].to_f
|
103
|
-
codes << code
|
104
|
-
end
|
105
|
-
codes
|
106
|
-
end
|
107
|
-
|
108
|
-
# ზედნადების ტიპების მიღება.
|
109
|
-
#
|
110
|
-
# უნდა გადაეცეს შემდეგი პარამეტრები:
|
111
|
-
#
|
112
|
-
# su -- სერვისის მომხმარებლის სახელი
|
113
|
-
# sp -- სერვისის მომხმარებლის პაროლი
|
114
|
-
def self.get_waybill_types(params)
|
115
|
-
RS.ensure_open_user(params)
|
116
|
-
RS.validate_presence_of(params, 'su', 'sp')
|
117
|
-
client = RS.waybill_service
|
118
|
-
response = client.request 'get_waybill_types' do
|
119
|
-
soap.body = params
|
120
|
-
end
|
121
|
-
types_hash = response.to_hash[:get_waybill_types_response][:get_waybill_types_result][:waybill_types][:waybill_type]
|
122
|
-
types = []
|
123
|
-
types_hash.each do |hash|
|
124
|
-
type = WaybillType.new
|
125
|
-
type.id = hash[:id]
|
126
|
-
type.name = hash[:name]
|
127
|
-
#puts "#{type.id}: #{type.name}"
|
128
|
-
types << type
|
129
|
-
end
|
130
|
-
types
|
131
|
-
end
|
132
|
-
|
133
|
-
# ზედნადების ზომის ერთეულების მიღება.
|
134
|
-
#
|
135
|
-
# უნდა გადაეცეს შემდეგი პარამეტრები:
|
136
|
-
#
|
137
|
-
# su -- სერვისის მომხმარებლის სახელი
|
138
|
-
# sp -- სერვისის მომხმარებლის პაროლი
|
139
|
-
def self.get_waybill_units(params)
|
140
|
-
RS.ensure_open_user(params)
|
141
|
-
RS.validate_presence_of(params, 'su', 'sp')
|
142
|
-
client = RS.waybill_service
|
143
|
-
response = client.request 'get_waybill_units' do
|
144
|
-
soap.body = params
|
145
|
-
end
|
146
|
-
units_hash = response.to_hash[:get_waybill_units_response][:get_waybill_units_result][:waybill_units][:waybill_unit]
|
147
|
-
units = []
|
148
|
-
units_hash.each do |hash|
|
149
|
-
unit = WaybillUnit.new
|
150
|
-
unit.id = hash[:id]
|
151
|
-
unit.name = hash[:name]
|
152
|
-
#puts "#{unit.id}: #{unit.name}"
|
153
|
-
units << unit
|
154
|
-
end
|
155
|
-
units
|
156
|
-
end
|
157
|
-
|
158
|
-
# ტრანსპორტის სახეობების მიღება.
|
159
|
-
#
|
160
|
-
# უნდა გადაეცეს შემდეგი პარამეტრები:
|
161
|
-
#
|
162
|
-
# su -- სერვისის მომხმარებლის სახელი
|
163
|
-
# sp -- სერვისის მომხმარებლის პაროლი
|
164
|
-
def self.get_transport_types(params)
|
165
|
-
RS.ensure_open_user(params)
|
166
|
-
RS.validate_presence_of(params, 'su', 'sp')
|
167
|
-
client = RS.waybill_service
|
168
|
-
response = client.request 'get_trans_types' do
|
169
|
-
soap.body = params
|
170
|
-
end
|
171
|
-
types_hash = response.to_hash[:get_trans_types_response][:get_trans_types_result][:transport_types][:transport_type]
|
172
|
-
types = []
|
173
|
-
types_hash.each do |hash|
|
174
|
-
type = TransportType.new
|
175
|
-
type.id = hash[:id]
|
176
|
-
type.name = hash[:name]
|
177
|
-
#puts "#{type.id}: #{type.name}"
|
178
|
-
types << type
|
179
|
-
end
|
180
|
-
types
|
181
|
-
end
|
182
|
-
|
183
|
-
# შტრიხკოდის შენახვის მეთოდი.
|
184
|
-
#
|
185
|
-
# უნდა გადაეცეს შემდეგი პარამეტრები:
|
186
|
-
#
|
187
|
-
# su -- სერვისის მომხმარებლის სახელი
|
188
|
-
# sp -- სერვისის მომხმარებლის პაროლი
|
189
|
-
# bar_code -- შტრიხკოდის მნიშვნელობა
|
190
|
-
# prod_name -- საქონლის დასახელება (შეესაბამება <code>goods_name</code> RS-ის სპეციფიკაციაში)
|
191
|
-
# unit_id -- ზომის ერთეულის კოდი
|
192
|
-
# unit_name -- ზომის ერთეულის დასახელება, როდესაც #{unit_id} ტოლია #{WaybillUnit::OTHERS},
|
193
|
-
# სხვა მნიშვნელობისთვის ეს პარამეტრი არ უნდა გადმოეცეს
|
194
|
-
# (შეესანამება <code>unit_txt</code> პარამეტრს RS-ის სპეციფიკაციაში)
|
195
|
-
# excise_id -- აქციზის კოდი. ან <code>nil</code>, თუ აქციზის კოდი არ უყენდება ამ საქონელს
|
196
|
-
# (შეესაბამება <code>a_id</code> პარამეტრს RS-ის სპეციფიკაციაში)
|
197
|
-
def self.save_bar_code(params)
|
198
|
-
RS.validate_presence_of(params, 'su', 'sp', 'bar_code', 'prod_name', 'unit_id')
|
199
|
-
params2 = {'su' => params['su'], 'sp' => params['sp'], 'bar_code' => params['bar_code'],
|
200
|
-
'goods_name' => params['prod_name'], 'unit_id' => params['unit_id'],
|
201
|
-
'unit_txt' => params['unit_name'], 'a_id' => params['excise_id']}
|
202
|
-
prepare_params(params2)
|
203
|
-
params2['order!'] = ['su', 'sp', 'bar_code', 'goods_name', 'unit_id', 'unit_txt', 'a_id']
|
204
|
-
client = RS.waybill_service
|
205
|
-
response = client.request 'save_bar_code' do
|
206
|
-
soap.body = params2
|
207
|
-
end
|
208
|
-
resp = response.to_hash[:save_bar_code_response][:save_bar_code_result]
|
209
|
-
resp.to_i == 1 # success!
|
210
|
-
end
|
211
|
-
|
212
|
-
# შტრიხკოდის წაშლის მეთოდი.
|
213
|
-
#
|
214
|
-
# უნდა გადაეცეს შემდეგი პარამეტრები:
|
215
|
-
#
|
216
|
-
# su -- სერვისის მომხმარებლის სახელი
|
217
|
-
# sp -- სერვისის მომხმარებლის პაროლი
|
218
|
-
# bar_code -- შტრიხკოდის მნიშვნელობა
|
219
|
-
def self.delete_bar_code(params)
|
220
|
-
RS.validate_presence_of(params, 'su', 'sp', 'bar_code')
|
221
|
-
params['order!'] = ['su', 'sp', 'bar_code']
|
222
|
-
client = RS.waybill_service
|
223
|
-
response = client.request 'delete_bar_code' do
|
224
|
-
soap.body = params
|
225
|
-
end
|
226
|
-
resp = response.to_hash[:delete_bar_code_response][:delete_bar_code_result]
|
227
|
-
resp.to_i == 1 # success!
|
228
|
-
end
|
229
|
-
|
230
|
-
# შტრიხკოდების მიღების მეთოდი.
|
231
|
-
#
|
232
|
-
# უნდა გადაეცეს შემდეგი პარამეტრები:
|
233
|
-
#
|
234
|
-
# su -- სერვისის მომხმარებლის სახელი
|
235
|
-
# sp -- სერვისის მომხმარებლის პაროლი
|
236
|
-
# bar_code -- შტრიხკოდის მნიშვნელობა, რომლის მსგავსის ამოღებაც გვინდა
|
237
|
-
def self.get_bar_codes(params)
|
238
|
-
RS.validate_presence_of(params, 'su', 'sp', 'bar_code')
|
239
|
-
params['order!']= ['su', 'sp', 'bar_code']
|
240
|
-
client = RS.waybill_service
|
241
|
-
response = client.request 'get_bar_codes' do
|
242
|
-
soap.body = params
|
243
|
-
end
|
244
|
-
codes_hash = response.to_hash[:get_bar_codes_response][:bar_codes][:bar_codes][:bar_code]
|
245
|
-
codes_hash = [codes_hash] if codes_hash.instance_of? Hash
|
246
|
-
codes = []
|
247
|
-
codes_hash.each do |hash|
|
248
|
-
code = BarCode.new
|
249
|
-
code.code = hash[:code]
|
250
|
-
code.name = hash[:name]
|
251
|
-
code.unit_id = hash[:unit_id].to_i
|
252
|
-
code.unit_name = hash[:unit_txt]
|
253
|
-
code.excise_id = hash[:a_id].to_i == 0 ? nil : hash[:a_id].to_i
|
254
|
-
codes << code
|
255
|
-
end
|
256
|
-
codes
|
257
|
-
end
|
258
|
-
|
259
|
-
end
|