billing 0.1.0 → 0.1.1

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: 185414d1f916093119f225eb3af4509801ea0592
4
- data.tar.gz: 5a643ae84c05265e996bdcc5bbbff13f377ad2e6
3
+ metadata.gz: 5d71320db03d43f48dc3ab5a41ba771aac145534
4
+ data.tar.gz: a679fda97bcf6323af367e7638b8da7a6d9bbf28
5
5
  SHA512:
6
- metadata.gz: 8a5a448c3c5a5d3cf9b2693f84f935e603078091d8bf9d7d3d6b8f8faaccdccdcaab9fbbce9b27118b24070723aa6076b814d85df118aee22e5e6abbd339f748
7
- data.tar.gz: 90cbdd19dccc69c905cfcc1666873b0134e38a6882132350ccd9ca4cb698021c8d4a774bbeecb9856b0ea6dc372136dd98136b78d82f756064bae227a6ce5d0f
6
+ metadata.gz: 0d09060049be62c40491c79129a77289c864b519d8360d5fd198cdbb7393e6af880b40ae562db7d09492326dbd0983d39503402dc1dcf5504d99a5bf9b79bf03
7
+ data.tar.gz: 8acc69df070e7c86deda9ec883aa88cbc7213c7f8bd3e803f6d26a820a11d9998d7a032d7b95403b61adee76ce8974e4fdd454639863e54e3638a6a05e448767
@@ -30,16 +30,16 @@ module Billing
30
30
 
31
31
  bill.charges.each do |charge|
32
32
  text = "#{charge.qty ? charge.qty : 1} x #{charge.name}"
33
- s.print "\r\n#{text.ljust(22)} #{charge.price.to_s.rjust(7)}\r\n"
33
+ s.print "\r\n#{text.truncate(22).ljust(22)} #{charge.price.to_s.rjust(7)}\r\n"
34
34
  if charge.description
35
- s.print "#{charge.description.truncate(30)}\r\n"
35
+ s.print "#{charge.description.truncate(26)}\r\n"
36
36
  end
37
37
  if charge.modifier.present?
38
38
  text = charge.modifier.percent_ratio.nil? ? "" : " #{charge.modifier.percentage}"
39
39
  if charge.modifier.positive?
40
- text += " Surcharge"
40
+ text += " #{ bill.origin.receipt_config ? bill.origin.receipt_config.surcharge_text || 'Surcharge' : 'Surcharge' }"
41
41
  else
42
- text += " Discount"
42
+ text += " #{ bill.origin.receipt_config ? bill.origin.receipt_config.discount_text || 'Discount' : 'Discount' }"
43
43
  end
44
44
  s.print "#{text.ljust(22)} #{(charge.value - charge.price).to_s.rjust(7)}\r\n"
45
45
  end
@@ -49,9 +49,9 @@ module Billing
49
49
  global_modifier = bill.modifiers.global.first
50
50
  text = global_modifier.percent_ratio.nil? ? "" : " #{global_modifier.percentage}"
51
51
  if global_modifier.positive?
52
- text += " Surcharge"
52
+ text += " #{ bill.origin.receipt_config ? bill.origin.receipt_config.surcharge_text || 'Surcharge' : 'Surcharge' }"
53
53
  else
54
- text += " Discount"
54
+ text += " #{ bill.origin.receipt_config ? bill.origin.receipt_config.discount_text || 'Discount' : 'Discount' }"
55
55
  end
56
56
  s.print "#{text.ljust(22)} #{bill.global_modifier_value.to_s.rjust(7)}\r\n"
57
57
  end
@@ -100,6 +100,7 @@ module Billing
100
100
  if defined?(Extface) && fiscalizable? && device = origin.try(:fiscal_device)
101
101
  #self.extface_job = origin.fiscal_device.driver.fiscalize(self) if fiscalizable? && origin.try(:fiscal_device)
102
102
  self.extface_job = device.jobs.new
103
+ self.perform_fiscalize = true
103
104
  self.extface_job if save
104
105
  end
105
106
  end
@@ -8,6 +8,7 @@ module Billing
8
8
  belongs_to :transfer_device, ->(o) { where( extfaceable_id: o.master_id ) }, class_name: 'Extface::Device'
9
9
  belongs_to :print_device, ->(o) { where( extfaceable_id: o.master_id ) }, class_name: 'Extface::Device'
10
10
  end
11
+ belongs_to :receipt_config, inverse_of: :origins
11
12
 
12
13
  validates_presence_of :name
13
14
  validates :payment_model, inclusion: { in: Payment::PAYMENT_MODELS }
@@ -0,0 +1,5 @@
1
+ module Billing
2
+ class ReceiptConfig < ActiveRecord::Base
3
+ has_many :origins, inverse_of: :receipt_config
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ class CreateBillingReceiptConfigs < ActiveRecord::Migration
2
+ def change
3
+ create_table :billing_receipt_configs do |t|
4
+ t.integer :master_id
5
+ t.string :type
6
+ t.string :name
7
+ t.string :discount_text
8
+ t.string :surcharge_text
9
+ t.boolean :sound_signal
10
+ t.boolean :open_cash_drawer
11
+
12
+ t.timestamps null: false
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ class AddReceiptConfigToBillingOrigin < ActiveRecord::Migration
2
+ def change
3
+ add_reference :billing_origins, :receipt_config, index: true, foreign_key: true
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Billing
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,19 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ master_id: 1
5
+ type:
6
+ name: MyString
7
+ discount_text: MyString
8
+ surcharge_text: MyString
9
+ sound_signal: false
10
+ open_cash_drawer: false
11
+
12
+ two:
13
+ master_id: 1
14
+ type:
15
+ name: MyString
16
+ discount_text: MyString
17
+ surcharge_text: MyString
18
+ sound_signal: false
19
+ open_cash_drawer: false
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module Billing
4
+ class ReceiptConfigTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ 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.0
4
+ version: 0.1.1
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-28 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,6 +108,7 @@ files:
108
108
  - app/models/billing/paypal_express.rb
109
109
  - app/models/billing/plu.rb
110
110
  - app/models/billing/profile.rb
111
+ - app/models/billing/receipt_config.rb
111
112
  - app/models/billing/report.rb
112
113
  - app/models/billing/resource.rb
113
114
  - app/models/billing/room_transfer.rb
@@ -178,6 +179,8 @@ files:
178
179
  - db/migrate/20160723160908_add_print_device_to_billing_origin.rb
179
180
  - db/migrate/20160723234233_add_print_job_to_billing_bill.rb
180
181
  - db/migrate/20160824235224_add_print_headers_to_billing_origin.rb
182
+ - db/migrate/20160828145106_create_billing_receipt_configs.rb
183
+ - db/migrate/20160828145448_add_receipt_config_to_billing_origin.rb
181
184
  - lib/billing.rb
182
185
  - lib/billing/billable.rb
183
186
  - lib/billing/engine.rb
@@ -239,6 +242,7 @@ files:
239
242
  - test/fixtures/billing/payments.yml
240
243
  - test/fixtures/billing/plus.yml
241
244
  - test/fixtures/billing/profiles.yml
245
+ - test/fixtures/billing/receipt_configs.yml
242
246
  - test/fixtures/billing/resources.yml
243
247
  - test/fixtures/billing/tax_groups.yml
244
248
  - test/fixtures/profiles.yml
@@ -252,6 +256,7 @@ files:
252
256
  - test/models/billing/payment_type_test.rb
253
257
  - test/models/billing/plu_test.rb
254
258
  - test/models/billing/profile_test.rb
259
+ - test/models/billing/receipt_config_test.rb
255
260
  - test/models/billing/resource_test.rb
256
261
  - test/models/billing/tax_group_test.rb
257
262
  - test/test_helper.rb
@@ -287,6 +292,7 @@ test_files:
287
292
  - test/fixtures/billing/payments.yml
288
293
  - test/fixtures/billing/bills.yml
289
294
  - test/fixtures/billing/resources.yml
295
+ - test/fixtures/billing/receipt_configs.yml
290
296
  - test/fixtures/billing/charges.yml
291
297
  - test/fixtures/billing/departments.yml
292
298
  - test/fixtures/billing/modifiers.yml
@@ -344,6 +350,7 @@ test_files:
344
350
  - test/models/billing/payment_test.rb
345
351
  - test/models/billing/resource_test.rb
346
352
  - test/models/billing/operator_test.rb
353
+ - test/models/billing/receipt_config_test.rb
347
354
  - test/models/billing/origin_test.rb
348
355
  - test/models/billing/profile_test.rb
349
356
  - test/models/billing/payment_type_test.rb