Skip to content

feat: add accounting dimensions to create journal entry#365

Merged
barredterra merged 16 commits into
alyf-de:version-15-hotfixfrom
0xD0M1M0:accounting-dimensions
Jun 12, 2026
Merged

feat: add accounting dimensions to create journal entry#365
barredterra merged 16 commits into
alyf-de:version-15-hotfixfrom
0xD0M1M0:accounting-dimensions

Conversation

@0xD0M1M0

@0xD0M1M0 0xD0M1M0 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Solves #362

Ref: LKP-76

@greptile-apps

greptile-apps Bot commented May 15, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe to merge — the dimension filtering is correctly allowlisted against live DB metadata, the caching logic is sound, and the awaited frappe.db.get_value response is accessed via the correct .message accessor.

The core backend helper _get_valid_accounting_dimensions is well-isolated and tested with mocks; the JE integration test verifies the end-to-end path including both account rows. The reload_transactions refactor correctly preserves cached dimension state across sort changes. No data-corruption or security concerns were found.

The test file is missing an integration test for the payment entry path — the new accounting_dimensions parameter in create_payment_entry_bts is only covered by the shared unit test of the helper function, not by a full PE creation flow.

Sequence Diagram

sequenceDiagram
    participant UI as Create Tab (JS)
    participant PM as PanelManager
    participant ERPNext as ERPNext API
    participant BankingPy as banking.bank_reconciliation_tool_beta

    PM->>ERPNext: "get_dimensions(with_cost_center_and_project=false)"
    ERPNext-->>PM: "[dimension_filters[], default_dimensions_map{}]"
    PM->>PM: cache accounting_dimensions + defaults
    PM->>ERPNext: frappe.db.get_value(Company, cost_center)
    ERPNext-->>PM: "{message: {cost_center: "Main - TC"}}"
    PM->>PM: store company_default_cost_center

    Note over UI: User opens Create tab
    PM->>UI: pass accounting_dimensions, defaults, company_default_cost_center
    UI->>UI: render Link fields for each dimension
    UI->>UI: apply dimension defaults

    Note over UI: User fills form and submits
    UI->>UI: get_selected_accounting_dimensions(values, fieldnames)
    UI->>UI: serialize_accounting_dimensions to JSON string
    UI->>BankingPy: "create_journal_entry_bts(..., accounting_dimensions="{...}")"
    BankingPy->>BankingPy: _get_valid_accounting_dimensions(json)
    BankingPy->>ERPNext: "get_accounting_dimensions(as_list=True)"
    ERPNext-->>BankingPy: ["branch", ...]
    BankingPy->>BankingPy: filter parsed dims to allowed fieldnames
    BankingPy->>BankingPy: apply dims to all account_rows
    BankingPy-->>UI: Journal Entry document
Loading

Reviews (10): Last reviewed commit: "refactor: _get_valid_accounting_dimensio..." | Re-trigger Greptile

Comment thread banking/public/js/bank_reconciliation_beta/actions_panel/create_tab.js Outdated

@barredterra barredterra left a comment

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.

Tested, functionality works as expected. Some comments on consistency, style and performance.

  • I think the "standard" Accounting Dimensions Project and Cost Center should also be visible for "Create Journal Entry" (they are already for "Create Payment Entry"). Then we can always show the collapsible section (maybe add it in Create Payment Entry" as well, for consistency?)
  • The frontend calls get_dimensions for each Bank Transaction. Calling it once when the reco tool is loaded should be enough.
  • I think adding short docstrings to the methods would help, at least where the content is long and not obvious from the name.
  • I don't mind merging allow_on_submit with this PR, but if it had been a separate PR it would have been merged already. ;)

Comment thread banking/public/js/bank_reconciliation_beta/actions_panel/create_tab.js Outdated
Comment thread banking/public/js/bank_reconciliation_beta/actions_panel/create_tab.js Outdated

@barredterra barredterra left a comment

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.

Non-blocking design thought: should we hard-wire project and cost_center in the create form and reconciliation flow instead of loading them dynamically via accounting dimension metadata?

They are standard ERPNext fields and are already special-cased in the backend allowlist, while Payment Entry also has explicit project / cost_center parameters. A clearer split might be:

  • render/pass project and cost_center explicitly
  • load dynamic accounting dimensions only for actual custom dimensions
  • keep the backend allowlist as standard fields plus get_accounting_dimensions(...)
  • keep applying dimensions to non-bank Journal Entry account rows, and to Payment Entry header fields

That would make the standard fields explicit and reduce coupling to the exact shape returned by get_dimensions(with_cost_center_and_project=True).

@0xD0M1M0 0xD0M1M0 requested a review from barredterra May 29, 2026 19:34
@barredterra

Copy link
Copy Markdown
Member

Let's wait for #379, then rebase on that.

Comment thread banking/public/js/bank_reconciliation_beta/panel_manager.js Outdated
Comment thread banking/public/js/bank_reconciliation_beta/actions_panel/create_tab.js Outdated
Comment thread banking/public/js/bank_reconciliation_beta/panel_manager.js
@barredterra barredterra assigned barredterra and unassigned 0xD0M1M0 Jun 9, 2026
@barredterra barredterra self-requested a review June 9, 2026 02:26
@barredterra

Copy link
Copy Markdown
Member

@greptileai

@barredterra barredterra merged commit 007417b into alyf-de:version-15-hotfix Jun 12, 2026
4 checks passed
@barredterra

Copy link
Copy Markdown
Member

Delay port to v16 until #368 is merged

@0xD0M1M0 0xD0M1M0 deleted the accounting-dimensions branch June 12, 2026 18:20
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