rs.ge 0.1.0.rc2 → 0.1.0
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/.gitignore +2 -0
- data/README.md +1 -1
- data/lib/rs.rb +3 -0
- data/lib/rs/models/factura.rb +34 -0
- data/lib/rs/models/initializable.rb +7 -0
- data/lib/rs/models/waybill.rb +64 -23
- data/lib/rs/requests/base.rb +16 -3
- data/lib/rs/requests/config.rb +1 -1
- data/lib/rs/requests/dict.rb +25 -0
- data/lib/rs/requests/factura.rb +132 -0
- data/lib/rs/requests/sys.rb +4 -0
- data/lib/rs/requests/waybill.rb +6 -3
- data/lib/rs/version.rb +1 -1
- data/spec/helpers.rb +3 -1
- data/spec/requests/dict_spec.rb +16 -0
- data/spec/requests/factura_spec.rb +172 -0
- data/spec/requests/waybill_driver_spec.rb +27 -0
- data/spec/requests/waybill_spec.rb +80 -9
- data/spec/spec_helper.rb +11 -3
- metadata +63 -70
- data/.project +0 -11
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,7 @@ which indicates if TIN numbers are validated remotely when a waybill is validate
|
|
22
22
|
RS.config.validate_remote = true
|
23
23
|
```
|
24
24
|
|
25
|
-
It's recommended to have this flag on `true`, unless performance considerations require the
|
25
|
+
It's recommended to have this flag on `true`, unless performance considerations require the opposite.
|
26
26
|
|
27
27
|
## System methods
|
28
28
|
|
data/lib/rs.rb
CHANGED
@@ -3,7 +3,9 @@ require 'savon'
|
|
3
3
|
require 'rs/version'
|
4
4
|
|
5
5
|
# models
|
6
|
+
require 'rs/models/initializable'
|
6
7
|
require 'rs/models/waybill'
|
8
|
+
require 'rs/models/factura'
|
7
9
|
|
8
10
|
# requests
|
9
11
|
require 'rs/requests/config'
|
@@ -11,6 +13,7 @@ require 'rs/requests/base'
|
|
11
13
|
require 'rs/requests/dict'
|
12
14
|
require 'rs/requests/sys'
|
13
15
|
require 'rs/requests/waybill'
|
16
|
+
require 'rs/requests/factura'
|
14
17
|
|
15
18
|
module RS
|
16
19
|
# This constant indicates 18% vat tariff.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
class RS::Factura
|
4
|
+
include RS::Initializable
|
5
|
+
|
6
|
+
# Source invoice -- პირველადი ა/ფ
|
7
|
+
STATUS_START = 0
|
8
|
+
STATUS_SENT = 1
|
9
|
+
STATUS_CONFIRMED = 2
|
10
|
+
STATUS_CORRECTED = 3
|
11
|
+
# Correction invoice -- კორექტირებული ა/ფ
|
12
|
+
STATUS_CORR_START = 4
|
13
|
+
STATUS_CORR_SENT = 5
|
14
|
+
STATUS_CORR_CONFIRMED = 8
|
15
|
+
# Canceled -- გაუქმებულია
|
16
|
+
STATUS_CANCELED = 6
|
17
|
+
STATUS_CONFIRMED_CANCELED = 7
|
18
|
+
|
19
|
+
attr_accessor :id
|
20
|
+
attr_accessor :index, :number
|
21
|
+
attr_accessor :operation_date, :registration_date
|
22
|
+
attr_accessor :seller_id, :buyer_id, :buyer_su_id
|
23
|
+
attr_accessor :status
|
24
|
+
attr_accessor :waybill_number, :waybill_date
|
25
|
+
attr_accessor :correction_of, :correction_type
|
26
|
+
end
|
27
|
+
|
28
|
+
class RS::FacturaItem
|
29
|
+
include RS::Initializable
|
30
|
+
|
31
|
+
attr_accessor :id, :factura_id
|
32
|
+
attr_accessor :name, :unit
|
33
|
+
attr_accessor :quantity, :total, :vat, :excise, :excise_id
|
34
|
+
end
|
data/lib/rs/models/waybill.rb
CHANGED
@@ -5,12 +5,6 @@ require 'active_support/all'
|
|
5
5
|
class RS::Validable
|
6
6
|
attr_accessor :errors, :warnings
|
7
7
|
|
8
|
-
def initialize(opts = {})
|
9
|
-
opts.each do |k, v|
|
10
|
-
instance_variable_set("@#{k}", v) unless v.nil?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
8
|
# Add error to the specified field.
|
15
9
|
def add_error(fld, msg)
|
16
10
|
self.errors = {} unless self.errors
|
@@ -31,6 +25,8 @@ end
|
|
31
25
|
|
32
26
|
# Waybill item class.
|
33
27
|
class RS::WaybillItem < RS::Validable
|
28
|
+
include RS::Initializable
|
29
|
+
|
34
30
|
# Item ID.
|
35
31
|
attr_accessor :id
|
36
32
|
# Barcode for the production in this item,
|
@@ -95,6 +91,8 @@ end
|
|
95
91
|
|
96
92
|
# Waybill class.
|
97
93
|
class RS::Waybill < RS::Validable
|
94
|
+
include RS::Initializable
|
95
|
+
|
98
96
|
# Constant, which indicates, that transportation cost is paid by buyer.
|
99
97
|
TRANSPORTATION_PAID_BY_BUYER = 1
|
100
98
|
# Constant, which indicates, that transportation cost is paid by seller.
|
@@ -167,7 +165,8 @@ class RS::Waybill < RS::Validable
|
|
167
165
|
attr_accessor :transport_type_name
|
168
166
|
# Vehicle number.
|
169
167
|
attr_accessor :car_number
|
170
|
-
#
|
168
|
+
# Vehicle number: trailer's number.
|
169
|
+
attr_accessor :car_number_trailer
|
171
170
|
# Comment on this waybill.
|
172
171
|
attr_accessor :comment
|
173
172
|
# Waybill items.
|
@@ -181,6 +180,18 @@ class RS::Waybill < RS::Validable
|
|
181
180
|
# Service user ID, who created this waybill.
|
182
181
|
attr_accessor :user_id
|
183
182
|
|
183
|
+
def transport_vehicle?
|
184
|
+
self.transport_type_id == RS::TRANS_VEHICLE || self.transport_type_id == RS::TRANS_VEHICLE_FRGN
|
185
|
+
end
|
186
|
+
|
187
|
+
def buyer_required?
|
188
|
+
self.type != RS::WAYBILL_TYPE_DISTR
|
189
|
+
end
|
190
|
+
|
191
|
+
def seller_required?
|
192
|
+
self.type != RS::WAYBILL_TYPE_SUBWB
|
193
|
+
end
|
194
|
+
|
184
195
|
# Convert this waybill to XML.
|
185
196
|
def to_xml(xml)
|
186
197
|
xml.WAYBILL do |b|
|
@@ -191,11 +202,25 @@ class RS::Waybill < RS::Validable
|
|
191
202
|
end
|
192
203
|
b.ID (self.id ? self.id : 0)
|
193
204
|
b.TYPE self.type
|
194
|
-
|
195
|
-
|
196
|
-
|
205
|
+
|
206
|
+
# buyer not sent for distrib order
|
207
|
+
if buyer_required?
|
208
|
+
b.BUYER_TIN self.buyer_tin
|
209
|
+
b.CHEK_BUYER_TIN (self.check_buyer_tin ? 1 : 0)
|
210
|
+
b.BUYER_NAME self.buyer_name
|
211
|
+
b.END_ADDRESS self.end_address
|
212
|
+
else
|
213
|
+
b.BUYER_TIN ''
|
214
|
+
b.CHEK_BUYER_TIN 0
|
215
|
+
b.BUYER_NAME ''
|
216
|
+
b.END_ADDRESS ''
|
217
|
+
end
|
218
|
+
|
219
|
+
# seller main info
|
220
|
+
b.SELER_UN_ID self.seller_id
|
221
|
+
b.PAR_ID (self.parent_id ? self.parent_id : '')
|
197
222
|
b.START_ADDRESS self.start_address
|
198
|
-
|
223
|
+
|
199
224
|
b.DRIVER_TIN self.driver_tin
|
200
225
|
b.CHEK_DRIVER_TIN (self.check_driver_tin ? 1 : 0)
|
201
226
|
b.DRIVER_NAME self.driver_name
|
@@ -204,15 +229,17 @@ class RS::Waybill < RS::Validable
|
|
204
229
|
b.RECEIVER_INFO self.buyer_info
|
205
230
|
b.DELIVERY_DATE (self.delivery_date ? self.delivery_date.strftime('%Y-%m-%dT%H:%M:%S') : '')
|
206
231
|
b.STATUS self.status
|
207
|
-
b.SELER_UN_ID self.seller_id
|
208
|
-
b.PAR_ID (self.parent_id ? self.parent_id : '')
|
209
232
|
b.CAR_NUMBER self.car_number
|
210
233
|
b.WAYBILL_NUMBER (self.number ? self.number : '')
|
211
234
|
## XXX: b.S_USER_ID
|
212
235
|
b.BEGIN_DATE (self.activate_date ? self.activate_date.strftime('%Y-%m-%dT%H:%M:%S') : '')
|
213
|
-
b.TRAN_COST_PAYER (self.transportation_cost_payer ? self.transportation_cost_payer : Waybill::TRANSPORTATION_PAID_BY_BUYER)
|
236
|
+
b.TRAN_COST_PAYER (self.transportation_cost_payer ? self.transportation_cost_payer : RS::Waybill::TRANSPORTATION_PAID_BY_BUYER)
|
214
237
|
b.TRANS_ID self.transport_type_id
|
215
|
-
|
238
|
+
if self.transport_vehicle?
|
239
|
+
b.TRANS_TXT self.car_number_trailer
|
240
|
+
else
|
241
|
+
b.TRANS_TXT self.transport_type_name
|
242
|
+
end
|
216
243
|
b.COMMENT self.comment
|
217
244
|
end
|
218
245
|
end
|
@@ -245,7 +272,7 @@ class RS::Waybill < RS::Validable
|
|
245
272
|
self.status = hash[:status].to_i
|
246
273
|
self.seller_id = hash[:seler_un_id].to_i
|
247
274
|
self.activate_date = hash[:activate_date]
|
248
|
-
self.parent_id = hash[:par_id]
|
275
|
+
self.parent_id = hash[:par_id] ? hash[:par_id].to_i : nil
|
249
276
|
self.total = hash[:full_amount].to_f
|
250
277
|
self.car_number = hash[:car_number]
|
251
278
|
self.number = hash[:waybill_number]
|
@@ -254,7 +281,11 @@ class RS::Waybill < RS::Validable
|
|
254
281
|
self.activate_date = hash[:begin_date]
|
255
282
|
self.transportation_cost_payer = hash[:tran_cost_payer] ? hash[:tran_cost_payer].to_i : nil
|
256
283
|
self.transport_type_id = hash[:trans_id].to_i
|
257
|
-
self.
|
284
|
+
if self.transport_type_id == RS::TRANS_VEHICLE
|
285
|
+
self.car_number_trailer = hash[:trans_txt]
|
286
|
+
else
|
287
|
+
self.transport_type_name = hash[:trans_txt]
|
288
|
+
end
|
258
289
|
self.comment = hash[:comment]
|
259
290
|
self
|
260
291
|
end
|
@@ -265,17 +296,19 @@ class RS::Waybill < RS::Validable
|
|
265
296
|
validate_buyer
|
266
297
|
validate_transport
|
267
298
|
validate_addresses
|
299
|
+
validate_parent
|
268
300
|
validate_remote if RS.config.validate_remote
|
269
301
|
end
|
270
302
|
|
271
303
|
def valid?
|
272
304
|
self.items.each { |it| return false unless it.valid? }
|
273
|
-
super
|
305
|
+
super
|
274
306
|
end
|
275
307
|
|
276
308
|
private
|
277
309
|
|
278
310
|
def validate_buyer
|
311
|
+
return if not buyer_required?
|
279
312
|
if self.buyer_tin.blank?
|
280
313
|
add_error(:buyer_tin, 'მყიდველის საიდენტიფიკაციო ნომერი განუსაზღვრელია')
|
281
314
|
else
|
@@ -288,7 +321,7 @@ class RS::Waybill < RS::Validable
|
|
288
321
|
end
|
289
322
|
|
290
323
|
def validate_transport
|
291
|
-
if self.
|
324
|
+
if self.transport_vehicle?
|
292
325
|
add_error(:car_number, 'მიუთითეთ სატრანსპორტო საშუალების სახელმწიფო ნომერი') if self.car_number.blank?
|
293
326
|
add_error(:driver_tin, 'მძღოლის პირადი ნომერი უნდა იყოს მითითებული') if self.driver_tin.blank?
|
294
327
|
if self.check_driver_tin
|
@@ -305,8 +338,8 @@ class RS::Waybill < RS::Validable
|
|
305
338
|
end
|
306
339
|
|
307
340
|
def validate_addresses
|
308
|
-
add_error(:start_address, 'საწყისი მისამართი განუსაზღვრელია') if self.start_address.blank?
|
309
|
-
add_error(:end_address, 'საბოლოო მისამართი განუსაზღვრელია') if self.end_address.blank?
|
341
|
+
add_error(:start_address, 'საწყისი მისამართი განუსაზღვრელია') if self.start_address.blank? and self.seller_required?
|
342
|
+
add_error(:end_address, 'საბოლოო მისამართი განუსაზღვრელია') if self.end_address.blank? and self.buyer_required?
|
310
343
|
if not self.start_address.blank? and not self.end_address.blank? and
|
311
344
|
self.start_address.strip != self.end_address.strip and
|
312
345
|
self.type == RS::WAYBILL_TYPE_WITHOUT_TRANS
|
@@ -322,7 +355,8 @@ class RS::Waybill < RS::Validable
|
|
322
355
|
add_error(:driver_tin, "საიდ. ნომერი ვერ მოიძებნა: #{self.driver_tin}") if driver_name.nil?
|
323
356
|
add_error(:driver_name, "მძღოლის სახელია: #{driver_name}") if driver_name and driver_name.split.join(' ') != self.driver_name.split.join(' ')
|
324
357
|
else
|
325
|
-
|
358
|
+
# IMPORTANT! this validation is not "remote", so it's moved into non-remote part
|
359
|
+
# add_error(:driver_tin, "მძღოლის პირადი ნომერი არაა მითითებული.")
|
326
360
|
end
|
327
361
|
end
|
328
362
|
# buyer
|
@@ -332,9 +366,16 @@ class RS::Waybill < RS::Validable
|
|
332
366
|
add_error(:buyer_tin, "საიდ. ნომერი ვერ მოიძებნა: #{self.buyer_tin}") if buyer_name.nil?
|
333
367
|
add_error(:buyer_name, "მყიდველის სახელია: #{buyer_name}") if buyer_name and buyer_name.split.join(' ') != self.buyer_name.split.join(' ')
|
334
368
|
else
|
335
|
-
|
369
|
+
# IMPORTANT! this validation is not "remote", so it's moved into non-remote part
|
370
|
+
# add_error(:buyer_tin, "მყიდველის პირადი ნომერი არაა მითითებული.")
|
336
371
|
end
|
337
372
|
end
|
338
373
|
end
|
339
374
|
|
375
|
+
def validate_parent
|
376
|
+
if self.type == RS::WAYBILL_TYPE_SUBWB and self.parent_id.blank?
|
377
|
+
add_error(:parent_id, 'მთავარი ზედნადები განუსაზღვრელია ან არაა გაგზავნილი.')
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
340
381
|
end
|
data/lib/rs/requests/base.rb
CHANGED
@@ -7,21 +7,29 @@ class RS::BaseRequest
|
|
7
7
|
# Waybill service WSDL location.
|
8
8
|
WAYBILL_SERVICE_URL = 'http://services.rs.ge/WayBillService/WayBillService.asmx?WSDL'
|
9
9
|
|
10
|
+
# Invoice service WSDL location.
|
11
|
+
INVOICE_SERVICE_URL = 'http://www.revenue.mof.ge/ntosservice/ntosservice.asmx?WSDL'
|
12
|
+
|
10
13
|
# Defaults
|
11
|
-
DEFAULTS = {su: 'dimitri1979', sp: '123456'}
|
14
|
+
DEFAULTS = {su: 'dimitri1979', sp: '123456', payer_id: 731937, user_id: 783}
|
12
15
|
|
13
16
|
# Last error code.
|
14
17
|
attr_accessor :last_error_code
|
15
18
|
|
16
|
-
# Getting
|
19
|
+
# Getting waybill SOAP client.
|
17
20
|
def waybill_client
|
18
21
|
Savon::Client.new { wsdl.document = WAYBILL_SERVICE_URL }
|
19
22
|
end
|
20
23
|
|
24
|
+
# Getting waybill SOAP client.
|
25
|
+
def invoice_client
|
26
|
+
Savon::Client.new { wsdl.document = INVOICE_SERVICE_URL }
|
27
|
+
end
|
28
|
+
|
21
29
|
# Validates presence of specified keys in the #{params} hash.
|
22
30
|
def validate_presence_of(params, *keys)
|
23
31
|
# XXX: do we always need this replacement???
|
24
|
-
[:su, :sp].each do |sym|
|
32
|
+
[:su, :sp, :user_id, :payer_id].each do |sym|
|
25
33
|
if keys.include?(sym) and params[sym].blank?
|
26
34
|
params[sym] = RS.config.send(sym)
|
27
35
|
end
|
@@ -30,4 +38,9 @@ class RS::BaseRequest
|
|
30
38
|
diff = keys - params.keys
|
31
39
|
raise ArgumentError, "The following parameter(s) not specified: #{diff.to_s[1..-2]}" unless diff.empty?
|
32
40
|
end
|
41
|
+
|
42
|
+
def format_date(dt)
|
43
|
+
dt.strftime('%Y-%m-%dT%H:%M:%S')
|
44
|
+
end
|
45
|
+
|
33
46
|
end
|
data/lib/rs/requests/config.rb
CHANGED
data/lib/rs/requests/dict.rb
CHANGED
@@ -81,6 +81,27 @@ module RS
|
|
81
81
|
types
|
82
82
|
end
|
83
83
|
|
84
|
+
# Returns user_id for the service users's payer.
|
85
|
+
def payer_user_id(params = {})
|
86
|
+
validate_presence_of(params, :su, :sp)
|
87
|
+
response = invoice_client.request 'chek' do
|
88
|
+
soap.body = {'su' => params[:su], 'sp' => params[:sp]}
|
89
|
+
end
|
90
|
+
response.to_hash[:chek_response][:user_id].to_i
|
91
|
+
end
|
92
|
+
|
93
|
+
# Returns information about payer (name, id) from it's TIN number.
|
94
|
+
def get_payer_info(params = {})
|
95
|
+
validate_presence_of(params, :su, :sp, :tin)
|
96
|
+
user_id = params[:user_id] || payer_user_id(params)
|
97
|
+
response = invoice_client.request 'get_un_id_from_tin' do
|
98
|
+
soap.body = {'user_id' => user_id, 'tin' => params[:tin], 'su' => params[:su], 'sp' => params[:sp]}
|
99
|
+
end.to_hash
|
100
|
+
p_id = response[:get_un_id_from_tin_response][:get_un_id_from_tin_result].to_i
|
101
|
+
name = response[:get_un_id_from_tin_response][:name]
|
102
|
+
{payer_id: p_id, name: name}
|
103
|
+
end
|
104
|
+
|
84
105
|
# Returns name by given TIN number.
|
85
106
|
def get_name_from_tin(params = {})
|
86
107
|
validate_presence_of(params, :su, :sp, :tin)
|
@@ -106,6 +127,10 @@ module RS
|
|
106
127
|
def dict
|
107
128
|
RS::DictionaryRequest.instance
|
108
129
|
end
|
130
|
+
|
131
|
+
def dictionary
|
132
|
+
RS::DictionaryRequest.instance
|
133
|
+
end
|
109
134
|
end
|
110
135
|
|
111
136
|
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module RS
|
5
|
+
|
6
|
+
# Factura requests.
|
7
|
+
class InvoiceRequest < BaseRequest
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
def save_factura(factura, opts = {})
|
11
|
+
validate_presence_of(opts, :user_id, :su, :sp)
|
12
|
+
response = invoice_client.request 'save_invoice' do
|
13
|
+
soap.body = {
|
14
|
+
'user_id' => opts[:user_id],
|
15
|
+
'invois_id' => factura.id || 0,
|
16
|
+
'operation_date' => format_date(factura.operation_date || Time.now),
|
17
|
+
'seller_un_id' => factura.seller_id || 0,
|
18
|
+
'buyer_un_id' => factura.buyer_id || 0,
|
19
|
+
'overhead_no' => '', 'overhead_dt' => format_date(Time.now), # this 2 parameters are not USED actually!!
|
20
|
+
'b_s_user_id' => factura.buyer_su_id || 0,
|
21
|
+
'su' => opts[:su], 'sp' => opts[:sp]}
|
22
|
+
end.to_hash
|
23
|
+
resp = response[:save_invoice_response][:save_invoice_result]
|
24
|
+
factura.id = response[:save_invoice_response][:invois_id].to_i if resp
|
25
|
+
resp
|
26
|
+
end
|
27
|
+
|
28
|
+
def save_factura_item(item, opts = {})
|
29
|
+
validate_presence_of(opts, :user_id, :su, :sp)
|
30
|
+
response = invoice_client.request 'save_invoice_desc' do
|
31
|
+
soap.body = {
|
32
|
+
'user_id' => opts[:user_id],
|
33
|
+
'id' => item.id || 0,
|
34
|
+
'su' => opts[:su], 'sp' => opts[:sp],
|
35
|
+
'invois_id' => item.factura_id,
|
36
|
+
'goods' => item.name,
|
37
|
+
'g_unit' => item.unit,
|
38
|
+
'g_number' => item.quantity || 1,
|
39
|
+
'full_amount' => item.total || 0,
|
40
|
+
'drg_amount' => item.vat || 0,
|
41
|
+
'aqcizi_amount' => item.excise || 0,
|
42
|
+
'akciz_id' => item.excise_id || 0
|
43
|
+
}
|
44
|
+
end.to_hash
|
45
|
+
resp = response[:save_invoice_desc_response][:save_invoice_desc_result]
|
46
|
+
item.id = response[:save_invoice_desc_response][:id].to_i if resp
|
47
|
+
resp
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_factura(opts = {})
|
51
|
+
validate_presence_of(opts, :id, :user_id, :su, :sp)
|
52
|
+
response = invoice_client.request 'get_invoice' do
|
53
|
+
soap.body = {'user_id' => opts[:user_id], 'invois_id' => opts[:id], 'su' => opts[:su], 'sp' => opts[:sp]}
|
54
|
+
end.to_hash
|
55
|
+
if response[:get_invoice_response][:get_invoice_result]
|
56
|
+
hash = response[:get_invoice_response]
|
57
|
+
factura = RS::Factura.new
|
58
|
+
factura.id = opts[:id]
|
59
|
+
factura.index = hash[:f_series]
|
60
|
+
factura.number = hash[:f_number].to_i unless hash[:f_number].to_i == -1
|
61
|
+
factura.operation_date = hash[:operation_dt]
|
62
|
+
factura.registration_date = hash[:reg_dt]
|
63
|
+
factura.seller_id = hash[:seller_un_id].to_i unless hash[:seller_un_id] == -1
|
64
|
+
factura.buyer_id = hash[:buyer_un_id].to_i unless hash[:buyer_un_id] == -1
|
65
|
+
factura.status = hash[:status].to_i
|
66
|
+
factura.waybill_number = hash[:overhead_no]
|
67
|
+
factura.waybill_date = hash[:overhead_dt]
|
68
|
+
factura.correction_of = hash[:k_id].to_i unless hash[:k_id].to_i == -1
|
69
|
+
factura.correction_type = hash[:k_type].to_i unless hash[:k_type].to_i == -1
|
70
|
+
factura
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_factura_items(opts = {})
|
75
|
+
validate_presence_of(opts, :id, :user_id, :su, :sp)
|
76
|
+
response = invoice_client.request 'get_invoice_desc' do
|
77
|
+
soap.body = { 'user_id' => opts[:user_id], 'invois_id' => opts[:id], 'su' => opts[:su], 'sp' => opts[:sp] }
|
78
|
+
end.to_hash
|
79
|
+
h_items = response[:get_invoice_desc_response][:get_invoice_desc_result][:diffgram][:document_element][:invoices_descs]
|
80
|
+
items = []
|
81
|
+
if h_items.kind_of?(Array)
|
82
|
+
h_items.each do |item|
|
83
|
+
items << factura_item_from_hash(item)
|
84
|
+
end
|
85
|
+
elsif h_items.kind_of?(Hash)
|
86
|
+
items << factura_item_from_hash(h_items)
|
87
|
+
end
|
88
|
+
items
|
89
|
+
end
|
90
|
+
|
91
|
+
def delete_factura_item(opts = {})
|
92
|
+
validate_presence_of(opts, :id, :factura_id, :su, :sp, :user_id)
|
93
|
+
response = invoice_client.request 'delete_invoice_desc' do
|
94
|
+
soap.body = { 'user_id' => opts[:user_id], 'id' => opts[:id], 'inv_id' => opts[:factura_id], 'su' => opts[:su], 'sp' => opts[:sp] }
|
95
|
+
end.to_hash
|
96
|
+
response[:delete_invoice_desc_response][:delete_invoice_desc_result]
|
97
|
+
end
|
98
|
+
|
99
|
+
def send_factura(opts = {})
|
100
|
+
# XXX: check status before send
|
101
|
+
change_factura_status(RS::Factura::STATUS_SENT, opts)
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def factura_item_from_hash(hash)
|
107
|
+
RS::FacturaItem.new(id: hash[:id].to_i, factura_id: hash[:inv_id].to_i, name: hash[:goods], unit: hash[:g_unit],
|
108
|
+
quantity: hash[:g_number].to_f, total: hash[:full_amount].to_f, vat: hash[:drg_amount].to_f,
|
109
|
+
excise: hash[:aqcizi_amount].to_f, excise_id: hash[:akcis_id].to_i)
|
110
|
+
end
|
111
|
+
|
112
|
+
def change_factura_status(status, opts)
|
113
|
+
validate_presence_of(opts, :user_id, :id, :su, :sp)
|
114
|
+
response = invoice_client.request 'change_invoice_status' do
|
115
|
+
soap.body = { 'user_id' => opts[:user_id], 'inv_id' => opts[:id], 'status' => status, 'su' => opts[:su], 'sp' => opts[:sp] }
|
116
|
+
end
|
117
|
+
response[:change_invoice_status_response][:change_invoice_status_result]
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
class << self
|
123
|
+
def fact
|
124
|
+
RS::InvoiceRequest.instance
|
125
|
+
end
|
126
|
+
|
127
|
+
def factura
|
128
|
+
RS::InvoiceRequest.instance
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
data/lib/rs/requests/sys.rb
CHANGED
data/lib/rs/requests/waybill.rb
CHANGED
@@ -40,7 +40,6 @@ module RS
|
|
40
40
|
soap.body = {'su' => opts[:su], 'sp' => opts[:sp], 'waybill_id' => opts[:id]}
|
41
41
|
end
|
42
42
|
wb = RS::Waybill.new
|
43
|
-
#puts response.to_hash
|
44
43
|
wb.init_from_hash(response.to_hash[:get_waybill_response][:get_waybill_result][:waybill])
|
45
44
|
end
|
46
45
|
|
@@ -49,7 +48,7 @@ module RS
|
|
49
48
|
validate_presence_of(opts, :id, :su, :sp)
|
50
49
|
if opts[:date]
|
51
50
|
response = waybill_client.request 'send_waybil_vd' do
|
52
|
-
soap.body = { 'su' => opts[:su], 'sp' => opts[:sp], 'begin_date' => opts[:date]
|
51
|
+
soap.body = { 'su' => opts[:su], 'sp' => opts[:sp], 'begin_date' => format_date(opts[:date]), 'waybill_id' => opts[:id] }
|
53
52
|
end
|
54
53
|
response.to_hash[:send_waybil_vd_response][:send_waybil_vd_result]
|
55
54
|
else
|
@@ -65,7 +64,7 @@ module RS
|
|
65
64
|
validate_presence_of(opts, :su, :sp, :id)
|
66
65
|
if opts[:date]
|
67
66
|
response = waybill_client.request 'close_waybill_vd' do
|
68
|
-
soap.body = { 'su' => opts[:su], 'sp' => opts[:sp], 'delivery_date' => opts[:date]
|
67
|
+
soap.body = { 'su' => opts[:su], 'sp' => opts[:sp], 'delivery_date' => format_date(opts[:date]), 'waybill_id' => opts[:id] }
|
69
68
|
end
|
70
69
|
response.to_hash[:close_waybill_vd_response][:close_waybill_vd_result].to_i == 1
|
71
70
|
else
|
@@ -118,6 +117,10 @@ module RS
|
|
118
117
|
def wb
|
119
118
|
RS::WaybillRequest.instance
|
120
119
|
end
|
120
|
+
|
121
|
+
def waybill
|
122
|
+
RS::WaybillRequest.instance
|
123
|
+
end
|
121
124
|
end
|
122
125
|
|
123
126
|
end
|
data/lib/rs/version.rb
CHANGED
data/spec/helpers.rb
CHANGED
@@ -22,8 +22,10 @@ def create_waybill(opts = {})
|
|
22
22
|
transportation_cost_payer: opts[:transportation_cost_payer] || 1,
|
23
23
|
transport_type_id: opts[:transport_type_id] || RS::TRANS_VEHICLE,
|
24
24
|
car_number: opts[:car_number] || 'wdw842',
|
25
|
+
car_number_trailer: opts[:car_number_trailer] || '',
|
25
26
|
comment: opts[:comment], user_id: USER01[:id],
|
26
|
-
items: opts[:items]
|
27
|
+
items: opts[:items],
|
28
|
+
parent_id: opts[:parent_id]
|
27
29
|
)
|
28
30
|
end
|
29
31
|
|
data/spec/requests/dict_spec.rb
CHANGED
@@ -46,6 +46,22 @@ describe 'getting payer name from tin' do
|
|
46
46
|
it { should == 'დიმიტრი ყურაშვილი' }
|
47
47
|
end
|
48
48
|
|
49
|
+
describe 'payer_user_id testing' do
|
50
|
+
before(:all) do
|
51
|
+
@user_id = RS.dict.payer_user_id
|
52
|
+
end
|
53
|
+
subject { @user_id }
|
54
|
+
it { should == RS.config.user_id }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'getting payer information by its TIN number' do
|
58
|
+
before(:all) do
|
59
|
+
@info = RS.dict.get_payer_info(tin: '422430239')
|
60
|
+
end
|
61
|
+
subject { @info }
|
62
|
+
it { should_not be_nil }
|
63
|
+
end
|
64
|
+
|
49
65
|
RSpec::Matchers.define :be_personal_tin do
|
50
66
|
match { |actual| RS.dict.personal_tin?(actual) }
|
51
67
|
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
seller_id = RS.config.payer_id
|
5
|
+
factura_buyer_id = RS.dict.get_payer_info(tin: '12345678910')[:payer_id]
|
6
|
+
|
7
|
+
describe 'create factura with items' do
|
8
|
+
before(:all) do
|
9
|
+
@factura = RS::Factura.new(seller_id: seller_id, buyer_id: factura_buyer_id)
|
10
|
+
RS.fact.save_factura(@factura)
|
11
|
+
@factura = RS.fact.get_factura(id: @factura.id)
|
12
|
+
end
|
13
|
+
context 'test header' do
|
14
|
+
subject { @factura }
|
15
|
+
its(:id) { should_not be_nil }
|
16
|
+
its(:id) { should > 0 }
|
17
|
+
its(:index) { should == 'ეა-36'}
|
18
|
+
its(:number) { should be_nil }
|
19
|
+
its(:operation_date) { should_not be_nil }
|
20
|
+
its(:registration_date) { should_not be_nil }
|
21
|
+
its(:seller_id) { should == 731937 }
|
22
|
+
its(:buyer_id) { should_not be_nil }
|
23
|
+
its(:buyer_id) { should == 1149251 }
|
24
|
+
its(:status) { should == RS::Factura::STATUS_START }
|
25
|
+
its(:waybill_number) { should be_nil }
|
26
|
+
its(:waybill_date) { should_not be_nil }
|
27
|
+
its(:correction_of) { should be_nil }
|
28
|
+
end
|
29
|
+
context 'add item 1' do
|
30
|
+
before(:all) do
|
31
|
+
@item = RS::FacturaItem.new(factura_id: @factura.id, name: 'tomato', unit: 'kg', quantity: 10, total: 100, vat: 18)
|
32
|
+
RS.fact.save_factura_item(@item)
|
33
|
+
end
|
34
|
+
subject { @item }
|
35
|
+
it { should_not be_nil }
|
36
|
+
its(:id) { should_not be_nil }
|
37
|
+
its(:id) { should > 0 }
|
38
|
+
its(:id) { should be_instance_of Fixnum }
|
39
|
+
end
|
40
|
+
context 'add item 2' do
|
41
|
+
before(:all) do
|
42
|
+
@item = RS::FacturaItem.new(factura_id: @factura.id, name: 'cucumber', unit: 'kg', quantity: 8, total: 80, vat: 14.4)
|
43
|
+
RS.fact.save_factura_item(@item)
|
44
|
+
end
|
45
|
+
subject { @item }
|
46
|
+
it { should_not be_nil }
|
47
|
+
its(:id) { should_not be_nil }
|
48
|
+
its(:id) { should > 0 }
|
49
|
+
its(:id) { should be_instance_of Fixnum }
|
50
|
+
end
|
51
|
+
context 'get factura items' do
|
52
|
+
before(:all) do
|
53
|
+
@items = RS.fact.get_factura_items(id: @factura.id)
|
54
|
+
end
|
55
|
+
context 'all items' do
|
56
|
+
subject { @items }
|
57
|
+
it { should_not be_nil }
|
58
|
+
its(:size) { should == 2 }
|
59
|
+
end
|
60
|
+
context 'first item' do
|
61
|
+
subject { @items[0] }
|
62
|
+
it { should_not be_nil }
|
63
|
+
its(:id) { should > 0 }
|
64
|
+
its(:factura_id) { should == @factura.id }
|
65
|
+
its(:name) { should == 'tomato' }
|
66
|
+
its(:unit) { should == 'kg' }
|
67
|
+
its(:quantity) { should == 10 }
|
68
|
+
its(:total) { should == 100 }
|
69
|
+
its(:vat) { should == 18 }
|
70
|
+
its(:excise) { should == 0 }
|
71
|
+
its(:excise_id) { should == 0 }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
context 'delete first item' do
|
75
|
+
before(:all) do
|
76
|
+
@items = RS.fact.get_factura_items(id: @factura.id)
|
77
|
+
@resp = RS.fact.delete_factura_item(id: @items.first.id, factura_id: @factura.id)
|
78
|
+
@items = RS.fact.get_factura_items(id: @factura.id)
|
79
|
+
end
|
80
|
+
context do
|
81
|
+
subject { @resp }
|
82
|
+
it { should == true }
|
83
|
+
end
|
84
|
+
context do
|
85
|
+
subject { @items }
|
86
|
+
its(:size) { should == 1 }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'get factura' do
|
92
|
+
context 'new factura' do
|
93
|
+
before(:all) do
|
94
|
+
@factura = RS::Factura.new(seller_id: RS.config.payer_id, buyer_id: factura_buyer_id)
|
95
|
+
RS.fact.save_factura(@factura)
|
96
|
+
@factura = RS.fact.get_factura(id: @factura.id)
|
97
|
+
end
|
98
|
+
subject { @factura }
|
99
|
+
its(:id) { should_not be_nil }
|
100
|
+
its(:id) { should > 0 }
|
101
|
+
its(:index) { should == 'ეა-36'}
|
102
|
+
its(:number) { should be_nil }
|
103
|
+
its(:operation_date) { should_not be_nil }
|
104
|
+
its(:registration_date) { should_not be_nil }
|
105
|
+
its(:seller_id) { should == 731937 }
|
106
|
+
its(:buyer_id) { should_not be_nil }
|
107
|
+
its(:buyer_id) { should == 1149251 }
|
108
|
+
its(:status) { should == RS::Factura::STATUS_START }
|
109
|
+
its(:waybill_number) { should be_nil }
|
110
|
+
its(:waybill_date) { should_not be_nil }
|
111
|
+
its(:correction_of) { should be_nil }
|
112
|
+
end
|
113
|
+
context do
|
114
|
+
before(:all) do
|
115
|
+
@id = 16953719
|
116
|
+
@factura = RS.fact.get_factura(id: @id)
|
117
|
+
end
|
118
|
+
subject { @factura }
|
119
|
+
it { should_not be_nil }
|
120
|
+
its(:id) { should == @id }
|
121
|
+
its(:index) { should == 'ეა-36'}
|
122
|
+
its(:number) { should == 269554 }
|
123
|
+
its(:operation_date) { should_not be_nil }
|
124
|
+
its(:registration_date) { should_not be_nil }
|
125
|
+
its(:seller_id) { should == 731937 }
|
126
|
+
its(:status) { should == RS::Factura::STATUS_SENT }
|
127
|
+
its(:correction_of) { should be_nil }
|
128
|
+
end
|
129
|
+
context do
|
130
|
+
before(:all) do
|
131
|
+
@id = 16166575
|
132
|
+
@factura = RS.fact.get_factura(id: @id)
|
133
|
+
end
|
134
|
+
subject { @factura }
|
135
|
+
it { should_not be_nil }
|
136
|
+
its(:id) { should == @id }
|
137
|
+
its(:index) { should == 'ეა-05'}
|
138
|
+
its(:number) { should == 6413864 }
|
139
|
+
its(:operation_date) { should_not be_nil }
|
140
|
+
its(:registration_date) { should_not be_nil }
|
141
|
+
its(:seller_id) { should == 1149251 }
|
142
|
+
its(:buyer_id) { should == 731937 }
|
143
|
+
its(:status) { should == RS::Factura::STATUS_CORRECTED }
|
144
|
+
its(:correction_of) { should be_nil }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe 'change factura statuses' do
|
149
|
+
before(:all) do
|
150
|
+
@factura = RS::Factura.new(seller_id: seller_id, buyer_id: factura_buyer_id)
|
151
|
+
RS.fact.save_factura(@factura)
|
152
|
+
@item = RS::FacturaItem.new(factura_id: @factura.id, name: 'tomato', unit: 'kg', quantity: 10, total: 100, vat: 18)
|
153
|
+
RS.fact.save_factura_item(@item)
|
154
|
+
end
|
155
|
+
context 'send factura' do
|
156
|
+
before(:all) do
|
157
|
+
@resp = RS.fact.send_factura(id: @factura.id)
|
158
|
+
@factura = RS.fact.get_factura(id: @factura.id)
|
159
|
+
end
|
160
|
+
context do
|
161
|
+
subject { @resp }
|
162
|
+
it { should == true }
|
163
|
+
end
|
164
|
+
context do
|
165
|
+
subject { @factura }
|
166
|
+
it { should_not be_nil }
|
167
|
+
its(:status) { should == RS::Factura::STATUS_SENT }
|
168
|
+
its(:index) { should_not be_blank }
|
169
|
+
its(:number) { should_not be_blank }
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'Save waybill: without driver name' do
|
5
|
+
before(:all) do
|
6
|
+
items = [create_item(bar_code: '001', prod_name: 'პამიდორი', price: 2, quantity: 5), create_item(bar_code: '002', prod_name: 'კიტრი', price: 3, quantity: 10)]
|
7
|
+
@waybill = create_waybill(items: items)
|
8
|
+
@waybill.driver_name = nil
|
9
|
+
RS.wb.save_waybill(@waybill)
|
10
|
+
end
|
11
|
+
subject { @waybill }
|
12
|
+
its(:id) { should_not be_nil }
|
13
|
+
its(:error_code) { should == 0 }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'Save waybill: without driver name (and buyer is foreigner)' do
|
17
|
+
before(:all) do
|
18
|
+
items = [create_item(bar_code: '001', prod_name: 'პამიდორი', price: 2, quantity: 5), create_item(bar_code: '002', prod_name: 'კიტრი', price: 3, quantity: 10)]
|
19
|
+
@waybill = create_waybill(items: items)
|
20
|
+
@waybill.driver_name = nil
|
21
|
+
@waybill.check_buyer_tin = false
|
22
|
+
RS.wb.save_waybill(@waybill)
|
23
|
+
end
|
24
|
+
subject { @waybill }
|
25
|
+
its(:id) { should == 0 }
|
26
|
+
its(:error_code) { should == -1013 }
|
27
|
+
end
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
describe 'Save waybill' do
|
5
5
|
before(:all) do
|
6
6
|
items = [create_item(bar_code: '001', prod_name: 'პამიდორი', price: 2, quantity: 5), create_item(bar_code: '002', prod_name: 'კიტრი', price: 3, quantity: 10)]
|
7
|
-
@waybill = create_waybill(items: items)
|
7
|
+
@waybill = create_waybill(transport_type_id: RS::TRANS_VEHICLE, car_number: 'abc123', car_number_trailer: 'de45', items: items)
|
8
8
|
RS.wb.save_waybill(@waybill)
|
9
9
|
end
|
10
10
|
context 'waybill' do
|
@@ -33,6 +33,8 @@ describe 'Save waybill' do
|
|
33
33
|
its(:activate_date) { should be_nil }
|
34
34
|
its(:close_date) { should be_nil }
|
35
35
|
its(:delivery_date) { should be_nil }
|
36
|
+
its(:car_number) { should == 'abc123' }
|
37
|
+
its(:car_number_trailer) { should == 'de45' }
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -63,7 +65,7 @@ describe 'Resave waybill' do
|
|
63
65
|
specify { subject.items.size.should == 1 }
|
64
66
|
end
|
65
67
|
end
|
66
|
-
|
68
|
+
|
67
69
|
describe 'Activate waybill' do
|
68
70
|
context 'with begin_date' do
|
69
71
|
before(:all) do
|
@@ -73,7 +75,7 @@ describe 'Activate waybill' do
|
|
73
75
|
]
|
74
76
|
@waybill = create_waybill(items: items)
|
75
77
|
RS.wb.save_waybill(@waybill)
|
76
|
-
@resp = RS.wb.activate_waybill(id: @waybill.id, date: Time.now)
|
78
|
+
@resp = RS.wb.activate_waybill(id: @waybill.id, date: Time.now + 1800)
|
77
79
|
@waybill = RS.wb.get_waybill(id: @waybill.id)
|
78
80
|
end
|
79
81
|
subject { @waybill }
|
@@ -131,20 +133,20 @@ describe 'Close waybill' do
|
|
131
133
|
create_item(bar_code: '001', prod_name: 'iPhone 4S 3G/32GB', price: 1800, quantity: 2),
|
132
134
|
create_item(bar_code: '002', prod_name: 'The New iPad 3G/16GB', price: 1200, quantity: 1)
|
133
135
|
]
|
134
|
-
|
135
|
-
RS.wb.save_waybill(
|
136
|
-
RS.wb.activate_waybill(id:
|
137
|
-
@resp = RS.wb.close_waybill(id:
|
138
|
-
@waybill = RS.wb.get_waybill(id:
|
136
|
+
waybill = create_waybill(items: items)
|
137
|
+
RS.wb.save_waybill(waybill)
|
138
|
+
RS.wb.activate_waybill(id: waybill.id, date: Time.now + 1800)
|
139
|
+
@resp = RS.wb.close_waybill(id: waybill.id, date: Time.now + 3600)
|
140
|
+
@waybill = RS.wb.get_waybill(id: waybill.id)
|
139
141
|
end
|
140
142
|
subject { @waybill }
|
141
143
|
its(:id) { should_not be_nil }
|
142
144
|
its(:total) { should == 4800 }
|
143
145
|
its(:number) { should_not be_nil }
|
144
|
-
specify { @resp.should == true }
|
145
146
|
its(:status) { should == RS::Waybill::STATUS_CLOSED }
|
146
147
|
its(:activate_date) { should_not be_nil }
|
147
148
|
its(:delivery_date) { should_not be_nil }
|
149
|
+
specify { @resp.should == true }
|
148
150
|
end
|
149
151
|
context 'without delivery_date' do
|
150
152
|
before(:all) do
|
@@ -209,3 +211,72 @@ describe 'Deactivate waybill' do
|
|
209
211
|
its(:status) { should == RS::Waybill::STATUS_DEACTIVATED }
|
210
212
|
end
|
211
213
|
end
|
214
|
+
|
215
|
+
describe 'Distrib waybill -> sub waybill' do
|
216
|
+
before(:all) do
|
217
|
+
items = [create_item(bar_code: '001', prod_name: 'პამიდორი', price: 2, quantity: 5), create_item(bar_code: '002', prod_name: 'კიტრი', price: 3, quantity: 10)]
|
218
|
+
@waybill = create_waybill(type: RS::WAYBILL_TYPE_DISTR, transport_type_id: RS::TRANS_VEHICLE, car_number: 'abc123', car_number_trailer: 'de45', items: items)
|
219
|
+
RS.wb.save_waybill(@waybill)
|
220
|
+
RS.wb.activate_waybill(id: @waybill.id)
|
221
|
+
@waybill = RS.wb.get_waybill(id: @waybill.id)
|
222
|
+
end
|
223
|
+
context 'waybill' do
|
224
|
+
subject { @waybill }
|
225
|
+
its(:id) { should_not be_nil }
|
226
|
+
its(:id) { should > 0 }
|
227
|
+
its(:type) { should == RS::WAYBILL_TYPE_DISTR }
|
228
|
+
its(:buyer_tin) { should == nil }
|
229
|
+
its(:status) { should == RS::Waybill::STATUS_ACTIVE }
|
230
|
+
end
|
231
|
+
context 'create sub-waybill' do
|
232
|
+
before(:all) do
|
233
|
+
items = [create_item(bar_code: '001', prod_name: 'პამიდორი', price: 2, quantity: 2), create_item(bar_code: '002', prod_name: 'კიტრი', price: 3, quantity: 5)]
|
234
|
+
@sub_waybill = create_waybill(type: RS::WAYBILL_TYPE_SUBWB, parent_id: @waybill.id, items: items)
|
235
|
+
RS.wb.save_waybill(@sub_waybill)
|
236
|
+
RS.wb.activate_waybill(id: @sub_waybill.id)
|
237
|
+
@sub_waybill = RS.wb.get_waybill(id: @sub_waybill.id)
|
238
|
+
end
|
239
|
+
context do
|
240
|
+
subject { @sub_waybill }
|
241
|
+
its(:id) { should_not be_nil }
|
242
|
+
its(:id) { should > 0 }
|
243
|
+
its(:type) { should == RS::WAYBILL_TYPE_SUBWB }
|
244
|
+
its(:seller_id) { should == @waybill.seller_id }
|
245
|
+
its(:status) { should == RS::Waybill::STATUS_ACTIVE }
|
246
|
+
its(:parent_id) { should == @waybill.id }
|
247
|
+
end
|
248
|
+
context 'update sub-waybill (correct quantities)' do
|
249
|
+
before(:all) do
|
250
|
+
@sub_waybill.items[0].quantity = 5
|
251
|
+
RS.wb.save_waybill(@sub_waybill)
|
252
|
+
end
|
253
|
+
subject { @sub_waybill }
|
254
|
+
its(:error_code) { should == 0 }
|
255
|
+
specify { subject.items.first.quantity.should == 5 }
|
256
|
+
end
|
257
|
+
context 'update sub-waybill (incorrect quantities)' do
|
258
|
+
before(:all) do
|
259
|
+
@sub_waybill.items[0].quantity = 100
|
260
|
+
RS.wb.save_waybill(@sub_waybill)
|
261
|
+
end
|
262
|
+
subject { @sub_waybill }
|
263
|
+
# XXX: ეს ძალიან ცუდია! rs.ge სერვისი არ ამოწმებს ნაშთების უარყოფითობას
|
264
|
+
its(:error_code) { should == 0 }
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
describe 'Return waybill' do
|
270
|
+
before(:all) do
|
271
|
+
items = [create_item(bar_code: '001', prod_name: 'პამიდორი', price: 2, quantity: 5), create_item(bar_code: '002', prod_name: 'კიტრი', price: 3, quantity: 10)]
|
272
|
+
@waybill = create_waybill(type: RS::WAYBILL_TYPE_RETRN, transport_type_id: RS::TRANS_VEHICLE, car_number: 'abc123', items: items)
|
273
|
+
RS.wb.save_waybill(@waybill)
|
274
|
+
RS.wb.activate_waybill(id: @waybill.id)
|
275
|
+
@waybill = RS.wb.get_waybill(id: @waybill.id)
|
276
|
+
end
|
277
|
+
subject { @waybill }
|
278
|
+
its(:type) { should == RS::WAYBILL_TYPE_RETRN }
|
279
|
+
its(:id) { should_not be_nil }
|
280
|
+
its(:id) { should > 0 }
|
281
|
+
its(:number) { should_not be_nil }
|
282
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,7 +11,6 @@ end
|
|
11
11
|
|
12
12
|
# RSpec
|
13
13
|
|
14
|
-
require 'rs'
|
15
14
|
require 'rspec'
|
16
15
|
|
17
16
|
RSpec.configure do |config|
|
@@ -20,7 +19,16 @@ end
|
|
20
19
|
|
21
20
|
# Test options.
|
22
21
|
|
22
|
+
require 'rs'
|
23
23
|
require 'helpers'
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
TEST_USERNAME = 'tbilisi'
|
26
|
+
TEST_PASSWORD = '123456'
|
27
|
+
RS.config.su = RS::BaseRequest::DEFAULTS[:su]
|
28
|
+
RS.config.sp = RS::BaseRequest::DEFAULTS[:sp]
|
29
|
+
RS.config.user_id = RS::BaseRequest::DEFAULTS[:user_id]
|
30
|
+
RS.config.payer_id = RS::BaseRequest::DEFAULTS[:payer_id]
|
31
|
+
|
32
|
+
# ეს განახლება საჭიროა, რათა სატესტო მომხმარებელი მუშაობდეს იგივე IP მისამართიდან, საიდანაც ეშვება ეს ტესტები.
|
33
|
+
# IP მისამართით შეზღუდვა მნიშვნელვანია ანგარიშ-ფაქტურის სერვისებისთვის!
|
34
|
+
RS.sys.update_user(username: TEST_USERNAME, password: TEST_PASSWORD, ip: RS.sys.what_is_my_ip, name: 'invoice.ge', su: RS.config.su, sp: RS.config.sp)
|
metadata
CHANGED
@@ -1,98 +1,84 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs.ge
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Dimitri Kurashvili
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2012-10-23 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: rspec
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '2'
|
22
|
-
type: :development
|
23
17
|
prerelease: false
|
24
|
-
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
19
|
none: false
|
26
|
-
requirements:
|
20
|
+
requirements:
|
27
21
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "2"
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
31
27
|
name: savon
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '1.0'
|
38
|
-
type: :runtime
|
39
28
|
prerelease: false
|
40
|
-
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
30
|
none: false
|
42
|
-
requirements:
|
31
|
+
requirements:
|
43
32
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version:
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: prawn
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.12'
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "1.0"
|
54
35
|
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: prawn
|
55
39
|
prerelease: false
|
56
|
-
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.12'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: c12-commons
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
65
41
|
none: false
|
66
|
-
requirements:
|
42
|
+
requirements:
|
67
43
|
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0.12"
|
70
46
|
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: c12-commons
|
71
50
|
prerelease: false
|
72
|
-
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
52
|
none: false
|
74
|
-
requirements:
|
53
|
+
requirements:
|
75
54
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
55
|
+
- !ruby/object:Gem::Version
|
77
56
|
version: 0.0.5
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: *id004
|
78
59
|
description: Ruby client for rs.ge web services
|
79
|
-
email:
|
60
|
+
email:
|
80
61
|
- dimitri@c12.ge
|
81
62
|
executables: []
|
63
|
+
|
82
64
|
extensions: []
|
65
|
+
|
83
66
|
extra_rdoc_files: []
|
84
|
-
|
67
|
+
|
68
|
+
files:
|
85
69
|
- .gitignore
|
86
|
-
- .project
|
87
70
|
- .rspec
|
88
71
|
- Gemfile
|
89
72
|
- README.md
|
90
73
|
- Rakefile
|
91
74
|
- lib/rs.rb
|
75
|
+
- lib/rs/models/factura.rb
|
76
|
+
- lib/rs/models/initializable.rb
|
92
77
|
- lib/rs/models/waybill.rb
|
93
78
|
- lib/rs/requests/base.rb
|
94
79
|
- lib/rs/requests/config.rb
|
95
80
|
- lib/rs/requests/dict.rb
|
81
|
+
- lib/rs/requests/factura.rb
|
96
82
|
- lib/rs/requests/sys.rb
|
97
83
|
- lib/rs/requests/waybill.rb
|
98
84
|
- lib/rs/version.rb
|
@@ -100,39 +86,46 @@ files:
|
|
100
86
|
- spec/helpers.rb
|
101
87
|
- spec/models/waybill_spec.rb
|
102
88
|
- spec/requests/dict_spec.rb
|
89
|
+
- spec/requests/factura_spec.rb
|
103
90
|
- spec/requests/invoice_spec.rb
|
104
91
|
- spec/requests/sys_spec.rb
|
92
|
+
- spec/requests/waybill_driver_spec.rb
|
105
93
|
- spec/requests/waybill_spec.rb
|
106
94
|
- spec/spec_helper.rb
|
107
95
|
homepage: http://c12.ge
|
108
96
|
licenses: []
|
97
|
+
|
109
98
|
post_install_message:
|
110
99
|
rdoc_options: []
|
111
|
-
|
100
|
+
|
101
|
+
require_paths:
|
112
102
|
- lib
|
113
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
104
|
none: false
|
115
|
-
requirements:
|
116
|
-
- -
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version:
|
119
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: "0"
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
110
|
none: false
|
121
|
-
requirements:
|
122
|
-
- -
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version:
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: "0"
|
125
115
|
requirements: []
|
116
|
+
|
126
117
|
rubyforge_project: rs
|
127
|
-
rubygems_version: 1.8.
|
118
|
+
rubygems_version: 1.8.24
|
128
119
|
signing_key:
|
129
120
|
specification_version: 3
|
130
121
|
summary: rs.ge web services
|
131
|
-
test_files:
|
122
|
+
test_files:
|
132
123
|
- spec/helpers.rb
|
133
124
|
- spec/models/waybill_spec.rb
|
134
125
|
- spec/requests/dict_spec.rb
|
126
|
+
- spec/requests/factura_spec.rb
|
135
127
|
- spec/requests/invoice_spec.rb
|
136
128
|
- spec/requests/sys_spec.rb
|
129
|
+
- spec/requests/waybill_driver_spec.rb
|
137
130
|
- spec/requests/waybill_spec.rb
|
138
131
|
- spec/spec_helper.rb
|