This commit is contained in:
Zeeshaun
2026-03-17 08:54:34 -05:00
parent 64856c640e
commit cdcba54aa4
330 changed files with 54110 additions and 0 deletions
@@ -0,0 +1,631 @@
Feature: Chargeback Calculation
Calculate chargeback for a paid loan
Scenario: NC - Calculate Chargeback for Paid Date is within 15 days of Loan date, 30 days to first payment
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 2/10/2021 | 3/12/2021 | 2/12/2028 | NC | 1206.8106 | 2/19/2021 | 84 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1206.8106 | Paid On or Before Chargeback Date | 84 |
#May 11, 2021 vs. May 12, 2021 First Payment Date wins by one day
Scenario: NC - Calculate Chargeback for Paid Date is within 15 days of Loan date, 30 days to first payment, Compare Loan Date vs. First Pmt Date, First Pmt Date Wins by 1 day
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 2/10/2021 | 3/12/2021 | 2/12/2028 | NC | 1206.8106 | 2/19/2021 | 84 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1206.8106 | Paid On or Before Chargeback Date | 84 |
Scenario: NC - Calculate Chargeback for Paid Date is after 15 days of Loan date, Compare Loan Date vs. First Pmt Date, Loan Date Wins by 1 day
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 2/1/2021 | 2/15/2021 | 2/15/2028 | NC | 1206.8106 | 2/19/2021 | 85 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1178.7452372093023255813953488 | Paid On or Before Chargeback Date | 84 |
Scenario: NC - Calculate Chargeback for Paid Date is after 15 days of Loan date, in a different year
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/1/2020 | 12/15/2020 | 12/15/2027 | NC | 1206.8106 | 1/19/2021 | 85 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1151.0100551573187414500683995 | Paid On or Before Chargeback Date | 83 |
Scenario: NC - Calculate Chargeback for Paid Date is within 15 days of Loan date, 30 days to first payment, Compare Loan Date vs. First Pmt Date, Loan Date Wins by 1 day
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 2/10/2021 | 3/10/2021 | 2/10/2028 | NC | 1206.8106 | 2/19/2021 | 84 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1206.8106 | Paid On or Before Chargeback Date | 84 |
Scenario: NC - Calculate Chargeback for Paid Date is after 15 days of Loan date, Compare Loan Date vs. First Pmt Date, Loan Date Wins by 1 day, Leslie's scenario
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 1/15/2019 | 2/14/2019 | 4/14/2025 | NC | 2141.8721 | 4/15/2019 | 75 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1975.0315364210526315789473684 | Paid On or Before Chargeback Date | 72 |
Scenario: Calculate Chargeback for Paid Date is within 15 days of Loan date, 30 days to first payment - Missing Loan Type Id
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 2/10/2021 | 3/12/2021 | 2/12/2028 | | 1206.8106 | 2/19/2021 | 84 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1206.8106 | Paid On or Before Chargeback Date | 84 |
Scenario: NC - Calculate Chargeback for Paid Date is within 15 days of Loan date, 45 days to first payment
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/30/2017 | 12/14/2017 | 11/14/2023 | NC | 927.0989 | 11/6/2017 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 927.0989 | Paid On or Before Chargeback Date | 72 |
Scenario: NC - Calculate Chargeback for Paid Date is within 15 days of Loan date, 90 days to first payment
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/7/2020 | 1/5/2021 | 12/5/2025 | NC | 229.0637 | 10/21/2020 | 48 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 238.60802083333333333333333333 | Paid On or Before Chargeback Date | 49 |
Scenario: NC - Calculate Chargeback for Paid Date is exactly 15 days from Loan date, 45 days to first payment
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/7/2020 | 1/21/2021 | 12/21/2025 | NC | 878.8602 | 12/22/2020 | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 878.8602 | Paid On or Before Chargeback Date | 60 |
Scenario: NC - Calculate Chargeback for Paid Date more than 15 days past Loan date but before or on the first payment date, 32 days until first payment date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 1/28/2021 | 3/1/2021 | 5/1/2027 | NC | 855.6368 | 2/25/2021 | 75 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 833.1200421052631578947368421 | Paid On or Before Chargeback Date | 74 |
Scenario: NC - Calculate Chargeback for Paid Date more than 15 days past Loan date but before or on the first payment date, 45 days until first payment date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/15/2019 | 11/29/2019 | 10/29/2025 | NC | 1320.8907 | 10/31/2019 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1320.8907 | Paid On or Before Chargeback Date | 72 |
Scenario: NC - Calculate Chargeback for Paid Date more than 15 days past Loan date but before or on the first payment date, 90 days until first payment date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/22/2020 | 3/22/2021 | 2/22/2027 | NC | 1689.8999 | 1/14/2021 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1736.8415638888888888888888889 | Paid On or Before Chargeback Date | 73 |
Scenario: NC - Calculate Chargeback for Paid Date more than 15 days past Loan date but before or on the first payment date, 91 days until first payment date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/26/2018 | 1/25/2019 | 12/25/2024 | NC | 203.7054 | 11/15/2018 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 209.36388333333333333333333333 | Paid On or Before Chargeback Date | 73 |
Scenario: NC - Calculate Chargeback for Paid Date more than 15 days past Loan date after the first payment date, over Feb month example to trigger "not a date" condition.
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 3/11/2021 | 4/25/2021 | 3/25/2027 | NC | 309.4481 | 4/30/2021 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 300.9700698630136986301369863 | Paid On or Before Chargeback Date | 71 |
Scenario: NC - Calculate Chargeback for Paid Date past the chargeback date - this is day after
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/26/2018 | 1/25/2019 | 12/25/2024 | NC | 203.7054 | 3/26/2019 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Paid After Chargeback Date | 69 |
Scenario: NC - Calculate Chargeback for Paid Date past the final payment date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/26/2018 | 1/25/2019 | 12/25/2024 | NC | 203.7054 | 3/26/2025 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Paid After Chargeback Date | 0 |
Scenario: NR - Calculate Chargeback for NR loan - paid past chargeback date (month before first payment date)
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/15/2019 | 11/29/2019 | 10/29/2025 | NR | 0 | 10/31/2019 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NR | No reserve to be paid | N | 0 | 0 | 0 | 0.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | No Reserve - No Chargeback | 72 |
Scenario: NR - Calculate Chargeback for NR loan - paid before chargeback date, 0 chargeback because reserve is 0
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/15/2019 | 11/29/2019 | 10/29/2025 | NR | 0 | 10/20/2019 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NR | No reserve to be paid | N | 0 | 0 | 0 | 0.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | No Reserve - No Chargeback | 72 |
Scenario: NR - Calculate Chargeback for NR loan - paid after final payment date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/15/2019 | 11/29/2019 | 10/29/2025 | NR | 0 | 12/1/2025 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NR | No reserve to be paid | N | 0 | 0 | 0 | 0.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | No Reserve - No Chargeback | 0 |
Scenario: BB - Calculate Chargeback for BB loan - 0 chargeback because reserve is 0
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/15/2019 | 11/29/2019 | 10/29/2025 | BB | 0 | 10/20/2019 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | No Reserve - No Chargeback | 72 |
Scenario: BB - Calculate Chargeback for BB loan - 0 chargeback because it is paid after final payment date.
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 8/24/2017 | 9/23/2017 | 8/23/2020 | BB | 127.24 | 5/18/2021 | 36 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Paid After Chargeback Date | 0 |
Scenario: BB - Calculate Chargeback for BB loan - 0 chargeback because it is paid on the final payment date.
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 8/24/2017 | 9/23/2017 | 5/18/2021 | BB | 127.24 | 5/18/2021 | 36 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Paid After Chargeback Date | 0 |
Scenario: BB - Calculate Chargeback for BB loan - using BB Chargeback method, past chargeback date, NoChargebackPayments
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 9/11/2018 | 10/24/2018 | 12/24/2024 | BB | 287.3639 | 4/30/2021 | 75 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 99.82114421052631578947368421 | Paid On or Before Chargeback Date | 44 |
Scenario: BB - Calculate Chargeback for BB loan - using BB Chargeback method, paid before first payment date, NoChargebackPayments
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/15/2019 | 11/29/2019 | 10/29/2025 | BB | 500 | 10/20/2019 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 500 | Paid On or Before Chargeback Date | 72 |
Scenario: BB - Calculate Chargeback for BB loan - using BB Chargeback method, paid more than a year after first payment.
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 1/18/2018 | 3/4/2018 | 2/4/2023 | BB | 790.4206 | 4/30/2021 | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 99.77440360655737704918032787 | Paid On or Before Chargeback Date | 21 |
Scenario: BB - Calculate Chargeback for BB loan - using BB Chargeback method, almost to final payment date.
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 5/2/2015 | 6/10/2015 | 5/10/2021 | BB | 26938.75 | 4/30/2021 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Paid After Chargeback Date | 0 |
Scenario: BB - Calculate Chargeback for BB loan - using BB Chargeback method, before final payment date.
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 3/30/2017 | 5/14/2017 | 4/14/2022 | BB | 115.00 | 4/30/2021 | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 4.1475409836065573770491803279 | Paid On or Before Chargeback Date | 11 |
Scenario: BB - Calculate Chargeback for BB loan - using BB Chargeback method, paid within a year of loan date.
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/22/2020 | 2/5/2021 | 4/5/2027 | BB | 265.9569 | 4/26/2021 | 75 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 238.52134610526315789473684211 | Paid On or Before Chargeback Date | 71 |
Scenario: BB - Calculate Chargeback for BB loan - paid after final pmt date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/22/2020 | 2/5/2021 | 4/5/2027 | BB | 265.9569 | 4/26/2027 | 75 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard Loan | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Paid After Chargeback Date | 0 |
Scenario: BB - Calculate Chargeback for Buydown reserve - checking Buydown message buydown reserve below threshold
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term | ReserveMessage |
| 8/4/2017 | 9/3/2017 | 8/3/2022 | NC | 0 | 10/20/2019 | 60 | BuyDown - Reserve - Below Threshold |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve Paid - No charge back- after 90 Days | N | 90 | 3 | 25 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Buy Down Reserve - No Chargeback | 33 |
Scenario: NC - Calculate Chargeback for Buydown reserve - checking Buydown message buydown reserve and negative value
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term | ReserveMessage |
| 9/30/2019 | 11/14/2019 | 10/14/2025 | NC | -3471.1087 | 3/20/2021 | 72 | BuyDown - Reserve |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve Paid - No charge back- after 90 Days | N | 90 | 3 | 25 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Buy Down Reserve - No Chargeback | 55 |
Scenario: NC - Calculate Boat Chargeback for Buydown reserve - checking Buydown message buydown reserve and negative value
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term | ReserveMessage | AccountType |
| 9/30/2019 | 11/14/2019 | 10/14/2025 | NC | -3471.1087 | 3/20/2021 | 60 | BuyDown - Reserve | DL10 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve Paid - No charge back- after 90 Days | N | 90 | 3 | 25 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Buy Down Reserve - No Chargeback | 43 |
Scenario: NC - Calculate Boat Chargeback for paid before chargeback date - Term 63 or less
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term | AccountType |
| 7/4/2019 | 8/3/2019 | 10/3/2024 | NC | 460.04 | 11/21/2019 | 63 | DL12 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 390.44069444444444444444444444 | Paid On or Before Chargeback Date | 58 |
Scenario: NC - Calculate Boat Chargeback for paid before chargeback date - Term greater than 63
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term | AccountType |
| 7/3/2019 | 8/2/2019 | 7/2/2029 | NC | 1163.05 | 5/6/2020 | 120 | DL11 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 978.0193181818181818181818182 | Paid On or Before Chargeback Date | 110 |
Scenario: NC - Calculate Boat Chargeback for after chargeback date - Term 63 or less
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term | AccountType |
| 07/04/2019 | 8/3/2019 | 10/3/2024 | NC | 460.04 | 12/21/2020 | 63 | DL11 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Paid After Chargeback Date | 45 |
Scenario: NC - Calculate Boat Chargeback for after chargeback date - Term greater than 63
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term | AccountType |
| 7/3/2019 | 8/2/2019 | 7/2/2029 | NC | 1163.05 | 5/6/2021 | 120 | DL09 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 0 | Paid After Chargeback Date | 98 |
Scenario Outline: NC - Calculate Chargeback for paid date between first payment date and chargeback date examples 1 and 2
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/26/2020 | 2/9/2021 | 4/9/2027 | NC | 1815.0503 | <PaidLoanDate> | 75 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| <Chargeback> | <ChargebackMessage> | <RemainingMonthsAtClose> |
Examples:
| PaidLoanDate | Chargeback | ChargebackMessage | RemainingMonthsAtClose |
| 2/26/2021 | 1720.1581965964912280701754386 | Paid On or Before Chargeback Date | 73 |
| 2/25/2021 | 1720.1581965964912280701754386 | Paid On or Before Chargeback Date | 73 |
Scenario: NC - Calculate Chargeback for paid date between first payment date and chargeback date - example 3
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/29/2020 | 2/12/2021 | 1/12/2027 | NC | 1835.6378 | 2/26/2021 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 1785.3463534246575342465753425 | Paid On or Before Chargeback Date | 71 |
Scenario: NC - Calculate Chargeback for paid date between first payment date and chargeback date - example 4
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 11/23/2020 | 1/7/2021 |12/7/2025 | NC | 1085.4654 | 2/25/2021 | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 980.477762950819672131147541 | Paid On or Before Chargeback Date | 57 |
Scenario: NC - Calculate Chargeback for paid date between first payment date and chargeback date - example 5
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/14/2020 | 1/28/2021 | 12/28/2024 | NC | 58.5443 | 2/19/2021 | 48 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 53.814956037414965986394557823 | Paid On or Before Chargeback Date | 46 |
Scenario: NC - Calculate Chargeback for paid date between first payment date and chargeback date - example 6
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/22/2020 | 2/5/2021 | 1/5/2027 | NC | 853.1331 | 2/19/2021 | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 829.7595904109589041095890411 | Paid On or Before Chargeback Date | 71 |
Scenario: NC - Calculate Chargeback for paid date between first payment date and chargeback date - example 7
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 12/4/2020 | 1/18/2021 | 12/18/2025 | NC | 584.2477 | 2/18/2021 | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 546.25563644808743169398907104 | Paid On or Before Chargeback Date | 58 |
Scenario: NC - Calculate Chargeback for paid date between first payment date and chargeback date - example 8 - paid day after first payment date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 1/2/2021 | 2/16/2021 | 11/16/2024 | NC | 116.0986 | 2/17/2021 | 46 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 111.15823404255319148936170213 | Paid On or Before Chargeback Date | 45 |
Scenario: NC - Calculate Chargeback for paid date between first payment date and chargeback date - example 9 - first payment in a month with 30 days
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 10/14/2020 | 11/28/2020 | 10/28/2023 | NC | 110.7846 | 1/25/2021 | 36 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 93.31855945945945945945945946 | Paid On or Before Chargeback Date | 33 |
Scenario: NC - Calculate Chargeback without using Arbitrary Date (paid loan date 29th, not leap year) for Paid Date after First Payment Date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 1/16/2020 | 4/15/2020 | 3/15/2025 | NC | 169.0256 | 4/29/2020 | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 163.48377704918032786885245902 | Paid On or Before Chargeback Date | 59 |
Scenario: NC - Calculate Chargeback without using Arbitrary Date (paid loan date 30th, not leap year) for Paid Date after First Payment Date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 3/17/2017 | 4/16/2017 | 3/16/2019 | NC | 86.4577 | 5/30/2017 | 24 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 72.912660333333333333333333333 | Paid On or Before Chargeback Date | 22 |
Scenario: NC - Calculate Chargeback without using Arbitrary Date (paid loan date 31st, not leap year) for Paid Date after First Payment Date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 3/17/2017 | 4/16/2017 | 3/16/2019 | NC | 86.4577 | 5/31/2017 | 24 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 72.912660333333333333333333333 | Paid On or Before Chargeback Date | 22 |
Scenario: NC - Calculate Chargeback using Arbitrary Date (paid loan date 29th, leap year) for Paid Date after First Payment Date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 1/16/2019 | 4/15/2019 | 3/15/2024 | NC | 169.0256 | 4/29/2019 | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 163.48377704918032786885245902 | Paid On or Before Chargeback Date | 59 |
Scenario: NC - Calculate Chargeback using Arbitrary Date (paid loan date 30th, leap year) for Paid Date after First Payment Date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 3/17/2018 | 4/16/2018 | 3/16/2020 | NC | 86.4577 | 5/30/2018 | 24 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 72.912660333333333333333333333 | Paid On or Before Chargeback Date | 22 |
Scenario: NC - Calculate Chargeback without using Arbitrary Date (paid loan date 31st, leap year) for Paid Date after First Payment Date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 3/17/2018 | 4/16/2018 | 3/16/2020 | NC | 86.4577 | 5/31/2018 | 24 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 72.912660333333333333333333333 | Paid On or Before Chargeback Date | 22 |
Scenario: NC - Calculate Chargeback using Arbitrary Date with Final pmt after Arbitrary Date (paid loan date 31st, not leap year) for Paid Date after First Payment Date
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Type Id | ReserveAmount | PaidLoanDate | Term |
| 11/30/2018 | 1/1/2019 | 3/1/2025 | NC | 2456.5546 | 1/31/2019 | 75 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the chargeback is calculated
Then the chargeback returned is
| ChargebackAmount | ChargebackTypeMessage | RemainingMonthsAtClose |
| 2328.1242016140350877192982456 | Paid On or Before Chargeback Date | 73 |
@@ -0,0 +1,155 @@
Feature: Dealer Service
Get a list of dealers when searching code or name. Update dealers
Scenario: Search for Dealer - Code - find multiple dealers
Given the dealer table looks like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 | 4535434333 |
| S11 | ANTHONY AUTO GROUP | 5678 | 7535434333 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 | 9535434333 |
When I search for dealers with search string 'S1'
Then dealers returned should be
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 | 4535434333 |
| S11 | ANTHONY AUTO GROUP | 5678 | 7535434333 |
Scenario: Search for Dealer - Code - no dealers returned
Given the dealer table looks like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 | 4535434333 |
| S11 | ANTHONY AUTO GROUP | 5678 | 7535434333 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 | 9535434333 |
When I search for dealers with search string 'A1'
Then dealers returned should be
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
Scenario: Search for Dealer - Name - find multiple dealers
Given the dealer table looks like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 | 4535434333 |
| S11 | ANTHONY AUTO GROUP OF WEST BEND | 5678 | 7535434333 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 | 9535434333 |
When I search for dealers with search string 'WEST'
Then dealers returned should be
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S11 | ANTHONY AUTO GROUP OF WEST BEND | 5678 | 7535434333 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 | 9535434333 |
Scenario: Search for Dealer - Name - no dealers returned
Given the dealer table looks like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 | 4535434333 |
| S11 | ANTHONY AUTO GROUP | 5678 | 7535434333 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 | 9535434333 |
When I search for dealers with search string 'A1'
Then dealers returned should be
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
Scenario: Search for Dealer - Code and name - find multiple dealers
Given the dealer table looks like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 | 4535434333 |
| A1 | ANTHONY AUTO GROUP OF WEST BEND S1 | 9234 | 3535434333 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 | 9535434333 |
When I search for dealers with search string 'S1'
Then dealers returned should be
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 | 4535434333 |
| A1 | ANTHONY AUTO GROUP OF WEST BEND S1 | 9234 | 3535434333 |
Scenario: Update dealers from loans - add dealer that doesn't exist
Given a list of loans with dealers that look like
| LoanId | Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1 | 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434333 |
And the dealer table looks like
|Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
When I update the dealers from the loans
Then the dealer table now looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434333 |
Scenario: Update dealers from loans - add dealer with blank org number
Given a list of loans with dealers that look like
| LoanId | Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1 | | | | |
And the dealer table looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434333 |
When I update the dealers from the loans
Then the dealer table now looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434333 |
| | | | |
Scenario: Update dealers from loans - update name and account number
Given a list of loans with dealers that look like
| LoanId | Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1 | 1234 | S1 | SUBURBAN MOTORS HD | 4535434334 |
And the dealer table looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
When I update the dealers from the loans
Then the dealer table now looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HD | 4535434334 |
Scenario: Update dealers from loans - DO update dealer code
Given a list of loans with dealers that look like
| LoanId | Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1 | 1234 | S11 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
And the dealer table looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
When I update the dealers from the loans
Then the dealer table now looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S11 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
Scenario: Update dealers from loans - only take updates from the first loan with that dealer
Given a list of loans with dealers that look like
| LoanId | Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1 | 1234 | S1 | SUBURBAN MOTORS HD | 4535434334 |
| 1 | 1234 | S1 | BEST SUBURBAN MOTORS HD | 4535434335 |
And the dealer table looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
When I update the dealers from the loans
Then the dealer table now looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HD | 4535434334 |
Scenario: Update dealers from loans - a null dealer code doesn't get pulled in
Given a list of loans with dealers that look like
| LoanId | Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1 | 1234 | <null> | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
And the dealer table looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
When I update the dealers from the loans
Then the dealer table now looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
Scenario: Update dealers from loans - a null dealer name doesn't get pulled in
Given a list of loans with dealers that look like
| LoanId | Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1 | 1234 | S1 | <null> | 4535434334 |
And the dealer table looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
When I update the dealers from the loans
Then the dealer table now looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
Scenario: Update dealers from loans - a null dealer account number doesn't get pulled in
Given a list of loans with dealers that look like
| LoanId | Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1 | 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | <null> |
And the dealer table looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
When I update the dealers from the loans
Then the dealer table now looks like
| Dealer Organization Number | Dealer Code | Name | Dealer Account Number |
| 1234 | S1 | SUBURBAN MOTORS HARLEY DAVIDSON | 4535434334 |
@@ -0,0 +1,95 @@
using Microsoft.EntityFrameworkCore;
using ReserveManagementSystemApi.Services;
using ReserveManagementSystemLib.Models;
using ReserveManagementSystemLib.Persistence;
using ReserveManagementSystemLib.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
using TechTalk.SpecFlow.Assist.ValueRetrievers;
namespace ReserveManagementSystemApi.Tests.Features
{
[Binding]
public sealed class DealerServiceSteps
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
private DealerService _dealerService;
private AppDbContext _appDbContext;
private IEnumerable<Dealer> _dealersResult;
private List<Loan> _loans;
public DealerServiceSteps(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
Service.Instance.ValueRetrievers.Register(new NullValueRetriever("<null>"));
}
[BeforeScenario]
public void CreateDatabase()
{
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
_appDbContext = new AppDbContext(options);
_dealerService = new DealerService(new DealerRepository(_appDbContext));
}
[AfterScenario]
public void Dispose()
{
_appDbContext.Database.EnsureDeleted();
_appDbContext.Dispose();
}
[Given(@"the dealer table looks like")]
public void GivenTheDealerTableLooksLike(Table table)
{
var dealers = table.CreateSet<Dealer>().ToList();
_appDbContext.Dealers.AddRange(dealers);
_appDbContext.SaveChanges();
}
[Given(@"a list of loans with dealers that look like")]
public void GivenAListOfLoansWithDealersThatLookLike(Table table)
{
_loans = table.CreateSet<Loan>().ToList();
var dealers = table.CreateSet<Dealer>().ToList();
for (var i=0; i < _loans.Count; i++)
{
_loans.Skip(i).First().Dealer = dealers.Skip(i).First();
}
}
[When(@"I search for dealers with search string '(.*)'")]
public async void WhenISearchForDealersWithSearchString(string dealerSearchText)
{
_dealersResult = await _dealerService.Search(dealerSearchText);
}
[When(@"I update the dealers from the loans")]
public async void WhenIUpdateTheDealersFromTheLoans()
{
await _dealerService.UpdateDealersAsync(_loans);
}
[Then(@"dealers returned should be")]
public void ThenDealersReturnedShouldBe(Table table)
{
table.CompareToSet(_dealersResult);
}
[Then(@"the dealer table now looks like")]
public void ThenTheDealerTableNowLooksLike(Table table)
{
var dealers = _appDbContext.Dealers.ToList();
table.CompareToSet(dealers);
}
}
}
@@ -0,0 +1,131 @@
Feature: Export Service
Export loans to DNA that have updated reserves or chargebacks
Scenario: Export loan reserves and mark as exported
Given the current loans that look like this
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 5/1/2021 2:00 PM | 5/2/2021 2 pm |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the dealers that look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1111 | 929292929292929 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 5678 | 121212212121212 |
| A1 | ACURA OF BROOKFIELD | 1234 | 48484848484844 |
And the Core Api is successful in saving reserves
When I export the loan reserves on the date '6/1/2021 3:00 PM'
Then the Core API is called with 2 loan reserves
And the loan list will be updated to look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 5/1/2021 2:00 PM | 5/2/2021 2 pm |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 6/1/2021 3:00 PM | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 6/1/2021 3:00 PM | |
And the result of saving the reserves will be 2
Scenario: Export loan reserves - core api service returns false
Given the current loans that look like this
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 5/1/2021 2:00 PM | 5/2/2021 2 pm |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the dealers that look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1111 | 929292929292929 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 5678 | 121212212121212 |
| A1 | ACURA OF BROOKFIELD | 1234 | 48484848484844 |
And the Core Api returns false when saving reserves
When I export the loan reserves on the date '6/1/2021 3:00 PM'
Then the Core API is called with 2 loan reserves
And the loan list will be updated to look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 5/1/2021 2:00 PM | 5/2/2021 2 pm |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the result of saving the reserves will be 0
Scenario: Export loan reserves - error in service client
Given the current loans that look like this
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 5/1/2021 2:00 PM | 5/2/2021 2 pm |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the dealers that look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1111 | 929292929292929 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 5678 | 121212212121212 |
| A1 | ACURA OF BROOKFIELD | 1234 | 48484848484844 |
And the Core Api throws an error in saving reserves
When I export the loan reserves on the date '6/1/2021 3:00 PM'
Then the Core API is called with 2 loan reserves
And the loan list will be updated to look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 5/1/2021 2:00 PM | 5/2/2021 2 pm |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the export service throws an Exception
Scenario: Export loan chargebacks and mark as exported
Given the current loans that look like this
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate | AccountType |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 4/20/2021 1 pm | | DL01 |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 4/20/2021 1 pm | | DL01 |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | | DL01 |
And the dealers that look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1111 | 929292929292929 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 5678 | 121212212121212 |
| A1 | ACURA OF BROOKFIELD | 1234 | 48484848484844 |
And the current minor account that look like this
| MinorAccountTypeId | GeneralLedgerAccountNumber | AccountType |
| 1 | 731 | DL01 |
And the Core Api is successful in saving chargebacks
When I export the loan chargebacks on the date '5/2/2021 2:00 PM'
Then the Core API is called with 1 loan chargebacks
And the loan list will be updated to look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate | AccountType |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 4/20/2021 1 pm | 5/2/2021 2:00 PM | DL01 |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 4/20/2021 1 pm | | DL01 |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | | DL01 |
And the result of saving the chargebacks will be 1
Scenario: Export loan chargebacks - core api returns false
Given the current loans that look like this
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 4/20/2021 1 pm | |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 4/20/2021 1 pm | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the dealers that look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1111 | 929292929292929 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 5678 | 121212212121212 |
| A1 | ACURA OF BROOKFIELD | 1234 | 48484848484844 |
And the Core Api returns false when saving chargebacks
When I export the loan chargebacks on the date '5/2/2021 2:00 PM'
Then the Core API is called with 1 loan chargebacks
And the loan list will be updated to look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 4/20/2021 1 pm | |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 4/20/2021 1 pm | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the result of saving the chargebacks will be 0
Scenario: Export loan chargebacks - error in service client
Given the current loans that look like this
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 4/20/2021 1 pm | |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 4/20/2021 1 pm | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the dealers that look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1111 | 929292929292929 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 5678 | 121212212121212 |
| A1 | ACURA OF BROOKFIELD | 1234 | 48484848484844 |
And the Core Api throws an error in saving chargebacks
When I export the loan chargebacks on the date '5/2/2021 2:00 PM'
Then the Core API is called with 1 loan chargebacks
And the loan list will be updated to look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ExportedReserveDate | ExportedChargebackDate |
| 1 | 452 | 731 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | 50.00 | 4/29/2021 | Standard | 4/20/2021 1 pm | |
| 2 | 451 | 6 | JONES | LAURA | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 4/20/2021 1 pm | |
| 3 | 451 | 73 | JONES | LAURA | M | 1111 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | | |
And the export service throws an Exception
@@ -0,0 +1,209 @@
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
using Microsoft.EntityFrameworkCore;
using Moq;
using ReserveManagementSystemApi.ServiceClients;
using ReserveManagementSystemApi.Services;
using ReserveManagementSystemLib.Models;
using ReserveManagementSystemLib.Persistence;
using ReserveManagementSystemLib.Repositories;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
using Xunit;
using ReserveManagementSystemLib.Configuration;
namespace ReserveManagementSystemApi.Tests.Features
{
[Binding]
public sealed class ExportServiceSteps
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
private ExportService _exportService;
private AppDbContext _appDbContext;
private Mock<ICoreApiServiceClient> _mockCoreApiServiceClient = new Mock<ICoreApiServiceClient>();
private int _exportResult;
private Mock<RmsApiConfiguration> _mockConfiguration = new Mock<RmsApiConfiguration>();
private Exception _exportException;
public ExportServiceSteps(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
[BeforeScenario]
public void CreateDatabase()
{
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
_appDbContext = new AppDbContext(options);
_mockConfiguration.Object.DefaultBatchSize = 100;
_exportService = new ExportService(new LoanRepository(_appDbContext), _mockCoreApiServiceClient.Object, new MinorAccountTypeRepository(_appDbContext), _mockConfiguration.Object);
}
[AfterScenario]
public void Dispose()
{
_appDbContext.Database.EnsureDeleted();
_appDbContext.Dispose();
}
[Given(@"the current loans that look like this")]
public void GivenTheCurrentLoansThatLookLikeThis(Table table)
{
var loans = table.CreateSet<Loan>();
_appDbContext.Loans.AddRange(loans);
_appDbContext.SaveChanges();
}
[Given(@"the current minor account that look like this")]
public void GivenTheCurrentMinorAccountsThatLookLikeThis(Table table)
{
var accounts = table.CreateSet<MinorAccountType>();
_appDbContext.MinorAccountTypes.AddRange(accounts);
_appDbContext.SaveChanges();
}
[Given(@"the Core Api is successful in saving reserves")]
public void GivenTheCoreApiIsSuccessfulInSavingReserves()
{
var transactionResponse = new MonetaryTransactionResponse();
transactionResponse.AccountNumber = 6;
transactionResponse.WasSuccessful = true;
var transactionResponse2 = new MonetaryTransactionResponse();
transactionResponse2.AccountNumber = 73;
transactionResponse2.WasSuccessful = true;
var transactionResponseList = new List<MonetaryTransactionResponse> { transactionResponse, transactionResponse2 };
_mockCoreApiServiceClient.Setup(x => x.PostMonetaryTransactions(It.IsAny<List<GroupedMonetaryTransactionRequest>>())).ReturnsAsync(transactionResponseList);
}
[Given(@"the Core Api returns false when saving reserves")]
public void GivenTheCoreApiReturnsFalseWhenSavingReserves()
{
var transactionResponse = new MonetaryTransactionResponse();
transactionResponse.AccountNumber = 6;
transactionResponse.WasSuccessful = false;
var transactionResponse2 = new MonetaryTransactionResponse();
transactionResponse.AccountNumber = 73;
transactionResponse.WasSuccessful = false;
var transactionResponseList = new List<MonetaryTransactionResponse> { transactionResponse, transactionResponse2 };
_mockCoreApiServiceClient.Setup(x => x.PostMonetaryTransactions(It.IsAny<List<GroupedMonetaryTransactionRequest>>())).ReturnsAsync(transactionResponseList);
}
[Given(@"the Core Api returns false when saving chargebacks")]
public void GivenTheCoreApiReturnsFalseWhenSavingChargebacks()
{
var transactionResponse = new MonetaryTransactionResponse();
transactionResponse.AccountNumber = 731;
transactionResponse.WasSuccessful = false;
var transactionResponseList = new List<MonetaryTransactionResponse> { transactionResponse };
_mockCoreApiServiceClient.Setup(x => x.PostMonetaryTransactions(It.IsAny<List<GroupedMonetaryTransactionRequest>>())).ReturnsAsync(transactionResponseList);
}
[Given(@"the Core Api throws an error in saving reserves")]
public void GivenTheCoreApiThrowsAnErrorInSavingReserves()
{
_mockCoreApiServiceClient.Setup(x => x.PostMonetaryTransactions(It.IsAny<List<GroupedMonetaryTransactionRequest>>())).Throws(new Exception());
}
[Given(@"the Core Api is successful in saving chargebacks")]
public void GivenTheCoreApiIsSuccessfulInSavingChargebacks()
{
var transactionResponse = new MonetaryTransactionResponse();
transactionResponse.AccountNumber = 731;
transactionResponse.WasSuccessful = true;
var transactionResponseList = new List<MonetaryTransactionResponse> { transactionResponse };
_mockCoreApiServiceClient.Setup(x => x.PostMonetaryTransactions(It.IsAny<List<GroupedMonetaryTransactionRequest>>())).ReturnsAsync(transactionResponseList);
}
[Given(@"the Core Api throws an error in saving chargebacks")]
public void GivenTheCoreApiThrowsAnErrorInSavingChargebacks()
{
_mockCoreApiServiceClient.Setup(x => x.PostMonetaryTransactions(It.IsAny<List<GroupedMonetaryTransactionRequest>>())).Throws(new Exception());
}
[When(@"I export the loan reserves on the date '(.*)'")]
public async void WhenIExportTheLoanReservesOnTheDate(DateTime currentDate)
{
try
{
_exportResult = await _exportService.ExportReservesAsync(currentDate);
}
catch(Exception ex)
{
_exportException = ex;
}
}
[When(@"I export the loan chargebacks on the date '(.*)'")]
public async void WhenIExportTheLoanChargebacksOnTheDate(DateTime currentDate)
{
try
{
_exportResult = await _exportService.ExportChargebacksAsync(currentDate);
}
catch (Exception ex)
{
_exportException = ex;
}
}
[Then(@"the Core API is called with (.*) loan reserves")]
public void ThenTheCoreAPIIsCalledWithLoanReserves(int numberOfReserves)
{
_mockCoreApiServiceClient.Verify(x => x.PostMonetaryTransactions(It.Is<List<GroupedMonetaryTransactionRequest>>(x => x.Count == numberOfReserves)));
}
[Then(@"the Core API is called with (.*) loan chargebacks")]
public void ThenTheCoreAPIIsCalledWithLoanChargebacks(int numberOfChargebacks)
{
_mockCoreApiServiceClient.Verify(x => x.PostMonetaryTransactions(It.Is<List<GroupedMonetaryTransactionRequest>>(x => x.Count == numberOfChargebacks)));
}
[Then(@"the loan list will be updated to look like")]
public void ThenTheLoanListWillBeUpdatedToLookLike(Table table)
{
var loansResult = _appDbContext.Loans;
table.CompareToSet(loansResult);
}
[Then(@"the result of saving the reserves will be (.*)")]
public void ThenTheResultOfSavingTheReservesWillBe(int exportNumber)
{
Assert.Equal(exportNumber, _exportResult);
}
[Then(@"the result of saving the chargebacks will be (.*)")]
public void ThenTheResultOfSavingTheChargebacksWillBe(int exportNumber)
{
Assert.Equal(exportNumber, _exportResult);
}
[Then(@"the export service throws an Exception")]
public void ThenTheExportServiceThrowsAnException()
{
Assert.IsType<Exception>(_exportException);
}
[Given(@"the dealers that look like")]
public void GivenTheDealersThatLookLike(Table table)
{
var dealers = table.CreateSet<Dealer>().ToList();
_appDbContext.Dealers.AddRange(dealers);
_appDbContext.SaveChanges();
}
}
}
@@ -0,0 +1,392 @@
Feature: Import Read Service - Closed Loans from DNA
Gets closed loans from DNA by calling a CoreApiWrapper endpoint, reads loans into memory, calculates chargebacks, saves loans, saves import information
Background:
Given a loan type table consisting of
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
| BB | Standard | S | 0 | 0 | 0 | 1.00 | 0.25 |
| NR | No reserve to be paid | N | 0 | 0 | 0 | 0.00 | 0.25 |
Scenario: AddImport for Closed Loans from DNA - all loans are saved
Given that I get these closed loans back from DNA
| LoanNumber | PaidLoanDate |
| 147 | 02/25/2021 |
| 143 | 02/12/2021 |
| 144 | 02/12/2021 |
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | RemainingMonthsAtClose |
| 1 | 1 | 5841 | 147 | SMITH | JOE | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New | |
| 2 | 2 | 10094 | 143 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message | Updated | |
| 3 | 2 | 100947 | 144 | JOHNSON | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message | New | |
When I process the closed loan import from DNA at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 5841 | 147 | 210.0375 | 2/25/2021 | Closed | 63 |
| 2 | 10094 | 143 | 1498.6354 | 2/12/2021 | Closed | 61 |
| 3 | 100947 | 144 | 1498.6354 | 2/12/2021 | Closed | 61 |
And AddHistoriesAsync is called with 2 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 1 history/ies having OldValue "Updated" and NewValue "Closed"
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
Scenario: AddImport for Closed Loans from DNA - saves two loans that are in the loan table
Given that I get these closed loans back from DNA
| LoanNumber | PaidLoanDate |
| 141 | 04/25/2021 |
| 143 | 02/12/2021 |
| 144 | 02/12/2021 |
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus |
| 1 | 1 | 12 | 3 | SMITH | JOE | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New |
| 2 | 2 | 10094 | 143 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New |
| 3 | 2 | 10621 | 144 | JOHNSON | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New |
When I process the closed loan import with missing loan "141" with date from DNA at "3/5/2021 5:00:00 AM" and select from "2/25/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type | ImportId |
| 3/5/2021 5:00:00 AM | 2 | 2 | true | | Closed | 1 |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 12 | 3 | | | New | |
| 2 | 10094 | 143 | 1498.6354 | 2/12/2021 | Closed | 61 |
| 3 | 10621 | 144 | 1498.6354 | 2/12/2021 | Closed | 61 |
And AddHistoriesAsync is called with 2 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 2 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | Term |
| 3250 | 141 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 5.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 4/25/2021 | 63 |
When I process the missing active loans with detail from DNA at "3/5/2021 5:00:00 AM" and export
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type | ImportId |
| 3/5/2021 5:00:00 AM | 1 | 1 | true | | Closed | 2 |
And the import has an end date that is greater or equal to the start date
And the loans with details now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 3250 | 141 | 720.6656 | 04/25/2021 | Closed | 60 |
Scenario: AddImport for Closed Boat Loans from DNA - saves two boat loans that are in the loan table
Given that I get these closed loans back from DNA
| LoanNumber | PaidLoanDate |
| 147 | 02/25/2021 |
| 143 | 04/12/2021 |
| 144 | 04/12/2021 |
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | AccountType |
| 1 | 1 | 12 | 3 | SMITH | JOE | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New | DL09 |
| 2 | 2 | 10094 | 143 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New | DL10 |
| 3 | 2 | 10621 | 144 | JOHNSON | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New | DL11 |
When I process the closed loan import with missing loan "147" with date from DNA at "3/5/2021 5:00:00 AM" and select from "2/25/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type | ImportId |
| 3/5/2021 5:00:00 AM | 2 | 2 | true | | Closed | 1 |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 12 | 3 | | | New | |
| 2 | 10094 | 143 | 1402.7417 | 4/12/2021 | Closed | 59 |
| 3 | 10621 | 144 | 1402.7417 | 4/12/2021 | Closed | 59 |
And AddHistoriesAsync is called with 2 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 2 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays | AccountType |
| 3250 | 147 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 2/25/2021 | 1918 | DL09 |
When I process the missing active loans with detail from DNA at "3/5/2021 5:00:00 AM" and export
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type | ImportId |
| 3/5/2021 5:00:00 AM | 1 | 1 | true | | Closed | 2 |
And the import has an end date that is greater or equal to the start date
And the loans with details now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 3250 | 147 | 769.1038 | 02/25/2021 | Closed | 62 |
Scenario: AddImport for Closed Loans from DNA - Set Action Required = false
Given that I get these closed loans back from DNA
| LoanNumber | PaidLoanDate |
| 148 | 05/25/2021 |
| 143 | 02/12/2021 |
| 144 | 02/12/2021 |
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | ActionRequired |
| 1 | 1 | 12 | 3 | SMITH | JOE | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New | false |
| 2 | 2 | 10094 | 143 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New | true |
| 3 | 2 | 10621 | 144 | JOHNSON | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New | true |
When I process the closed loan import with missing loan "148" with date from DNA at "3/5/2021 5:00:00 AM" and select from "2/25/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type | ImportId |
| 3/5/2021 5:00:00 AM | 2 | 2 | true | | Closed | 1 |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | ActionRequired |
| 1 | 12 | 3 | | | New | | false |
| 2 | 10094 | 143 | 1498.6354 | 2/12/2021 | Closed | 61 | false |
| 3 | 10621 | 144 | 1498.6354 | 2/12/2021 | Closed | 61 | false |
And AddHistoriesAsync is called with 2 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 2 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | Term |
| 3250 | 148 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 5/25/2021 | 63 |
When I process the missing active loans with detail from DNA at "3/5/2021 5:00:00 AM" and export
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type | ImportId |
| 3/5/2021 5:00:00 AM | 1 | 1 | true | | Closed | 2 |
And the import has an end date that is greater or equal to the start date
And the loans with details now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 3250 | 147 | 0 | 05/25/2021 | Closed | 59 |
Scenario: AddImport for Closed Loans from DNA - no loans are returned
Given that I get these closed loans back from DNA
| LoanNumber | PaidLoanDate |
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | RemainingMonthsAtClose |
| 1 | 1 | 5841 | 147 | SMITH | JOE | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New | |
| 2 | 2 | 10094 | 143 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message | Updated | |
| 3 | 2 | 100947 | 144 | JOHNSON | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message | New | |
When I process the closed loan import from DNA at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 0 | 0 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And ExportChargebacksAsync is called
Scenario: Import Closed Loans from DNA with loan details, first adding them, starting at a certain closed date
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate |Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | RemainingMonthsAtClose |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
And ExportReservesAsync is called
Scenario: Import Closed Loans from DNA with loan details, skipping the exports
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate |Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | RemainingMonthsAtClose |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM" and skip the export
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And MarkReservesAndChargebacksAsExportedAsync is called
And ExportChargebacksAsync is not called
And ExportReservesAsync is not called
Scenario: Import Closed Loans from DNA with loan details, two new loans and one updated (changed member initial)
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | X | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | MUELLER | STEVEN | C | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | HAYDEN | ALEXANDER | W | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | JONES | FRED | X | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
And ExportReservesAsync is called
Scenario: Import Closed Loans from DNA with loan details, two new loans and one updated (to change contract rate)
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | Y | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5.5 | false | true | true | false | false | 3434 | 324324324324324 | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | MUELLER | STEVEN | C | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | HAYDEN | ALEXANDER | W | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | JONES | FRED | Y | 37 | false | 524.41373886682351065543659741 | 0 | 7/3/2021 | Closed | 33 | |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
And ExportReservesAsync is called
Scenario: Import Closed Loans from DNA with loan details, with skip the export
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 2233 | 2233143 | JONES | FRED | Y | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5.5 | false | true | true | false | false | 3434 | 324324324324324 | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM" and skip the export
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 1 | 1 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 2233 | 2233143 | JONES | FRED | Y | 37 | false | 524.41373886682351065543659741 | 0 | 7/3/2021 | Closed | 33 | |
And AddHistoriesAsync is called with 1 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And MarkReservesAndChargebacksAsExportedAsync is called
And ExportChargebacksAsync is not called
And ExportReservesAsync is not called
Scenario: Import Closed Loans from DNA with loan details, two new loans and one existing which is already closed with same paid loan date - should ignore that
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | Y | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | MUELLER | STEVEN | C | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | HAYDEN | ALEXANDER | W | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | JONES | FRED | Y | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
And ExportReservesAsync is called
Scenario: Import Closed Loans from DNA with loan details, two new loans and one existing which is already closed but had a different paid loan date
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | Y | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | MUELLER | STEVEN | C | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | HAYDEN | ALEXANDER | W | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | JONES | FRED | Y | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
And ExportReservesAsync is called
Scenario: Import Closed Loans from DNA with loan details, Set Action Required = false
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | Y | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment | ActionRequired |
| 1 | 3250 | 3250144 | MUELLER | STEVEN | C | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | | false |
| 2 | 12021 | 12021143 | HAYDEN | ALEXANDER | W | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | | false |
| 3 | 2233 | 2233143 | JONES | FRED | Y | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | | false |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
And ExportReservesAsync is called
Scenario: Import Closed Loans from DNA with loan details, all dealers are added
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | DealerName | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | SUBURBAN MOTORS HARLEY DAVIDSON | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | HEISER CHEVROLET CADILLAC OF WEST BEND | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | X | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | SUBURBAN MOTORS HARLEY DAVIDSON | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1121 |
And dealers that look like
| Dealer Code | Name | Address1 | Address2 | City | State | Zip | DealerOrganizationNumber | DealerAccountNumber |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | MUELLER | STEVEN | C | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | HAYDEN | ALEXANDER | W | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | JONES | FRED | X | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | |
And the dealers now look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 3434 | 324324324324324 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 3488 | 9888447543454544 |
Scenario: Import Closed Loans from DNA with loan details, all dealers are added, but only dealer information from first loan is added
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | DealerName | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | | | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | HEISER CHEVROLET CADILLAC OF WEST BEND | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | X | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | SUBURBAN MOTORS HARLEY DAVIDSON | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1120 |
And dealers that look like
| Dealer Code | Name | Address1 | Address2 | City | State | Zip | DealerOrganizationNumber | DealerAccountNumber |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | MUELLER | STEVEN | C | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | HAYDEN | ALEXANDER | W | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | JONES | FRED | X | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | |
And the dealers now look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | | 3434 | |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 3488 | 9888447543454544 |
Scenario: Import Closed Loans from DNA with loan details, dealers are updated
Given an import from DNA that contains
| Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | LoanType | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | LoanAmount | Buy Rate | Contract Rate | Gap | Warranty | Mbp | CreditLife | CreditDisability | DealerOrganizationNumber | DealerAccountNumber | DealerName | ApplicationId | VIN | Make | Model | Year | Mileage | Color | PaidLoanDate | OriginalTermInDays |
| 3250 | 3250144 | MUELLER | STEVEN | C | S7 | NC | 2/10/2021 | 02/03/2021 | 03/05/2021 | 05/05/2026 | 27889.51 | 2.03 | 3.39 | True | False | False | False | True | 3434 | 324324324324324 | SUBURBAN MOTORS HARLEY DAVIDSON | 2123444 | | | | | | | 6/30/2021 | 1918 |
| 12021 | 12021143 | HAYDEN | ALEXANDER | W | H21 | BB | 10/31/2019 | 11/6/2019 | 12/15/2019 | 2/15/2026 | 20171.51 | 3.29 | 4.90 | False | True | False | True | False | 3488 | 9888447543454544 | HEISER CHEVROLET CADILLAC OF WEST BEND | 232323455 | M233333389Y853128921 | Honda | Civic | 2020 | 1900 | Black | 7/1/2021 | 2294 |
| 2233 | 2233143 | JONES | FRED | X | S7 | NC | 2/1/2021 | 2/5/2021 | 4/1/2021 | 3/1/2024 | 20000 | 3.5 | 5 | false | true | true | false | false | 3434 | 324324324324324 | SUBURBAN MOTORS HARLEY DAVIDSON | 21235 | M34kls | Toyota | Camry | 2019 | 5 | Red | 7/3/2021 | 1120 |
And dealers that look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HD | 3434 | 324324324324324 |
When I process the closed loan import with detail from DNA at "8/1/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 8/1/2021 5:00:00 AM | 3 | 3 | true | | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Term | FlatFeePaid | ReserveAmount | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | Adjustment |
| 1 | 3250 | 3250144 | MUELLER | STEVEN | C | 63 | false | 793.9136070432343049958707190 | 0 | 6/30/2021 | Closed | 58 | |
| 2 | 12021 | 12021143 | HAYDEN | ALEXANDER | W | 75 | false | 1132.5564086943452341656244555 | 611.9778 | 7/1/2021 | Closed | 55 | |
| 3 | 2233 | 2233143 | JONES | FRED | X | 37 | false | 392.12008534200236229531665461 | 0 | 7/3/2021 | Closed | 33 | |
And the dealers now look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 3434 | 324324324324324 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 3488 | 9888447543454544 |
@@ -0,0 +1,194 @@
Feature: Import Read Service - Closed Loans
Gets closed loans from a stream of csv data, reads loans into memory, calculates chargebacks, saves loans, saves import information
Scenario: AddImport for Closed Loans - all loans are saved
Given an import file named "ClosedLoans 2021-03-01.txt" that contains
"""
LoanNumber,PaidLoanDate
147,02/25/2021
143,02/12/2021
144,02/12/2021
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | RemainingMonthsAtClose |
| 1 | 1 | 5841 | 147 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New | |
| 2 | 2 | 10094 | 143 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message | Updated | |
| 3 | 2 | 100947 | 144 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message | New | |
When I read this closed loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 3 | 3 | true | ClosedLoans 2021-03-01.txt | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 5841 | 147 | 210.0375 | 2/25/2021 | Closed | 63 |
| 2 | 10094 | 143 | 1498.6354 | 2/12/2021 | Closed | 61 |
| 3 | 100947 | 144 | 1498.6354 | 2/12/2021 | Closed | 61 |
And AddHistoriesAsync is called with 2 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 1 history/ies having OldValue "Updated" and NewValue "Closed"
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
Scenario: AddImport for Closed Loans - trim fields and header
Given an import file named "ClosedLoans 2021-03-01.txt" that contains
"""
LoanNumber,PaidLoanDate
147, 02/25/2021
143, 02/12/2021
144, 02/12/2021
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus |
| 1 | 1 | 5841 | 147 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New |
| 2 | 2 | 10094 | 143 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New |
| 3 | 2 | 10621 | 144 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New |
When I read this closed loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 3 | 3 | true | ClosedLoans 2021-03-01.txt | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 5841 | 147 | 210.0375 | 2/25/2021 | Closed | 63 |
| 2 | 10094 | 143 | 1498.6354 | 2/12/2021 | Closed | 61 |
| 3 | 10621 | 144 | 1498.6354 | 2/12/2021 | Closed | 61 |
And AddHistoriesAsync is called with 3 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
Scenario: AddImport for Closed Loans - Set Action Required to False
Given an import file named "ClosedLoans 2021-03-01.txt" that contains
"""
LoanNumber,PaidLoanDate
147, 02/25/2021
143, 02/12/2021
144, 02/12/2021
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | ActionRequired |
| 1 | 1 | 5841 | 147 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New | true |
| 2 | 2 | 10094 | 143 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New | false |
| 3 | 2 | 10621 | 144 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New | true |
When I read this closed loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 3 | 3 | true | ClosedLoans 2021-03-01.txt | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose | ActionRequired |
| 1 | 5841 | 147 | 210.0375 | 2/25/2021 | Closed | 63 | false |
| 2 | 10094 | 143 | 1498.6354 | 2/12/2021 | Closed | 61 | false |
| 3 | 10621 | 144 | 1498.6354 | 2/12/2021 | Closed | 61 | false |
And AddHistoriesAsync is called with 3 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
Scenario: AddImport for Closed Loans - header case insensitive
Given an import file named "ClosedLoans 2021-03-01.txt" that contains
"""
loannumber,PaidLoanDate
147, 02/25/2021
143, 02/12/2021
144, 02/12/2021
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus |
| 1 | 1 | 5841 | 147 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New |
| 2 | 2 | 10094 | 143 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New |
| 3 | 2 | 10621 | 144 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New |
When I read this closed loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 3 | 3 | true | ClosedLoans 2021-03-01.txt | Closed |
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 5841 | 147 | 210.0375 | 2/25/2021 | Closed | 63 |
| 2 | 10094 | 143 | 1498.6354 | 2/12/2021 | Closed | 61 |
| 3 | 10621 | 144 | 1498.6354 | 2/12/2021 | Closed | 61 |
And the import has an end date that is greater or equal to the start date
And AddHistoriesAsync is called with 3 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 3 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And ExportChargebacksAsync is called
Scenario: AddImport for Closed Loans - saves two loans that are in the loan table
Given an import file named "ClosedLoans 2021-03-01.txt" that contains
"""
LoanNumber,PaidLoanDate
149,02/25/2021
143,02/12/2021
144,02/12/2021
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus |
| 1 | 1 | 12 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New |
| 2 | 2 | 10094 | 143 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New |
| 3 | 2 | 10621 | 144 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | New |
When I read this closed loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 3 | 2 | true | ClosedLoans 2021-03-01.txt | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 12 | 3 | | | New | |
| 2 | 10094 | 143 | 1498.6354 | 2/12/2021 | Closed | 61 |
| 3 | 10621 | 144 | 1498.6354 | 2/12/2021 | Closed | 61 |
And AddHistoriesAsync is called with 2 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 2 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And AddHistoriesAsync is called with 1 history/ies having ActivityType "Error" and AuditDescription "Loan in closed import not found"
And ExportChargebacksAsync is called
Scenario: AddImport for Closed Boat Loans - saves two loans that are in the loan table
Given an import file named "ClosedLoans 2021-03-01.txt" that contains
"""
LoanNumber,PaidLoanDate,AccountType
151,02/25/2021,DL10
143,04/12/2021,DL11
144,04/12/2021,DL12
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | LoanStatus | AccountType |
| 1 | 1 | 12 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | New | DL10 |
| 2 | 2 | 10094 | 143 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message | New | DL11 |
| 3 | 2 | 10621 | 144 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 1/10/2027 | 21274.24 | 2.490 | 4.470 | NC | 70 | 1063.7120 | 500 | false | | | Message | New | DL12 |
When I read this closed loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 3 | 2 | true | ClosedLoans 2021-03-01.txt | Closed |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | Member Number | Loan Number | Chargeback | Paid Loan Date | LoanStatus | RemainingMonthsAtClose |
| 1 | 12 | 3 | | | New | |
| 2 | 10094 | 143 | 1402.7417 | 4/12/2021 | Closed | 59 |
| 3 | 10621 | 144 | 1033.7483 | 4/12/2021 | Closed | 69 |
And AddHistoriesAsync is called with 2 history/ies having OldValue "New" and NewValue "Closed"
And AddHistoriesAsync is called with 2 history/ies having ActivityType "LoanStatusChange" and AuditDescription "Importing closed loan changed loan status"
And AddHistoriesAsync is called with 1 history/ies having ActivityType "Error" and AuditDescription "Loan in closed import not found"
And ExportChargebacksAsync is called
Scenario: AddImport - file has a header with one column named incorrectly
Given an import file named "ClosedLoans 2021-03-01.txt" that contains
"""
LoanNumber,PaidDate
147,02/25/2021
143,02/12/2021
144,02/12/2021
"""
When I read this closed loan import file at "3/5/2021 5:00:00 AM"
And I get the record from the ImportTable
Then the import looks like
| StartDate | EndDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | | 0 | 0 | false | ClosedLoans 2021-03-01.txt | Closed |
Scenario: AddImport - file is missing the header
Given an import file named "ClosedLoans 2021-03-01.txt" that contains
"""
147,02/25/2021
143,02/12/2021
144,02/12/2021
"""
When I read this closed loan import file at "3/5/2021 5:00:00 AM"
And I get the record from the ImportTable
Then the import looks like
| StartDate | EndDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | | 0 | 0 | false | ClosedLoans 2021-03-01.txt | Closed |
@@ -0,0 +1,234 @@
Feature: Import Read Service - New Loans
Gets loans from a stream of csv data, reads loans into memory, calculates reserve, saves loans, saves import information
Scenario: AddImport - happy path
Given an import file named "NewLoans 2021-03-01.txt" that contains
"""
3434,3250,144,MUELLER, STEVEN C,02/10/2021,02/12/2021,03/12/2021,2/12/2025,25989.97,2.03,3.39,579.76,NC,XX,N,1462
4545,12021,143,HAYDEN, ALEXANDER W,01/23/2021,02/02/2021,03/09/2021,2/9/2027,14975.57,4.39,6.39,251.61,NC,XX,N,2189
"""
When I read this new loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 2 | 2 | true | NewLoans 2021-03-01.txt | Active |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | Loan Status | ExportedReserveDate | Term |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | 3434 | 2/10/2021 | 2.03 | 3.39 | New | | 48 |
| 1 | 12021 | 143 | HAYDEN | ALEXANDER | W | 4545 | 1/23/2021 | 4.39 | 6.39 | New | | 72 |
And ExportReservesAsync is called
Scenario: AddImport with Boat Loan Account Type
Given an import file named "NewLoans 2021-03-01.txt" that contains
"""
3434,71229741,143,WILLIAMS,SAM R,01/06/2021,02/03/2021,03/05/2021,05/05/2026,27889.51,2.49,4.49,472.71,NC,XX,N,1918,M233333389Y85312,Honda,Civic,2020,1900,Black,1245988,false,false,false,false,false,DL10
"""
When I read this new loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 1 | 1 | true | NewLoans 2021-03-01.txt | Active |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | Loan Status | ExportedReserveDate | ReserveAmount | ReserveMessage | Term |
| 1 | 71229741 | 143 | WILLIAMS | SAM | R | 3434 | 1/06/2021 | 2.49 | 4.49 | New | | 1673.3706 | Standard Reserve | 63 |
And ExportReservesAsync is called
Scenario: AddImport - file is wrong format (missing column, etc.) - note that this doesn't return the import that was saved but it is in the table
Given an import file named "NewLoans 2021-03-01.txt" that contains
"""
C9,3250,144,MUELLER, STEVEN C,02/10/2021,03/12/2021,2/12/2025,25989.97,2.03,3.39,579.76,NC,XX,N
R23,12021,143,HAYDEN, ALEXANDER W,01/23/2021,03/09/2021,2/9/2027,14975.57,4.39,6.39,251.61,NC,XX,N
"""
When I read this new loan import file at "3/5/2021 5:00:00 AM"
And I get the record from the ImportTable
Then the import looks like
| StartDate | EndDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | | 0 | 0 | false | NewLoans 2021-03-01.txt | Active |
And ExportReservesAsync is not called
Scenario: AddImport - file name has more than 50 characters
Given an import file named "NewLoans 2021-03-011234567890123456789012345678901234567890.txt" that contains
"""
1234,3250,144,MUELLER, STEVEN C,02/10/2021,02/12/2021,03/12/2021,2/12/2025,25989.97,2.03,3.39,579.76,NC,XX,N,1462
5678,12021,143,HAYDEN, ALEXANDER W,01/23/2021,02/02/2021,03/09/2021,2/9/2027,14975.57,4.39,6.39,251.61,NC,XX,N,2189
"""
When I read this new loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename |
| 3/5/2021 5:00:00 AM | 2 | 2 | true | NewLoans 2021-03-011234567890123456789012345678901 |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| ImportId | Member Number | Loan Number | Member LastName | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | Loan Status | ExportedReserveDate | Term |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | 1234 | 2/10/2021 | 2.03 | 3.39 | New | | 48 |
| 1 | 12021 | 143 | HAYDEN | ALEXANDER | W | 5678 | 1/23/2021 | 4.39 | 6.39 | New | | 72 |
And ExportReservesAsync is called
Scenario: AddImport for Update Loans - updates three new loans that are in the loan table, saves one brand new loan
Given an import file named "NewLoans 2021-03-01.txt" that contains
"""
3434,13,3,SMITH, JOE,02/25/2021,02/28/2021,04/11/2021,6/11/2026,12615.87,4.03,5.790,579.76,NC,XX,N,1930
4545,3250,144,MUELLER, STEVEN C,02/10/2021,02/12/2021,03/12/2021,2/12/2025,25989.97,2.03,3.39,579.76,NC,XX,N,1462
1212,12021,143,HAYDEN, ALEXANDER W,01/23/2021,02/02/2021,03/09/2021,2/9/2027,14975.57,4.39,6.39,251.61,NC,XX,N,2199
7878,13991,145,RUTHENBERG, RICHARD J,01/22/2021,02/02/2021,03/08/2021,5/8/2027,32891.50,2.43,3.19,484.92,NC,XX,N,2287
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | LoanStatus | ExportedReserveDate | Term |
| 1 | 1 | 13 | 3 | SMITH | JOE | | 3434 | 2/25/2021 | 4.030 | 4.790 | New | 5/2/2021 | 63 |
| 2 | 1 | 3250 | 144 | MUELLER | STEVEN | C | 4545 | 2/10/2021 | 2.03 | 3.39 | New | 5/2/2021 | 48 |
| 3 | 1 | 12021 | 143 | HAYDEN | ALEXANDER | W | 1212 | 1/23/2021 | 4.39 | 6.39 | New | 5/2/2021 | 72 |
When I read this new loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename |
| 3/5/2021 5:00:00 AM | 4 | 4 | true | NewLoans 2021-03-01.txt |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | LoanStatus | ExportedReserveDate | Term |
| 1 | 1 | 13 | 3 | SMITH | JOE | | 3434 | 2/25/2021 12:00:00 AM | 4.03 | 5.790 | Updated | | 63 |
| 2 | 1 | 3250 | 144 | MUELLER | STEVEN | C | 4545 | 2/10/2021 12:00:00 AM | 2.03 | 3.39 | Updated | | 48 |
| 3 | 1 | 12021 | 143 | HAYDEN | ALEXANDER | W | 1212 | 1/23/2021 12:00:00 AM | 4.39 | 6.39 | Updated | | 72 |
| 4 | 1 | 13991 | 145 | RUTHENBERG | RICHARD | J | 7878 | 1/22/2021 12:00:00 AM | 2.43 | 3.19 | New | | 75 |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "NewLoanUpdate" and AuditDescription "Loan found in table, record updated"
And AddHistoriesAsync is called with 1 history/ies having LoanNumber "3" and MemberNumber "13"
And ExportReservesAsync is called
Scenario: AddImport for Update Loans - updates three new loans that are in the loan table, one loan has ten thousandth decimal place difference in buy rate, and same with contract rate, round down
Given an import file named "NewLoans 2021-03-01.txt" that contains
"""
3434,13,3,SMITH, JOE,02/25/2021,02/28/2021,04/11/2021,6/11/2026,12615.87,4.03124,5.790,579.76,NC,XX,N,1930
4545,3250,144,MUELLER, STEVEN C,02/10/2021,02/12/2021,03/12/2021,2/12/2025,25989.97,2.03,3.39,579.76,NC,XX,N,1462
1212,12021,143,HAYDEN, ALEXANDER W,01/23/2021,02/02/2021,03/09/2021,2/9/2027,14975.57,4.39,6.39,251.61,NC,XX,N,2199
7878,13991,145,RUTHENBERG, RICHARD J,01/22/2021,02/02/2021,03/08/2021,5/8/2027,32891.50,2.43,3.19,484.92,NC,XX,N,2287
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | LoanStatus | ExportedReserveDate | Term |
| 1 | 1 | 13 | 3 | SMITH | JOE | | 3434 | 2/25/2021 | 4.031 | 4.790 | New | 5/2/2021 | 63 |
| 2 | 1 | 3250 | 144 | MUELLER | STEVEN | C | 4545 | 2/10/2021 | 2.03 | 3.39 | New | 5/2/2021 | 48 |
| 3 | 1 | 12021 | 143 | HAYDEN | ALEXANDER | W | 1212 | 1/23/2021 | 4.39 | 6.39 | New | 5/2/2021 | 72 |
When I read this new loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename |
| 3/5/2021 5:00:00 AM | 4 | 4 | true | NewLoans 2021-03-01.txt |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | LoanStatus | ExportedReserveDate | Term |
| 1 | 1 | 13 | 3 | SMITH | JOE | | 3434 | 2/25/2021 12:00:00 AM | 4.031 | 5.790 | Updated | | 63 |
| 2 | 1 | 3250 | 144 | MUELLER | STEVEN | C | 4545 | 2/10/2021 12:00:00 AM | 2.03 | 3.39 | Updated | | 48 |
| 3 | 1 | 12021 | 143 | HAYDEN | ALEXANDER | W | 1212 | 1/23/2021 12:00:00 AM | 4.39 | 6.39 | Updated | | 72 |
| 4 | 1 | 13991 | 145 | RUTHENBERG | RICHARD | J | 7878 | 1/22/2021 12:00:00 AM | 2.43 | 3.19 | New | | 75 |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "NewLoanUpdate" and AuditDescription "Loan found in table, record updated"
And AddHistoriesAsync is called with 1 history/ies having LoanNumber "3" and MemberNumber "13"
And ExportReservesAsync is called
Scenario: AddImport for Update Loans - updates three new loans that are in the loan table, one loan has ten thousandth decimal place difference in buy rate, and same with contract rate, round up
Given an import file named "NewLoans 2021-03-01.txt" that contains
"""
3434,13,3,SMITH, JOE,02/25/2021,02/28/2021,04/11/2021,6/11/2026,12615.87,4.03155,5.790,579.76,NC,XX,N,1930
4545,3250,144,MUELLER, STEVEN C,02/10/2021,02/12/2021,03/12/2021,2/12/2025,25989.97,2.03,3.39,579.76,NC,XX,N,1462
1212,12021,143,HAYDEN, ALEXANDER W,01/23/2021,02/02/2021,03/09/2021,2/9/2027,14975.57,4.39,6.2465,251.61,NC,XX,N,2199
7878,13991,145,RUTHENBERG, RICHARD J,01/22/2021,02/02/2021,03/08/2021,5/8/2027,32891.50,2.43,3.19,484.92,NC,XX,N,2287
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | LoanStatus | ExportedReserveDate | Term |
| 1 | 1 | 13 | 3 | SMITH | JOE | | 3434 | 2/25/2021 | 4.031 | 5.790 | New | 5/2/2021 | 63 |
| 2 | 1 | 3250 | 144 | MUELLER | STEVEN | C | 4545 | 2/10/2021 | 2.03 | 3.39 | New | 5/2/2021 | 48 |
| 3 | 1 | 12021 | 143 | HAYDEN | ALEXANDER | W | 1212 | 1/23/2021 | 4.39 | 6.246 | New | 5/2/2021 | 72 |
When I read this new loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename |
| 3/5/2021 5:00:00 AM | 4 | 4 | true | NewLoans 2021-03-01.txt |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | LoanStatus | ExportedReserveDate | Term |
| 1 | 1 | 13 | 3 | SMITH | JOE | | 3434 | 2/25/2021 12:00:00 AM | 4.032 | 5.790 | Updated | | 63 |
| 2 | 1 | 3250 | 144 | MUELLER | STEVEN | C | 4545 | 2/10/2021 12:00:00 AM | 2.03 | 3.39 | Updated | | 48 |
| 3 | 1 | 12021 | 143 | HAYDEN | ALEXANDER | W | 1212 | 1/23/2021 12:00:00 AM | 4.39 | 6.247 | Updated | | 72 |
| 4 | 1 | 13991 | 145 | RUTHENBERG | RICHARD | J | 7878 | 1/22/2021 12:00:00 AM | 2.43 | 3.19 | New | | 75 |
And AddHistoriesAsync is called with 3 history/ies having ActivityType "NewLoanUpdate" and AuditDescription "Loan found in table, record updated"
And AddHistoriesAsync is called with 1 history/ies having LoanNumber "3" and MemberNumber "13"
And ExportReservesAsync is called
Scenario: AddImport for Update Loans - updates one loan that is in the loan table, 1 records to audit table for updates
Given an import file named "NewLoans 2021-03-01.txt" that contains
"""
3434,12,3,SMITH, JOE,02/25/2021,02/28/2021,04/11/2021,6/11/2026,12615.87,4.03,5.790,579.76,NC,XX,N,1930
"""
And a loan table consisting of
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | LoanStatus | ExportedReserveDate | Term |
| 1 | 1 | 12 | 3 | SMITH | JOE | | 3434 | 2/25/2021 | 4.030 | 4.790 | New | 5/2/2021 | 63 |
When I read this new loan import file at "3/5/2021 5:00:00 AM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 3/5/2021 5:00:00 AM | 1 | 1 | true | NewLoans 2021-03-01.txt | Active |
And the import has an end date that is greater or equal to the start date
And the loans now look like
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | LoanStatus | ExportedReserveDate | Term |
| 1 | 1 | 12 | 3 | SMITH | JOE | | 3434 | 2/25/2021 12:00:00 AM | 4.03 | 5.790 | Updated | | 63 |
And AddHistoriesAsync is called with 1 history/ies having ActivityType "NewLoanUpdate" and AuditDescription "Loan found in table, record updated"
And AddHistoriesAsync is called with 1 history/ies having LoanNumber "3" and MemberNumber "12"
And ExportReservesAsync is called
Scenario: AddImport - Vehicle Info - One record populated with VIN, one record optional, Not checking for invalid dealer code any more, Two Invalid Missing VIN action required True
Given an import file named "NewLoans 2021-05-19.txt" that contains
"""
3434,71229741,143,WILLIAMS,SAM R,01/06/2021,02/03/2021,03/05/2021,05/05/2026,27889.51,2.49,2.49,472.71,NC,XX,N,1918,M233333389Y85312,Honda,Civic,2020,1900,Black
4545,7488740,144,STERLING, JIM C,01/06/2021,02/03/2021,03/05/2021,05/05/2026,27889.51,2.49,2.49,472.71,NC,XX,N,1918
4545,8488740,144,STERLING, KIM C,01/06/2021,02/03/2021,03/05/2021,05/05/2026,27889.51,2.49,2.49,472.71,NC,XX,N,1918,,Honda,Civic,2020,1900,Black
"""
And dealers that look like
| Dealer Code | Name | DealerOrganizationNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 3333 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 4545 |
When I read this new loan import file at "5/19/2021 1:00:00 PM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 5/19/2021 1:00:00 PM | 3 | 3 | true | NewLoans 2021-05-19.txt | Active |
And the loans now look like
| ImportId | LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | Loan Status | Action Required | ExportedReserveDate | Term |
| 1 | 1 | 71229741 | 143 | WILLIAMS | SAM | R | 3434 | 1/06/2021 | 2.49 | 2.49 | New | False | | 63 |
| 1 | 2 | 7488740 | 144 | STERLING | JIM | C | 4545 | 1/06/2021 | 2.49 | 2.49 | New | True | | 63 |
| 1 | 3 | 8488740 | 144 | STERLING | KIM | C | 4545 | 1/06/2021 | 2.49 | 2.49 | New | True | | 63 |
And ExportReservesAsync is called
Scenario: AddImport - Vehicle Info - One record populated with VIN, one record optional
Given an import file named "NewLoans 2021-05-19.txt" that contains
"""
3434,71229741,143,WILLIAMS,SAM R,01/06/2021,02/03/2021,03/05/2021,05/05/2026,27889.51,2.49,2.49,472.71,NC,XX,N,1918
4545,7488740,144,STERLING, JIM C,01/06/2021,02/03/2021,03/05/2021,05/05/2026,27889.51,2.49,2.49,472.71,NC,XX,N,1918,M233333389Y85312,Honda,Civic,2020,1900,Black
"""
When I read this new loan import file at "5/19/2021 1:00:00 PM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 5/19/2021 1:00:00 PM | 2 | 2 | true | NewLoans 2021-05-19.txt | Active |
And the loans now look like
| ImportId | LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | Loan Status | ExportedReserveDate | Term |
| 1 | 1 | 71229741 | 143 | WILLIAMS | SAM | R | 3434 | 1/06/2021 | 2.49 | 2.49 | New | | 63 |
| 1 | 2 | 7488740 | 144 | STERLING | JIM | C | 4545 | 1/06/2021 | 2.49 | 2.49 | New | | 63 |
And the vehicle for LoanId 2 looks like this
| VIN Number | LoanId | Make | Model | Year | Mileage | Color |
| M233333389Y85312 | 2 | Honda | Civic | 2020 | 1900 | Black |
And the vehicle for LoanId 1 looks like this
| VIN Number | LoanId | Make | Model | Year | Mileage | Color |
| | 1 | | | | 0 | |
And ExportReservesAsync is called
Scenario: AddImport - Vehicle Info - Both records populated with VIN, can handle VIN longer than 17 characters
Given an import file named "NewLoans 2021-05-19-2.txt" that contains
"""
3434,7488740,144,SWEENEY, JIM C,01/06/2021,02/03/2021,03/05/2021,05/05/2026,27889.51,2.49,2.49,472.71,NC,XX,N,1918,M733P33389Y85216,Chevrolet,Cruze,2013,10K,White
4545,71229741,143,BARNES,BILL R,01/06/2021,02/03/2021,03/05/2021,05/05/2026,27889.51,2.49,2.49,472.71,NC,XX,N,1918,M233333389Y853128921,Buick,LaCrosse,2017,56000,Burgundy
"""
When I read this new loan import file at "5/19/2021 1:00:00 PM"
Then the import looks like
| StartDate | RecordCount | RecordsSaved | Success | Filename | Import Type |
| 5/19/2021 1:00:00 PM | 2 | 2 | true | NewLoans 2021-05-19-2.txt | Active |
And the loans now look like
| ImportId | LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | Buy Rate | Contract Rate | Loan Status | ExportedReserveDate | Term |
| 1 | 1 | 7488740 | 144 | SWEENEY | JIM | C | 3434 | 1/06/2021 | 2.49 | 2.49 | New | | 63 |
| 1 | 2 | 71229741 | 143 | BARNES | BILL | R | 4545 | 1/06/2021 | 2.49 | 2.49 | New | | 63 |
And the vehicle for LoanId 1 looks like this
| VehicleId | VIN Number | LoanId | Make | Model | Year | Mileage | Color |
| 1 | M733P33389Y85216 | 1 | Chevrolet | Cruze | 2013 | 0 | White |
And the vehicle for LoanId 2 looks like this
| VehicleId | VIN Number | LoanId | Make | Model | Year | Mileage | Color |
| 2 | M233333389Y853128921 | 2 | Buick | LaCrosse | 2017 | 56000 | Burgundy |
And ExportReservesAsync is called
@@ -0,0 +1,434 @@
using Microsoft.EntityFrameworkCore;
using Moq;
using System.Globalization;
using System.Text;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
using TechTalk.SpecFlow.Assist.ValueRetrievers;
using Xunit;
using ReserveManagementSystemApi.ServiceClients;
using ReserveManagementSystemApi.Services;
using ReserveManagementSystemLib.Configuration;
using ReserveManagementSystemLib.Models;
using ReserveManagementSystemLib.Persistence;
using ReserveManagementSystemLib.Repositories;
using LCU.Library.Internal.ApiSecurity.Enums;
using LCU.Library.Internal.ApiSecurity.Models;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.IndirectLoan;
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
namespace ReserveManagementSystemApi.Tests.Features
{
[Binding]
public sealed class ImportReadServiceSteps
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
private ApiSecurityConfiguration _apiSecurityConfiguration;
private ImportReadService _importReadService;
private LoanRepository _loanRepository;
private LoanTypeRepository _loanTypeRepository;
private DealerRepository _dealerRepository;
private DealerService _dealerService;
private Mock<IAuditHistoryRepository> _mockAuditHistRepo;
private Mock<IExportService> _mockExportService;
private LoanService _loanService;
private ImportRepository _importRepository;
private ImportService _importService;
private AppDbContext _appDbContext;
private Import _importResult;
private Exception _exception;
private string _importFileName;
private StreamReader _importStreamReader;
private List<Loan> _loansResult;
private List<Dealer> _dealersResult;
private List<IndirectLoanDetail> _loanDetailsFromDNA;
private List<ClosedIndirectLoan> _closedLoansFromDNA;
private Mock<CoreApiConfiguration> _mockCoreApiConfiguration;
private Mock<IGetRequest> _mockgetRequest;
private Mock<IPostRequest> _mockpostRequest;
private Mock<IPutRequest> _mockputRequest;
public ImportReadServiceSteps(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
Service.Instance.ValueRetrievers.Register(new NullValueRetriever("<null>"));
}
[BeforeScenario]
public void CreateDatabase()
{
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
_apiSecurityConfiguration = new ApiSecurityConfiguration(ApiKeyAuthenticationFailureBehavior.Warn);
_mockCoreApiConfiguration = new Mock<CoreApiConfiguration>();
_mockCoreApiConfiguration.Object.ApiTimeOutInSeconds = "420";
_mockpostRequest = new Mock<IPostRequest>();
_mockputRequest = new Mock<IPutRequest>();
_mockgetRequest = new Mock<IGetRequest>();
_appDbContext = new AppDbContext(options);
_loanRepository = new LoanRepository(_appDbContext);
_loanTypeRepository = new LoanTypeRepository(_appDbContext);
_dealerRepository = new DealerRepository(_appDbContext);
_importRepository = new ImportRepository(_appDbContext);
_mockAuditHistRepo = new Mock<IAuditHistoryRepository>();
_mockExportService = new Mock<IExportService>();
_dealerService = new DealerService(_dealerRepository);
_loanService = new LoanService(_loanRepository, _loanTypeRepository, new AuditHistoryService(_mockAuditHistRepo.Object),
new Mock<ICoreApiServiceClient>().Object);
_importService = new ImportService(_importRepository);
_importReadService = new ImportReadService(
_loanService, _importService,
_dealerService,
_mockExportService.Object,
new CoreApiServiceClient(_apiSecurityConfiguration, _mockCoreApiConfiguration.Object, _mockgetRequest.Object, _mockpostRequest.Object, _mockputRequest.Object),
new Mock<RmsApiConfiguration>().Object
);
}
[AfterScenario]
public void DisposeAppDbContext()
{
_appDbContext.Database.EnsureDeleted();
_appDbContext.Dispose();
}
[Given(@"an import file named ""(.*)"" that contains")]
public void GivenAnImportFileNamedThatContains(string fileName, string fileContent)
{
_importFileName = fileName;
var byteArray = Encoding.UTF8.GetBytes(fileContent);
var stream = new MemoryStream(byteArray);
_importStreamReader = new StreamReader(stream);
}
[Given(@"that I get these closed loans back from DNA")]
public void GivenThatIGetTheseClosedLoansBackFromDNA(Table table)
{
_closedLoansFromDNA = table.CreateSet<ClosedIndirectLoan>().ToList();
}
[Given(@"an import from DNA that contains")]
public void GivenAnImportFromDNAThatContains(Table table)
{
_loanDetailsFromDNA = table.CreateSet<IndirectLoanDetail>().ToList();
}
[Given(@"a loan table consisting of")]
public void GivenALoanTableConsistingOf(Table table)
{
var loans = table.CreateSet<Loan>().ToList();
_appDbContext.Loans.AddRange(loans);
_appDbContext.SaveChanges();
}
[Given(@"a loan type table consisting of")]
public void GivenALoanTypeTableConsistingOf(Table table)
{
var types = table.CreateSet<LoanType>().ToList();
_appDbContext.LoanTypes.AddRange(types);
_appDbContext.SaveChanges();
}
[Given(@"dealers that look like")]
public void GivenDealersThatLookLike(Table table)
{
var dealers = table.CreateSet<Dealer>().ToList();
_appDbContext.Dealers.AddRange(dealers);
_appDbContext.SaveChanges();
}
[Given(@"the current vehicle for loanId (.*) is")]
public void GivenTheCurrentVehicleForLoanIdIs(int loanId, Table table)
{
var vehicle = table.CreateInstance<Vehicle>();
vehicle.LoanId = loanId;
_appDbContext.Vehicles.Add(vehicle);
_appDbContext.SaveChanges();
}
[When(@"I read this new loan import file at ""(.*)""")]
public async void WhenIReadThisNewLoanImportFileAt(DateTime currentTime)
{
try
{
_importResult = await _importReadService.ReadNewLoanImportFile(_importStreamReader, _importFileName, currentTime);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I process this DNA new/updated loan import at ""(.*)""")]
public async void WhenIReadThisNewDNALoanImportFileAt(DateTime currentTime)
{
try
{
_importResult = await _importReadService.ProcessActiveLoanImport(_loanDetailsFromDNA, currentTime);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I process this DNA new/updated loan import at ""(.*)"" and skip the export")]
public async void WhenIProcessThisDNANewUpdatedLoanImportAtAndSkipTheExport(DateTime currentTime)
{
try
{
_importResult = await _importReadService.ProcessActiveLoanImport(_loanDetailsFromDNA, currentTime, true);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I process the closed loan import from DNA at ""(.*)""")]
public async void WhenIReadTheClosedLoanImportFromDNAAt(DateTime currentTime)
{
try
{
_importResult = await _importReadService.ProcessClosedLoanImport(_closedLoansFromDNA, currentTime, string.Empty);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I process the closed loan import with missing loan ""(.*)"" with date from DNA at ""(.*)"" and select from ""(.*)""")]
public async void WhenIProcessTheClosedLoanImportWithMissingLoanWithDateFromDNAAt(string missingLoanNumber, DateTime currentTime, DateTime newerThan)
{
try
{
var stringDate = newerThan.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
_importResult = await _importReadService.ProcessClosedLoanImport(_closedLoansFromDNA.Where(l => l.LoanNumber != missingLoanNumber).ToList(),
currentTime, stringDate);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I process the missing active loans with detail from DNA at ""(.*)"" and export")]
public async void WhenIProcessTheMissingActiveLoansWithDetailFromDNAAtAndExport(DateTime currentTime)
{
try
{
_importResult = await _importReadService.ProcessClosedLoansWithUpdates(_loanDetailsFromDNA, currentTime, false);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I process the closed loan import with detail from DNA at ""(.*)""")]
public async void WhenIReadTheInitialClosedLoanImportFromDNAAt(DateTime currentTime)
{
try
{
_importResult = await _importReadService.ProcessClosedLoansWithUpdates(_loanDetailsFromDNA, currentTime, false);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I process the closed loan import with detail from DNA at ""(.*)"" and skip the export")]
public async void WhenIReadTheInitialClosedLoanImportFromDNAAtAndSkipTheExport(DateTime currentTime)
{
try
{
_importResult = await _importReadService.ProcessClosedLoansWithUpdates(_loanDetailsFromDNA, currentTime, true);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I read this closed loan import file at ""(.*)""")]
public async void WhenIReadThisClosedLoanImportFileAt(DateTime currentTime)
{
try
{
_importResult = await _importReadService.ReadClosedLoanImportFile(_importStreamReader, _importFileName, currentTime);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the record from the ImportTable")]
public async void WhenIGetTheRecordFromTheImportTable()
{
_importResult = (await _importRepository.GetAll().ToListAsync()).First();
}
[Then(@"the import has start date ""(.*)""")]
public void ThenTheImportHasStartDate(DateTime startDate)
{
Assert.Equal(startDate, _importResult.StartDate);
}
[Then(@"the import has an end date that is greater or equal to the start date")]
public void ThenTheImportHasAnEndDateThatIsGreaterOrEqualToTheStartDate()
{
Assert.True(_importResult.EndDate >= _importResult.StartDate);
}
[Then(@"the import has record count (.*)")]
public void ThenTheImportHasRecordCount(int recordCount)
{
Assert.Equal(recordCount, _importResult.RecordCount);
}
[Then(@"the import has success ""(.*)""")]
public void ThenTheImportHasSuccess(bool success)
{
Assert.Equal(success, _importResult.Success);
}
[Then(@"the import has file name ""(.*)""")]
public void ThenTheImportHasFileName(string fileName)
{
Assert.Equal(fileName, _importResult.FileName);
}
[Then(@"an exception is thrown")]
public void ThenAnExceptionIsThrown()
{
Assert.NotNull(_exception);
}
[Then(@"the import looks like")]
public void ThenTheImportLooksLike(Table table)
{
table.CompareToInstance(_importResult);
}
[Then(@"there is a record added to the Audit History table")]
public void ThenThereIsARecordAddedToTheAuditHistoryTable()
{
_mockAuditHistRepo.Verify(x => x.AddHistoriesAsync(It.IsAny<List<AuditHistory>>()));
}
[Then(@"no audit history record is added")]
public void ThenNoAuditHistoryRecordIsAdded()
{
_mockAuditHistRepo.Verify(x => x.AddHistoriesAsync(It.IsAny<List<AuditHistory>>()), Times.Never);
}
[Then(@"AddHistoriesAsync is called with (.*) history/ies having OldValue ""(.*)"" and NewValue ""(.*)""")]
public void ThenAddHistoriesAsyncIsCalledWithHistoryIesHavingOldValueAndNewValue(int number, string oldValue, string newValue)
{
_mockAuditHistRepo.Verify(x =>
x.AddHistoriesAsync(It.Is<List<AuditHistory>>(a => a.Count(x => x.NewValue == newValue && x.OldValue == oldValue) == number)));
}
[Then(@"AddHistoriesAsync is called with (.*) history/ies having ActivityType ""(.*)"" and AuditDescription ""(.*)""")]
public void ThenAddHistoriesAsyncIsCalledWithHistoryHavingActivityTypeAndAuditDescription(int number, string type, string description)
{
_mockAuditHistRepo.Verify(x =>
x.AddHistoriesAsync(It.Is<List<AuditHistory>>(a => a.Count(x => x.ActivityType == type && x.AuditDescription == description) == number)));
}
[Then(@"AddHistoriesAsync is called with (.*) history/ies having LoanNumber ""(.*)"" and MemberNumber ""(.*)""")]
public void ThenAddHistoriesAsyncIsCalledWithHistoryHavingLoanNumberAndMemberNumber(int number, string loanNumber, string memberNumber)
{
_mockAuditHistRepo.Verify(x =>
x.AddHistoriesAsync(It.Is<List<AuditHistory>>(a => a.Count(x => x.MemberNumber == memberNumber && x.LoanNumber == loanNumber) == number)));
}
[Then(@"ExportChargebacksAsync is called")]
public void ThenExportChargebacksAsyncIsCalled()
{
_mockExportService.Verify(x => x.ExportChargebacksAsync(It.IsAny<DateTime>()));
}
[Then(@"ExportChargebacksAsync is not called")]
public void ThenExportChargebacksAsyncIsNotCalled()
{
_mockExportService.Verify(x => x.ExportChargebacksAsync(It.IsAny<DateTime>()), Times.Never);
}
[Then(@"MarkReservesAndChargebacksAsExportedAsync is called")]
public void ThenMarkReservesAndChargebacksAsExportedAsyncIsCalled()
{
_mockExportService.Verify(x => x.MarkReservesAndChargebacksAsExportedAsync(It.IsAny<List<Loan>>(), It.IsAny<DateTime>()));
}
[Then(@"all loans have non-null ExportedChargebackDate")]
public void ThenAllLoansHaveNon_NullExportedChargebackDate()
{
Assert.DoesNotContain(_loansResult, l => l.ExportedChargebackDate == null);
}
[Then(@"ExportReservesAsync is called")]
public void ThenExportReservesAsyncIsCalled()
{
_mockExportService.Verify(x => x.ExportReservesAsync(It.IsAny<DateTime>()));
}
[Then(@"ExportReservesAsync is not called")]
public void ThenExportReservesAsyncIsNotCalled()
{
_mockExportService.Verify(x => x.ExportReservesAsync(It.IsAny<DateTime>()), Times.Never);
}
[Then(@"MarkReservesAsExportedAsync is called")]
public void ThenMarkReservesAsExportedAsyncIsCalled()
{
_mockExportService.Verify(x => x.MarkReservesAsExportedAsync(It.IsAny<List<Loan>>(), It.IsAny<DateTime>()));
}
[Then(@"all loans have non-null ExportedReserveDate")]
public void ThenAllLoansHaveNon_NullExportedReserveDate()
{
Assert.DoesNotContain(_loansResult, l => l.ExportedReserveDate == null);
}
[Then(@"the loans now look like")]
public async void ThenTheLoansNowLookLike(Table table)
{
_loansResult = await _loanRepository.GetAll().AsNoTracking().ToListAsync();
table.CompareToSet(_loansResult);
}
[Then(@"the dealers now look like")]
public async void ThenTheDealersNowLookLike(Table table)
{
_dealersResult = await _dealerRepository.GetAll().ToListAsync();
table.CompareToSet(_dealersResult);
}
[Then(@"the vehicle for LoanId (.*) looks like this")]
public void ThenTheVehicleForLoanIdLooksLikeThis(int loanId, Table table)
{
var result = _loansResult.FirstOrDefault(v => v.LoanId == loanId)?.Vehicle;
table.CompareToInstance<Vehicle>(result);
}
[Then(@"the vehicle for LoanId (.*) is null")]
public void ThenTheVehicleForLoanIdIsNull(int loanId)
{
Assert.Null(_loansResult.FirstOrDefault(v => v.LoanId == loanId).Vehicle);
}
[Then(@"the loans with details now look like")]
public void ThenTheLoansWithDetailsNowLookLike(Table table)
{
var loans = table.CreateInstance<Loan>();
_loansResult.Add(loans);
}
}
}
@@ -0,0 +1,92 @@
Feature: ImportService
Gets Imports from database
Scenario: GetAllAsync Success
Given the Import table has the following imports
| ImportId | Start Date | End Date | RecordCount | Success | FileName |
| 1 | 1/2/2021 5:00:00 AM | 1/2/2021 5:10:00 AM | 25 | true | New Loans 1-2-2021.txt |
| 2 | 1/3/2021 5:00:00 AM | 1/3/2021 5:15:00 AM | 50 | false | New Loans 1-3-2021.txt |
| 3 | 1/4/2021 5:00:00 AM | 1/4/2021 5:05:00 AM | 75 | true | New Loans 1-4-2021.txt |
When I get the list of all imports with the import service
Then the result from the import service should have 3 imports
And the first import from the import service has ImportId 3
Scenario: GetAllAsync Exception
Given the Import Repository throws an exception in ListAll
When I get the list of all imports with the import service
Then the Import Service throws an exception with the message "Exception of type 'System.Exception' was thrown."
Scenario: GetRecentAsync Success
Given the Import table has the following imports
| ImportId | Start Date | End Date | RecordCount | Success | FileName | ImportType |
| 1 | 1/2/2021 5:00:00 AM | 1/2/2021 5:10:00 AM | 25 | true | New Loans 1-2-2021.txt | Active |
| 2 | 1/3/2021 5:00:00 AM | 1/3/2021 5:15:00 AM | 50 | false | New Loans 1-3-2021.txt | Active |
| 3 | 1/4/2021 5:00:00 AM | 1/4/2021 5:05:00 AM | 75 | true | New Loans 1-4-2021.txt | Active |
When I get the list of the top 2 imports with the import service
Then the result from the import service should have 2 imports
And the first import from the import service has ImportId 3
Scenario: GetRecentAsync Success - more imports asked for then are in the table
Given the Import table has the following imports
| ImportId | Start Date | End Date | RecordCount | Success | FileName |ImportType |
| 1 | 1/2/2021 5:00:00 AM | 1/2/2021 5:10:00 AM | 25 | true | New Loans 1-2-2021.txt |Active |
| 2 | 1/3/2021 5:00:00 AM | 1/3/2021 5:15:00 AM | 50 | false | New Loans 1-3-2021.txt |Active |
| 3 | 1/4/2021 5:00:00 AM | 1/4/2021 5:05:00 AM | 75 | true | New Loans 1-4-2021.txt |Active |
When I get the list of the top 5 imports with the import service
Then the result from the import service should have 3 imports
And the first import from the import service has ImportId 3
Scenario: GetRecentAsync Exception
Given the Import Repository throws an exception in ListAll
When I get the list of the top 5 imports with the import service
Then the Import Service throws an exception with the message "Exception of type 'System.Exception' was thrown."
Scenario: GetByIdAsync Success
Given the Import table has the following imports
| ImportId | Start Date | End Date | RecordCount | Success | FileName |ImportType |
| 1 | 1/2/2021 5:00:00 AM | 1/2/2021 5:10:00 AM | 25 | true | New Loans 1-2-2021.txt |Active |
| 2 | 1/3/2021 5:00:00 AM | 1/3/2021 5:15:00 AM | 50 | false | New Loans 1-3-2021.txt |Active |
| 3 | 1/4/2021 5:00:00 AM | 1/4/2021 5:05:00 AM | 75 | true | New Loans 1-4-2021.txt |Active |
When I get the import with the importId 2 from the import service
Then the import from the import service has ImportId 2
Scenario: GetByIdAsync Exception - Not Found
Given the Import table has the following imports
| ImportId | Start Date | End Date | RecordCount | Success | FileName |ImportType |
| 1 | 1/2/2021 5:00:00 AM | 1/2/2021 5:10:00 AM | 25 | true | New Loans 1-2-2021.txt |Active |
| 2 | 1/3/2021 5:00:00 AM | 1/3/2021 5:15:00 AM | 50 | false | New Loans 1-3-2021.txt |Active |
| 3 | 1/4/2021 5:00:00 AM | 1/4/2021 5:05:00 AM | 75 | true | New Loans 1-4-2021.txt |Active |
When I get the import with the importId 4 from the import service
Then the Import Service throws an exception with the message "Import with id 4 not found."
Scenario: GetByIdAsync Exception - Import Repository exception
Given the Import Repository throws an exception in FindByIdAsync
When I get the import with the importId 3 from the import service
Then the Import Service throws an exception with the message "Exception of type 'System.Exception' was thrown."
Scenario: GetLastLoanImport - active when there are only active
Given the Import table has the following imports
| ImportId | Start Date | End Date | RecordCount | Success | FileName | ImportType |
| 1 | 1/2/2021 5:00:00 AM | 1/2/2021 5:10:00 AM | 25 | true | <null> | Active |
| 2 | 1/3/2021 5:00:00 AM | 1/3/2021 5:15:00 AM | 50 | false | <null> | Active |
| 3 | 1/4/2021 5:00:00 AM | 1/4/2021 5:05:00 AM | 75 | true | <null> | Active |
When I get the last loan import of type "Active"
Then the import from the import service has ImportId 3
Scenario: GetLastLoanImport - ignore imports that have a non-null filename
Given the Import table has the following imports
| ImportId | Start Date | End Date | RecordCount | Success | FileName | ImportType |
| 1 | 1/2/2021 5:00:00 AM | 1/2/2021 5:10:00 AM | 25 | true | <null> | Active |
| 2 | 1/3/2021 5:00:00 AM | 1/3/2021 5:15:00 AM | 50 | false | <null> | Active |
| 3 | 1/4/2021 5:00:00 AM | 1/4/2021 5:05:00 AM | 75 | true | New Loans 1-4-2021.txt | Active |
When I get the last loan import of type "Active"
Then the import from the import service has ImportId 1
Scenario: GetLastLoanImport - closed when there are both types
Given the Import table has the following imports
| ImportId | Start Date | End Date | RecordCount | Success | FileName | ImportType |
| 1 | 1/2/2021 5:00:00 AM | 1/2/2021 5:10:00 AM | 25 | true | <null> | Closed |
| 2 | 1/3/2021 5:00:00 AM | 1/3/2021 5:15:00 AM | 50 | false | <null> | Active |
| 3 | 1/4/2021 5:00:00 AM | 1/4/2021 5:05:00 AM | 75 | true | <null> | Active |
When I get the last loan import of type "Closed"
Then the import from the import service has ImportId 1
@@ -0,0 +1,149 @@
using Microsoft.EntityFrameworkCore;
using Moq;
using ReserveManagementSystemApi.Services;
using ReserveManagementSystemLib.Models;
using ReserveManagementSystemLib.Persistence;
using ReserveManagementSystemLib.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
using TechTalk.SpecFlow.Assist.ValueRetrievers;
using Xunit;
using ReserveManagementSystemLib.Enums;
namespace ReserveManagementSystemApi.Tests.ServiceTests
{
[Binding]
public sealed class ImportServiceSteps
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
private ImportService _importService;
private AppDbContext _appDbContext;
private IEnumerable<Import> _importsResult;
private Import _importResult;
private Exception _exception;
public ImportServiceSteps(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
Service.Instance.ValueRetrievers.Register(new NullValueRetriever("<null>"));
}
[BeforeScenario]
public void CreateDatabase()
{
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
_appDbContext = new AppDbContext(options);
_importService = new ImportService(new ImportRepository(_appDbContext));
}
[AfterScenario]
public void DisposeAppDbContext()
{
_appDbContext.Database.EnsureDeleted();
_appDbContext.Dispose();
}
[Given(@"the Import table has the following imports")]
public void GivenTheImportTableHasTheFollowingImports(Table table)
{
var imports = table.CreateSet<Import>();
_appDbContext.Imports.AddRange(imports);
_appDbContext.SaveChanges();
}
[Given(@"the Import Repository throws an exception in ListAll")]
public void GivenTheImportRepositoryThrowsAnExceptionInListAll()
{
var mockImportRepo = new Mock<IImportRepository>();
mockImportRepo.Setup(a => a.GetAll()).Throws(new Exception());
_importService = new ImportService(mockImportRepo.Object);
}
[Given(@"the Import Repository throws an exception in FindByIdAsync")]
public void GivenTheImportRepositoryThrowsAnExceptionInFindByIdAsync()
{
var mockImportRepo = new Mock<IImportRepository>();
mockImportRepo.Setup(a => a.FindByIdAsync(It.IsAny<int>())).Throws(new Exception());
_importService = new ImportService(mockImportRepo.Object);
}
[When(@"I get the list of all imports with the import service")]
public async void WhenIGetTheListOfAllImportsWithTheImportService()
{
try
{
_importsResult = await _importService.GetAllAsync();
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the list of the top (.*) imports with the import service")]
public async void WhenIGetTheListOfAllImportsWithTheImportService(int numberOfImports)
{
try
{
_importsResult = await _importService.GetRecentAsync(numberOfImports);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the import with the importId (.*) from the import service")]
public async void WhenIGetTheImportWithTheImportIdFromTheImportService(int importId)
{
try
{
_importResult = await _importService.GetByIdAsync(importId);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the last loan import of type ""(.*)""")]
public async void WhenIGetTheLastLoanImportOfType(string importType)
{
var type = (ImportType)Enum.Parse(typeof(ImportType), importType, true);
_importResult = await _importService.GetLastLoanImportByType(type);
}
[Then(@"the result from the import service should have (.*) imports")]
public void ThenTheResultFromTheImportServiceShouldHaveImports(int importCount)
{
Assert.Equal(importCount, _importsResult.Count());
}
[Then(@"the first import from the import service has ImportId (.*)")]
public void ThenTheFirstImportFromTheImportServiceHasImportId(int importId)
{
Assert.Equal(importId, _importsResult.First().ImportId);
}
[Then(@"the Import Service throws an exception with the message ""(.*)""")]
public void ThenTheImportServiceThrowsAnExceptionWithTheMessage(string message)
{
Assert.NotNull(_exception);
Assert.Equal(message, _exception.Message);
}
[Then(@"the import from the import service has ImportId (.*)")]
public void ThenTheImportFromTheImportServiceHasImportId(int importId)
{
Assert.Equal(importId, _importResult.ImportId);
}
}
}
@@ -0,0 +1,104 @@
using Microsoft.EntityFrameworkCore;
using Moq;
using ReserveManagementSystemApi.Services;
using ReserveManagementSystemLib.Models;
using ReserveManagementSystemLib.Persistence;
using ReserveManagementSystemLib.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
using Xunit;
namespace ReserveManagementSystemApi.Tests
{
[Binding]
public sealed class LoanCalculationServiceSteps
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
private Loan _loan;
private LoanReserve _reserve;
private LoanChargeback _chargeback;
private List<LoanType> _loanTypes;
private AppDbContext _appDbContext;
public LoanCalculationServiceSteps(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
[BeforeScenario]
public void CreateDatabase()
{
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
_appDbContext = new AppDbContext(options);
}
[AfterScenario]
public void DisposeAppDbContext()
{
_appDbContext.Database.EnsureDeleted();
_appDbContext.Dispose();
}
[Given(@"a loan that looks like")]
public void GivenALoanThatLooksLike(Table table)
{
_loan = table.CreateInstance<Loan>();
}
[Given(@"a loan type table that looks like")]
public void GivenALoanTypeTableThatLooksLike(Table table)
{
_loanTypes = table.CreateSet<LoanType>().ToList();
_appDbContext.LoanTypes.AddRange(_loanTypes);
_appDbContext.SaveChanges();
}
[When(@"the reserve is calculated")]
public async void WhenTheReserveIsCalculated()
{
_loan.LoanType = await new LoanTypeRepository(_appDbContext).GetLoanTypeAsync(_loan.LoanTypeId);
var loanCalculationService = new LoanCalculationService();
_reserve = loanCalculationService.CalculateSingleReserve(_loan);
}
[When(@"the chargeback is calculated")]
public async void WhenTheChargebackIsCalculated()
{
_loan.LoanType = await new LoanTypeRepository(_appDbContext).GetLoanTypeAsync(_loan.LoanTypeId);
var loanCalculationService = new LoanCalculationService();
_chargeback = loanCalculationService.CalculateSingleChargeback(_loan);
}
[Then(@"FlatFeePaid should be ""(.*)""")]
public void ThenFlatFeePaidShouldBe(bool flatFeePaid)
{
Assert.Equal(flatFeePaid, _reserve.FlatFeePaid);
}
[Then(@"the reserve amount should be (.*)")]
public void ThenTheReserveAmountShouldBe(decimal reserve)
{
Assert.Equal(reserve, _reserve.ReserveAmount);
}
[Then(@"the reserve message should be (.*)")]
public void ThenTheReserveMessageShouldBe(string message)
{
Assert.Equal(message, _reserve.ReserveTypeMessage);
}
[Then(@"the chargeback returned is")]
public void ThenTheChargebackReturnedIs(Table table)
{
table.CompareToInstance<LoanChargeback>(_chargeback);
}
}
}
@@ -0,0 +1,475 @@
Feature: Loan Service - Filtering, Pagination
Get filtered list of loans, get paginated list of loans
Scenario: GetFilteredAsync Success - ImportId - sorting will be by Dealer Code ASC importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 345 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 0 |
| 2 | 2 | 45 | 2 | 678 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 3 | 2 | 22 | 6 | 901 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | ImportId | DealerCodeText | ActionRequired | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | 2 | | | | | | | DealerCode | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "3,2"
Scenario: GetFilteredAsync Success - MemberNumber - sorting will be by Action Required DESC importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 345 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 0 |
| 2 | 2 | 45 | 6 | 678 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 12 | 4 | 901 | Smith | Joe | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| 12 | | | | | | | | | ActionRequired | DESC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "3,1"
Scenario: GetFilteredAsync Success - MemberName, searches both first and last name - sorting will be by MemberLastName DESC importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 345 | SMITH | JOE | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 0 |
| 2 | 2 | 45 | 6 | 678 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 12 | 4 | 901 | SMITH | JOE | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | Jo | | | | | | | | MemberLastName | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "2,3,1"
Scenario: GetFilteredAsync Success - MemberName, returns one - sorting will be by MemberLastName DESC importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number |Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 |345 | SMITH | JOE | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 0 |
| 2 | 2 | 45 | 6 |678 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 12 | 4 |901 | SMITH | JOE | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | Jon | | | | | | | | MemberLastName | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "2"
Scenario: GetFilteredAsync Success - LoanNumber - sorting will be by Action Required DESC importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number |Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 |345 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 0 |
| 2 | 2 | 45 | 6 |678 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 56 | 3 |901 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | 3 | | | | | | | ActionRequired | DESC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "3,1"
Scenario: GetFilteredAsync Success - Application Id - sorting will be by Action Required DESC importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number |Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 |345 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 0 |
| 2 | 2 | 45 | 6 |378 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 56 | 3 |901 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | | 3 | | | | | | ActionRequired | DESC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "2,1"
Scenario: GetFilteredAsync Success - DealerCode - sorting will be by Action Required ASC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 345 | Smith | Joe | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 0 |
| 2 | 2 | 45 | 6 | 678 | Jones | Laura | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 3 | 2 | 22 | 2 | 901 | Johnson | Laura | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And the dealer table has these dealers
| Dealer Code | Name | DealerOrganizationNumber |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 |
| A1 | ACURA OF BROOKFIELD | 5678 |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | H21 | | ActionRequired | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "2,3"
Scenario: GetFilteredAsync Success - ActionRequired - sorting will be by Dealer Code ASC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number |Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate |Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 |345 | SMITH | JOE | | H21 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 |NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 |678 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 |BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 3 | 2 | 22 | 2 |901 | JOHNSON | LAURA | M | S7 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 |BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | | 1 | DealerCode | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "1,3"
Scenario: GetFilteredAsync Success - Loan Date - start and end - sorting will be by Dealer Code ASC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id |Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 345 |SMITH | JOE | | H21 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 678 |JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 3 | 2 | 22 | 2 | 901 |JOHNSON | LAURA | M | S7 | 2/23/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | |2/23/2021 | 2/24/2021 | | | | DealerCode | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "2,3"
Scenario: GetFilteredAsync Success - Loan Date - only start date - sorting will be by Dealer Code ASC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number |Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 |345 | SMITH | JOE | | H21 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 |678 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 3 | 2 | 22 | 2 |901 | JOHNSON | LAURA | M | S7 | 2/23/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText |LoanNumberText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | | 2/24/2021 | | | | | DealerCode | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "2,1"
Scenario: GetFilteredAsync Success - Loan Date - only end date - sorting will be by Dealer Code ASC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | SMITH | JOE | | H21 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 3 | 2 | 22 | 2 | JOHNSON | LAURA | M | S7 | 2/23/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | LoanDateStart | LoanDateEnd | ImportId | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | 2/24/2021 | | | | DealerCode | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "2,3"
Scenario: GetFilteredAsync Success - all filters used - sorting will be by DealerCode ASC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 345 | SMITH | JOE | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 678 | JONES | LAURA | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 3 | 2 | 22 | 2 | 901 | JOHNSON | LAURA | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
And the dealer table has these dealers
| Dealer Code | Name | DealerOrganizationNumber |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 |
| A1 | ACURA OF BROOKFIELD | 5678 |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| 22 | Joh | 2 | 9 | 2 | 2/24/2021 | 2/24/2021 | H21 | 1 | DealerCode | ASC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the loan ids from the loan service look like "3"
Scenario: GetFilteredAsync Success - returning nothing - sorting will be by Dealer Code DESC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id |Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 345 |SMITH | JOE | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 678 |JONES | LAURA | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 901 |JOHNSON | LAURA | M | H22 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | MaxRecordsPerPage | MaxPagesPerRange |
| | | | |1 | | | H21 | 0 | DealerCode | DESC | 15 | 7 |
When I get the list of the filtered loans with the loan service
Then the result from the loan service should have 0 loans
Scenario: GetPagedListAsync Success - returning page count with one index and one record validation - no filtering sorting will be by MemberFirstName DESC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 | Gallagher | Frank | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 | Luke | Dwight | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 | Patterson | Sandy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 | Best | Ronald | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 | Hayes | Willie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 | McGuire | Jerry | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 | Smith | Joey | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 | Jones | Loren | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 | Johnson | Lizzie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 | Gallagher | Farrah | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 | Luke | Delilah | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 | Patterson | Steve | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 | Best | Rainier | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 | Hayes | Wendy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 | McGuire | Sara | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | | | MemberFirstName | DESC | 2 | 15 | 7 |
When I get the list of paged loans
Then the result from the loan service should have 2 pages
And the first result from the loan service should have loanid 13
Scenario: GetPagedListAsync Success - returning one index record count and one record validation - no filtering sorting will be by MemberLastName DESC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id |Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 |Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 |Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 |Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 |Gallagher | Frank | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 |Luke | Dwight | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 |Patterson | Sandy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 |Best | Ronald | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 |Hayes | Willie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 |McGuire | Jerry | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 |Smith | Joey | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 |Jones | Loren | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 |Johnson | Lizzie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 |Gallagher | Farrah | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 |Luke | Delilah | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 |Patterson | Steve | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 |Best | Rainier | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 |Hayes | Wendy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 |McGuire | Sara | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | | | MemberLastName | DESC | 1 | 15 | 7 |
When I get the list of paged loans
Then the result from the loan service should have 15 records
And the first result from the loan service should have loanid 1
Scenario: GetPagedListAsync Fail - not returning pages no records - no sorting or filtering
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id |Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 |Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 |Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 |Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 |Gallagher | Frank | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 |Luke | Dwight | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 |Patterson | Sandy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 |Best | Ronald | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 |Hayes | Willie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 |McGuire | Jerry | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 |Smith | Joey | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 |Jones | Loren | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 |Johnson | Lizzie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 |Gallagher | Farrah | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 |Luke | Delilah | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 |Patterson | Steve | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 |Best | Rainier | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 |Hayes | Wendy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 |McGuire | Sara | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
Then the result from the loan service should have 0 total items
Scenario: GetPagedListAsync HasPrevious Page Success HasNext Page Fail - returning one index record count checking previous next - no sorting or filtering
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 | Gallagher | Frank | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 | Luke | Dwight | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 | Patterson | Sandy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 | Best | Ronald | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 | Hayes | Willie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 | McGuire | Jerry | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 | Smith | Joey | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 | Jones | Loren | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 | Johnson | Lizzie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 | Gallagher | Farrah | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 | Luke | Delilah | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 | Patterson | Steve | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 | Best | Rainier | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 | Hayes | Wendy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 | McGuire | Sara | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | | | | | 2 | 15 | 7 |
When I get the list of paged loans
Then the result from the loan service should have 3 records
And the result from the loan service has previous page should be true
And the result from the loan service has next page should be false
Scenario: GetPagedListAsync HasPrevious Page Fail HasNext Page Success - returning one index record count checking previous next - no sorting or filtering
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id |Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 |Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 |Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 |Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 |Gallagher | Frank | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 |Luke | Dwight | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 |Patterson | Sandy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 |Best | Ronald | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 |Hayes | Willie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 |McGuire | Jerry | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 |Smith | Joey | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 |Jones | Loren | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 |Johnson | Lizzie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 |Gallagher | Farrah | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 |Luke | Delilah | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 |Patterson | Steve | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 |Best | Rainier | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 |Hayes | Wendy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 |McGuire | Sara | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | | | | | 1 | 15 | 7 |
When I get the list of paged loans
Then the result from the loan service should have 15 records
And the result from the loan service has previous page should be false
And the result from the loan service has next page should be true
Scenario: GetPagedListAsync Success - returning page count with one index and one record validation - Filter by DealerCodeText sorting will be by MemberFirstName DESC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 | Smith | Joe | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 | Jones | Laura | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 | Johnson | Laura | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 | Gallagher | Frank | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 | Luke | Dwight | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 | Patterson | Sandy | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 | Best | Ronald | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 | Hayes | Willie | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 | McGuire | Jerry | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 | Smith | Joey | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 | Jones | Loren | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 | Johnson | Lizzie | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 | Gallagher | Farrah | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 | Luke | Delilah | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 | Patterson | Steve | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 | Best | Rainier | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 | Hayes | Wendy | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 | McGuire | Sara | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And the dealer table has these dealers
| Dealer Code | Name | DealerOrganizationNumber |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 |
| A1 | ACURA OF BROOKFIELD | 5678 |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 |
And a loan filter that looks like
| MemberNumberText | MemberFirstNameText | MemberLastNameText | ApplicationIdText | LoanNumberText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | | H21 | | MemberFirstName | DESC | 1 | 15 | 7 |
When I get the list of paged loans
Then the result from the loan service should have 1 pages
And the first result from the loan service should have loanid 8
Scenario: GetPagedListAsync Success - returning one index record count and one record validation - Filtering by ActionRequired sorting will be by MemberLastName DESC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 | Gallagher | Frank | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 | Luke | Dwight | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 | Patterson | Sandy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 | Best | Ronald | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 | Hayes | Willie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 | McGuire | Jerry | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 | Smith | Joey | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 | Jones | Loren | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 | Johnson | Lizzie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 | Gallagher | Farrah | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 | Luke | Delilah | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 | Patterson | Steve | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 | Best | Rainier | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 | Hayes | Wendy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 | McGuire | Sara | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | | 1 | MemberLastName | DESC | 1 | 15 | 7 |
When I get the list of paged loans
Then the result from the loan service should have 8 records
And the first result from the loan service should have loanid 1
Scenario: GetPagedListAsync Success Page Range Values Check Last Page Index First and Last Page - returning one index record count and one record validation - Filtering by ImportId sorting will be by MemberLastName DESC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 | Zeman | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 1 | 45 | 6 | 2 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 1 | 22 | 2 | 3 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 | Gallagher | Frank | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 1 | 99 | 8 | 5 | Luke | Dwight | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 1 | 78 | 9 | 6 | Patterson | Sandy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 | Best | Ronald | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 1 | 11 | 1 | 8 | Hayes | Willie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 1 | 11 | 2 | 9 | McGuire | Jerry | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 | Smith | Joey | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 1 | 45 | 6 | 11 | Jones | Loren | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 1 | 22 | 2 | 12 | Johnson | Lizzie | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 | Gallagher | Farrah | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 1 | 99 | 8 | 14 | Luke | Delilah | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 1 | 78 | 9 | 15 | Patterson | Steve | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 | Best | Rainier | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 1 | 11 | 1 | 17 | Hayes | Wendy | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 1 | 11 | 2 | 18 | McGuire | Sara | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 19 | 2 | 11 | 1 | 19 | Sorenson | Jill | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 20 | 2 | 11 | 2 | 20 | Berry | Bill | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | 1 | | | | | MemberLastName | DESC | 9 | 2 | 3 |
When I get the list of paged loans
Then the result from the loan service should have 2 records
And the first result from the loan service should have loanid 7
And the result from the loan service has previous page should be true
And the result from the loan service has next page should be false
And the result from the loan service first page should be 7
And the result from the loan service last page should be 9
Scenario: GetPagedListAsync Success - Page Range Values Check First and Last Page - returning one index record count and one record validation - Filtering by Dealer Code sorting will be by MemberLastName DESC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 | Smith | Joe | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 | Jones | Laura | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 | Johnson | Laura | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 | Gallagher | Frank | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 | Luke | Dwight | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 | Patterson | Sandy | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 | Best | Ronald | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 | Hayes | Willie | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 | McGuire | Jerry | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 | Smith | Joey | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 | Jones | Loren | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 | Johnson | Lizzie | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 | Gallagher | Farrah | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 | Luke | Delilah | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 | Patterson | Steve | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 | Best | Rainier | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 | Hayes | Wendy | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 | McGuire | Sara | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And the dealer table has these dealers
| Dealer Code | Name | DealerOrganizationNumber |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 |
| A1 | ACURA OF BROOKFIELD | 5678 |
| S21 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | S21 | | MemberLastName | DESC | 5 | 2 | 3 |
When I get the list of paged loans
Then the result from the loan service should have 2 records
And the first result from the loan service should have loanid 11
And the result from the loan service has previous page should be true
And the result from the loan service has next page should be true
And the result from the loan service first page should be 4
And the result from the loan service last page should be 6
Scenario: GetPagedListAsync Success - Page Range Values Check Below Page Range Max - returning one index record count and one record validation - Filtering by Dealer Code sorting will be by MemberLastName DESC then importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Action Required |
| 1 | 1 | 12 | 3 | 1 | Smith | Joe | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 2 | 2 | 45 | 6 | 2 | Jones | Laura | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 3 | 2 | 22 | 2 | 3 | Johnson | Laura | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 4 | 1 | 55 | 5 | 4 | Gallagher | Frank | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 5 | 2 | 99 | 8 | 5 | Luke | Dwight | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 6 | 2 | 78 | 9 | 6 | Patterson | Sandy | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 7 | 1 | 34 | 3 | 7 | Best | Ronald | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 8 | 2 | 11 | 1 | 8 | Hayes | Willie | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 9 | 2 | 11 | 2 | 9 | McGuire | Jerry | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 10 | 1 | 12 | 3 | 10 | Smith | Joey | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 11 | 2 | 45 | 6 | 11 | Jones | Loren | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 1 |
| 12 | 2 | 22 | 2 | 12 | Johnson | Lizzie | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 13 | 1 | 55 | 5 | 13 | Gallagher | Farrah | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 14 | 2 | 99 | 8 | 14 | Luke | Delilah | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 15 | 2 | 78 | 9 | 15 | Patterson | Steve | M | 1234 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
| 16 | 1 | 34 | 3 | 16 | Best | Rainier | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard | 1 |
| 17 | 2 | 11 | 1 | 17 | Hayes | Wendy | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | 0 |
| 18 | 2 | 11 | 2 | 18 | McGuire | Sara | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message | |
And the dealer table has these dealers
| Dealer Code | Name | DealerOrganizationNumber |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 |
| A1 | ACURA OF BROOKFIELD | 5678 |
| S21 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 |
And a loan filter that looks like
| MemberNumberText | MemberNameText | LoanNumberText | ApplicationIdText | ImportId | LoanDateStart | LoanDateEnd | DealerCodeText | ActionRequired | SortField | SortDirection | PageIndex | MaxRecordsPerPage | MaxPagesPerRange |
| | | | | | | | S21 | 1 | MemberLastName | DESC | 2 | 4 | 4 |
When I get the list of paged loans
Then the result from the loan service should have 4 records
And the first result from the loan service should have loanid 4
And the result from the loan service has previous page should be true
And the result from the loan service has next page should be false
And the result from the loan service first page should be 1
And the result from the loan service last page should be 2
@@ -0,0 +1,183 @@
Feature: Loan Service Get all, Get By Id
Gets all loans, get loan by loanId
Scenario: GetListAsync Success and sorting will be by importid descending and then by member number ascending
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 1 | 12 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 2 | 45 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 2 | 22 | 2 | Johnson | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of all loans with the loan service
Then the result from the loan service should have 3 loans
And the first loan from the loan service has LoanId 3
Scenario: GetListAsync Exception
Given the Loan Repository throws an exception in ListAll
When I get the list of all loans with the loan service with the mock loan repo
Then the Loan Service throws an exception with the message "Exception of type 'System.Exception' was thrown."
Scenario: GetListAsync - get dealer info
Given the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 1 | 12 | 3 | Smith | Joe | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 2 | 45 | 6 | Jones | Laura | M | 1111 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 2 | 22 | 2 | Johnson | Laura | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
And the dealer table has these dealers
| Dealer Code | Name | DealerOrganizationNumber |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 |
| A1 | ACURA OF BROOKFIELD | 5678 |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 |
When I get the list of all loans with the loan service
Then the result from the loan service should have 3 loans
And the first loan from the loan service has LoanId 3
And the loan with LoanId 1 has dealer name "SUBURBAN MOTORS HARLEY DAVIDSON"
And the loan with LoanId 2 has dealer name "HEISER CHEVROLET CADILLAC OF WEST BEND"
Scenario: GetByIdAsync Success
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 12 | 3 | Smith | Joe | | 1234 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | BB | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 45 | 6 | Jones | Laura | M | 5678 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message |
And the dealer table has these dealers
| Dealer Code | Name | DealerOrganizationNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 1234 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 5678 |
And loan types that look like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
| BB | Standard | S | 0 | 0 | 0 | 1.00 | 0.25 |
When I get the loan with the loanId 2 from the loan service
Then the loan from the loan service has LoanId 2
And the loan from the loan service has LoanType.LoanComment "75% Reserve"
And the loan from the loan service has dealer name "HEISER CHEVROLET CADILLAC OF WEST BEND"
Scenario: GetByIdAsync - unknown loan type
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 12 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | BB | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 45 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | NC | 60 | 1450.2923 | 500 | false | | | Message |
And loan types that look like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When I get the loan with the loanId 1 from the loan service
Then the loan from the loan service has LoanId 1
And the loan from the loan service has LoanType.LoanComment ""
Scenario: GetByIdAsync Exception - Not Found
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 12 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 45 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
And loan types that look like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When I get the loan with the loanId 3 from the loan service
Then the Loan Service throws an exception with the message "Loan with id 3 not found."
Scenario: GetByIdAsync Exception - Loan Repository exception
Given the Loan Repository throws an exception in FindByIdAsync
When I get the loan with the loanId 2 from the loan service using the Mock Loan Repo
Then the Loan Service throws an exception with the message "Exception of type 'System.Exception' was thrown."
Scenario: Get Members - searching member number, don't return duplicates
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 452 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 451 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 451 | 7 | Jones | Laura | M | H21 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of members with search string "45"
Then the list of members returned is in this order
| Member Number |
| 451 |
| 452 |
Scenario: Get Members - searching member number, return in number order, not string order
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate |Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 452 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 |NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 4510 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 |BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of members with search string "45"
Then the list of members returned is in this order
| Member Number |
| 452 |
| 4510 |
Scenario: Get Members - only get numbers starting with the search string
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 245 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 451 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 451 | 7 | Jones | Laura | M | H21 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of members with search string "45"
Then the list of members returned is in this order
| Member Number |
| 451 |
Scenario: Get Members - not searching name
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate |Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 452 | 3 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 |NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 451 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 |BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 451 | 7 | Jones | Laura | M | H21 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 |BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of members with search string "Jo"
Then the list of members returned is in this order
| Member Number |
Scenario: Get Loan Numbers
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 452 | 731 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 451 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 451 | 73 | Jones | Laura | M | H21 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of loan numbers with search string "73"
Then the list of loan numbers looks like
| Loan Number |
| 73 |
| 731 |
Scenario: Get Loan Numbers, return in number order, not string order
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 452 | 731 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 451 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 451 | 7307 | Jones | Laura | M | H21 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of loan numbers with search string "73"
Then the list of loan numbers looks like
| Loan Number |
| 731 |
| 7307 |
Scenario: Get Loan Numbers - only get numbers starting with the search string
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 452 | 173 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 451 | 6 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 451 | 73 | Jones | Laura | M | H21 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of loan numbers with search string "73"
Then the list of loan numbers looks like
| Loan Number |
| 73 |
Scenario: Get Application Ids, return in number order
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 452 | 731 | 112 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 451 | 6 | 334 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 451 | 73 | 35 | Jones | Laura | M | H21 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of application ids with search string "3"
Then the list of application ids looks like
|Application Id |
| 35 |
| 334 |
Scenario: Get Application Ids - only get ids starting with the search string
Given the Loan table has the following loans
| LoanId | Member Number | Loan Number | Application Id | Member Last Name | Member First Name | Member Initial | Dealer Code | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term | Reserve Amount | MonthlyPmt | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message |
| 1 | 452 | 173 | 133 | Smith | Joe | | S7 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | 12615.87 | 4.030 | 4.790 | NC | 63 | 210.0375 | 200 | false | | | Standard |
| 2 | 451 | 6 | 334 | Jones | Laura | M | H21 | 2/24/2021 | 2/27/2021 | 4/10/2021 | 3/10/2026 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
| 3 | 451 | 73 | 35 | Jones | Laura | M | H21 | 2/24/2023 | 2/27/2023 | 4/10/2023 | 3/10/2028 | 21274.24 | 2.490 | 4.970 | BB | 60 | 1450.2923 | 500 | false | | | Message |
When I get the list of application ids with search string "33"
Then the list of application ids looks like
|Application Id |
| 334 |
@@ -0,0 +1,77 @@
Feature: Loan Service - Saving
Save loan with Reserve, save loan with chargeback
Background:
Given dealers that look like
| Dealer Code | Name | DealerOrganizationNumber | DealerAccountNumber |
| S7 | SUBURBAN MOTORS HARLEY DAVIDSON | 3434 | 324324324324324 |
| H21 | HEISER CHEVROLET CADILLAC OF WEST BEND | 1111 | |
| | | 1234 | 924324324324324 |
And loan types that look like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
Scenario: Save with Reserve Success
Given I have these loans to save
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial |DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Loan Status |
| 1 | 3250 | 144 | MUELLER | STEVEN | C |1234 | 2/10/2021 | 3/20/2021 | 2/10/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | 48 | 0 | false | 0.00 | | | New |
When I save the loan with the reserve
Then the loans from the loan service look like
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Loan Status |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | 1234 | 2/10/2021 | 3/20/2021 | 2/10/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | 48 | 566.98877654773011071101556050 | false | 0.00 | | Standard Reserve | New |
Scenario: Save with Reserve Failure
Given the Loan Repository throws an exception in UpdateAsync
And I have these loans to save
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Loan Status |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | 1234 | 2/10/2021 | 3/15/2021 | 3/12/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | | | false | 0.00 | | | New |
When I save the loan with the reserve with the mock loan repo
Then the Loan Service throws an exception with the message "Exception of type 'System.Exception' was thrown."
Scenario: Save with Reserve - Set ActionRequired - Dealer organization null
Given I have these loans to save
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial |DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Loan Status | VIN Number | Make | Model | Year | Mileage | Color |
| 1 | 3250 | 144 | MUELLER | STEVEN | C |<null> | 2/10/2021 | 3/20/2021 | 2/10/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | 48 | 0 | false | 0.00 | | | New | M733P33389Y85216 | | | | | |
When I save the loan with the reserve
Then the loans from the loan service look like
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ActionRequired | Loan Status |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | | 2/10/2021 | 3/20/2021 | 2/10/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | 48 | 566.98877654773011071101556050 | false | 0.00 | | Standard Reserve | true | New |
Scenario: Save with Reserve - Set ActionRequired - first payment date before loan date
Given I have these loans to save
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Loan Status | OriginalTermInDays |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | 1234 | 2/10/2021 | 1/12/2021 | 2/10/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | 50 | 0 | false | 0.00 | | | New | 1491 |
When I save the loan with the reserve
Then the loans from the loan service look like
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ActionRequired | Loan Status |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | 1234 | 2/10/2021 | 1/12/2021 | 2/10/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | 50 | 584.06654602341792014440573200 | false | 0.00 | | Standard Reserve | true | New |
Scenario: Save with Reserve - Set ActionRequired True - Invalid Dealer Code
Given I have these loans to save
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | Loan Status | DealerOrganizationNumber | OriginalTermInDays |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | 6222 | 2/10/2021 | 1/12/2021 | 2/10/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | 50 | 0 | false | 0.00 | | | New | 2345 | 1491 |
When I save the loan with the reserve
Then the loans from the loan service look like
| ImportId | Member Number | Loan Number | Member Last Name | Member First Name | Member Initial | DealerOrganizationNumber | Loan Date | FirstPmtDate | FinalPmtDate | Posted Date | Loan Amount | Buy Rate | Contract Rate | MonthlyPmt | Loan Type Id | Term | Reserve Amount | Flat Fee Paid | Chargeback | Paid Loan Date | Reserve Message | ActionRequired | Loan Status |
| 1 | 3250 | 144 | MUELLER | STEVEN | C | 6222 | 2/10/2021 | 1/12/2021 | 2/10/2025 | 02/12/2021 | 25989.97 | 2.03 | 3.39 | 579.76 | NC | 50 | 584.06654602341792014440573200 | false | 0.00 | | Standard Reserve | true | New |
Scenario: SaveWithChargeback
Given I have these loans to save with chargebacks
| ImportId | Member Number | Loan Number | PaidLoanDate |
| 2 | 5841 | 147 | 2/19/2021 |
| 2 | 10094 | 143 | 12/22/2020 |
And the Loan table has the following loans
| LoanId | ImportId | Member Number | Loan Number | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Type Id | Term | Reserve Amount | Chargeback | Paid Loan Date | Reserve Message | Loan Status |
| 1 | 1 | 12 | 3 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | NC | 63 | 210.0375 | | | Standard | New |
| 2 | 1 | 5841 | 147 | 2/10/2021 | 2/27/2021 | 3/12/2021 | 2/12/2028 | NC | 84 | 1206.8106 | | | Message | New |
| 3 | 1 | 10094 | 143 | 12/7/2020 | 12/15/2020 | 1/21/2021 | 12/21/2025 | NC | 60 | 878.8602 | | | Message | New |
When I save the loans with chargebacks
And I get the list of all loans with the loan service
Then the loans in the loan table will look like
| LoanId | ImportId | Member Number | Loan Number | Loan Date | PostedDate | FirstPmtDate | FinalPmtDate | Loan Type Id | Term | Reserve Amount | Chargeback | Chargeback Message | Paid Loan Date | Reserve Message | Loan Status | Remaining Months at Close |
| 1 | 1 | 12 | 3 | 2/25/2021 | 2/28/2021 | 4/11/2021 | 6/11/2026 | NC | 63 | 210.0375 | | | | Standard | New | |
| 2 | 2 | 5841 | 147 | 2/10/2021 | 2/27/2021 | 3/12/2021 | 2/12/2028 | NC | 84 | 1206.8106 | 1206.8106 | Paid On or Before Chargeback Date | 2/19/2021 | Message | Closed | 84 |
| 3 | 2 | 10094 | 143 | 12/7/2020 | 12/15/2020 | 1/21/2021 | 12/21/2025 | NC | 60 | 878.8602 | 878.8602 | Paid On or Before Chargeback Date | 12/22/2020 | Message | Closed | 60 |
@@ -0,0 +1,436 @@
using FluentAssertions;
using FluentValidation;
using Microsoft.EntityFrameworkCore;
using Moq;
using ReserveManagementSystemApi.Models;
using ReserveManagementSystemApi.ServiceClients;
using ReserveManagementSystemApi.Services;
using ReserveManagementSystemLib.Models;
using ReserveManagementSystemLib.Persistence;
using ReserveManagementSystemLib.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
using TechTalk.SpecFlow.Assist.ValueRetrievers;
using Xunit;
namespace ReserveManagementSystemApi.Tests.ServiceTests
{
[Binding]
public sealed class LoanServiceSteps
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
private LoanService _loanService;
private AppDbContext _appDbContext;
private IEnumerable<Loan> _loansResult;
private List<Loan> _loansToSave;
private Loan _loanResult;
private Exception _exception;
private LoanFilter _loanFilter;
private List<string> _memberResult;
private List<string> _loanNumberResult;
private List<string> _applicationIdResult;
PaginatedListResponse _pagedListResponse = new PaginatedListResponse();
private IEnumerable<Loan> _closedLoans;
private IEnumerable<Loan> _loansInSystem;
private IEnumerable<Loan> _loansNotInSystem;
private Mock<ILoanRepository> _mockLoanRepo = new Mock<ILoanRepository>();
private Mock<IAuditHistoryRepository> _mockAuditHistRepo = new Mock<IAuditHistoryRepository>();
public LoanServiceSteps(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
[BeforeScenario]
public void CreateDatabase()
{
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
_appDbContext = new AppDbContext(options);
_loanService = new LoanService(new LoanRepository(_appDbContext), new LoanTypeRepository(_appDbContext), new AuditHistoryService(_mockAuditHistRepo.Object), new Mock<ICoreApiServiceClient>().Object);
}
[AfterScenario]
public void Dispose()
{
_appDbContext.Database.EnsureDeleted();
_appDbContext.Dispose();
}
[Given(@"the Loan table has the following loans")]
public void GivenTheLoanTableHasTheFollowingLoans(Table table)
{
var loans = table.CreateSet<Loan>();
_appDbContext.Loans.AddRange(loans);
_appDbContext.SaveChanges();
}
[Given(@"I have these loans to save")]
public void GivenIHaveThisLoanToSave(Table table)
{
_loansToSave = table.CreateSet<Loan>().ToList();
}
[Given(@"a loan filter that looks like")]
public void GivenALoanFilterThatLooksLike(Table table)
{
_loanFilter = table.CreateInstance<LoanFilter>();
}
[Then(@"the first loan from the loan service has ImportId (.*)")]
public void ThenTheFirstLoanFromTheLoanServiceHasImportId(int importId)
{
Assert.Equal(importId, _loansResult.First().ImportId);
}
[Given(@"the Loan Repository throws an exception in ListAll")]
public void GivenTheLoanRepositoryThrowsAnExceptionInListAll()
{
_mockLoanRepo.Setup(a => a.GetAll()).Throws(new Exception());
_loanService = new LoanService(_mockLoanRepo.Object, new LoanTypeRepository(_appDbContext), new AuditHistoryService(_mockAuditHistRepo.Object), new Mock<ICoreApiServiceClient>().Object);
}
[Given(@"the Loan Repository throws an exception in FindByIdAsync")]
public void GivenTheLoanRepositoryThrowsAnExceptionInFindByIdAsync()
{
_mockLoanRepo.Setup(a => a.FindByIdAsync(It.IsAny<int>())).Throws(new Exception());
_loanService = new LoanService(_mockLoanRepo.Object, new LoanTypeRepository(_appDbContext), new AuditHistoryService(_mockAuditHistRepo.Object), new Mock<ICoreApiServiceClient>().Object);
}
[Given(@"the Loan Repository throws an exception in UpdateAsync")]
public void GivenTheLoanRepositoryThrowsAnExceptionInAdd()
{
_mockLoanRepo.Setup(a => a.UpdateAsync(It.IsAny<List<Loan>>())).Throws(new Exception());
_loanService = new LoanService(_mockLoanRepo.Object, new LoanTypeRepository(_appDbContext), new AuditHistoryService(_mockAuditHistRepo.Object), new Mock<ICoreApiServiceClient>().Object);
}
[Given(@"loan types that look like")]
public void GivenLoanTypesThatLookLike(Table table)
{
var loanTypes = table.CreateSet<LoanType>().ToList();
_appDbContext.LoanTypes.AddRange(loanTypes);
_appDbContext.SaveChanges();
}
[Given(@"I have these loans to save with chargebacks")]
public void GivenIHaveTheseLoansToSaveWithChargebacks(Table table)
{
_closedLoans = table.CreateSet<Loan>().ToList();
}
[Given(@"the dealer table has these dealers")]
public void GivenTheDealerTableHasTheseDealers(Table table)
{
var dealers = table.CreateSet<Dealer>().ToList();
_appDbContext.Dealers.AddRange(dealers);
_appDbContext.SaveChanges();
}
[When(@"I save the loans with chargebacks")]
public async void WhenISaveTheLoansWithChargebacks()
{
try
{
var result = await _loanService.SaveWithChargebackAsync(_closedLoans.ToList());
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the list of all loans with the loan service")]
public async void WhenIGetTheListOfAllLoansWithTheLoanService()
{
try
{
_loansResult = await _loanService.GetAllAsync();
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the list of all loans with the loan service with the mock loan repo")]
public async void WhenIGetTheListOfAllLoansWithTheLoanServiceWithTheMockLoanRepo()
{
try
{
_loansResult = await _loanService.GetAllAsync();
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the list of the filtered loans with the loan service")]
public async void WhenIGetTheListOfTheFilteredLoansWithTheLoanService()
{
try
{
_pagedListResponse = await _loanService.GetFilteredAsync(_loanFilter);
_loansResult = _pagedListResponse.LoanList;
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the list of paged loans")]
public async void WhenIGetTheListOfPagedLoans()
{
try
{
_pagedListResponse = await _loanService.GetFilteredAsync(_loanFilter);
_loansResult = _pagedListResponse.LoanList;
}
catch (Exception ex)
{
_exception = ex;
}
}
[Then(@"the result from the loan service should have (.*) pages")]
public void ThenTheResultFromTheLoanServiceShouldHavePages(int pageCount)
{
Assert.Equal(pageCount, _pagedListResponse.TotalPages);
}
[Then(@"the result from the loan service should have (.*) records")]
public void ThenTheResultFromTheLoanServiceShouldHaveRecords(int recordCount)
{
Assert.Equal(recordCount, _pagedListResponse.LoanList.Count());
}
[Then(@"the result from the loan service should have (.*) total items")]
public void ThenTheResultFromTheLoanServiceShouldHaveTotalItems(int recordCount)
{
Assert.Equal(recordCount, _pagedListResponse.TotalItems);
}
[Then(@"the first result from the loan service should have loanid (.*)")]
public void ThenTheFirstResultFromTheLoanServiceShouldHaveLoanId(int loanId)
{
Assert.Equal(loanId, _pagedListResponse.LoanList.First().LoanId);
}
//have to rethink this if we get rid of the other one
[When(@"I save the loan with the reserve")]
public async void WhenISaveTheLoan()
{
try
{
await _loanService.SaveLoansAsync(_loansToSave);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I save the loan with the reserve with the mock loan repo")]
public async void WhenISaveTheLoanWithTheReserveWithTheMockLoanRepo()
{
try
{
await _loanService.SaveLoansAsync(_loansToSave);
}
catch (Exception ex)
{
_exception = ex;
}
}
[Then(@"the result from the loan service has previous page should be (.*)")]
public void ThenTheResultFromTheLoanServiceHasPreviousPageShouldBe(bool hasPreviousPage)
{
Assert.Equal(hasPreviousPage, _pagedListResponse.HasPreviousPage);
}
[Then(@"the result from the loan service has next page should be (.*)")]
public void ThenTheResultFromTheLoanServiceHasNextPageShouldBe(bool hasNextPage)
{
Assert.Equal(hasNextPage, _pagedListResponse.HasNextPage);
}
[Then (@"the result from the loan service first page should be (.*)")]
public void ThenTheResultFromTheLoanServiceFirstPageShouldBe(int firstPage)
{
Assert.Equal(firstPage, _pagedListResponse.FirstPage);
}
[Then(@"the result from the loan service last page should be (.*)")]
public void ThenTheResultFromTheLoanServiceLastPageShouldBe(int lastPage)
{
Assert.Equal(lastPage, _pagedListResponse.LastPage);
}
[When(@"I get the loan with the loanId (.*) from the loan service")]
public async void WhenIGetTheLoanWithTheLoanIdFromTheLoanService(int loanId)
{
try
{
_loanResult = await _loanService.GetByIdAsync(loanId);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the loan with the loanId (.*) from the loan service using the Mock Loan Repo")]
public async void WhenIGetTheLoanWithTheLoanIdFromTheLoanServiceUsingTheMockLoanRepo(int loanId)
{
try
{
_loanResult = await _loanService.GetByIdAsync(loanId);
}
catch (Exception ex)
{
_exception = ex;
}
}
[When(@"I get the list of members with search string ""(.*)""")]
public async void WhenIGetTheListOfMembersWithSearchString(string searchString)
{
_memberResult = await _loanService.SearchMembers(searchString);
}
[When(@"I get the list of loan numbers with search string ""(.*)""")]
public async void WhenIGetTheListOfLoanNumbersWithSearchString(string searchString)
{
_loanNumberResult = await _loanService.SearchLoanNumbers(searchString);
}
[When(@"I get the list of application ids with search string ""(.*)""")]
public async void WhenIGetTheListOfApplicationIdsWithSearchString(string searchString)
{
_applicationIdResult = await _loanService.SearchApplicationIds(searchString);
}
[Then(@"the result from the loan service should have (.*) loans")]
public void ThenTheResultFromTheLoanServiceShouldHaveLoans(int loanCount)
{
Assert.Equal(loanCount, _loansResult.Count());
}
[Then(@"the list of members returned is in this order")]
public void ThenTheListOfMembersReturnedIsInThisOrder(Table table)
{
var expectedMemberNumbers = table.Rows.Select(x => x[0]).ToList();
_memberResult.Should().BeEquivalentTo(expectedMemberNumbers).And.ContainInOrder(expectedMemberNumbers);
}
[Then(@"the list of loan numbers looks like")]
public void ThenTheListOfLoanNumbersLooksLike(Table table)
{
var expectedLoanNumbers = table.Rows.Select(x => x[0]).ToList();
_loanNumberResult.Should().BeEquivalentTo(expectedLoanNumbers).And.ContainInOrder(expectedLoanNumbers);
}
[Then(@"the list of application ids looks like")]
public void ThenTheListOfApplicationIdsLooksLike(Table table)
{
var expectedApplicationIds = table.Rows.Select(x => x[0]).ToList();
_applicationIdResult.Should().BeEquivalentTo(expectedApplicationIds).And.ContainInOrder(expectedApplicationIds);
}
[Then(@"the loans from the loan service look like")]
public async void ThenTheLoanFromTheLoanServiceLooksLike(Table table)
{
var actualLoans = (await _loanService.GetAllAsync()).ToList();
table.CompareToSet(actualLoans);
}
[Then(@"the first loan from the loan service has LoanId (.*)")]
public void ThenTheFirstLoanFromTheLoanServiceHasLoanId(int loanId)
{
Assert.Equal(loanId, _loansResult.First().LoanId);
}
[Then(@"the loan ids from the loan service look like")]
public void ThenTheLoanIdsFromTheLoanServiceLookLike(Table table)
{
var expectedLoanIds = table.CreateSet<int>().ToList();
_loansResult.Select(x => x.LoanId).Should().BeEquivalentTo(expectedLoanIds).And.ContainInOrder(expectedLoanIds);
}
[Then(@"the loan ids from the loan service look like ""(.*)""")]
public void ThenTheLoanIdsFromTheLoanServiceLookLike(string listOfIds)
{
var expected = listOfIds.Split(',').Select(x => int.Parse(x)).ToList();
_loansResult.Select(x => x.LoanId).Should().BeEquivalentTo(expected);
}
[Then(@"the loan with LoanId (.*) has dealer name ""(.*)""")]
public void ThenTheLoanWithLoanIdHasDealerName(int loanId, string dealerName)
{
Assert.Equal(dealerName, _loansResult.First(x => x.LoanId == loanId).Dealer.Name);
}
[Then(@"the Loan Service throws an exception with the message ""(.*)""")]
public void ThenTheLoanServiceThrowsAnExceptionWithTheMessage(string message)
{
Assert.NotNull(_exception);
Assert.Equal(message, _exception.Message);
}
[Then(@"the loan from the loan service has LoanId (.*)")]
public void ThenTheLoanFromTheLoanServiceHasLoanId(int loanId)
{
Assert.Equal(loanId, _loanResult.LoanId);
}
[Then(@"the loan from the loan service has dealer name ""(.*)""")]
public void ThenTheLoanFromTheLoanServiceHasDealerName(string dealerName)
{
Assert.Equal(dealerName, _loanResult.Dealer.Name);
}
[Then(@"the flat fee result for MemberNumber (.*) should be (.*)")]
public void ThenTheReserveAmountResultShouldBe(string member, bool feePaid)
{
Assert.Equal(feePaid, _loansResult.FirstOrDefault(x => x.MemberNumber == member).FlatFeePaid);
}
[Then(@"the loan from the loan service has LoanType.LoanComment ""(.*)""")]
public void ThenTheLoanFromTheLoanServiceHasLoanTypeDescription(string description)
{
Assert.Equal(description, _loanResult.LoanType?.LoanComment ?? string.Empty);
}
[Then(@"the loans in the system look like")]
public void ThenTheLoansInTheSystemLookLike(Table table)
{
table.CompareToSet(_loansInSystem);
}
[Then(@"the loans not in the system look like")]
public void ThenTheLoansNotInTheSystemLookLike(Table table)
{
table.CompareToSet(_loansNotInSystem);
}
[Then(@"the loans in the loan table will look like")]
public void ThenTheLoansInTheLoanTableWillLookLike(Table table)
{
table.CompareToSet(_loansResult);
}
}
}
@@ -0,0 +1,230 @@
Feature: Reserve Calculation
Calculates reserve amount for a loan
Scenario: Calculate Reserve with Standard Markup
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 5/28/2015 | 6/27/2015 | 5/27/2017 | 6200.20 | 1.48 | 3.89 | NC | 24 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 118.73687752592344707611833965
And the reserve message should be Standard Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Boat Reserve with Standard Markup
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | AccountType |
| 5/28/2015 | 6/27/2015 | 5/27/2017 | 6200.20 | 1.50 | 3.00 | NC | 24 | DL09 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 310.01
And the reserve message should be Standard Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Reserve with Standard Markup and Days to First Payment is less than 30
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 2/27/2021 | 3/27/2021 | 2/27/2028 | 55799.16 | 4.59 | 6.34 | NC | 84 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 2917.8694562514364202612072482
And the reserve message should be Standard Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Reserve with Standard Markup - first pay date is less than 30 days from loan date (this calculation might be wrong)
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 4/23/2021 | 5/21/2021 | 4/21/2026 | 6474.80 | 3.24 | 5.24 | NC | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 263.93215613213476391531161260
And the reserve message should be Standard Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Reserve with Standard Markup - loan type id is missing, but will calculate the same as NC
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term |
| 5/28/2015 | 6/27/2015 | 5/27/2017 | 6200.20 | 1.48 | 3.89 | | 24 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 118.73687752592344707611833965
And the reserve message should be Standard Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Reserve with Standard Markup - BB
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term |
| 5/28/2015 | 6/27/2015 | 5/27/2017 | 6200.20 | 1.48 | 3.89 | BB | 24 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| BB | Standard | S | 0 | 0 | 0 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 158.3158367012312627681577862
And the reserve message should be Standard Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Reserve with Standard Markup - NR
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type Id | Term |
| 5/28/2015 | 6/27/2015 | 5/27/2017 | 6200.20 | 3.89 | 3.89 | NR | 24 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NR | No reserve to be paid | N | 0 | 0 | 0 | 0.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 0
And the reserve message should be No Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Reserve with Standard Markup Flat Fee Applied
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 2/18/2021 | 4/4/2021 | 3/1/2024 | 12000.95 | 2.89 | 3.49 | NC | 36 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 90.007125
And the reserve message should be Flat Fee Reserve
And FlatFeePaid should be "true"
Scenario: Calculate Reserve with No Markup Flat Fee Applied
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 7/10/2019 | 8/24/2019 | 7/24/2024 | 20500 | 3.49 | 3.49 | NC | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 153.75
Then the reserve message should be Flat Fee Reserve
And FlatFeePaid should be "true"
Scenario: Calculate Boat Reserve with No Markup Standard Reserve Applied @ 1% Reserve
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | AccountType |
| 7/10/2019 | 8/24/2019 | 7/24/2024 | 20500 | 3.49 | 3.49 | NC | 60 | DL12 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 205
Then the reserve message should be Standard Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Boat Reserve with Non Standard Markup
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | AccountType |
| 1/2/2021 | 2/16/2021 | 1/26/2026 | 28423.05 | 1.83 | 11.73 | NC | 60 | DL10 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 1705.383
Then the reserve message should be Standard Reserve - Exceeds Max Markup
And FlatFeePaid should be "false"
Scenario: Calculate Reserve with Non Standard Markup
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 1/2/2021 | 2/16/2021 | 1/26/2026 | 28423.05 | 1.83 | 11.73 | NC | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 6104.6234279062733014747185835
Then the reserve message should be Standard Reserve - Exceeds Max Markup
And FlatFeePaid should be "false"
Scenario: Calculate Buydown Reserve
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 4/19/2018 | 5/19/2018 | 4/19/2024 | 27042.25 | 4.6 | 1.9 | NC | 72 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be -2362.679817869475221821891298
Then the reserve message should be Buy Down Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Boat Buydown Reserve
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | AccountType |
| 4/19/2018 | 5/19/2018 | 4/19/2024 | 27042.25 | 4.6 | 1.9 | NC | 72 | DL11 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be -2362.679817869475221821891298
Then the reserve message should be Buy Down Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Buydown Reserve - 0.5 difference
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 5/15/2019 | 7/1/2019 | 6/1/2022 | 6261 | 5.27 | 4.77 | NC | 36 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be -52.284980016715778985051587237
Then the reserve message should be Buy Down Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Boat Buydown Reserve - 0.05 difference (reserve should be 0)
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term | AccountType |
| 8/4/2017 | 9/3/2017 | 8/3/2022 | 15721.42 | 9.95 | 9.9 | NC | 60 | DL09 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 0
Then the reserve message should be No Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Buydown Reserve - 0.05 difference (reserve should be 0)
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 8/4/2017 | 9/3/2017 | 8/3/2022 | 15721.42 | 9.95 | 9.9 | NC | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 0
Then the reserve message should be No Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Buydown Reserve - 0.25 difference (reserve should be 0)
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | Loan Amount | Buy Rate | Contract Rate | Loan Type | Term |
| 8/4/2017 | 9/3/2017 | 8/3/2022 | 15721.42 | 8.25 | 8 | NC | 60 |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 0
Then the reserve message should be No Reserve
And FlatFeePaid should be "false"
Scenario: Calculate Reserve when there are weird payment dates
Given a loan that looks like
| Loan Date | First Pmt Date | Final Pmt Date | PostedDate | Loan Amount | Buy Rate | Contract Rate | Loan Type |
| 6/14/2021 | 7/24/2021 | 6/30/2021 | 6/18/2021 | 20500 | 3.49 | 3.49 | NC |
And a loan type table that looks like
| LoanTypeId | LoanComment | ChargebackMethod | NoChargebackDays | NoChargebackPayments | ReserveDiscount | FlatFeePercent | NoReserveThreshold |
| NC | 75% Reserve | N | 90 | 3 | 25.00 | 1.00 | 0.25 |
When the reserve is calculated
Then the reserve amount should be 0
Then the reserve message should be Exception while calculating reserve
And FlatFeePaid should be "false"