File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,22 @@ const handleCommand = async (argv: ArgumentsCamelCase) => {
30
30
const fromDate = argv . from
31
31
? parse ( argv . from as string , DATE_FORMAT , new Date ( ) )
32
32
: undefined ;
33
+ const toDate = argv . to
34
+ ? parse ( argv . to as string , DATE_FORMAT , new Date ( ) )
35
+ : undefined ;
33
36
34
37
if ( fromDate && isNaN ( fromDate . getTime ( ) ) ) {
35
38
throw new Error (
36
39
`Invalid from date: '${ argv . from } '. Expected a date in the format: ${ DATE_FORMAT } `
37
40
) ;
38
41
}
39
42
43
+ if ( toDate && isNaN ( toDate . getTime ( ) ) ) {
44
+ throw new Error (
45
+ `Invalid "to" date: '${ argv . to } '. Expected a date in the format: ${ DATE_FORMAT } `
46
+ ) ;
47
+ }
48
+
40
49
for ( const serverConfig of config . actualServers ) {
41
50
const actualApi = new ActualApi ( serverConfig , logger ) ;
42
51
@@ -106,6 +115,11 @@ export default {
106
115
. describe (
107
116
'from' ,
108
117
`Import transactions on or after this date (${ DATE_FORMAT } )`
118
+ )
119
+ . string ( 'to' )
120
+ . describe (
121
+ 'from' ,
122
+ `Import transactions up to this date (${ DATE_FORMAT } )`
109
123
) ;
110
124
} ,
111
125
handler : ( argv ) => handleCommand ( argv ) ,
Original file line number Diff line number Diff line change @@ -130,16 +130,19 @@ class Importer {
130
130
async importTransactions ( {
131
131
accountMapping,
132
132
from,
133
+ to,
133
134
isDryRun = false ,
134
135
} : {
135
136
accountMapping : Map < MonMonAccount , Account > ;
136
137
from ?: Date ;
138
+ to ?: Date ;
137
139
isDryRun ?: boolean ;
138
140
} ) {
139
141
const fromDate = from ?? subMonths ( new Date ( ) , 1 ) ;
140
142
const earliestImportDate = this . budgetConfig . earliestImportDate
141
143
? new Date ( this . budgetConfig . earliestImportDate )
142
144
: null ;
145
+ const toDate = to ;
143
146
144
147
const importDate =
145
148
earliestImportDate && earliestImportDate > fromDate
@@ -157,6 +160,7 @@ class Importer {
157
160
158
161
let monMonTransactions = await getTransactions ( {
159
162
from : importDate ,
163
+ to : toDate
160
164
} ) ;
161
165
162
166
if ( monMonTransactions . length === 0 ) {
You can’t perform that action at this time.
0 commit comments