Skip to content

fix formula date variable in rules#7373

Merged
youngcw merged 3 commits intomasterfrom
youngcw/fix-formula-date-var
Apr 8, 2026
Merged

fix formula date variable in rules#7373
youngcw merged 3 commits intomasterfrom
youngcw/fix-formula-date-var

Conversation

@youngcw
Copy link
Copy Markdown
Member

@youngcw youngcw commented Apr 3, 2026

Description

addresses #5949 (comment)

This also modifies what counts as a date. Are there other formats we should use? The trade off is that anything that matches a date format is treated as a date and will need formatted if used in a note.

Related issue(s)

Testing

Checklist

  • Release notes added (see link above)
  • No obvious regressions in affected areas
  • Self-review has been performed - I understand what each change in the code does and why it is needed

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 28 12.17 MB → 12.18 MB (+4.84 kB) +0.04%
loot-core 1 4.83 MB → 4.83 MB (+87 B) +0.00%
api 4 4.06 MB → 4.06 MB (+82 B) +0.00%
cli 1 7.88 MB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
28 12.17 MB → 12.18 MB (+4.84 kB) +0.04%
Changeset
File Δ Size
locale/zh-Hans.json 📈 +4.75 kB (+5.50%) 86.32 kB → 91.07 kB
src/hooks/useFormulaExecution.ts 📈 +87 B (+0.51%) 16.63 kB → 16.71 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/zh-Hans.js 86.32 kB → 91.07 kB (+4.75 kB) +5.50%
static/js/ReportRouter.js 1.02 MB → 1.02 MB (+87 B) +0.01%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/index.js 3.23 MB 0%
static/js/BackgroundImage.js 119.98 kB 0%
static/js/FormulaEditor.js 846.44 kB 0%
static/js/TransactionList.js 81.29 kB 0%
static/js/ca.js 182.91 kB 0%
static/js/da.js 104.66 kB 0%
static/js/de.js 174.79 kB 0%
static/js/en-GB.js 7.16 kB 0%
static/js/en.js 170.76 kB 0%
static/js/es.js 182.18 kB 0%
static/js/fr.js 177.47 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 166.25 kB 0%
static/js/narrow.js 354.5 kB 0%
static/js/nb-NO.js 152.2 kB 0%
static/js/nl.js 108.93 kB 0%
static/js/pl.js 88.34 kB 0%
static/js/pt-BR.js 177.84 kB 0%
static/js/resize-observer.js 18.03 kB 0%
static/js/sv.js 80.58 kB 0%
static/js/th.js 179.94 kB 0%
static/js/theme.js 30.68 kB 0%
static/js/uk.js 213.14 kB 0%
static/js/useTransactionBatchActions.js 4.29 MB 0%
static/js/wide.js 418 B 0%
static/js/workbox-window.prod.es5.js 7.28 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 4.83 MB → 4.83 MB (+87 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/rules/action.ts 📈 +87 B (+1.10%) 7.74 kB → 7.83 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
kcab.worker.CDaZ7TiH.js 0 B → 4.83 MB (+4.83 MB) -

Removed

Asset File Size % Changed
kcab.worker.CwpE34S5.js 4.83 MB → 0 B (-4.83 MB) -100%

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged
No assets were unchanged


api

Total

Files count Total bundle size % Changed
4 4.06 MB → 4.06 MB (+82 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/rules/action.ts 📈 +82 B (+1.10%) 7.31 kB → 7.39 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
index.js 3.84 MB → 3.84 MB (+82 B) +0.00%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
from-Bl-Hslp4.js 167.73 kB 0%
multipart-parser-BnDysoMr.js 8.1 kB 0%
src-iMkUmuwR.js 43.64 kB 0%

cli

Total

Files count Total bundle size % Changed
1 7.88 MB 0%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
cli.js 7.88 MB 0%

@actual-github-bot actual-github-bot bot changed the title Youngcw/fix formula date var [WIP] Youngcw/fix formula date var Apr 3, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 3, 2026

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit e4f891a
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/69d012d673398b0008ecaab9
😎 Deploy Preview https://deploy-preview-7373.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@youngcw youngcw changed the title [WIP] Youngcw/fix formula date var fix formula date variable in rules Apr 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

Added explicit dateFormats (DD/MM/YYYY, YYYY-MM-DD, YYYY/MM/DD) to HyperFormula initializations in three formula-execution locations; added a release note and adjusted a test to expect a formatted today value.

Changes

Cohort / File(s) Summary
HyperFormula Date Format Configuration
packages/desktop-client/src/hooks/useFormulaExecution.ts, packages/desktop-client/src/hooks/useTransactionFormulaExecution.ts, packages/loot-core/src/server/rules/action.ts
Added dateFormats: ['DD/MM/YYYY','YYYY-MM-DD','YYYY/MM/DD'] to HyperFormula initialization in each file.
Tests
packages/loot-core/src/server/rules/formula-action.test.ts
Updated test to assert today via TEXT(today,"YYYY-MM-DD") formatted expression.
Release Notes
upcoming-release-notes/7373.md
Added bugfix release note documenting correction related to the date variable in rule formulas.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

size small

Poem

🐰 A tiny tweak to dates I bring,
Formats tidy, ready to sing,
DD/MM/YYYY and friends in queue,
Rules and tests now parse them true,
A carrot-hop for code anew 🥕

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix formula date variable in rules' clearly and specifically describes the main change in the PR: fixing how the date variable is handled in formula rules.
Description check ✅ Passed The PR description directly addresses the issue (#5949) and explains the changes made to date format handling in formula execution, including the trade-offs involved.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch youngcw/fix-formula-date-var

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/loot-core/src/server/rules/action.ts (1)

306-307: Centralize formula date formats to avoid future drift.

At Line 306, this list is now duplicated across server and both client hooks. Please extract one shared constant and reuse it in all HyperFormula init sites.

As per coding guidelines: packages/*/src/**/*.{ts,tsx,js,jsx}: Prefer iteration and modularization over code duplication.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/loot-core/src/server/rules/action.ts` around lines 306 - 307, The
hard-coded dateFormats array (dateFormats: ['DD/MM/YYYY', 'YYYY-MM-DD',
'YYYY/MM/DD']) is duplicated across the server and client HyperFormula init
sites; extract this array into a single exported constant (e.g., DATE_FORMATS)
in a shared module and import it wherever HyperFormula is initialized
(referencing the dateFormats symbol and each HyperFormula init site such as the
server rule initializer in action.ts and the two client hook initializers) so
all places use the shared constant instead of duplicating the literal.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/loot-core/src/server/rules/action.ts`:
- Around line 306-307: The hard-coded dateFormats array (dateFormats:
['DD/MM/YYYY', 'YYYY-MM-DD', 'YYYY/MM/DD']) is duplicated across the server and
client HyperFormula init sites; extract this array into a single exported
constant (e.g., DATE_FORMATS) in a shared module and import it wherever
HyperFormula is initialized (referencing the dateFormats symbol and each
HyperFormula init site such as the server rule initializer in action.ts and the
two client hook initializers) so all places use the shared constant instead of
duplicating the literal.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7e271749-5b8b-4c4f-beb3-a70fe4308111

📥 Commits

Reviewing files that changed from the base of the PR and between c0c2d16 and 8ce6210.

📒 Files selected for processing (4)
  • packages/desktop-client/src/hooks/useFormulaExecution.ts
  • packages/desktop-client/src/hooks/useTransactionFormulaExecution.ts
  • packages/loot-core/src/server/rules/action.ts
  • upcoming-release-notes/7373.md

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 3, 2026
@matt-fidd matt-fidd force-pushed the master branch 2 times, most recently from 5c7c70d to d262f7d Compare April 5, 2026 17:13
Copy link
Copy Markdown
Member

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I realised we have 3 separate instances of hyperformula. Do you know if this is how it's usually used?

@@ -329,6 +329,7 @@ export function useFormulaExecution(
licenseKey: 'gpl-v3',
localeLang: typeof locale === 'string' ? locale : 'en-US',
language: 'enUS',
dateFormats: ['DD/MM/YYYY', 'YYYY-MM-DD', 'YYYY/MM/DD'],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a breaking change as non-US dates are used by default, but for the future we should look at using the user date pref to set this if possible.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that using locales + the Actual format would be best.

@youngcw
Copy link
Copy Markdown
Member Author

youngcw commented Apr 8, 2026

I don't think I realised we have 3 separate instances of hyperformula. Do you know if this is how it's usually used?

They all are used for different things. I don't see why we couldn't have a single core set of HF code, that then gets used in 3 different ways. It took me floundering around not understanding why my changes were doing anything to figure out there were multiple instances.

@youngcw youngcw added this pull request to the merge queue Apr 8, 2026
Merged via the queue into master with commit 926f719 Apr 8, 2026
40 checks passed
@youngcw youngcw deleted the youngcw/fix-formula-date-var branch April 8, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants