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