The generator unrolled the whole engine into the Client Script: one inline block per formula per trigger, plus an if-chain over every report field. A VAT declaration came out at 403 KB of generated code, which then shipped inside taxes_az's fixtures. It now emits a CONFIG object — a copy of the storage — and one call into taxes_az.formula. The storage format is untouched, so every existing Formula Editor record keeps working. Generated scripts no longer reference this app, which is what lets it be removed from production machines. Generation moved from the browser to on_update. It used to run in before_save off the editor's rendered DOM, so a half-drawn form could serialise empty formulas over real ones; it now builds from the stored JSON. Removed with it: the emitters (transform_expression, table-row handlers, universal fields, report fields), plus dead code they hid — processFormula had no call sites, applyAggregation was never emitted, and generate_child_table_script referenced a variable outside its closure and would have thrown on the first is_table_field formula. VAT script: 403 KB -> 120 KB. Output verified identical across all 426 formulas. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| formula_editor | ||
| .editorconfig | ||
| .eslintrc | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| README.md | ||
| license.txt | ||
| package-lock.json | ||
| package.json | ||
| pyproject.toml | ||
| yarn.lock | ||
README.md
Formula Editor
App for adding formulas for any doctype
Installation
You can install this app using the bench CLI:
cd $PATH_TO_YOUR_BENCH
bench get-app $URL_OF_THIS_REPO --branch develop
bench install-app formula_editor
Contributing
This app uses pre-commit for code formatting and linting. Please install pre-commit and enable it for this repository:
cd apps/formula_editor
pre-commit install
Pre-commit is configured to use the following tools for checking and formatting your code:
- ruff
- eslint
- prettier
- pyupgrade
License
unlicense