billing 0.1.2 → 0.1.3

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: 9f1871d4f0eef0349654f133f1a3a8d2bf3304e9
4
- data.tar.gz: 122c98a4d1aced10bbb4b37a7f865e65862a9244
3
+ metadata.gz: 88ff829bdbd83ab185e5ca53228d2b21c617ced3
4
+ data.tar.gz: 8a1e290b31270563089268bcd39e3368641e831f
5
5
  SHA512:
6
- metadata.gz: b2e393db4785eb7932539fa2e78b57f25fd8f1cc51f3071118c561721bc7267fb8a8bc914efe83d21f6acae7699423b1d822852d4a9703ae47426e3b93d8735c
7
- data.tar.gz: 13f5133e55ffad492d4e1c7a782d18446a42ea6d392ec4d5140dad772ba6da710e8ad2d67d9145d129337c9be04d942fd3b68c65990699835472810866d21b3b
6
+ metadata.gz: 5daaed3e3b140280f2b91cdfe780350f4755e1e8f64ca3f144a910b0dd5b35afffa7add8e3bd4ef587243ee6c921e1b47a0a34fb4da8c13576b147557930a1de
7
+ data.tar.gz: 9f6946cd864e9280b30de05cac0c14654130900419dd61a42cef8f452cefed6ac9f251c956ac01fc3fb07cbaaf0a1f6f8075d0d1b566bce2ab50c8428a2b9251
@@ -22,17 +22,17 @@ module Billing
22
22
  bill.print_job.runtime do |s|
23
23
  return unless bill.printable?
24
24
  s.notify "Print Doc Start"
25
+
26
+ s.print "#{bill.origin.print_header}\r\n"
27
+ s.print_center_row "******"
28
+ s.print "#{bill.name}\r\n"
29
+ s.print_fill_row "-"
25
30
 
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
- text = "#{charge.qty ? charge.qty : 1} x #{charge.name}"
33
- s.print "\r\n#{text.truncate(22).ljust(22)} #{charge.price.to_s.rjust(7)}\r\n"
31
+ bill.charges.each_with_index do |charge, index|
32
+ s.print "\r\n" unless index == 0
33
+ s.print_text_price_row "#{charge.qty ? charge.qty : 1} x #{charge.name}", charge.price
34
34
  if charge.description
35
- s.print "#{charge.description.truncate(26)}\r\n"
35
+ s.print_ljust_row charge.description, ' ', 4
36
36
  end
37
37
  if charge.modifier.present?
38
38
  text = charge.modifier.percent_ratio.nil? ? "" : " #{charge.modifier.percentage}"
@@ -41,10 +41,10 @@ module Billing
41
41
  else
42
42
  text += " #{ bill.origin.receipt_config ? bill.origin.receipt_config.discount_text || 'Discount' : 'Discount' }"
43
43
  end
44
- s.print "#{text.ljust(22)} #{(charge.value - charge.price).to_s.rjust(7)}\r\n"
44
+ s.print_text_price_row text, (charge.value - charge.price)
45
45
  end
46
46
  end
47
- s.print "-----------\r\n".rjust(32)
47
+ s.print_rjust_row "-----------"
48
48
  if bill.modifiers.global.any?
49
49
  global_modifier = bill.modifiers.global.first
50
50
  text = global_modifier.percent_ratio.nil? ? "" : " #{global_modifier.percentage}"
@@ -53,20 +53,18 @@ module Billing
53
53
  else
54
54
  text += " #{ bill.origin.receipt_config ? bill.origin.receipt_config.discount_text || 'Discount' : 'Discount' }"
55
55
  end
56
- s.print "#{text.ljust(22)} #{bill.global_modifier_value.to_s.rjust(7)}\r\n"
56
+ s.print_text_price_row text, bill.global_modifier_value
57
57
  end
58
- s.print "TOTAL: #{bill.total.to_s.rjust(20)}\r\n"
59
-
60
- # s.print "..............................\r\n"
61
- # bill.payments.each do |payment|
62
- # s.print "#{payment.payment_type.name.humanize}\r\n"
63
- # end
58
+ s.print_text_price_row "TOTAL:", bill.total
64
59
 
65
- s.print " ****** \r\n"
66
- s.print bill.origin.print_footer
67
- s.print "\r\n------------------------------\r\n"
68
- s.print Time.now.strftime("Printed on %m/%d/%Y %T\r\n").rjust(32)
60
+ s.print_center_row "******"
61
+ s.print "#{bill.origin.print_footer}\r\n"
62
+ s.print_fill_row "-"
63
+ s.print_edges_row bill.number, Time.now.strftime("%Y-%d-%m %T")
69
64
  s.print "\r\n\r\n\r\n"
65
+ s.try :autocut if bill.origin.receipt_config.try(:paper_cut)
66
+ s.try :beep if bill.origin.receipt_config.try(:sound_signal)
67
+ s.try :pulse if bill.origin.receipt_config.try(:open_cash_drawer)
70
68
  s.notify "Print Doc End"
71
69
  end
72
70
  rescue Resque::TermException
@@ -1,5 +1,6 @@
1
1
  module Billing
2
2
  class ReceiptConfig < ActiveRecord::Base
3
- has_many :origins, inverse_of: :receipt_config
3
+ has_many :origins, inverse_of: :receipt_config, dependent: :restrict_with_exception
4
+ validates :name, presence: true, uniqueness: { scope: :master_id }
4
5
  end
5
6
  end
@@ -0,0 +1,5 @@
1
+ class AddPaperCutToBillingReceiptConfig < ActiveRecord::Migration
2
+ def change
3
+ add_column :billing_receipt_configs, :paper_cut, :boolean
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Billing
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.1.2
4
+ version: 0.1.3
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-30 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -181,6 +181,7 @@ files:
181
181
  - db/migrate/20160824235224_add_print_headers_to_billing_origin.rb
182
182
  - db/migrate/20160828145106_create_billing_receipt_configs.rb
183
183
  - db/migrate/20160828145448_add_receipt_config_to_billing_origin.rb
184
+ - db/migrate/20160831231640_add_paper_cut_to_billing_receipt_config.rb
184
185
  - lib/billing.rb
185
186
  - lib/billing/billable.rb
186
187
  - lib/billing/engine.rb