Skip to content

Demo data can put the freight account under the wrong expense group #261

Open

Description

@Rl0007

Since #221 the demo data uses the company's own currency and chart of accounts. Three gaps are left.

  1. If the chart of accounts has no Stock Expenses group, the demo creates Freight and Forwarding Charges under whichever expense group comes last in the account tree. The Cash on Delivery Charges account goes under the same group. ERPNext's standard chart keeps freight under Indirect Expenses.
  2. Clicking Install demo data looks up the USD exchange rate online in the click itself. When there is no Currency Exchange record and the lookup fails, the user sees two error messages, ERPNext's and ours, and an Error Log is written.
  3. No test covers the freight fallback or a full install leaving the company's currency and accounts unchanged.

Expected

The freight account goes next to an existing chargeable account, otherwise under the top-level Expense group, otherwise the install stops with one clear message. A missing rate shows one message.

Technical details
  • commera/install_summer_demo.py, get_freight_account: the fallback uses order_by="lft desc", which takes the last Expense group, not the most specific one. Prefer the parent of an existing account_type = "Chargeable" leaf, then the root Expense group, then frappe.throw. Filter the existing-account lookup on is_group: 0. On a child company the insert throws "Please add the account to root level Company".
  • The freight and COD account inserts are almost the same code. One helper should create both.
  • commera_settings.py: the button calls get_exchange_rate, which makes an HTTP request with no timeout (erpnext/setup/utils.py) and repeats it in the job. Check only that a company exists in the request, and leave the rate lookup to the job.
  • Tests use the Standard chart, which already has the account, so the fallback branch never runs. Add a company without Stock Expenses.
  • Checked on a Russian company (RUB, Standard chart): currency, accounts and price lists stay RUB, and the fallback picked Indirect Expenses only because it sorts last.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions