rs.ge 0.1.0.beta2 → 0.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/README.md +18 -82
- data/lib/rs.rb +6 -3
- data/lib/rs/models/waybill.rb +340 -0
- data/lib/rs/requests/{base_request.rb → base.rb} +13 -0
- data/lib/rs/requests/config.rb +19 -0
- data/lib/rs/requests/dict.rb +111 -0
- data/lib/rs/requests/sys.rb +92 -0
- data/lib/rs/requests/waybill.rb +123 -0
- data/lib/rs/version.rb +1 -1
- data/rs.gemspec +1 -1
- data/spec/helpers.rb +41 -0
- data/spec/models/waybill_spec.rb +99 -0
- data/spec/requests/dict_spec.rb +68 -0
- data/spec/requests/invoice_spec.rb +36 -0
- data/spec/requests/sys_spec.rb +60 -0
- data/spec/requests/waybill_spec.rb +211 -0
- data/spec/spec_helper.rb +5 -2
- metadata +27 -12
- data/lib/rs/models/waybill_unit.rb +0 -21
- data/lib/rs/requests/waybill_unit_request.rb +0 -44
- data/spec/requests/waybill_units_spec.rb +0 -24
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,44 +0,0 @@
|
|
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
|
@@ -1,24 +0,0 @@
|
|
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
|