-
Notifications
You must be signed in to change notification settings - Fork 36
/
bdd-stories-interest-credit.txt
88 lines (69 loc) · 3.08 KB
/
bdd-stories-interest-credit.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
>> Heuristic: generate credits from (most recent credit month/year + 1) thru (current month/year)
for each month/year, date will have day = 1 (e.g., 12/1/2018)
-- Ensure that interest credit is based on balance as of interest credit date
Given today is 2/28/2019
And a deposit of $100 was made on 12/1/2018
And another deposit of $200 was made on 1/15/2019
When we request balance
Then we add interest credits of 1/1/2018 (bal=$100.00->21c), 2/1/2018 (bal=$300.21->63c)
-- Test for including interest credit in balance
Test: monthsWithoutCreditsShouldFillInCreditsRetroactively
-- Multiple Retroactive Credit + Crossing Year Boundary
Given today is 2/28/2019
And last interest credit was on 11/1/2018
When we request balance today (2/28/2019)
Then we add interest credits for 12/1/2018, 1/1/2019, 2/1/2019
Test: retroactiveCreditShouldOnlyBeCreatedAsOfFirstAccountTransaction
-- Retroactive, where no other interest credit transactions have occurred
Given today is 2/2/2019
And first (and only) transaction was a DEPOSIT on 1/31/2019 (no interest credit)
When we request balance
Then we should have interest credit for 2/1/2019
Test: retroactiveCreditShouldOnlyBeCreatedAsOfFirstAccountTransaction
-- Retroactive credit, no previous credits
Given today is 3/10/2019
And account balance is $100
And first transaction was 2/3/2019
And no interest was ever credited (0 interest credited transactions)
When we request balance (on 3/10/2019)
Then we add credit ONLY for 3/1/2019
Test: interestShouldOnlyBeDepositedOnceForCurrentMonth
Given today is 2/1/2017
And account balance is $100
And last interest credit was on 2/1/2017
When we request balance
Then we don't add any credit
Test: missingOneMonthCreditShouldAddOneMonthCreditEvenIfTodayIsNotTheFirstDayOfMonth
Given today is 2/27/2019
And last interest credit was on 1/1/2019
When we request balance on 2/27/2019
Then we add credit ONLY for 2/1/2019 (1 + 1 = 2 thru 2): {2}
Test: missingOneMonthCreditShouldAddOneMonthCredit
Given today 2/1/2019 (current-month-year = 2/2019)
And last interest credit was on 1/1/2019 (most-recent-credit-month-year = 1/2019)
When we request balance (on 2/1/2019)
Then we add credit ONLY for 2/1/2019 (1 + 1 thru 2)
---- Recalculate Interest in the Past ---
Given:
04/25/2018 Cash Deposit $4.00
05/01/2018 Interest Credit $0.24
05/03/2018 Cash Deposit $6.75
06/01/2018 Interest Credit $0.24
And: Today is 06/05/2018
When:
Add an "old" transaction:
05/12/2018 Spent Cash $5.25
Then:
Recalculate interest credit for 6/1/2018, resulting in transactions:
04/25/2018 Cash Deposit $4.00
05/01/2018 Interest Credit $0.24
05/03/2018 Cash Deposit $6.75
05/12/2018 Spent Cash ($5.25)
06/01/2018 Interest Credit $0.24
06/01/2018 Interest Reverse ($0.24)
06/01/2018 Interest Credit $0.23
Rule: recalculate if deposit/spend added on or before most recent interest credit transaction
Virtual Interest Credit Transactions
1. Delete existing IC Txns
-> Every time Account.transactions() is request, recalculate IC Txns
-> Have to make sure that this happens before balance calculation