billing 0.0.4 → 0.0.5a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/billing/{account.rb → bill.rb} +40 -34
- data/app/models/billing/charge.rb +25 -11
- data/app/models/billing/modifier.rb +5 -5
- data/app/models/billing/origin.rb +7 -2
- data/app/models/billing/payment.rb +8 -11
- data/app/models/billing/payment_with_type.rb +3 -9
- data/app/models/billing/report.rb +29 -13
- data/app/models/billing/room_transfer.rb +4 -0
- data/app/models/concerns/billing/{account_item.rb → bill_item.rb} +5 -6
- data/app/models/concerns/billing/bill_text_parser.rb +18 -0
- data/config/initializers/money.rb +67 -0
- data/config/routes.rb +1 -6
- data/db/migrate/20140803073707_rename_billing_account_to_bill.rb +8 -0
- data/db/migrate/20140804065726_add_qty_to_billing_charge.rb +5 -0
- data/db/migrate/20140804070517_add_tax_ratio_to_billing_charge.rb +5 -0
- data/db/migrate/20141001185321_add_transfer_device_to_billing_origin.rb +5 -0
- data/db/migrate/20141027235427_add_f_amount_to_billing_report.rb +7 -0
- data/lib/billing.rb +0 -2
- data/lib/billing/billable.rb +3 -3
- data/lib/billing/engine.rb +3 -0
- data/lib/billing/version.rb +1 -1
- data/lib/collection_proxy_wild.rb +9 -0
- data/test/dummy/config/routes.rb +1 -3
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +23 -17
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +8144 -0
- data/test/dummy/log/test.log +64325 -0
- data/test/fixtures/billing/{accounts.yml → bills.yml} +0 -0
- data/test/fixtures/billing/charges.yml +2 -2
- data/test/fixtures/billing/modifiers.yml +2 -2
- data/test/fixtures/billing/payments.yml +2 -2
- data/test/models/billing/bill_test.rb +76 -0
- data/test/models/billing/charge_test.rb +13 -6
- data/test/models/billing/modifier_test.rb +2 -2
- data/test/models/billing/payment_test.rb +12 -12
- metadata +20 -58
- data/app/assets/javascripts/billing/accounts.js +0 -2
- data/app/assets/javascripts/billing/application.js +0 -13
- data/app/assets/javascripts/billing/charges.js +0 -2
- data/app/assets/javascripts/billing/modifiers.js +0 -2
- data/app/assets/stylesheets/billing/accounts.css +0 -4
- data/app/assets/stylesheets/billing/application.css +0 -15
- data/app/assets/stylesheets/billing/charges.css +0 -4
- data/app/assets/stylesheets/billing/modifiers.css +0 -4
- data/app/assets/stylesheets/billing/payments.css +0 -4
- data/app/controllers/billing/accounts_controller.rb +0 -29
- data/app/controllers/billing/application_controller.rb +0 -22
- data/app/controllers/billing/charges_controller.rb +0 -29
- data/app/controllers/billing/modifiers_controller.rb +0 -29
- data/app/controllers/billing/payments_controller.rb +0 -29
- data/app/helpers/billing/accounts_helper.rb +0 -4
- data/app/helpers/billing/application_helper.rb +0 -4
- data/app/helpers/billing/charges_helper.rb +0 -4
- data/app/helpers/billing/modifiers_helper.rb +0 -4
- data/app/helpers/billing/payments_helper.rb +0 -4
- data/app/views/billing/accounts/index.html.erb +0 -7
- data/app/views/billing/accounts/new.html.erb +0 -8
- data/app/views/billing/accounts/show.html.erb +0 -29
- data/app/views/billing/application/index.html.erb +0 -3
- data/app/views/billing/charges/new.html.erb +0 -12
- data/app/views/billing/modifiers/new.html.erb +0 -18
- data/app/views/billing/payments/new.html.erb +0 -11
- data/app/views/layouts/billing/application.html.erb +0 -14
- data/lib/billing/mapping.rb +0 -32
- data/lib/billing/routes.rb +0 -16
- data/test/controllers/billing/accounts_controller_test.rb +0 -19
- data/test/controllers/billing/charges_controller_test.rb +0 -16
- data/test/controllers/billing/modifiers_controller_test.rb +0 -16
- data/test/controllers/billing/payments_controller_test.rb +0 -16
- data/test/helpers/billing/accounts_helper_test.rb +0 -6
- data/test/helpers/billing/charges_helper_test.rb +0 -6
- data/test/helpers/billing/modifiers_helper_test.rb +0 -6
- data/test/helpers/billing/payments_helper_test.rb +0 -6
- data/test/integration/navigation_test.rb +0 -10
- data/test/models/billing/account_test.rb +0 -56
@@ -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
|