billing 0.0.7 → 0.0.8a

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ad7f574f1fd705d1c3fa07c37a6d82206cebe8d
4
- data.tar.gz: d9c2f1161ef14b21b15fce52fa6befe525946cd9
3
+ metadata.gz: 72e0f8705a8e02564bb5fe4c63c6983a8ccf537a
4
+ data.tar.gz: 3862882f2315d1b8268af66f3ce9c02b188ebf7b
5
5
  SHA512:
6
- metadata.gz: 59892ba7beb3905f859f85f4c564191c0e85ac59c2cc48486f6077653f9e8881c10bba5ff39e6242ac6768e978b8de4663cad0f27f0e2c4058643ec398c77dc7
7
- data.tar.gz: df3c4069cc8a8cb59d6439fb9daf72fa9cbba6889c02c375dc7dc9d264781ff1ce614d3056896942fdbaebcb4c885109c8a789dfb7919f3e2a8cb551224a0497
6
+ metadata.gz: 424e3fde6c0dd2685c5791a328a50a608f08bc226885521a3342cdadcb316211c78cc86f20249b9921e620fabe792f1e776049df4844e91f71c9bdfee25bac0c
7
+ data.tar.gz: d7b7a374bd2b740b276e4b37cb5a2b3f803c4a5e43725ec8e14421ff9b9b72279ab737debfefbc8ccad93edd502dbe51b0b4d3b114bbcec3671ac74c937c062b
@@ -0,0 +1,67 @@
1
+ require 'rescue/plugins/extface_lonely_device'
2
+
3
+ module Billing
4
+ class IssueFiscalDoc
5
+ extend Resque::Plugins::ExtfaceLonelyDevice
6
+
7
+ def self.redis_key(bill_id)
8
+ "extface_#{Bill.find(bill_id).extface_job.device_id}"
9
+ end
10
+
11
+ def self.perform(bill_id)
12
+ bill = Bill.find(bill_id)
13
+ qname = "extface_#{bill.extface_job.device_id}"
14
+ wjs = Resque::Worker.working.find_all{ |w| w.job && w.job['queue'] == qname }
15
+
16
+ p "############################"
17
+ p "d: #{bill.extface_job.device_id} Issue Fiscal Doc ##{bill_id}, job: #{bill.extface_job_id}, wjs: #{wjs.inspect}"
18
+ p "____________________________"
19
+ p "active jobs: #{bill.extface_job.device.jobs.active.count}"
20
+
21
+
22
+ bill.extface_job.runtime do |s|
23
+ return unless bill.fiscalizable?
24
+ operator_mapping = bill.find_operator_mapping_for(s)
25
+ s.notify "Fiscal Doc Start"
26
+ s.autofix_unclosed_doc
27
+ s.open_fiscal_doc(operator_mapping.try(:mapping), operator_mapping.try(:pwd))
28
+ s.notify "Register Sale"
29
+ bill.charges.each do |charge|
30
+ neto, percent_ratio = nil, nil, nil
31
+ if modifier = charge.modifier
32
+ neto = modifier.fixed_value
33
+ percent_ratio = modifier.percent_ratio unless neto.present?
34
+ end
35
+ if charge.price.zero? #printing comments with zero charges (TODO check zero charges allowed?)
36
+ s.add_comment charge.text
37
+ else
38
+ s.add_sale(
39
+ s.class::SaleItem.new(
40
+ price: charge.price.to_f,
41
+ text1: charge.name,
42
+ text2: charge.description,
43
+ tax_group: charge.find_tax_group_mapping_for(s), #find tax group mapping by ratio , not nice
44
+ qty: charge.qty,
45
+ neto: neto,
46
+ percent_ratio: percent_ratio #TODO check format
47
+ )
48
+ )
49
+ end
50
+ end
51
+ if global_modifier_value = bill.global_modifier_value
52
+ s.notify "Register Global Modifier"
53
+ s.add_total_modifier global_modifier_value.to_f
54
+ end
55
+ s.notify "Register Payment"
56
+ bill.payments.each do |payment|
57
+ s.add_payment payment.value.to_f, payment.find_payment_type_mapping_for(s)
58
+ end
59
+ s.notify "Close Fiscal Receipt"
60
+ s.close_fiscal_doc
61
+ s.notify "Fiscal Doc End"
62
+ end
63
+ rescue Resque::TermException
64
+ reenqueue(bill_id)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,53 @@
1
+ require 'rescue/plugins/extface_lonely_device'
2
+
3
+ module Billing
4
+ class IssuePrintDoc
5
+ extend Resque::Plugins::ExtfaceLonelyDevice
6
+
7
+ def self.redis_key(bill_id)
8
+ "extface_#{Bill.find(bill_id).print_job.device_id}"
9
+ end
10
+
11
+ def self.perform(bill_id)
12
+ bill = Bill.find(bill_id)
13
+ qname = "extface_#{bill.print_job.device_id}"
14
+ wjs = Resque::Worker.working.find_all{ |w| w.job && w.job['queue'] == qname }
15
+
16
+ p "############################"
17
+ p "d: #{bill.print_job.device_id} Issue Print Doc ##{bill_id}, job: #{bill.print_job_id}, wjs: #{wjs.inspect}"
18
+ p "____________________________"
19
+ p "active jobs: #{bill.print_job.device.jobs.active.count}"
20
+
21
+
22
+ bill.print_job.runtime do |s|
23
+ return unless bill.printable?
24
+ s.notify "Print Doc Start"
25
+
26
+ s.print bill.origin.print_header
27
+ s.print "\r\n ****** \r\n"
28
+ s.print "#{bill.name}".truncate(30)
29
+ s.print "\r\n------------------------------\r\n"
30
+
31
+ bill.charges.each do |charge|
32
+ s.print "#{charge.name.ljust(22)} #{charge.value.to_s.rjust(7)}\r\n"
33
+ end
34
+ s.print "-----------\r\n".rjust(32)
35
+ s.print "#{bill.total}\r\n".rjust(32)
36
+
37
+ # s.print "..............................\r\n"
38
+ # bill.payments.each do |payment|
39
+ # s.print "#{payment.payment_type.name.humanize}\r\n"
40
+ # end
41
+
42
+ s.print " ****** \r\n"
43
+ s.print bill.origin.print_footer
44
+ s.print "\r\n------------------------------\r\n"
45
+ s.print Time.now.strftime("Printed on %m/%d/%Y %T\r\n").rjust(32)
46
+ s.print "\r\n\r\n\r\n"
47
+ s.notify "Print Doc End"
48
+ end
49
+ rescue Resque::TermException
50
+ reenqueue(bill_id)
51
+ end
52
+ end
53
+ end
@@ -19,6 +19,7 @@ module Billing
19
19
 
20
20
  if defined? Extface
21
21
  belongs_to :extface_job, class_name: 'Extface::Job'
22
+ belongs_to :print_job, class_name: 'Extface::Job'
22
23
  end
23
24
 
24
25
  accepts_nested_attributes_for :charges, :modifiers, :payments
@@ -39,6 +40,8 @@ module Billing
39
40
  self.name = "B:#{number}" if name.nil?
40
41
  end
41
42
  before_save :perform_autofin, if: :becomes_paid?
43
+ after_save :create_fiscal_job, if: :fiscalizable?
44
+ after_save :create_print_job, if: :printable?
42
45
 
43
46
  validates_numericality_of :total, greater_than_or_equal_to: 0
44
47
  validates_numericality_of :balance, less_than_or_equal_to: 0
@@ -89,17 +92,24 @@ module Billing
89
92
  end
90
93
 
91
94
  def fiscalize(detailed = false)
92
- self.extface_job = origin.fiscal_device.driver.fiscalize(self, detailed) if fiscalizable? && origin.try(:fiscal_device)
93
- self.extface_job if save
95
+ #TODO create resque job
96
+ #self.extface_job = origin.fiscal_device.driver.fiscalize(self, detailed) if fiscalizable? && origin.try(:fiscal_device)
97
+ #self.extface_job if save
98
+ if defined?(Extface) && fiscalizable? && device = origin.try(:fiscal_device)
99
+ #self.extface_job = origin.fiscal_device.driver.fiscalize(self) if fiscalizable? && origin.try(:fiscal_device)
100
+ self.extface_job = device.jobs.new
101
+ self.extface_job if save
102
+ end
94
103
  end
95
104
 
96
105
  def global_modifier_value
97
- if global_modifiers = modifiers.select{ |m| m.charge.nil? }
98
- Money.new(0).tap() do |value|
99
- global_modifiers.each do |global_modifier|
100
- value += global_modifier.percent_ratio.nil? ? global_modifier.fixed_value : (charges_a.sum(&:value).to_money * global_modifier.percent_ratio)
101
- end
102
- end if global_modifiers.any?
106
+ global_modifiers = modifiers.select{ |m| m.charge.nil? }
107
+ if global_modifiers.any?
108
+ gvalue = Money.new(0)
109
+ global_modifiers.each do |global_modifier|
110
+ gvalue += global_modifier.percent_ratio.nil? ? global_modifier.fixed_value : (charges_a.sum(&:value).to_money * global_modifier.percent_ratio)
111
+ end
112
+ return gvalue
103
113
  end
104
114
  end
105
115
 
@@ -107,6 +117,14 @@ module Billing
107
117
  # get operator, who close/pay the bill?
108
118
  #operator.operator_fiscal_driver_mapping.find_by(extface_driver_id: fiscal_driver.id) if fiscal_driver.fiscal?
109
119
  end
120
+
121
+ def fiscalizable?
122
+ self.finalized_at.present? && payments.select(&:fiscal?).any? && origin.try(:fiscal_device) && balance.zero?
123
+ end
124
+
125
+ def printable?
126
+ origin.print_device.present?
127
+ end
110
128
 
111
129
  private
112
130
  def calculate_modifiers
@@ -152,18 +170,39 @@ module Billing
152
170
  end
153
171
 
154
172
  def perform_autofin
173
+ p "!!!!!!!!!!perform_autofin"
155
174
  if autofin
156
175
  self.finalized_at = Time.now
