billing 0.0.8a → 0.0.8
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85a0bd23ac0ea7985a56a4a4ffb41890f30b290f
|
4
|
+
data.tar.gz: f5a71cf981e5bf73c36a797893bd81fcb112cb66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e46daa7655ef8825493c364fee6104cc37b37ada9b0ade3ae7e761654abc6408af0f8e57d20da42525bd04c21c658d9a4d07a60a2d06d1cc963cb6ae2efcc882
|
7
|
+
data.tar.gz: caa0ec0e93301541458037bc462cb6054db3582e44269aeb3f8b64376ddb44d1a8e7ee1138dc16bc4cbaa2eb6d0aef3cf4ab9941fce4603ab1ca533442f91ea2
|
@@ -1,4 +1,69 @@
|
|
1
|
-
|
1
|
+
module Resque
|
2
|
+
module Plugins
|
3
|
+
module ExtfaceLonelyDevice
|
4
|
+
LOCK_TIMEOUT = 60 * 60 * 24 * 5 # 5 days
|
5
|
+
|
6
|
+
def lock_timeout
|
7
|
+
Time.now.to_i + LOCK_TIMEOUT + 1
|
8
|
+
end
|
9
|
+
|
10
|
+
def requeue_interval
|
11
|
+
self.instance_variable_get(:@requeue_interval) || 1
|
12
|
+
end
|
13
|
+
|
14
|
+
# Overwrite this method to uniquely identify which mutex should be used
|
15
|
+
# for a resque worker.
|
16
|
+
def redis_key(*args)
|
17
|
+
"extface_"
|
18
|
+
end
|
19
|
+
|
20
|
+
def can_lock_queue?(*args)
|
21
|
+
now = Time.now.to_i
|
22
|
+
key = redis_key(*args)
|
23
|
+
timeout = lock_timeout
|
24
|
+
|
25
|
+
# Per http://redis.io/commands/setnx
|
26
|
+
return true if Resque.redis.setnx(key, timeout)
|
27
|
+
return false if Resque.redis.get(key).to_i > now
|
28
|
+
return true if Resque.redis.getset(key, timeout).to_i <= now
|
29
|
+
return false
|
30
|
+
rescue ActiveRecord::RecordNotFound #redis_key exception
|
31
|
+
p "Not found!!!"
|
32
|
+
sleep 1
|
33
|
+
reenqueue(*args) #will stop if new redis_key exception
|
34
|
+
end
|
35
|
+
|
36
|
+
def unlock_queue(*args)
|
37
|
+
Resque.redis.del(redis_key(*args))
|
38
|
+
end
|
39
|
+
|
40
|
+
def reenqueue(*args)
|
41
|
+
Resque.enqueue_to(redis_key(*args), self, *args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def before_perform(*args)
|
45
|
+
unless can_lock_queue?(*args)
|
46
|
+
# Sleep so the CPU's rest
|
47
|
+
sleep(requeue_interval)
|
48
|
+
|
49
|
+
# can't get the lock, so re-enqueue the task
|
50
|
+
reenqueue(*args)
|
51
|
+
|
52
|
+
# and don't perform
|
53
|
+
raise Resque::Job::DontPerform
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def around_perform(*args)
|
58
|
+
begin
|
59
|
+
yield
|
60
|
+
ensure
|
61
|
+
unlock_queue(*args)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
2
67
|
|
3
68
|
module Billing
|
4
69
|
class IssueFiscalDoc
|
@@ -1,4 +1,69 @@
|
|
1
|
-
|
1
|
+
module Resque
|
2
|
+
module Plugins
|
3
|
+
module ExtfaceLonelyDevice
|
4
|
+
LOCK_TIMEOUT = 60 * 60 * 24 * 5 # 5 days
|
5
|
+
|
6
|
+
def lock_timeout
|
7
|
+
Time.now.to_i + LOCK_TIMEOUT + 1
|
8
|
+
end
|
9
|
+
|
10
|
+
def requeue_interval
|
11
|
+
self.instance_variable_get(:@requeue_interval) || 1
|
12
|
+
end
|
13
|
+
|
14
|
+
# Overwrite this method to uniquely identify which mutex should be used
|
15
|
+
# for a resque worker.
|
16
|
+
def redis_key(*args)
|
17
|
+
"extface_"
|
18
|
+
end
|
19
|
+
|
20
|
+
def can_lock_queue?(*args)
|
21
|
+
now = Time.now.to_i
|
22
|
+
key = redis_key(*args)
|
23
|
+
timeout = lock_timeout
|
24
|
+
|
25
|
+
# Per http://redis.io/commands/setnx
|
26
|
+
return true if Resque.redis.setnx(key, timeout)
|
27
|
+
return false if Resque.redis.get(key).to_i > now
|
28
|
+
return true if Resque.redis.getset(key, timeout).to_i <= now
|
29
|
+
return false
|
30
|
+
rescue ActiveRecord::RecordNotFound #redis_key exception
|
31
|
+
p "Not found!!!"
|
32
|
+
sleep 1
|
33
|
+
reenqueue(*args) #will stop if new redis_key exception
|
34
|
+
end
|
35
|
+
|
36
|
+
def unlock_queue(*args)
|
37
|
+
Resque.redis.del(redis_key(*args))
|
38
|
+
end
|
39
|
+
|
40
|
+
def reenqueue(*args)
|
41
|
+
Resque.enqueue_to(redis_key(*args), self, *args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def before_perform(*args)
|
45
|
+
unless can_lock_queue?(*args)
|
46
|
+
# Sleep so the CPU's rest
|
47
|
+
sleep(requeue_interval)
|
48
|
+
|
49
|
+
# can't get the lock, so re-enqueue the task
|
50
|
+
reenqueue(*args)
|
51
|
+
|
52
|
+
# and don't perform
|
53
|
+
raise Resque::Job::DontPerform
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def around_perform(*args)
|
58
|
+
begin
|
59
|
+
yield
|
60
|
+
ensure
|
61
|
+
unlock_queue(*args)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
2
67
|
|
3
68
|
module Billing
|
4
69
|
class IssuePrintDoc
|
@@ -22,11 +87,10 @@ module Billing
|
|
22
87
|
bill.print_job.runtime do |s|
|
23
88
|
return unless bill.printable?
|
24
89
|
s.notify "Print Doc Start"
|
25
|
-
|
26
|
-
s.print bill.
|
27
|
-
s.print "
|
28
|
-
s.print "
|
29
|
-
s.print "\r\n------------------------------\r\n"
|
90
|
+
s.print "******************************\r\n*"
|
91
|
+
s.print "Bill ##{bill.number}".center(28)
|
92
|
+
s.print "*\r\n******************************\r\n"
|
93
|
+
s.print "------------------------------\r\n"
|
30
94
|
|
31
95
|
bill.charges.each do |charge|
|
32
96
|
s.print "#{charge.name.ljust(22)} #{charge.value.to_s.rjust(7)}\r\n"
|
@@ -38,10 +102,9 @@ module Billing
|
|
38
102
|
# bill.payments.each do |payment|
|
39
103
|
# s.print "#{payment.payment_type.name.humanize}\r\n"
|
40
104
|
# end
|
41
|
-
|
42
|
-
s.print "
|
43
|
-
s.print
|
44
|
-
s.print "\r\n------------------------------\r\n"
|
105
|
+
|
106
|
+
s.print "\r\n"
|
107
|
+
s.print "------------------------------\r\n"
|
45
108
|
s.print Time.now.strftime("Printed on %m/%d/%Y %T\r\n").rjust(32)
|
46
109
|
s.print "\r\n\r\n\r\n"
|
47
110
|
s.notify "Print Doc End"
|
data/lib/billing/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: billing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Vangelov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -177,13 +177,11 @@ files:
|
|
177
177
|
- db/migrate/20150512040421_add_deleted_at_to_billing_report.rb
|
178
178
|
- db/migrate/20160723160908_add_print_device_to_billing_origin.rb
|
179
179
|
- db/migrate/20160723234233_add_print_job_to_billing_bill.rb
|
180
|
-
- db/migrate/20160824235224_add_print_headers_to_billing_origin.rb
|
181
180
|
- lib/billing.rb
|
182
181
|
- lib/billing/billable.rb
|
183
182
|
- lib/billing/engine.rb
|
184
183
|
- lib/billing/version.rb
|
185
184
|
- lib/collection_proxy_wild.rb
|
186
|
-
- lib/rescue/plugins/extface_lonely_device.rb
|
187
185
|
- lib/tasks/billing.rake
|
188
186
|
- lib/tasks/billing_tasks.rake
|
189
187
|
- test/billing_test.rb
|
@@ -268,9 +266,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
268
266
|
version: '0'
|
269
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
270
268
|
requirements:
|
271
|
-
- - "
|
269
|
+
- - ">="
|
272
270
|
- !ruby/object:Gem::Version
|
273
|
-
version:
|
271
|
+
version: '0'
|
274
272
|
requirements: []
|
275
273
|
rubyforge_project:
|
276
274
|
rubygems_version: 2.5.0
|
@@ -1,67 +0,0 @@
|
|
1
|
-
module Resque
|
2
|
-
module Plugins
|
3
|
-
module ExtfaceLonelyDevice
|
4
|
-
LOCK_TIMEOUT = 60 * 60 * 24 * 5 # 5 days
|
5
|
-
|
6
|
-
def lock_timeout
|
7
|
-
Time.now.to_i + LOCK_TIMEOUT + 1
|
8
|
-
end
|
9
|
-
|
10
|
-
def requeue_interval
|
11
|
-
self.instance_variable_get(:@requeue_interval) || 1
|
12
|
-
end
|
13
|
-
|
14
|
-
# Overwrite this method to uniquely identify which mutex should be used
|
15
|
-
# for a resque worker.
|
16
|
-
def redis_key(*args)
|
17
|
-
"extface_"
|
18
|
-
end
|
19
|
-
|
20
|
-
def can_lock_queue?(*args)
|
21
|
-
now = Time.now.to_i
|
22
|
-
key = redis_key(*args)
|
23
|
-
timeout = lock_timeout
|
24
|
-
|
25
|
-
# Per http://redis.io/commands/setnx
|
26
|
-
return true if Resque.redis.setnx(key, timeout)
|
27
|
-
return false if Resque.redis.get(key).to_i > now
|
28
|
-
return true if Resque.redis.getset(key, timeout).to_i <= now
|
29
|
-
return false
|
30
|
-
rescue ActiveRecord::RecordNotFound #redis_key exception
|
31
|
-
p "Not found!!!"
|
32
|
-
sleep 1
|
33
|
-
reenqueue(*args) #will stop if new redis_key exception
|
34
|
-
end
|
35
|
-
|
36
|
-
def unlock_queue(*args)
|
37
|
-
Resque.redis.del(redis_key(*args))
|
38
|
-
end
|
39
|
-
|
40
|
-
def reenqueue(*args)
|
41
|
-
#Resque.enqueue_to(redis_key(*args), self, *args)
|
42
|
-
Resque.redis.lpush("queue:#{Resque.queue_from_class(self)}", Resque.encode(class: self, args: args))
|
43
|
-
end
|
44
|
-
|
45
|
-
def before_perform(*args)
|
46
|
-
unless can_lock_queue?(*args)
|
47
|
-
# Sleep so the CPU's rest
|
48
|
-
sleep(requeue_interval)
|
49
|
-
|
50
|
-
# can't get the lock, so re-enqueue the task
|
51
|
-
reenqueue(*args)
|
52
|
-
|
53
|
-
# and don't perform
|
54
|
-
raise Resque::Job::DontPerform
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def around_perform(*args)
|
59
|
-
begin
|
60
|
-
yield
|
61
|
-
ensure
|
62
|
-
unlock_queue(*args)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|