From 0985c38be81860641d6005c6fc86ea05522213c2 Mon Sep 17 00:00:00 2001
From: siddharthd
Date: Wed, 11 Mar 2026 12:46:16 +1100
Subject: [PATCH] fix(rules): save-as-rule uses full merchant name with equals,
not first description word
---
src/app/transactions/page.tsx | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/app/transactions/page.tsx b/src/app/transactions/page.tsx
index 8602798..e22104c 100644
--- a/src/app/transactions/page.tsx
+++ b/src/app/transactions/page.tsx
@@ -86,20 +86,19 @@ function SaveAsRulePrompt({
const createRule = useCreateRule();
const [saving, setSaving] = useState(false);
- // Build a sensible default rule from the transaction context
- const merchantMatch = tx.effective_merchant || tx.description;
+ // Build a sensible default rule from the transaction context.
+ // Prefer merchant_normalized (full name, exact match) over a partial description word.
+ const hasMerchant = !!tx.effective_merchant;
+ const conditionField = hasMerchant ? "merchant_normalized" : "description";
+ const conditionOperator = hasMerchant ? "equals" : "contains";
+ const conditionValue = hasMerchant ? tx.effective_merchant : tx.description;
+
const defaultName =
field === "category"
- ? `${merchantMatch} → ${formatCategory(newValue)}`
- : `Rename ${tx.effective_merchant || tx.description} → ${newValue}`;
+ ? `${conditionValue} → ${formatCategory(newValue)}`
+ : `Rename ${conditionValue} → ${newValue}`;
- const conditions = [
- {
- field: "description",
- operator: "contains",
- value: (tx.effective_merchant || tx.description).split(" ")[0] ?? "",
- },
- ];
+ const conditions = [{ field: conditionField, operator: conditionOperator, value: conditionValue }];
const actions =
field === "category"
? { set_category: newValue }
@@ -118,7 +117,7 @@ function SaveAsRulePrompt({
Automatically apply this {field === "category" ? "category" : "merchant name"} to future matching transactions.
-
If description contains "{conditions[0].value}"
+
If {conditionField === "merchant_normalized" ? "merchant" : "description"} {conditionOperator} "{conditionValue}"
Then{" "}
{field === "category"