Skip to content

Add priority reordering function for BRR#367

Open
0xD0M1M0 wants to merge 3 commits into
alyf-de:version-15-hotfixfrom
0xD0M1M0:brr-reordering
Open

Add priority reordering function for BRR#367
0xD0M1M0 wants to merge 3 commits into
alyf-de:version-15-hotfixfrom
0xD0M1M0:brr-reordering

Conversation

@0xD0M1M0
Copy link
Copy Markdown
Contributor

@0xD0M1M0 0xD0M1M0 commented May 17, 2026

  • Enhanced the bank reconciliation rule list view to include a "Reorder by Priority" button.
  • Implemented backend methods to retrieve bank accounts with rules and reorder rules based on user-defined priorities.
  • Updated the bank reconciliation rule model to support priority management.
  • Added tests for the new reordering feature to ensure correct functionality.

Depends on #365, as it introduced the allow_on_submit of the priority.

…nality

- Enhanced the bank reconciliation rule list view to include a "Reorder by Priority" button.
- Implemented backend methods to retrieve bank accounts with rules and reorder rules based on user-defined priorities.
- Updated the bank reconciliation rule model to support priority management.
- Added tests for the new reordering feature to ensure correct functionality.
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR adds a drag-and-drop "Reorder by Priority" dialog to the Bank Reconciliation Rule list view, backed by three new whitelisted Python endpoints and a two-pass db.set_value strategy that avoids duplicate-priority constraint violations when renumbering submitted documents.

  • Backend: Three new endpoints with solid input validation, deduplication checks, and per-record permission guards. The two-pass stagger correctly handles the allow_on_submit constraint on submitted rules.
  • Frontend: A Sortable-backed dialog wires the endpoints together. The rule-load callback handles errors correctly, but the initial account-fetch callback lacks an r.exc guard and duplicate event listeners cause double loads on autocomplete picks.
  • Tests: Two focused test cases cover draft and submitted reorder paths, verifying priorities and docstatus after the operation.

Confidence Score: 5/5

Safe to merge; the core reorder logic is correct and well-tested, with only minor UX gaps in the JS error-handling paths.

The backend validation, permission checks, and two-pass write strategy are solid. Both test cases cover the happy path for draft and submitted rules. The JS issues affect UX feedback only and cannot corrupt data or leave records in a bad state.

banking/klarna_kosma_integration/doctype/bank_reconciliation_rule/bank_reconciliation_rule_list.js — the outer callback and event-listener binding are worth a second look before shipping.

Important Files Changed

Filename Overview
banking/klarna_kosma_integration/doctype/bank_reconciliation_rule/bank_reconciliation_rule_list.js Adds a Reorder by Priority dialog backed by Sortable. Error handling in the load-rules callback is correct, but the outer get_bank_accounts call lacks an r.exc guard and duplicate change/awesomplete listeners cause double loads.
banking/klarna_kosma_integration/doctype/bank_reconciliation_rule/bank_reconciliation_rule.py Adds three whitelisted endpoints for listing accounts, fetching rules, and reordering by priority. Two-pass db.set_value stagger correctly avoids duplicate-priority constraint violations on submitted docs.
banking/klarna_kosma_integration/doctype/bank_reconciliation_rule/test_bank_reconciliation_rule.py Adds two test cases covering draft and submitted reordering, verifying priorities and docstatus are correctly preserved after reorder.
banking/klarna_kosma_integration/doctype/bank_reconciliation_rule/bank_reconciliation_rule.json Adds allow_on_submit=1 to the priority field, consistent with the PR goal of allowing priority updates on submitted documents.

Sequence Diagram

sequenceDiagram
    participant U as User
    participant JS as bank_reconciliation_rule_list.js
    participant PY as bank_reconciliation_rule.py
    participant DB as Database

    U->>JS: Click Reorder by Priority
    JS->>PY: get_bank_accounts_with_rules()
    PY->>DB: "get_all BRR docstatus!=2 group_by bank_account"
    DB-->>PY: account list
    PY-->>JS: r.message accounts
    JS->>U: Show dialog pre-filtered Bank Account link

    U->>JS: Select bank account
    JS->>PY: get_rules_for_reorder(bank_account)
    PY->>DB: "get_all BRR bank_account=X order priority desc"
    DB-->>PY: rules
    PY-->>JS: r.message rules
    JS->>U: Render sortable rule list

    U->>JS: Drag to reorder then click Save order
    JS->>PY: reorder_bank_reconciliation_rule_priorities(bank_account, ordered_names)
    PY->>PY: Validate completeness and per-record permissions
    PY->>DB: Pass 1 set priority to stagger values
    PY->>DB: Pass 2 set priority to final 10 20 30 values
    PY-->>JS: success
    JS->>U: Hide dialog and refresh list
Loading

Fix All in Cursor

Reviews (3): Last reviewed commit: "fix: avoid save() on priority reorder" | Re-trigger Greptile

@barredterra
Copy link
Copy Markdown
Member

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants