Commit Graph
11 Commits
Author SHA1 Message Date
markhainesandClaude Opus 5 5a0723bb84 fix(generators): stop provider:family emitting a broken migration and invalid enum (#3047)
* fix(generators): stop provider:family emitting a broken migration and invalid enum

Two bugs in the per-family provider generator, both of which stop the generated code
from running at all.

1. Duplicate migration columns. The items table already defines institution_id,
   institution_name, status and others, but any matching field passed on the command
   line was emitted a second time in the provider-specific block, so db:migrate aborted
   with "you can't define an already defined column". Reserved names are now filtered
   out of that block, with a notice, since the standard column serves the same purpose.

2. Invalid Ruby in the source enums. The patcher appended the new entry directly before
   the closing brace. In a multi-line hash the previous entry is followed by a newline,
   so the inserted text landed on its own line after Ruby had already ended the
   expression, producing:

       redbark: "redbark"
     , gocardless: "gocardless"}

   data_enrichment.rb then failed to parse, surfacing later as a confusing eager-load
   error rather than anything pointing at the generator. The comma is now attached to
   the final entry and the new entry indented to match its siblings. The single-line
   form used by provider_merchant.rb is preserved.

Found while adding a GoCardless provider; both reproduce with any invocation of
rails g provider:family.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(generators): add the syncable scope the family syncer requires

The generated item model includes Syncable, so Family::Syncer's reflective discovery
picks up the new `*_items` association and calls `syncable` on it. The template never
defined that scope, so a freshly generated provider raises

    NoMethodError: undefined method 'syncable' for an instance of
    ActiveRecord::Associations::CollectionProxy
    app/models/family/syncer.rb:38

and takes down the ENTIRE nightly family sync, not just the new provider. Every other
item model in the app defines `scope :syncable, -> { active }`; the template now does
the same.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(generators): emit valid i18n interpolation in the locale template

The locale template wrote %%{count} where I18n expects %{count}. Rails generator ERB
does not collapse %% (percent trim mode only applies to lines starting with %), so the
doubled percent reached the generated file verbatim and I18n rendered it as a literal
percent sign followed by the placeholder.

Every generated provider therefore displayed strings like

    %{count} accounts synced

instead of the count. 40 occurrences across sync status, institution summary, account
setup and error messages. Every hand-written locale in the app uses the single-percent
form.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(generators): reject reserved field names instead of silently dropping them

Addresses review feedback on the duplicate-column fix.

Filtering reserved names out of the migration alone was inconsistent: parsed_fields
also feeds the item model (validations, encryption), the settings panel (form inputs),
the controller params, the locale strings, the adapter and the SDK. A declared
institution_id:integer would therefore render a numeric form input and a presence
validation over the built-in string column. Declaring a reserved name is now a
Thor::Error naming the field and telling the user to drop it, which keeps the generated
code self-consistent and fails at generate time rather than at db:migrate.

Also removes 'family' from the reserved list. The migration writes
t.references :family, which creates family_id, so a field named family is not a
collision; family_id remains reserved.

Verified: institution_id is rejected with a useful message, family:string generates
cleanly, and an ordinary invocation is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(generators): do not double the comma when the source enum has a trailing one

Addresses review feedback. When the enum hash is written with a trailing comma, the
captured body already ends with a separator, so appending another produced

    redbark: "redbark",,
    gocardless: "gocardless"

which is the same class of syntax error the surrounding fix exists to prevent. The
separator is now chosen from whether the body already ends with a comma.

Extracts the transformation to Provider::FamilyGenerator.append_source_enum_entry, a
pure string operation, and adds regression tests covering single-line and multiline
enums with and without trailing commas. Each case asserts the result actually parses:
the failure mode here is a SyntaxError surfacing in an unrelated file with nothing
pointing back at the generator, so asserting on shape alone would be too weak.

Verified the tests fail without the fix (2 failures, both trailing-comma cases).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(generators): do not emit a leading comma into an empty source enum

Addresses review feedback. When the target has `enum :source, {}` the captured body is
empty, so the separator produced `enum :source, {, gocardless: "gocardless"}` and the
generated model failed to parse.

