Skip to content

Commit

Permalink
Add support for filtering out pending transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
AmineI committed Apr 4, 2024
1 parent 94fbfab commit d19aea9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class PolledSyncRunner @Autowired constructor(
private val cursorFileDirectoryPath: String,
@Value("\${fireflyPlaidConnector2.plaid.batchSize}")
private val plaidBatchSize: Int,
@Value("\${fireflyPlaidConnector2.includePending:true}")
private val includePending: Boolean,

private val plaidApiWrapper: PlaidApiWrapper,
private val fireflyTxApi: TransactionsApi,
Expand Down Expand Up @@ -172,8 +174,9 @@ class PolledSyncRunner @Autowired constructor(

/**
* The transaction sync endpoint doesn't take accountId as a parameter, so do that filtering here
* We also add a filter to ignore pending Txs only if "includePending" is not true
*/
plaidCreatedTxs.addAll(response.added.filter { accountIdSet.contains(it.accountId) })
plaidCreatedTxs.addAll(response.added.filter { accountIdSet.contains(it.accountId) && (includePending || !it.pending)})
plaidUpdatedTxs.addAll(response.modified.filter { accountIdSet.contains(it.accountId) })
plaidDeletedTxs.addAll(response.removed.mapNotNull { it.transactionId })

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ fireflyPlaidConnector2:
# a generic "Unknown" name.
# Defaults to true.
useNameForDestination: true
# Transactions are registered by a bank as pending for a while, before they get confirmed or cancelled.
# If this is set to true, the connector will include pending transactions in the sync process.
# If this is set to false, the connector will ignore pending transactions, and them a few days later when they report as confirmed.
# Defaults to true.
includePending: true
# Firefly uses a timestamp for when transactions occurred, but Plaid does not always provide a timestamp
# for transactions; often it only provides a date. In those cases, we need a time zone to apply so that
# the timestamp that shows up in Firefly properly spans the specified date in the user's timezone.
Expand Down

0 comments on commit d19aea9

Please sign in to comment.