Skip to content

Open source personal finance application

feat (getTrns): add fromDate and untilDate

ilkome2748b0ec3c57
diff --git a/components/trns/functions/getTrns.ts b/components/trns/functions/getTrns.ts
index 6e1e45aa..1cc2a860 100644
--- a/components/trns/functions/getTrns.ts
+++ b/components/trns/functions/getTrns.ts
@@ -11,6 +11,8 @@ interface Props {
trnType?: TrnType
periodName?: PeriodName
date?: Date
+ fromDate?: number
+ untilDate?: number
}
export const getTrnsIds = (props: Props) => {
@@ -25,7 +27,7 @@ export const getTrnsIds = (props: Props) => {
})
}
- // Date
+ // @deprecated: Date
if (props?.date && props?.periodName !== 'all') {
const filterDate = dayjs(props.date)
const filterPeriod = props.periodName
@@ -37,6 +39,14 @@ export const getTrnsIds = (props: Props) => {
&& (props.trnsItems[trnId].date <= untilDate))
}
+ // From date
+ if (props.fromDate)
+ trnsIds = trnsIds.filter(trnId => (props.trnsItems[trnId].date >= props.fromDate))
+
+ // Until date
+ if (props.untilDate)
+ trnsIds = trnsIds.filter(trnId => (props.trnsItems[trnId].date <= props.untilDate))
+
// Wallet
if (props.walletsIds?.length > 0) {
trnsIds = trnsIds.filter((trnId: TrnID) => {