From 7a9c25ba35c2e5d2fa98d3699bbe9c5a09f32eeb Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Wed, 29 Apr 2026 10:59:15 +0000 Subject: [PATCH] Auto-pick Kassa for micro entities, Hesablama otherwise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fetch_company_profile now also returns the lower-cased criteriaOfBusinessEntity ("micro" / "small" / "medium" / "big" / etc.) so the JS layer can react before the user reaches the company step. Heuristic in fetch_company_profile callback: criteria === "micro" → Kassa metodu any other criteria → Hesablama metodu unknown / fetch error → static "Hesablama metodu" default stands The auto-pick is one-shot and respectful: once the user manually changes the select on the company step we set accounting_method_user_edited = true, and subsequent renders / re-fetches no longer overwrite the choice. The hint line under the field explains where the default came from when the heuristic ran. --- jey_wizard/__init__.py | 2 +- jey_wizard/etaxes.py | 9 ++++++- jey_wizard/public/js/jey_setup.js | 39 ++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/jey_wizard/__init__.py b/jey_wizard/__init__.py index fb69db9..f3b4574 100644 --- a/jey_wizard/__init__.py +++ b/jey_wizard/__init__.py @@ -1 +1 @@ -__version__ = "0.1.14" +__version__ = "0.1.15" diff --git a/jey_wizard/etaxes.py b/jey_wizard/etaxes.py index 5de7f14..ec6da82 100644 --- a/jey_wizard/etaxes.py +++ b/jey_wizard/etaxes.py @@ -200,16 +200,23 @@ def fetch_company_profile(): cache.save() frappe.db.commit() + # Lower-case the raw criteria once so the JS layer can do a simple + # equality check (criteriaOfBusinessEntity arrives capitalised in some + # tenants — "Micro" vs "micro"). + criteria_raw = profile.get("criteriaOfBusinessEntity") if isinstance(profile, dict) else None + criteria = str(criteria_raw).strip().lower() if criteria_raw else "" + frappe.log_error( json.dumps({ "has_profile": bool(profile), "profile_keys": sorted(list(profile.keys())) if isinstance(profile, dict) else None, "resolved": resolved, + "criteria": criteria, }, ensure_ascii=False, indent=2), "Jey Wizard trace: fetch_company_profile done", ) - return {"ok": True, "resolved": resolved} + return {"ok": True, "resolved": resolved, "criteria": criteria} @frappe.whitelist() diff --git a/jey_wizard/public/js/jey_setup.js b/jey_wizard/public/js/jey_setup.js index 7dac559..fc3db77 100644 --- a/jey_wizard/public/js/jey_setup.js +++ b/jey_wizard/public/js/jey_setup.js @@ -10,7 +10,7 @@ frappe.provide("jey_wizard"); // Bump this string in every commit that changes wizard code. Displayed in the badge so // we can tell at a glance which version is actually running on a given machine. Kept in // sync with __version__ in jey_wizard/__init__.py. -const JEY_WIZARD_VERSION = "0.1.14"; +const JEY_WIZARD_VERSION = "0.1.15"; // Wipe Frappe + ERPNext default slides so their `before_load`/`after_load` listeners // don't try to mutate a wizard that isn't slide-based anymore. @@ -54,6 +54,13 @@ frappe.setup.SetupWizard = class JeySetupWizard { fy_end_date: `${year}-12-31`, valuation_method: "FIFO", accounting_method: "Hesablama metodu", + // Auto-pick Kassa for micro entities. Reset to true only when + // fetch_company_profile returns a known criteria — without that + // signal we keep the static default. Toggled to true the moment + // the user touches the select so the criteria heuristic stops + // overwriting their choice. + accounting_method_user_edited: false, + business_criteria: "", // Admin user (fresh user step — Administrator stays untouched) user_full_name: "", user_email: "", @@ -432,7 +439,7 @@ frappe.setup.SetupWizard = class JeySetupWizard { -