No separator is emitted when the body is empty. Adds regression tests for the empty
single-line and multiline forms, both asserting the result parses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 01:16:36 +02:00
Otter 1c6d018b6a Fix transactions posting a day early when booked around midnight. (#2744)
* Fix 2668

* Fix CodeRabbit nitpick

* Fix Akahu parsing

* Anchor provider transaction date parsing to family timezone

* Coderabbit suggestion for Date/DateTime order

* Remove duplicate condition in wise

* Safe unless column_exists + pass family to date parse to family components
2026-07-30 02:29:13 +02:00
Juan José MataandClaude 17df5179ae Remove reference to nonexistent Sidekiq::Throttled gem (#950)
The sidekiq-throttled gem is not in the Gemfile, so including
Sidekiq::Throttled::Job causes an uninitialized constant NameError
at boot time, breaking production builds.

https://claude.ai/code/session_01Bj7xgndJt28BcUHW1v1M9S

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-09 16:32:38 +01:00
Juan José MataandClaude 0fb9d60ee6 Use dependent: :purge_later for ActiveRecord attachments (#882)
* Use dependent: :purge_later for user profile_image cleanup

This is a simpler alternative to PR #787's callback-based approach.
Instead of adding a custom callback and method, we use Rails' built-in
`dependent: :purge_later` option which is already used by FamilyExport
and other models in the codebase.

This single-line change ensures orphaned ActiveStorage attachments are
automatically purged when a user is destroyed, without the overhead of
querying all attachments manually.

https://claude.ai/code/session_01Np3deHEAJqCBfz3aY7c3Tk

* Add dependent: :purge_later to all ActiveStorage attachments

Extends the attachment cleanup from PR #787 to cover ALL models with
ActiveStorage attachments, not just User.profile_image.

Models updated:
- PdfImport.pdf_file - prevents orphaned PDF files from imports
- Account.logo - prevents orphaned account logos
- PlaidItem.logo, SimplefinItem.logo, SnaptradeItem.logo,
  CoinstatsItem.logo, CoinbaseItem.logo, LunchflowItem.logo,
  MercuryItem.logo, EnableBankingItem.logo - prevents orphaned
  provider logos

This ensures that when a family is deleted (cascade from last user
purge), all associated storage files are properly cleaned up via
Rails' built-in dependent: :purge_later mechanism.

https://claude.ai/code/session_01Np3deHEAJqCBfz3aY7c3Tk

* Make sure `Provider` generator adds it

* Fix tests

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-03 15:45:25 +01:00
luckyPipewrench 4909532a08 fix: address PR review feedback for generator templates
- Fix invalid Tailwind class bg-gray -> bg-gray-400 in panel template
- Fix count_holdings to only count linked accounts for consistency
2026-01-23 12:50:34 -05:00
luckyPipewrench 9caee4ec36 Remove Testprovider support and related references for streamlined provider handling. 2026-01-23 11:52:20 -05:00
luckyPipewrench b8ffe06974 Add banking support to family generator, including transactions processor, SDK updates, and related templates. Streamline logic for handling provider types. 2026-01-23 11:31:57 -05:00
luckyPipewrench 3382c07194 Refactor family generator templates for streamlined labels, error handling, and account setup logic. 2026-01-22 22:19:38 -05:00
luckyPipewrench 17693f0418 Refactor family generator to centralize concern creation, improve SDK support, and add tests, views, jobs, and sync logic. 2026-01-22 22:07:22 -05:00
soky srmandJuan José Mata 179552657c Mercury integration (#723)
* Initial mercury impl

* FIX both mercury and generator class

* Finish mercury integration and provider generator

* Fix schema

* Fix linter and tags

* Update routes.rb

* Avoid schema drift

---------

Signed-off-by: soky srm <sokysrm@gmail.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-01-22 20:37:07 +01:00
soky srmandJuan José Mata 5d6c1bc280 Provider generator (#364)
* Move provider config to family

* Update schema.rb

* Add provier generator

* Add table creation also

* FIX generator namespace

* Add support for global providers also

* Remove over-engineered stuff

* FIX parser

* FIX linter

* Some generator fixes

* Update generator with fixes

* Update item_model.rb.tt

* Add missing linkable concern

* Add missing routes

* Update adapter.rb.tt

* Update connectable_concern.rb.tt

* Update unlinking_concern.rb.tt

* Update family_generator.rb

* Update family_generator.rb

* Delete .claude/settings.local.json

Signed-off-by: soky srm <sokysrm@gmail.com>

* Move docs under API related folder

* Rename Rails generator doc

* Light edits to LLM generated doc

* Small Lunch Flow config panel regressions.

---------

Signed-off-by: soky srm <sokysrm@gmail.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2025-12-08 22:52:30 +01:00