@jonstuebe/allot-utils v0.1.10
@jonstuebe/allot-utils
Util functions for Allot
Install
yarn add @jonstuebe/allot-utils date-fns date-fns-holiday-usor with npm:
npm i @jonstuebe/allot-utils date-fns date-fns-holiday-usAPI
Interfaces
Type aliases
Functions
- addFutureBillDates
- chunk
- createBill
- createPaycheck
- firstDayOfMonth
- formatCurrency
- formatPayPeriodDate
- getBillAmountForPayPeriod
- getBillDatesForPayPeriod
- getFutureBillDates
- getPayPeriods
- getPaydays
- getSemiMonthlyForDate
- getSemiMonthlyForMonth
- isBetween
- isBillInPayPeriod
- isPaycheckInPayPeriod
- parseISO
- renderTable
- totalBillsInPayPeriod
- totalIncomeInPayPeriod
- validatePayPeriod
- validatePayPeriods
Type aliases
Bills
Ƭ Bills: Bill[]
Defined in types.ts:16
DayOfMonthIndex
Ƭ DayOfMonthIndex: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30
Defined in types.ts:18
DayOfWeekIndex
Ƭ DayOfWeekIndex: 0 | 1 | 2 | 3 | 4 | 5 | 6
Defined in types.ts:17
MonthIndex
Ƭ MonthIndex: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11
Defined in types.ts:50
PayPeriods
Ƭ PayPeriods: PayPeriod[]
Defined in types.ts:1
Paychecks
Ƭ Paychecks: Paycheck[]
Defined in types.ts:9
YearIndexes
Ƭ YearIndexes: [MonthIndex, DayOfMonthIndex]
Defined in types.ts:51
Functions
addFutureBillDates
▸ addFutureBillDates(bill: Bill, numDates: number): object
Defined in bill.ts:68
Parameters:
| Name | Type | Default |
|---|---|---|
bill | Bill | - |
numDates | number | 3 |
Returns: object
- dueDates: Date[] = getFutureBillDates(bill, numDates)
chunk
▸ chunk(array: Array‹any›, size: number): Array‹any›
Defined in utils.ts:10
Parameters:
| Name | Type |
|---|---|
array | Array‹any› |
size | number |
Returns: Array‹any›
createBill
▸ createBill(bill: InitialBill): object
Defined in bill.ts:96
Parameters:
| Name | Type |
|---|---|
bill | InitialBill |
Returns: object
- dueDates: never[] = []
createPaycheck
▸ createPaycheck(paycheck: Paycheck): Paycheck
Defined in paycheck.ts:3
Parameters:
| Name | Type |
|---|---|
paycheck | Paycheck |
Returns: Paycheck
firstDayOfMonth
▸ firstDayOfMonth(date: Date): Date
Defined in payday.ts:13
Parameters:
| Name | Type |
|---|---|
date | Date |
Returns: Date
formatCurrency
▸ formatCurrency(amount: number, country: string, currency: string): string
Defined in utils.ts:47
Parameters:
| Name | Type | Default |
|---|---|---|
amount | number | - |
country | string | "en-US" |
currency | string | "USD" |
Returns: string
formatPayPeriodDate
▸ formatPayPeriodDate(__namedParameters: object, formatType: string): string
Defined in payPeriod.ts:68
Parameters:
▪ __namedParameters: object
| Name | Type |
|---|---|
end | Date |
start | Date |
▪Default value formatType: string= "MMM do y"
Returns: string
getBillAmountForPayPeriod
▸ getBillAmountForPayPeriod(bill: Bill, payPeriod: PayPeriod): number
Defined in bill.ts:75
Parameters:
| Name | Type |
|---|---|
bill | Bill |
payPeriod | PayPeriod |
Returns: number
getBillDatesForPayPeriod
▸ getBillDatesForPayPeriod(__namedParameters: object, __namedParameters: object): Date[]
Defined in bill.ts:84
Parameters:
▪ __namedParameters: object
| Name | Type |
|---|---|
dueDates | Date[] |
▪ __namedParameters: object
| Name | Type |
|---|---|
end | Date |
start | Date |
Returns: Date[]
getFutureBillDates
▸ getFutureBillDates(__namedParameters: object, numDates: number): Date[]
Defined in bill.ts:21
Parameters:
▪ __namedParameters: object
| Name | Type |
|---|---|
due | object |
startOn | Date |
▪Default value numDates: number= 3
Returns: Date[]
getPayPeriods
▸ getPayPeriods(paydays: Date[]): PayPeriod[]
Defined in payPeriod.ts:54
Parameters:
| Name | Type |
|---|---|
paydays | Date[] |
Returns: PayPeriod[]
getPaydays
▸ getPaydays(type: "weekly" | "bi_weekly" | "semi_monthly" | "monthly", startOn: Date, numPaydays: number, opts?: undefined | object): Array‹Date›
Defined in payday.ts:53
Parameters:
| Name | Type | Default |
|---|---|---|
type | "weekly" | "bi_weekly" | "semi_monthly" | "monthly" | - |
startOn | Date | - |
numPaydays | number | 12 |
opts? | undefined | object | - |
Returns: Array‹Date›
getSemiMonthlyForDate
▸ getSemiMonthlyForDate(date: Date): Date[]
Defined in payday.ts:17
Parameters:
| Name | Type |
|---|---|
date | Date |
Returns: Date[]
getSemiMonthlyForMonth
▸ getSemiMonthlyForMonth(date: Date): Date[]
Defined in payday.ts:49
Parameters:
| Name | Type |
|---|---|
date | Date |
Returns: Date[]
isBetween
▸ isBetween(date: Date, start: Date, end: Date, includeEqual: boolean): Boolean
Defined in utils.ts:32
Parameters:
| Name | Type | Default |
|---|---|---|
date | Date | - |
start | Date | - |
end | Date | - |
includeEqual | boolean | false |
Returns: Boolean
isBillInPayPeriod
▸ isBillInPayPeriod(bill: Bill, payPeriod: PayPeriod): boolean
Defined in bill.ts:80
Parameters:
| Name | Type |
|---|---|
bill | Bill |
payPeriod | PayPeriod |
Returns: boolean
isPaycheckInPayPeriod
▸ isPaycheckInPayPeriod(paycheck: Paycheck, payPeriod: PayPeriod): Boolean
Defined in payPeriod.ts:75
Parameters:
| Name | Type |
|---|---|
paycheck | Paycheck |
payPeriod | PayPeriod |
Returns: Boolean
parseISO
▸ parseISO(dateISO: string): Date
Defined in utils.ts:23
Parameters:
| Name | Type |
|---|---|
dateISO | string |
Returns: Date
renderTable
▸ renderTable(payPeriods: PayPeriods): void
Defined in utils.ts:58
Parameters:
| Name | Type |
|---|---|
payPeriods | PayPeriods |
Returns: void
totalBillsInPayPeriod
▸ totalBillsInPayPeriod(payPeriod: PayPeriod): number
Defined in payPeriod.ts:47
Parameters:
| Name | Type |
|---|---|
payPeriod | PayPeriod |
Returns: number
totalIncomeInPayPeriod
▸ totalIncomeInPayPeriod(payPeriod: PayPeriod): number
Defined in payPeriod.ts:40
Parameters:
| Name | Type |
|---|---|
payPeriod | PayPeriod |
Returns: number
validatePayPeriod
▸ validatePayPeriod(payPeriod: PayPeriod, bills: Bills, paychecks: Paychecks): object
Defined in payPeriod.ts:14
Parameters:
| Name | Type |
|---|---|
payPeriod | PayPeriod |
bills | Bills |
paychecks | Paychecks |
Returns: object
bills: Bill[] = bills.filter((bill: Bill) => { return isBillInPayPeriod(bill, payPeriod); })
paychecks: Paycheck[] = paychecks.filter((paycheck: Paycheck) => { return isPaycheckInPayPeriod(paycheck, payPeriod); })
validatePayPeriods
▸ validatePayPeriods(payPeriods: PayPeriods, bills: Bills, paychecks: Paychecks): object[]
Defined in payPeriod.ts:30
Parameters:
| Name | Type |
|---|---|
payPeriods | PayPeriods |
bills | Bills |
paychecks | Paychecks |
Returns: object[]
© 2020 Jon Stuebe