-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d644a9a
commit a793de7
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
interface Config { | ||
monthsThreshold: number; | ||
} | ||
|
||
const config: Config = { | ||
monthsThreshold: 36, | ||
}; | ||
|
||
const calculateMonthsBetween = (fyeDate: number, currentDate: Date): number => { | ||
const fyeYear = Math.floor(fyeDate / 100); | ||
const fyeMonth = fyeDate % 100; | ||
|
||
if (fyeDate < 100000 || fyeDate > 999999 || fyeMonth < 1 || fyeMonth > 12) { | ||
throw new Error('fyeDate is expected to be in IRS tax period format YYYYMM'); | ||
} | ||
|
||
const currentYear = currentDate.getFullYear(); | ||
const currentMonth = currentDate.getMonth() + 1; | ||
|
||
return (currentYear - fyeYear) * 12 + (currentMonth - fyeMonth); | ||
}; | ||
|
||
export const isLikelyInactive = (eobmfStatus: boolean, taxPeriod: number): boolean => { | ||
const monthsSinceFye = calculateMonthsBetween(taxPeriod, new Date()); | ||
if (eobmfStatus === false) { | ||
if (monthsSinceFye >= config.monthsThreshold) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; |