157
- if defined? Extface
158
- self.extface_job = origin.fiscal_device.driver.fiscalize(self) if fiscalizable? && origin.try(:fiscal_device)
176
+ if defined?(Extface) && fiscalizable? && device = origin.try(:fiscal_device)
177
+ #self.extface_job = origin.fiscal_device.driver.fiscalize(self) if fiscalizable? && origin.try(:fiscal_device)
178
+ self.extface_job = device.jobs.new
179
+ end
180
+ if defined?(Extface) && printable? && print_device = origin.try(:print_device)
181
+ #self.extface_job = origin.fiscal_device.driver.fiscalize(self) if fiscalizable? && origin.try(:fiscal_device)
182
+ self.print_job = print_device.jobs.new
159
183
  end
160
184
  end
161
185
  true
162
186
  end
163
187
 
164
- def fiscalizable?
165
- payments.select(&:fiscal?).any?
188
+ def create_fiscal_job
189
+ if self.extface_job_id_changed? && defined?(Resque) && defined?(Extface) && device = origin.try(:fiscal_device)
190
+ p "device: #{device.try(:id)}"
191
+ p "self: #{self.try(:id)}"
192
+ p "self.finalized_at changed: #{self.finalized_at_changed?}"
193
+
194
+ Resque.enqueue_to("extface_#{device.id}", Billing::IssueFiscalDoc, self.id)
195
+ end
196
+ true
166
197
  end
167
198
 
199
+ def create_print_job
200
+ if self.print_job_id_changed? && defined?(Resque) && defined?(Extface) && print_device = origin.try(:print_device)
201
+ p "################ vprint device: #{print_device.try(:id)}"
202
+ p "self: #{self.try(:id)}"
203
+ Resque.enqueue_to("extface_#{print_device.id}", Billing::IssuePrintDoc, self.id)
204
+ end
205
+ true
206
+ end
168
207
  end
169
208
  end
@@ -6,6 +6,7 @@ module Billing
6
6
  if defined? Extface
7
7
  belongs_to :fiscal_device, ->(o) { where( extfaceable_id: o.master_id ) }, class_name: 'Extface::Device'
8
8
  belongs_to :transfer_device, ->(o) { where( extfaceable_id: o.master_id ) }, class_name: 'Extface::Device'
9
+ belongs_to :print_device, ->(o) { where( extfaceable_id: o.master_id ) }, class_name: 'Extface::Device'
9
10
  end
10
11
 
11
12
  validates_presence_of :name
@@ -5,7 +5,8 @@ module Billing
5
5
  FISCAL_PERIOD_REPORT = 'period_report'.freeze
6
6
  FISCAL_PAYED_RECVD = 'payed_recvd'.freeze
7
7
  F_OPERATIONS = [FISCAL_X_REPORT, FISCAL_Z_REPORT, FISCAL_PERIOD_REPORT, FISCAL_PAYED_RECVD].freeze
8
-
8
+
9
+ acts_as_paranoid if respond_to?(:acts_as_paranoid)
9
10
  has_paper_trail class_name: 'Billing::Version'
10
11
  belongs_to :origin, inverse_of: :reports
11
12
  has_many :bills, inverse_of: :report, autosave: true
@@ -1,5 +1,7 @@
1
1
  module Billing
2
2
  class Version < PaperTrail::Version
3
3
  self.table_name = :billing_versions
4
+
5
+ belongs_to :changable, -> { with_deleted }, polymorphic: true, foreign_key: :item_id, foreign_type: :item_type
4
6
  end
5
7
  end
@@ -0,0 +1,6 @@
1
+ class AddMasterToBillingVersion < ActiveRecord::Migration
2
+ def change
3
+ add_column :billing_versions, :master_id, :integer
4
+ add_column :billing_versions, :master_type, :string
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddDeletedAtToBillingReport < ActiveRecord::Migration
2
+ def change
3
+ add_column :billing_reports, :deleted_at, :timestamp
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddPrintDeviceToBillingOrigin < ActiveRecord::Migration
2
+ def change
3
+ add_column :billing_origins, :print_device_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddPrintJobToBillingBill < ActiveRecord::Migration
2
+ def change
3
+ add_column :billing_bills, :print_job_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddPrintHeadersToBillingOrigin < ActiveRecord::Migration
2
+ def change
3
+ add_column :billing_origins, :print_header, :string
4
+ add_column :billing_origins, :print_footer, :string
5
+ end
6
+ end
@@ -6,5 +6,10 @@ require 'collection_proxy_wild'
6
6
  module Billing
7
7
  class Engine < ::Rails::Engine
8
8
  isolate_namespace Billing
9
+ config.to_prepare do
10
+ PaperTrail::Version.module_eval do
11
+ self.abstract_class = true
12
+ end
13
+ end
9
14
  end
10
15
  end
@@ -1,3 +1,3 @@
1
1
  module Billing
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8a"
3
3
  end
@@ -0,0 +1,67 @@
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
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20150510142229) do
14
+ ActiveRecord::Schema.define(version: 20150512040421) do
15
15
 
16
16
  create_table "billing_bills", force: :cascade do |t|
17
17
  t.integer "billable_id"
@@ -231,6 +231,7 @@ ActiveRecord::Schema.define(version: 20150510142229) do
231
231
  t.string "f_operation", limit: 255
232
232
  t.integer "f_amount_cents", default: 0, null: false
233
233
  t.string "f_amount_currency", limit: 255, default: "USD", null: false
234
+ t.datetime "deleted_at"
234
235
  end
235
236
 
236
237
  add_index "billing_reports", ["origin_id"], name: "index_billing_reports_on_origin_id"
@@ -279,6 +280,8 @@ ActiveRecord::Schema.define(version: 20150510142229) do
279
280
  t.string "ip", limit: 255
280
281
  t.string "user_agent", limit: 255
281
282
  t.text "object_changes"
283
+ t.integer "master_id"
284
+ t.string "master_type"
282
285
  end
283
286
 
284
287
  add_index "billing_versions", ["item_type", "item_id"], name: "index_billing_versions_on_item_type_and_item_id"
@@ -2331,3 +2331,482 @@ Migrating to AddObjectChangesToBillingVersions (20150510142229)
2331
2331
  FROM sqlite_temp_master
2332
2332
  WHERE name='index_billing_versions_on_item_type_and_item_id' AND type='index'
2333
2333
  
2334
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
2335
+ Migrating to AddMasterToBillingVersion (20150510235441)
2336
+  (0.1ms) begin transaction
2337
+  (0.5ms) ALTER TABLE "billing_versions" ADD "master_id" integer
2338
+  (0.3ms) ALTER TABLE "billing_versions" ADD "master_type" varchar
2339
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150510235441"]]
2340
+  (82.0ms) commit transaction
2341
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
2342
+  (0.3ms) SELECT sql
2343
+ FROM sqlite_master
2344
+ WHERE name='index_billing_bills_on_billable_id_and_billable_type' AND type='index'
2345
+ UNION ALL
2346
+ SELECT sql
2347
+ FROM sqlite_temp_master
2348
+ WHERE name='index_billing_bills_on_billable_id_and_billable_type' AND type='index'
2349
+
2350
+  (0.2ms)  SELECT sql
2351
+ FROM sqlite_master
2352
+ WHERE name='index_billing_bills_on_origin_id' AND type='index'
2353
+ UNION ALL
2354
+ SELECT sql
2355
+ FROM sqlite_temp_master
2356
+ WHERE name='index_billing_bills_on_origin_id' AND type='index'
2357
+ 
2358
+  (0.2ms) SELECT sql
2359
+ FROM sqlite_master
2360
+ WHERE name='index_billing_bills_on_extface_job_id' AND type='index'
2361
+ UNION ALL
2362
+ SELECT sql
2363
+ FROM sqlite_temp_master
2364
+ WHERE name='index_billing_bills_on_extface_job_id' AND type='index'
2365
+
2366
+  (0.2ms)  SELECT sql
2367
+ FROM sqlite_master
2368
+ WHERE name='index_billing_bills_on_report_id' AND type='index'
2369
+ UNION ALL
2370
+ SELECT sql
2371
+ FROM sqlite_temp_master
2372
+ WHERE name='index_billing_bills_on_report_id' AND type='index'
2373
+ 
2374
+  (0.2ms) SELECT sql
2375
+ FROM sqlite_master
2376
+ WHERE name='index_billing_charges_on_bill_id' AND type='index'
2377
+ UNION ALL
2378
+ SELECT sql
2379
+ FROM sqlite_temp_master
2380
+ WHERE name='index_billing_charges_on_bill_id' AND type='index'
2381
+
2382
+  (0.2ms)  SELECT sql
2383
+ FROM sqlite_master
2384
+ WHERE name='index_billing_charges_on_revenue_at' AND type='index'
2385
+ UNION ALL
2386
+ SELECT sql
2387
+ FROM sqlite_temp_master
2388
+ WHERE name='index_billing_charges_on_revenue_at' AND type='index'
2389
+ 
2390
+  (0.2ms) SELECT sql
2391
+ FROM sqlite_master
2392
+ WHERE name='index_billing_charges_on_deleted_at' AND type='index'
2393
+ UNION ALL
2394
+ SELECT sql
2395
+ FROM sqlite_temp_master
2396
+ WHERE name='index_billing_charges_on_deleted_at' AND type='index'
2397
+
2398
+  (0.2ms)  SELECT sql
2399
+ FROM sqlite_master
2400
+ WHERE name='index_billing_charges_on_origin_id' AND type='index'
2401
+ UNION ALL
2402
+ SELECT sql
2403
+ FROM sqlite_temp_master
2404
+ WHERE name='index_billing_charges_on_origin_id' AND type='index'
2405
+ 
2406
+  (0.2ms) SELECT sql
2407
+ FROM sqlite_master
2408
+ WHERE name='index_billing_charges_on_chargable_id_and_chargable_type' AND type='index'
2409
+ UNION ALL
2410
+ SELECT sql
2411
+ FROM sqlite_temp_master
2412
+ WHERE name='index_billing_charges_on_chargable_id_and_chargable_type' AND type='index'
2413
+
2414
+  (0.2ms)  SELECT sql
2415
+ FROM sqlite_master
2416
+ WHERE name='index_billing_departments_on_deleted_at' AND type='index'
2417
+ UNION ALL
2418
+ SELECT sql
2419
+ FROM sqlite_temp_master
2420
+ WHERE name='index_billing_departments_on_deleted_at' AND type='index'
2421
+ 
2422
+  (0.2ms) SELECT sql
2423
+ FROM sqlite_master
2424
+ WHERE name='index_billing_departments_on_tax_group_id' AND type='index'
2425
+ UNION ALL
2426
+ SELECT sql
2427
+ FROM sqlite_temp_master
2428
+ WHERE name='index_billing_departments_on_tax_group_id' AND type='index'
2429
+
2430
+  (0.2ms)  SELECT sql
2431
+ FROM sqlite_master
2432
+ WHERE name='index_billing_modifiers_on_bill_id' AND type='index'
2433
+ UNION ALL
2434
+ SELECT sql
2435
+ FROM sqlite_temp_master
2436
+ WHERE name='index_billing_modifiers_on_bill_id' AND type='index'
2437
+ 
2438
+  (0.2ms) SELECT sql
2439
+ FROM sqlite_master
2440
+ WHERE name='index_billing_op_fp_mappings_on_operator_id' AND type='index'
2441
+ UNION ALL
2442
+ SELECT sql
2443
+ FROM sqlite_temp_master
2444
+ WHERE name='index_billing_op_fp_mappings_on_operator_id' AND type='index'
2445
+
2446
+  (0.2ms)  SELECT sql
2447
+ FROM sqlite_master
2448
+ WHERE name='index_billing_op_fp_mappings_on_extface_driver_id' AND type='index'
2449
+ UNION ALL
2450
+ SELECT sql
2451
+ FROM sqlite_temp_master
2452
+ WHERE name='index_billing_op_fp_mappings_on_extface_driver_id' AND type='index'
2453
+ 
2454
+  (0.2ms) SELECT sql
2455
+ FROM sqlite_master
2456
+ WHERE name='index_billing_operators_on_deleted_at' AND type='index'
2457
+ UNION ALL
2458
+ SELECT sql
2459
+ FROM sqlite_temp_master
2460
+ WHERE name='index_billing_operators_on_deleted_at' AND type='index'
2461
+
2462
+  (0.2ms)  SELECT sql
2463
+ FROM sqlite_master
2464
+ WHERE name='index_billing_origins_on_transfer_device_id' AND type='index'
2465
+ UNION ALL
2466
+ SELECT sql
2467
+ FROM sqlite_temp_master
2468
+ WHERE name='index_billing_origins_on_transfer_device_id' AND type='index'
2469
+ 
2470
+  (0.2ms) SELECT sql
2471
+ FROM sqlite_master
2472
+ WHERE name='index_billing_origins_on_deleted_at' AND type='index'
2473
+ UNION ALL
2474
+ SELECT sql
2475
+ FROM sqlite_temp_master
2476
+ WHERE name='index_billing_origins_on_deleted_at' AND type='index'
2477
+
2478
+  (0.2ms)  SELECT sql
2479
+ FROM sqlite_master
2480
+ WHERE name='index_billing_origins_on_fiscal_device_id' AND type='index'
2481
+ UNION ALL
2482
+ SELECT sql
2483
+ FROM sqlite_temp_master
2484
+ WHERE name='index_billing_origins_on_fiscal_device_id' AND type='index'
2485
+ 
2486
+  (0.2ms) SELECT sql
2487
+ FROM sqlite_master
2488
+ WHERE name='index_billing_payment_types_on_deleted_at' AND type='index'
2489
+ UNION ALL
2490
+ SELECT sql
2491
+ FROM sqlite_temp_master
2492
+ WHERE name='index_billing_payment_types_on_deleted_at' AND type='index'
2493
+
2494
+  (0.2ms)  SELECT sql
2495
+ FROM sqlite_master
2496
+ WHERE name='index_billing_payments_on_bill_id' AND type='index'
2497
+ UNION ALL
2498
+ SELECT sql
2499
+ FROM sqlite_temp_master
2500
+ WHERE name='index_billing_payments_on_bill_id' AND type='index'
2501
+ 
2502
+  (0.2ms) SELECT sql
2503
+ FROM sqlite_master
2504
+ WHERE name='index_billing_payments_on_deleted_at' AND type='index'
2505
+ UNION ALL
2506
+ SELECT sql
2507
+ FROM sqlite_temp_master
2508
+ WHERE name='index_billing_payments_on_deleted_at' AND type='index'
2509
+
2510
+  (0.2ms)  SELECT sql
2511
+ FROM sqlite_master
2512
+ WHERE name='index_billing_plus_on_department_id' AND type='index'
2513
+ UNION ALL
2514
+ SELECT sql
2515
+ FROM sqlite_temp_master
2516
+ WHERE name='index_billing_plus_on_department_id' AND type='index'
2517
+ 
2518
+  (0.2ms) SELECT sql
2519
+ FROM sqlite_master
2520
+ WHERE name='index_billing_plus_on_tax_group_id' AND type='index'
2521
+ UNION ALL
2522
+ SELECT sql
2523
+ FROM sqlite_temp_master
2524
+ WHERE name='index_billing_plus_on_tax_group_id' AND type='index'
2525
+
2526
+  (0.2ms)  SELECT sql
2527
+ FROM sqlite_master
2528
+ WHERE name='index_billing_pt_fp_mappings_on_payment_type_id' AND type='index'
2529
+ UNION ALL
2530
+ SELECT sql
2531
+ FROM sqlite_temp_master
2532
+ WHERE name='index_billing_pt_fp_mappings_on_payment_type_id' AND type='index'
2533
+ 
2534
+  (0.2ms) SELECT sql
2535
+ FROM sqlite_master
2536
+ WHERE name='index_billing_pt_fp_mappings_on_extface_driver_id' AND type='index'
2537
+ UNION ALL
2538
+ SELECT sql
2539
+ FROM sqlite_temp_master
2540
+ WHERE name='index_billing_pt_fp_mappings_on_extface_driver_id' AND type='index'
2541
+
2542
+  (0.2ms)  SELECT sql
2543
+ FROM sqlite_master
2544
+ WHERE name='index_billing_reports_on_origin_id' AND type='index'
2545
+ UNION ALL
2546
+ SELECT sql
2547
+ FROM sqlite_temp_master
2548
+ WHERE name='index_billing_reports_on_origin_id' AND type='index'
2549
+ 
2550
+  (0.2ms) SELECT sql
2551
+ FROM sqlite_master
2552
+ WHERE name='index_billing_tg_fp_mappings_on_tax_group_id' AND type='index'
2553
+ UNION ALL
2554
+ SELECT sql
2555
+ FROM sqlite_temp_master
2556
+ WHERE name='index_billing_tg_fp_mappings_on_tax_group_id' AND type='index'
2557
+
2558
+  (0.2ms)  SELECT sql
2559
+ FROM sqlite_master
2560
+ WHERE name='index_billing_tg_fp_mappings_on_extface_driver_id' AND type='index'
2561
+ UNION ALL
2562
+ SELECT sql
2563
+ FROM sqlite_temp_master
2564
+ WHERE name='index_billing_tg_fp_mappings_on_extface_driver_id' AND type='index'
2565
+ 
2566
+  (0.2ms) SELECT sql
2567
+ FROM sqlite_master
2568
+ WHERE name='index_billing_versions_on_item_type_and_item_id' AND type='index'
2569
+ UNION ALL
2570
+ SELECT sql
2571
+ FROM sqlite_temp_master
2572
+ WHERE name='index_billing_versions_on_item_type_and_item_id' AND type='index'
2573
+
2574
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
2575
+ Migrating to AddDeletedAtToBillingReport (20150512040421)
2576
+  (0.1ms) begin transaction
2577
+  (0.6ms) ALTER TABLE "billing_reports" ADD "deleted_at" datetime
2578
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20150512040421"]]
2579
+  (114.6ms) commit transaction
2580
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
2581
+  (0.3ms)  SELECT sql
2582
+ FROM sqlite_master
2583
+ WHERE name='index_billing_bills_on_billable_id_and_billable_type' AND type='index'
2584
+ UNION ALL
2585
+ SELECT sql
2586
+ FROM sqlite_temp_master
2587
+ WHERE name='index_billing_bills_on_billable_id_and_billable_type' AND type='index'
2588
+ 
2589
+  (0.3ms) SELECT sql
2590
+ FROM sqlite_master
2591
+ WHERE name='index_billing_bills_on_origin_id' AND type='index'
2592
+ UNION ALL
2593
+ SELECT sql
2594
+ FROM sqlite_temp_master
2595
+ WHERE name='index_billing_bills_on_origin_id' AND type='index'
2596
+
2597
+  (0.2ms)  SELECT sql
2598
+ FROM sqlite_master
2599
+ WHERE name='index_billing_bills_on_extface_job_id' AND type='index'
2600
+ UNION ALL
2601
+ SELECT sql
2602
+ FROM sqlite_temp_master
2603
+ WHERE name='index_billing_bills_on_extface_job_id' AND type='index'
2604
+ 
2605
+  (0.2ms) SELECT sql
2606
+ FROM sqlite_master
2607
+ WHERE name='index_billing_bills_on_report_id' AND type='index'
2608
+ UNION ALL
2609
+ SELECT sql
2610
+ FROM sqlite_temp_master
2611
+ WHERE name='index_billing_bills_on_report_id' AND type='index'
2612
+
2613
+  (0.2ms)  SELECT sql
2614
+ FROM sqlite_master
2615
+ WHERE name='index_billing_charges_on_bill_id' AND type='index'
2616
+ UNION ALL
2617
+ SELECT sql
2618
+ FROM sqlite_temp_master
2619
+ WHERE name='index_billing_charges_on_bill_id' AND type='index'
2620
+ 
2621
+  (0.2ms) SELECT sql
2622
+ FROM sqlite_master
2623
+ WHERE name='index_billing_charges_on_revenue_at' AND type='index'
2624
+ UNION ALL
2625
+ SELECT sql
2626
+ FROM sqlite_temp_master
2627
+ WHERE name='index_billing_charges_on_revenue_at' AND type='index'
2628
+
2629
+  (0.2ms)  SELECT sql
2630
+ FROM sqlite_master
2631
+ WHERE name='index_billing_charges_on_deleted_at' AND type='index'
2632
+ UNION ALL
2633
+ SELECT sql
2634
+ FROM sqlite_temp_master
2635
+ WHERE name='index_billing_charges_on_deleted_at' AND type='index'
2636
+ 
2637
+  (0.2ms) SELECT sql
2638
+ FROM sqlite_master
2639
+ WHERE name='index_billing_charges_on_origin_id' AND type='index'
2640
+ UNION ALL
2641
+ SELECT sql
2642
+ FROM sqlite_temp_master
2643
+ WHERE name='index_billing_charges_on_origin_id' AND type='index'
2644
+
2645
+  (0.2ms)  SELECT sql
2646
+ FROM sqlite_master
2647
+ WHERE name='index_billing_charges_on_chargable_id_and_chargable_type' AND type='index'
2648
+ UNION ALL
2649
+ SELECT sql
2650
+ FROM sqlite_temp_master
2651
+ WHERE name='index_billing_charges_on_chargable_id_and_chargable_type' AND type='index'
2652
+ 
2653
+  (0.2ms) SELECT sql
2654
+ FROM sqlite_master
2655
+ WHERE name='index_billing_departments_on_deleted_at' AND type='index'
2656
+ UNION ALL
2657
+ SELECT sql
2658
+ FROM sqlite_temp_master
2659
+ WHERE name='index_billing_departments_on_deleted_at' AND type='index'
2660
+
2661
+  (0.2ms)  SELECT sql
2662
+ FROM sqlite_master
2663
+ WHERE name='index_billing_departments_on_tax_group_id' AND type='index'
2664
+ UNION ALL
2665
+ SELECT sql
2666
+ FROM sqlite_temp_master
2667
+ WHERE name='index_billing_departments_on_tax_group_id' AND type='index'
2668
+ 
2669
+  (0.2ms) SELECT sql
2670
+ FROM sqlite_master
2671
+ WHERE name='index_billing_modifiers_on_bill_id' AND type='index'
2672
+ UNION ALL
2673
+ SELECT sql
2674
+ FROM sqlite_temp_master
2675
+ WHERE name='index_billing_modifiers_on_bill_id' AND type='index'
2676
+
2677
+  (0.2ms)  SELECT sql
2678
+ FROM sqlite_master
2679
+ WHERE name='index_billing_op_fp_mappings_on_operator_id' AND type='index'
2680
+ UNION ALL
2681
+ SELECT sql
2682
+ FROM sqlite_temp_master
2683
+ WHERE name='index_billing_op_fp_mappings_on_operator_id' AND type='index'
2684
+ 
2685
+  (0.2ms) SELECT sql
2686
+ FROM sqlite_master
2687
+ WHERE name='index_billing_op_fp_mappings_on_extface_driver_id' AND type='index'
2688
+ UNION ALL
2689
+ SELECT sql
2690
+ FROM sqlite_temp_master
2691
+ WHERE name='index_billing_op_fp_mappings_on_extface_driver_id' AND type='index'
2692
+
2693
+  (0.2ms)  SELECT sql
2694
+ FROM sqlite_master
2695
+ WHERE name='index_billing_operators_on_deleted_at' AND type='index'
2696
+ UNION ALL
2697
+ SELECT sql
2698
+ FROM sqlite_temp_master
2699
+ WHERE name='index_billing_operators_on_deleted_at' AND type='index'
2700
+ 
2701
+  (0.2ms) SELECT sql
2702
+ FROM sqlite_master
2703
+ WHERE name='index_billing_origins_on_transfer_device_id' AND type='index'
2704
+ UNION ALL
2705
+ SELECT sql
2706
+ FROM sqlite_temp_master
2707
+ WHERE name='index_billing_origins_on_transfer_device_id' AND type='index'
2708
+
2709
+  (0.2ms)  SELECT sql
2710
+ FROM sqlite_master
2711
+ WHERE name='index_billing_origins_on_deleted_at' AND type='index'
2712
+ UNION ALL
2713
+ SELECT sql
2714
+ FROM sqlite_temp_master
2715
+ WHERE name='index_billing_origins_on_deleted_at' AND type='index'
2716
+ 
2717
+  (0.2ms) SELECT sql
2718
+ FROM sqlite_master
2719
+ WHERE name='index_billing_origins_on_fiscal_device_id' AND type='index'
2720
+ UNION ALL
2721
+ SELECT sql
2722
+ FROM sqlite_temp_master
2723
+ WHERE name='index_billing_origins_on_fiscal_device_id' AND type='index'
2724
+
2725
+  (0.2ms)  SELECT sql
2726
+ FROM sqlite_master
2727
+ WHERE name='index_billing_payment_types_on_deleted_at' AND type='index'
2728
+ UNION ALL
2729
+ SELECT sql
2730
+ FROM sqlite_temp_master
2731
+ WHERE name='index_billing_payment_types_on_deleted_at' AND type='index'
2732
+ 
2733
+  (0.2ms) SELECT sql
2734
+ FROM sqlite_master
2735
+ WHERE name='index_billing_payments_on_bill_id' AND type='index'
2736
+ UNION ALL
2737
+ SELECT sql
2738
+ FROM sqlite_temp_master
2739
+ WHERE name='index_billing_payments_on_bill_id' AND type='index'
2740
+
2741
+  (0.2ms)  SELECT sql
2742
+ FROM sqlite_master
2743
+ WHERE name='index_billing_payments_on_deleted_at' AND type='index'
2744
+ UNION ALL
2745
+ SELECT sql
2746
+ FROM sqlite_temp_master
2747
+ WHERE name='index_billing_payments_on_deleted_at' AND type='index'
2748
+ 
2749
+  (0.2ms) SELECT sql
2750
+ FROM sqlite_master
2751
+ WHERE name='index_billing_plus_on_department_id' AND type='index'
2752
+ UNION ALL
2753
+ SELECT sql
2754
+ FROM sqlite_temp_master
2755
+ WHERE name='index_billing_plus_on_department_id' AND type='index'
2756
+
2757
+  (0.2ms)  SELECT sql
2758
+ FROM sqlite_master
2759
+ WHERE name='index_billing_plus_on_tax_group_id' AND type='index'
2760
+ UNION ALL
2761
+ SELECT sql
2762
+ FROM sqlite_temp_master
2763
+ WHERE name='index_billing_plus_on_tax_group_id' AND type='index'
2764
+ 
2765
+  (0.2ms) SELECT sql
2766
+ FROM sqlite_master
2767
+ WHERE name='index_billing_pt_fp_mappings_on_payment_type_id' AND type='index'
2768
+ UNION ALL
2769
+ SELECT sql
2770
+ FROM sqlite_temp_master
2771
+ WHERE name='index_billing_pt_fp_mappings_on_payment_type_id' AND type='index'
2772
+
2773
+  (0.2ms)  SELECT sql
2774
+ FROM sqlite_master
2775
+ WHERE name='index_billing_pt_fp_mappings_on_extface_driver_id' AND type='index'
2776
+ UNION ALL
2777
+ SELECT sql
2778
+ FROM sqlite_temp_master
2779
+ WHERE name='index_billing_pt_fp_mappings_on_extface_driver_id' AND type='index'
2780
+ 
2781
+  (0.2ms) SELECT sql
2782
+ FROM sqlite_master
2783
+ WHERE name='index_billing_reports_on_origin_id' AND type='index'
2784
+ UNION ALL
2785
+ SELECT sql
2786
+ FROM sqlite_temp_master
2787
+ WHERE name='index_billing_reports_on_origin_id' AND type='index'
2788
+
2789
+  (0.2ms)  SELECT sql
2790
+ FROM sqlite_master
2791
+ WHERE name='index_billing_tg_fp_mappings_on_tax_group_id' AND type='index'
2792
+ UNION ALL
2793
+ SELECT sql
2794
+ FROM sqlite_temp_master
2795
+ WHERE name='index_billing_tg_fp_mappings_on_tax_group_id' AND type='index'
2796
+ 
2797
+  (0.2ms) SELECT sql
2798
+ FROM sqlite_master
2799
+ WHERE name='index_billing_tg_fp_mappings_on_extface_driver_id' AND type='index'
2800
+ UNION ALL
2801
+ SELECT sql
2802
+ FROM sqlite_temp_master
2803
+ WHERE name='index_billing_tg_fp_mappings_on_extface_driver_id' AND type='index'
2804
+
2805
+  (0.2ms)  SELECT sql
2806
+ FROM sqlite_master
2807
+ WHERE name='index_billing_versions_on_item_type_and_item_id' AND type='index'
2808
+ UNION ALL
2809
+ SELECT sql
2810
+ FROM sqlite_temp_master
2811
+ WHERE name='index_billing_versions_on_item_type_and_item_id' AND type='index'
2812
+ 
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.7
4
+ version: 0.0.8a
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Vangelov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-10 00:00:00.000000000 Z
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: resque
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: sqlite3
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -76,6 +90,8 @@ files:
76
90
  - MIT-LICENSE
