Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getTransactions() {
const DATE_FORMAT = 'YYYY-MM-DD'
const today = new Date()
const lt = formatDate(subDays(today, this.interval), DATE_FORMAT)
const gt = formatDate(subMonths(lt, 6), DATE_FORMAT)
log('info', `Fetching transactions between ${gt} and ${lt}`)
const transactionsInDateRange = await BankTransaction.queryAll({
date: {
$gt: gt,
$lt: lt
}
})
log(
'info',
`${transactionsInDateRange.length} fetched transactions between ${gt} and ${lt}`
)
const healthExpenses = transactionsInDateRange.filter(isHealthExpense)
log('info', `${healthExpenses.length} are health expenses`)
const billIds = getReimbursementBillIds(healthExpenses)
const bills = await Bill.getAll(billIds)