billing 0.0.4d → 0.0.4

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/billing/accounts.js +2 -0
  3. data/app/assets/javascripts/billing/application.js +13 -0
  4. data/app/assets/javascripts/billing/charges.js +2 -0
  5. data/app/assets/javascripts/billing/modifiers.js +2 -0
  6. data/app/assets/stylesheets/billing/accounts.css +4 -0
  7. data/app/assets/stylesheets/billing/application.css +15 -0
  8. data/app/assets/stylesheets/billing/charges.css +4 -0
  9. data/app/assets/stylesheets/billing/modifiers.css +4 -0
  10. data/app/assets/stylesheets/billing/payments.css +4 -0
  11. data/app/controllers/billing/accounts_controller.rb +29 -0
  12. data/app/controllers/billing/application_controller.rb +22 -0
  13. data/app/controllers/billing/charges_controller.rb +29 -0
  14. data/app/controllers/billing/modifiers_controller.rb +29 -0
  15. data/app/controllers/billing/payments_controller.rb +29 -0
  16. data/app/helpers/billing/accounts_helper.rb +4 -0
  17. data/app/helpers/billing/application_helper.rb +4 -0
  18. data/app/helpers/billing/charges_helper.rb +4 -0
  19. data/app/helpers/billing/modifiers_helper.rb +4 -0
  20. data/app/helpers/billing/payments_helper.rb +4 -0
  21. data/app/models/billing/{bill.rb → account.rb} +30 -37
  22. data/app/models/billing/charge.rb +11 -25
  23. data/app/models/billing/modifier.rb +5 -5
  24. data/app/models/billing/origin.rb +2 -7
  25. data/app/models/billing/payment.rb +11 -8
  26. data/app/models/billing/payment_with_type.rb +1 -1
  27. data/app/models/billing/report.rb +12 -23
  28. data/app/models/concerns/billing/{bill_item.rb → account_item.rb} +6 -5
  29. data/app/views/billing/accounts/index.html.erb +7 -0
  30. data/app/views/billing/accounts/new.html.erb +8 -0
  31. data/app/views/billing/accounts/show.html.erb +29 -0
  32. data/app/views/billing/application/index.html.erb +3 -0
  33. data/app/views/billing/charges/new.html.erb +12 -0
  34. data/app/views/billing/modifiers/new.html.erb +18 -0
  35. data/app/views/billing/payments/new.html.erb +11 -0
  36. data/app/views/layouts/billing/application.html.erb +14 -0
  37. data/config/routes.rb +6 -1
  38. data/lib/billing.rb +2 -0
  39. data/lib/billing/billable.rb +3 -3
  40. data/lib/billing/engine.rb +0 -3
  41. data/lib/billing/mapping.rb +32 -0
  42. data/lib/billing/routes.rb +16 -0
  43. data/lib/billing/version.rb +1 -1
  44. data/test/controllers/billing/accounts_controller_test.rb +19 -0
  45. data/test/controllers/billing/charges_controller_test.rb +16 -0
  46. data/test/controllers/billing/modifiers_controller_test.rb +16 -0
  47. data/test/controllers/billing/payments_controller_test.rb +16 -0
  48. data/test/dummy/config/routes.rb +3 -1
  49. data/test/dummy/db/development.sqlite3 +0 -0
  50. data/test/dummy/db/schema.rb +17 -23
  51. data/test/dummy/db/test.sqlite3 +0 -0
  52. data/test/dummy/log/development.log +0 -8144
  53. data/test/dummy/log/test.log +0 -64325
  54. data/test/fixtures/billing/{bills.yml → accounts.yml} +0 -0
  55. data/test/fixtures/billing/charges.yml +2 -2
  56. data/test/fixtures/billing/modifiers.yml +2 -2
  57. data/test/fixtures/billing/payments.yml +2 -2
  58. data/test/helpers/billing/accounts_helper_test.rb +6 -0
  59. data/test/helpers/billing/charges_helper_test.rb +6 -0
  60. data/test/helpers/billing/modifiers_helper_test.rb +6 -0
  61. data/test/helpers/billing/payments_helper_test.rb +6 -0
  62. data/test/integration/navigation_test.rb +10 -0
  63. data/test/models/billing/account_test.rb +56 -0
  64. data/test/models/billing/charge_test.rb +6 -13
  65. data/test/models/billing/modifier_test.rb +2 -2
  66. data/test/models/billing/payment_test.rb +12 -12
  67. metadata +58 -20
  68. data/app/models/billing/room_transfer.rb +0 -4
  69. data/app/models/concerns/billing/bill_text_parser.rb +0 -18
  70. data/config/initializers/money.rb +0 -67
  71. data/db/migrate/20140803073707_rename_billing_account_to_bill.rb +0 -8
  72. data/db/migrate/20140804065726_add_qty_to_billing_charge.rb +0 -5
  73. data/db/migrate/20140804070517_add_tax_ratio_to_billing_charge.rb +0 -5
  74. data/db/migrate/20141001185321_add_transfer_device_to_billing_origin.rb +0 -5
  75. data/db/migrate/20141027235427_add_f_amount_to_billing_report.rb +0 -7
  76. data/lib/collection_proxy_wild.rb +0 -9
  77. data/test/models/billing/bill_test.rb +0 -76
@@ -1,8 +0,0 @@
1
- class RenameBillingAccountToBill < ActiveRecord::Migration
2
- def change
3
- rename_table :billing_accounts, :billing_bills
4
- rename_column :billing_charges, :account_id, :bill_id
5
- rename_column :billing_modifiers, :account_id, :bill_id
6
- rename_column :billing_payments, :account_id, :bill_id
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- class AddQtyToBillingCharge < ActiveRecord::Migration
2
- def change
3
- add_column :billing_charges, :qty, :decimal, precision: 6, scale: 3
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddTaxRatioToBillingCharge < ActiveRecord::Migration
2
- def change
3
- add_column :billing_charges, :tax_ratio, :decimal, precision: 6, scale: 3
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddTransferDeviceToBillingOrigin < ActiveRecord::Migration
2
- def change
3
- add_reference :billing_origins, :transfer_device, index: true
4
- end
5
- end
@@ -1,7 +0,0 @@
1
- class AddFAmountToBillingReport < ActiveRecord::Migration
2
- def change
3
- change_table :billing_reports do |t|
4
- t.money :f_amount
5
- end
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- module ActiveRecord
2
- module Associations
3
- class CollectionProxy < Relation
4
- def wild(*args)
5
- @association.build(klass.wild_args(*args))
6
- end
7
- end
8
- end
9
- end
@@ -1,76 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Billing
4
- class BillTest < ActiveSupport::TestCase
5
- setup do
6
- @bill = billing_bills(:one)
7
- @bill.charges.each(&:save!) #update values
8
- @bill.save! # force summary calculation
9
- end
10
-
11
- test "summaries" do
12
- assert_equal '4 USD'.to_money, @bill.charges_sum
13
- assert_equal '5 USD'.to_money, @bill.surcharges_sum
14
- assert_equal '0 USD'.to_money, @bill.discounts_sum
15
- assert_equal '3 USD'.to_money, @bill.payments_sum
16
- assert_equal '8 USD'.to_money, @bill.total
17
- assert_equal '-5 USD'.to_money, @bill.balance
18
- end
19
-
20
- test "charge" do
21
- charge = @bill.charge 3
22
- assert_difference "@bill.charges.count" do
23
- assert @bill.save!
24
- end
25
- assert charge.persisted?
26
- assert_equal '14 USD'.to_money, @bill.total # ((1+1) + 2 + 3) + 100%
27
- end
28
-
29
- test "discount" do
30
- discount = @bill.modify(-1.00, charge: billing_charges(:two))
31
- c = billing_charges(:two)
32
- assert_difference "@bill.modifiers.count" do
33
- assert @bill.save
34
- end
35
- assert discount.try(:persisted?)
36
- p @bill.discounts_sum
37
- p @bill.surcharges_sum
38
- assert_equal '6 USD'.to_money, @bill.total # ((1+1) + (2-1)) + 100%
39
- end
40
- =begin
41
- test "surcharge" do
42
- surcharge = @bill.modify(1.00, charge: billing_charges(:two))
43
- assert surcharge.try(:persisted?)
44
- assert_equal '8 USD'.to_money, @bill.total
45
- end
46
-
47
- test "pay" do
48
- payment = @bill.pay billing_payment_types(:one)
49
- assert @bill.balance.zero?, @bill.errors.full_messages.join(', ')
50
- assert_equal '7 USD'.to_money, @bill.payments_sum
51
- end
52
-
53
- test "validate positive total" do
54
- assert @bill.save
55
- @bill.modify(-500)
56
- assert @bill.errors.messages[:total]
57
- assert_raise ActiveRecord::RecordInvalid do
58
- @bill.save!
59
- end
60
- end
61
-
62
- test "bill with payments should have origin" do
63
- assert @bill.origin
64
- assert @bill.payments.any?
65
- @bill.origin = nil
66
- assert_equal false, @bill.save
67
- assert @bill.errors.messages[:origin]
68
- end
69
-
70
- test "autofin" do
71
- assert @bill.pay billing_payment_types(:one)
72
- assert @bill.finalized_at
73
- end
74
- =end
75
- end
76
- end