mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-08 06:55:21 +02:00
Handle dates in student loan processor correctly
This commit is contained in:
parent
1f662cb1a9
commit
4d9f86d073
1 changed files with 12 additions and 3 deletions
|
@ -24,15 +24,24 @@ class PlaidAccount::Liabilities::StudentLoanProcessor
|
|||
def term_months
|
||||
return nil unless origination_date && expected_payoff_date
|
||||
|
||||
(expected_payoff_date - origination_date).to_i / 30
|
||||
((expected_payoff_date - origination_date).to_i / 30).to_i
|
||||
end
|
||||
|
||||
def origination_date
|
||||
student_loan_data["origination_date"]
|
||||
parse_date(student_loan_data["origination_date"])
|
||||
end
|
||||
|
||||
def expected_payoff_date
|
||||
student_loan_data["expected_payoff_date"]
|
||||
parse_date(student_loan_data["expected_payoff_date"])
|
||||
end
|
||||
|
||||
def parse_date(value)
|
||||
return value if value.is_a?(Date)
|
||||
return nil unless value.present?
|
||||
|
||||
Date.parse(value.to_s)
|
||||
rescue ArgumentError
|
||||
nil
|
||||
end
|
||||
|
||||
def student_loan_data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue