[FEAT] Exclude transactions with given tag(s)

This commit is contained in:
2023-10-28 23:30:18 +01:00
parent a490b00e1e
commit 072740a2b7

View File

@@ -29,7 +29,7 @@ bcscale(12);
* Keep in mind that running this script is entirely AT YOUR OWN RISK with ZERO GUARANTEES.
*/
const FIREFLY_III_URL = 'http://firefly.sd.home';
const EXCLUDED_TAGS = 'Direct debit';
const FIREFLY_III_TOKEN = 'ey...';
/*
@@ -282,9 +282,18 @@ function getTransactions(int $accountId): array
foreach ($transactions as $transaction) {
$time = strtotime($transaction['date']);
if ($time > TIMESTAMP) {
$tags = $transaction['tags'];
$noExcludedTags = true;
foreach (explode(";", EXCLUDED_TAGS) as $excludedTag) {
if (in_array($tags, $excludedTag)) {
$noExcludedTags = false;
}
}
if ($noExcludedTags) {
// add it to the array:
$addToSet = true;
}
}
if ($time <= TIMESTAMP) {
//message(sprintf('Will not include transaction group #%d, the date is %s', $currentGroup['id'], $transaction['date']));
// break the loop: