Track merchant subfields (officers, bank accounts) in activity diffs
Repo: · Issue: #1069 Status: Open · Priority: P2 Assignee: Sparsh
Description
Summary
Merchant subfields (officers, bank accounts) are not included in the activity diff when a merchant is updated. Only top-level merchant columns are compared and stored in activity.meta_data["changes"]. As a result:
- Officers: Adding, removing, or editing officers does not appear in the activity feed (no diff entries, and if no other merchant fields change, no activity is created at all).
- Bank accounts: Same for mutable bank accounts (add/update/remove).
- MCA: Updates to MCA data in the same
update_merchantflow are also not reflected in the diff (only merchant table columns are considered).
Current behavior
In app/api/merchants_helpers.py, update_merchant():
- Splits the payload via
MerchantUpdate.to_update_dicts()into:merchant_updates(flat dict of merchant columns)officers_dicts,bas_dicts(lists of officer / bank account dicts)mca_data
- Updates the DB for merchant (1), then officers (2), then bank accounts (3), then MCA (4).
- Activity diff is computed only from
merchant_updates(lines 817–838):
if existing_merchant and merchant_updates:
changes = []
for key, new_value in merchant_updates.items():
if not hasattr(existing_merchant, key):
continue
old_value = getattr(existing_merchant, key)
if old_value != new_value:
changes.append({"field": key, "from": ..., "to": ...})So:
- Only keys in
merchant_updates(i.e.DbMerchantcolumns) are compared; officers and bank accounts are never added tochanges. - When the only updates are officers and/or bank accounts,
merchant_updatesmay be empty, so the conditionexisting_merchant and merchant_updatesis false and no activity is created.
Relevant code:
- Diff and activity:
app/api/merchants_helpers.py~817–869 (diff calculation andtrack_activity_on_changewithmeta_data={"changes": changes}). - Officers update: same file ~612–691 (`ex
Implementation Notes
Dash adds notes here while working
Related
Link to people, meetings, dependent tickets