billing 0.1.8 → 0.1.9
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 +4 -4
- data/app/jobs/billing/issue_print_doc.rb +2 -2
- data/app/models/billing/bill.rb +8 -8
- data/app/models/billing/charge.rb +4 -0
- data/lib/billing/version.rb +1 -1
- data/test/dummy/config/application.rb +2 -0
- data/test/dummy/config/initializers/monetize.rb +1 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +22410 -0
- data/test/fixtures/billing/bills.yml +4 -0
- data/test/models/billing/bill_test.rb +19 -10
- data/test/models/billing/charge_test.rb +6 -0
- data/test/test_helper.rb +1 -1
- metadata +4 -2
@@ -28,28 +28,37 @@ module Billing
|
|
28
28
|
|
29
29
|
test "discount" do
|
30
30
|
discount = @bill.modify(-1.00, charge: billing_charges(:two))
|
31
|
-
c = billing_charges(:two)
|
31
|
+
#c = billing_charges(:two)
|
32
32
|
assert_difference "@bill.modifiers.count" do
|
33
33
|
assert @bill.save
|
34
34
|
end
|
35
35
|
assert discount.try(:persisted?)
|
36
|
-
p @bill.discounts_sum
|
37
|
-
p @bill.surcharges_sum
|
38
36
|
assert_equal '6 USD'.to_money, @bill.total # ((1+1) + (2-1)) + 100%
|
39
37
|
end
|
40
|
-
|
38
|
+
|
41
39
|
test "surcharge" do
|
42
40
|
surcharge = @bill.modify(1.00, charge: billing_charges(:two))
|
41
|
+
assert_difference "@bill.modifiers.count" do
|
42
|
+
assert @bill.save
|
43
|
+
end
|
43
44
|
assert surcharge.try(:persisted?)
|
44
|
-
assert_equal '
|
45
|
+
assert_equal '6 USD'.to_money, @bill.total
|
45
46
|
end
|
46
47
|
|
47
|
-
test "pay" do
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
test "pay with qty" do
|
49
|
+
@bill = billing_bills(:open)
|
50
|
+
@bill.charge qty: 1.5, price: 10
|
51
|
+
assert_difference "@bill.charges.count" do
|
52
|
+
assert @bill.save
|
53
|
+
end
|
54
|
+
payment = @bill.pay type: 'Billing::PaymentWithType', payment_type: billing_payment_types(:cash)
|
55
|
+
assert_difference "@bill.payments.count" do
|
56
|
+
assert @bill.save
|
57
|
+
end
|
58
|
+
assert @bill.balance.zero?
|
59
|
+
assert_equal '15 USD'.to_money, @bill.payments_sum
|
51
60
|
end
|
52
|
-
|
61
|
+
=begin
|
53
62
|
test "validate positive total" do
|
54
63
|
assert @bill.save
|
55
64
|
@bill.modify(-500)
|
@@ -20,5 +20,11 @@ module Billing
|
|
20
20
|
assert_equal charge.name, 'Umbrella'
|
21
21
|
#p charge
|
22
22
|
end
|
23
|
+
|
24
|
+
test "qty" do
|
25
|
+
charge = Billing::Charge.new price: 0.95, qty: 2.0
|
26
|
+
assert_equal charge.price, '0.95'.to_money
|
27
|
+
assert_equal charge.qtyprice, '1.90'.to_money
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
data/test/test_helper.rb
CHANGED
@@ -30,7 +30,7 @@ module Billing
|
|
30
30
|
parameters = { profile_id: profiles(:one) }.merge(parameters || {})
|
31
31
|
process_without_profile(action, http_method, parameters, session, flash)
|
32
32
|
end
|
33
|
-
alias_method_chain :process, :profile
|
33
|
+
#alias_method_chain :process, :profile
|
34
34
|
end
|
35
35
|
end
|
36
36
|
class ActionDispatch::Routing::RouteSet
|
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.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Vangelov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- test/dummy/config/initializers/filter_parameter_logging.rb
|
218
218
|
- test/dummy/config/initializers/inflections.rb
|
219
219
|
- test/dummy/config/initializers/mime_types.rb
|
220
|
+
- test/dummy/config/initializers/monetize.rb
|
220
221
|
- test/dummy/config/initializers/session_store.rb
|
221
222
|
- test/dummy/config/initializers/wrap_parameters.rb
|
222
223
|
- test/dummy/config/locales/en.yml
|
@@ -329,6 +330,7 @@ test_files:
|
|
329
330
|
- test/dummy/config/secrets.yml
|
330
331
|
- test/dummy/config/environment.rb
|
331
332
|
- test/dummy/config/database.yml
|
333
|
+
- test/dummy/config/initializers/monetize.rb
|
332
334
|
- test/dummy/config/initializers/assets.rb
|
333
335
|
- test/dummy/config/initializers/cookies_serializer.rb
|
334
336
|
- test/dummy/config/initializers/wrap_parameters.rb
|