77
91
  - README.rdoc
78
92
  - Rakefile
93
+ - app/jobs/billing/issue_fiscal_doc.rb
94
+ - app/jobs/billing/issue_print_doc.rb
79
95
  - app/models/billing/bill.rb
80
96
  - app/models/billing/charge.rb
81
97
  - app/models/billing/department.rb
@@ -157,11 +173,17 @@ files:
157
173
  - db/migrate/20141229234928_create_billing_resources.rb
158
174
  - db/migrate/20150311013019_add_pwd_to_billing_operator_mapping.rb
159
175
  - db/migrate/20150510142229_add_object_changes_to_billing_versions.rb
176
+ - db/migrate/20150510235441_add_master_to_billing_version.rb
177
+ - db/migrate/20150512040421_add_deleted_at_to_billing_report.rb
178
+ - db/migrate/20160723160908_add_print_device_to_billing_origin.rb
179
+ - db/migrate/20160723234233_add_print_job_to_billing_bill.rb
180
+ - db/migrate/20160824235224_add_print_headers_to_billing_origin.rb
160
181
  - lib/billing.rb
161
182
  - lib/billing/billable.rb
162
183
  - lib/billing/engine.rb
163
184
  - lib/billing/version.rb
164
185
  - lib/collection_proxy_wild.rb
186
+ - lib/rescue/plugins/extface_lonely_device.rb
165
187
  - lib/tasks/billing.rake
166
188
  - lib/tasks/billing_tasks.rake
167
189
  - test/billing_test.rb
@@ -246,12 +268,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
246
268
  version: '0'
247
269
  required_rubygems_version: !ruby/object:Gem::Requirement
248
270
  requirements:
249
- - - ">="
271
+ - - ">"
250
272
  - !ruby/object:Gem::Version
251
- version: '0'
273
+ version: 1.3.1
252
274
  requirements: []
253
275
  rubyforge_project:
254
- rubygems_version: 2.4.6
276
+ rubygems_version: 2.5.0
255
277
  signing_key:
256
278
  specification_version: 4
257
279
  summary: Billing for Rails 4 app