Added functionality for an !exclude tag.
This commit is contained in:
		
							parent
							
								
									2237293eda
								
							
						
					
					
						commit
						7d50b12a4f
					
				| 
						 | 
				
			
			@ -58,7 +58,6 @@ public class EditAccountController implements RouteSelectionListener {
 | 
			
		|||
        var numberValid = new ValidationApplier<>(new PredicateValidator<String>()
 | 
			
		||||
                .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.matches("\\d+"), "Account number should contain only numeric digits.")
 | 
			
		||||
        ).attachToTextField(accountNumberField);
 | 
			
		||||
 | 
			
		||||
        var balanceValid = new ValidationApplier<>(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,17 @@ public record JdbcAnalyticsRepository(Connection conn) implements AnalyticsRepos
 | 
			
		|||
                FROM transaction
 | 
			
		||||
                LEFT JOIN transaction_vendor tv ON tv.id = transaction.vendor_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
 | 
			
		||||
                ORDER BY total DESC""",
 | 
			
		||||
                List.of(currency.getCurrencyCode(), range.start(), range.end()),
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +85,17 @@ public record JdbcAnalyticsRepository(Connection conn) implements AnalyticsRepos
 | 
			
		|||
                FROM transaction
 | 
			
		||||
                LEFT JOIN transaction_category tc ON tc.id = transaction.category_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
 | 
			
		||||
                ORDER BY total DESC;""",
 | 
			
		||||
                List.of(currency.getCurrencyCode(), type.name(), range.start(), range.end()),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,10 +11,7 @@ import javafx.scene.control.ChoiceBox;
 | 
			
		|||
import javafx.scene.layout.Pane;
 | 
			
		||||
import javafx.scene.paint.Color;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.Currency;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.concurrent.CompletableFuture;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +36,11 @@ public abstract class PieChartModule extends DashboardModule {
 | 
			
		|||
        this.getChildren().add(chart);
 | 
			
		||||
        currencyChoiceBox.valueProperty().addListener((observable, oldValue, newValue) -> {
 | 
			
		||||
            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);
 | 
			
		||||
                    if (!dataColors.isEmpty()) {
 | 
			
		||||
                        for (int i = 0; i < dataColors.size(); i++) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,6 +65,10 @@
 | 
			
		|||
        and earnings. With **tags**, you can add custom text tags to your
 | 
			
		||||
        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
 | 
			
		||||
        in a transaction. For example, you bought a new computer and some
 | 
			
		||||
        accessories at an electronics store. You can record the exact purchase
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue