billing 0.0.4 → 0.0.5a

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/models/billing/{account.rb → bill.rb} +40 -34
  3. data/app/models/billing/charge.rb +25 -11
  4. data/app/models/billing/modifier.rb +5 -5
  5. data/app/models/billing/origin.rb +7 -2
  6. data/app/models/billing/payment.rb +8 -11
  7. data/app/models/billing/payment_with_type.rb +3 -9
  8. data/app/models/billing/report.rb +29 -13
  9. data/app/models/billing/room_transfer.rb +4 -0
  10. data/app/models/concerns/billing/{account_item.rb → bill_item.rb} +5 -6
  11. data/app/models/concerns/billing/bill_text_parser.rb +18 -0
  12. data/config/initializers/money.rb +67 -0
  13. data/config/routes.rb +1 -6
  14. data/db/migrate/20140803073707_rename_billing_account_to_bill.rb +8 -0
  15. data/db/migrate/20140804065726_add_qty_to_billing_charge.rb +5 -0
  16. data/db/migrate/20140804070517_add_tax_ratio_to_billing_charge.rb +5 -0
  17. data/db/migrate/20141001185321_add_transfer_device_to_billing_origin.rb +5 -0
  18. data/db/migrate/20141027235427_add_f_amount_to_billing_report.rb +7 -0
  19. data/lib/billing.rb +0 -2
  20. data/lib/billing/billable.rb +3 -3
  21. data/lib/billing/engine.rb +3 -0
  22. data/lib/billing/version.rb +1 -1
  23. data/lib/collection_proxy_wild.rb +9 -0
  24. data/test/dummy/config/routes.rb +1 -3
  25. data/test/dummy/db/development.sqlite3 +0 -0
  26. data/test/dummy/db/schema.rb +23 -17
  27. data/test/dummy/db/test.sqlite3 +0 -0
  28. data/test/dummy/log/development.log +8144 -0
  29. data/test/dummy/log/test.log +64325 -0
  30. data/test/fixtures/billing/{accounts.yml → bills.yml} +0 -0
  31. data/test/fixtures/billing/charges.yml +2 -2
  32. data/test/fixtures/billing/modifiers.yml +2 -2
  33. data/test/fixtures/billing/payments.yml +2 -2
  34. data/test/models/billing/bill_test.rb +76 -0
  35. data/test/models/billing/charge_test.rb +13 -6
  36. data/test/models/billing/modifier_test.rb +2 -2
  37. data/test/models/billing/payment_test.rb +12 -12
  38. metadata +20 -58
  39. data/app/assets/javascripts/billing/accounts.js +0 -2
  40. data/app/assets/javascripts/billing/application.js +0 -13
  41. data/app/assets/javascripts/billing/charges.js +0 -2
  42. data/app/assets/javascripts/billing/modifiers.js +0 -2
  43. data/app/assets/stylesheets/billing/accounts.css +0 -4
  44. data/app/assets/stylesheets/billing/application.css +0 -15
  45. data/app/assets/stylesheets/billing/charges.css +0 -4
  46. data/app/assets/stylesheets/billing/modifiers.css +0 -4
  47. data/app/assets/stylesheets/billing/payments.css +0 -4
  48. data/app/controllers/billing/accounts_controller.rb +0 -29
  49. data/app/controllers/billing/application_controller.rb +0 -22
  50. data/app/controllers/billing/charges_controller.rb +0 -29
  51. data/app/controllers/billing/modifiers_controller.rb +0 -29
  52. data/app/controllers/billing/payments_controller.rb +0 -29
  53. data/app/helpers/billing/accounts_helper.rb +0 -4
  54. data/app/helpers/billing/application_helper.rb +0 -4
  55. data/app/helpers/billing/charges_helper.rb +0 -4
  56. data/app/helpers/billing/modifiers_helper.rb +0 -4
  57. data/app/helpers/billing/payments_helper.rb +0 -4
  58. data/app/views/billing/accounts/index.html.erb +0 -7
  59. data/app/views/billing/accounts/new.html.erb +0 -8
  60. data/app/views/billing/accounts/show.html.erb +0 -29
  61. data/app/views/billing/application/index.html.erb +0 -3
  62. data/app/views/billing/charges/new.html.erb +0 -12
  63. data/app/views/billing/modifiers/new.html.erb +0 -18
  64. data/app/views/billing/payments/new.html.erb +0 -11
  65. data/app/views/layouts/billing/application.html.erb +0 -14
  66. data/lib/billing/mapping.rb +0 -32
  67. data/lib/billing/routes.rb +0 -16
  68. data/test/controllers/billing/accounts_controller_test.rb +0 -19
  69. data/test/controllers/billing/charges_controller_test.rb +0 -16
  70. data/test/controllers/billing/modifiers_controller_test.rb +0 -16
  71. data/test/controllers/billing/payments_controller_test.rb +0 -16
  72. data/test/helpers/billing/accounts_helper_test.rb +0 -6
  73. data/test/helpers/billing/charges_helper_test.rb +0 -6
  74. data/test/helpers/billing/modifiers_helper_test.rb +0 -6
  75. data/test/helpers/billing/payments_helper_test.rb +0 -6
  76. data/test/integration/navigation_test.rb +0 -10
  77. data/test/models/billing/account_test.rb +0 -56
@@ -1,6 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Billing
4
- class ModifiersHelperTest < ActionView::TestCase
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Billing
4
- class PaymentsHelperTest < ActionView::TestCase
5
- end
6
- end
@@ -1,10 +0,0 @@
1
- require 'test_helper'
2
-
3
- class NavigationTest < ActionDispatch::IntegrationTest
4
- fixtures :all
5
-
6
- # test "the truth" do
7
- # assert true
8
- # end
9
- end
10
-
@@ -1,56 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Billing
4
- class AccountTest < ActiveSupport::TestCase
5
- setup do
6
- @account = billing_accounts(:one)
7
- @account.save! # force summary calculation
8
- end
9
-
10
- test "charge" do
11
- charge = @account.charge 3
12
- assert charge.try(:persisted?)
13
- assert_equal '13 USD'.to_money, @account.total # (1 + 3) + 100% + $1
14
- end
15
-
16
- test "discount" do
17
- discount = @account.modify(-1.00, charge: billing_charges(:two))
18
- assert discount.try(:persisted?)
19
- assert_equal '6 USD'.to_money, @account.total
20
- end
21
-
22
- test "surcharge" do
23
- surcharge = @account.modify(1.00, charge: billing_charges(:two))
24
- assert surcharge.try(:persisted?)
25
- assert_equal '8 USD'.to_money, @account.total
26
- end
27
-
28
- test "pay" do
29
- payment = @account.pay billing_payment_types(:one)
30
- assert @account.balance.zero?, @account.errors.full_messages.join(', ')
31
- assert_equal '7 USD'.to_money, @account.payments_sum
32
- end
33
-
34
- test "validate positive total" do
35
- assert @account.save
36
- @account.modify(-500)
37
- assert @account.errors.messages[:total]
38
- assert_raise ActiveRecord::RecordInvalid do
39
- @account.save!
40
- end
41
- end
42
-
43
- test "account with payments should have origin" do
44
- assert @account.origin
45
- assert @account.payments.any?
46
- @account.origin = nil
47
- assert_equal false, @account.save
48
- assert @account.errors.messages[:origin]
49
- end
50
-
51
- test "autofin" do
52
- assert @account.pay billing_payment_types(:one)
53
- assert @account.finalized_at
54
- end
55
- end
56
- end