Added functionality for an !exclude tag.

This commit is contained in:
Andrew Lalis 2024-02-05 15:22:26 -05:00
parent 2237293eda
commit 7d50b12a4f
4 changed files with 32 additions and 8 deletions

View File

@ -58,7 +58,6 @@ public class EditAccountController implements RouteSelectionListener {
var numberValid = new ValidationApplier<>(new PredicateValidator<String>() var numberValid = new ValidationApplier<>(new PredicateValidator<String>()
.addTerminalPredicate(s -> s != null && !s.isBlank(), "Account number should not be empty.") .addTerminalPredicate(s -> s != null && !s.isBlank(), "Account number should not be empty.")
.addPredicate(s -> s.length() <= 255, "Account number is too long.") .addPredicate(s -> s.length() <= 255, "Account number is too long.")
.addPredicate(s -> s.matches("\\d+"), "Account number should contain only numeric digits.")
).attachToTextField(accountNumberField); ).attachToTextField(accountNumberField);
var balanceValid = new ValidationApplier<>( var balanceValid = new ValidationApplier<>(

View File

@ -45,7 +45,17 @@ public record JdbcAnalyticsRepository(Connection conn) implements AnalyticsRepos
FROM transaction FROM transaction
LEFT JOIN transaction_vendor tv ON tv.id = transaction.vendor_id LEFT JOIN transaction_vendor tv ON tv.id = transaction.vendor_id
LEFT JOIN account_entry ae ON ae.transaction_id = transaction.id LEFT JOIN account_entry ae ON ae.transaction_id = transaction.id
WHERE transaction.currency = ? AND ae.type = 'CREDIT' AND transaction.timestamp >= ? AND transaction.timestamp <= ? WHERE
transaction.currency = ? AND
transaction.timestamp >= ? AND
transaction.timestamp <= ? AND
ae.type = 'CREDIT' AND
'!exclude' NOT IN (
SELECT tt.name
FROM transaction_tag tt
LEFT JOIN transaction_tag_join ttj ON tt.id = ttj.tag_id
WHERE ttj.transaction_id = transaction.id
)
GROUP BY tv.id GROUP BY tv.id
ORDER BY total DESC""", ORDER BY total DESC""",
List.of(currency.getCurrencyCode(), range.start(), range.end()), List.of(currency.getCurrencyCode(), range.start(), range.end()),
@ -75,7 +85,17 @@ public record JdbcAnalyticsRepository(Connection conn) implements AnalyticsRepos
FROM transaction FROM transaction
LEFT JOIN transaction_category tc ON tc.id = transaction.category_id LEFT JOIN transaction_category tc ON tc.id = transaction.category_id
LEFT JOIN account_entry ae ON ae.transaction_id = transaction.id LEFT JOIN account_entry ae ON ae.transaction_id = transaction.id
WHERE transaction.currency = ? AND ae.type = ? AND transaction.timestamp >= ? AND transaction.timestamp <= ? WHERE
transaction.currency = ? AND
ae.type = ? AND
transaction.timestamp >= ? AND
transaction.timestamp <= ? AND
'!exclude' NOT IN (
SELECT tt.name
FROM transaction_tag tt
LEFT JOIN transaction_tag_join ttj ON tt.id = ttj.tag_id
WHERE ttj.transaction_id = transaction.id
)
GROUP BY tc.id GROUP BY tc.id
ORDER BY total DESC;""", ORDER BY total DESC;""",
List.of(currency.getCurrencyCode(), type.name(), range.start(), range.end()), List.of(currency.getCurrencyCode(), type.name(), range.start(), range.end()),

View File

@ -11,10 +11,7 @@ import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator;
import java.util.Currency;
import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
@ -39,7 +36,11 @@ public abstract class PieChartModule extends DashboardModule {
this.getChildren().add(chart); this.getChildren().add(chart);
currencyChoiceBox.valueProperty().addListener((observable, oldValue, newValue) -> { currencyChoiceBox.valueProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) { if (newValue != null) {
getChartData(newValue).thenAccept(data -> Platform.runLater(() -> { getChartData(newValue).exceptionally(throwable -> {
throwable.printStackTrace(System.err);
return Collections.emptyList();
})
.thenAccept(data -> Platform.runLater(() -> {
chartData.setAll(data); chartData.setAll(data);
if (!dataColors.isEmpty()) { if (!dataColors.isEmpty()) {
for (int i = 0; i < dataColors.size(); i++) { for (int i = 0; i < dataColors.size(); i++) {

View File

@ -65,6 +65,10 @@
and earnings. With **tags**, you can add custom text tags to your and earnings. With **tags**, you can add custom text tags to your
transaction, sort of like social media's "hashtag" phenomenon. transaction, sort of like social media's "hashtag" phenomenon.
-- --
**Pro-tip**: You can add the tag `!exclude` to a transaction to exclude
it from analytics and visuals. This is useful for things like transfers
between your accounts.
--
**Line items** can be used to specify in more detail what was bought or sold **Line items** can be used to specify in more detail what was bought or sold
in a transaction. For example, you bought a new computer and some in a transaction. For example, you bought a new computer and some
accessories at an electronics store. You can record the exact purchase accessories at an electronics store. You can record the exact purchase