Skip to content

Conversation

@ljain112
Copy link
Member

@ljain112 ljain112 commented Sep 24, 2025

Automatically set the session default company on setup.

closes: #3389

Summary by CodeRabbit

  • Bug Fixes

    • Purchase Reconciliation Tool now auto-fills your default Company immediately on open to avoid a blank Company.
    • GST Invoice Management System now ensures a default Company is set during setup to stabilize company-dependent fields.
  • Changes

    • GSTR-1 now sets the default Company earlier and triggers company-related logic immediately.
    • Automatic remote GSTIN lookup/auto-fill has been removed, so GSTIN may no longer populate automatically.

@coderabbitai
Copy link

coderabbitai bot commented Sep 24, 2025

Walkthrough

Assign user session default Company (frappe.defaults.get_user_default("Company")) into frm.doc.company earlier during form setup for multiple GST-related tools, and refactor GSTR-1 initialization to await bundle loading and remove the helper set_default_company_gstin function.

Changes

Cohort / File(s) Summary
Purchase Reconciliation Tool init
india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js
On setup: unconditionally assign frm.doc.company from frappe.defaults.get_user_default("Company") before calling frm.trigger("company") (previously only set when falsy).
GST Invoice Management System init
india_compliance/gst_india/doctype/gst_invoice_management_system/gst_invoice_management_system.js
On setup: assign frm.doc.company from frappe.defaults.get_user_default("Company") before invoking company-related logic to ensure company is present earlier.
GSTR-1 init & defaults refactor
india_compliance/gst_india/doctype/gstr_1/gstr_1.js
Initialization now awaits bundle load before constructing GSTR1 (replacing .then() flow). Default company setup changed to directly set frm.doc.company from user defaults and frm.trigger("company"). Removed exported async function set_default_company_gstin(frm) (logic deleted). Minor whitespace cleanup.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Form as Any GST Form (frm)
  participant Defaults as frappe.defaults

  rect rgba(230,245,255,0.6)
  note over Form: Setup / onload (company default)
  User->>Form: Open form
  Form->>Defaults: get_user_default("Company")
  Defaults-->>Form: default_company
  Form->>Form: set frm.doc.company = default_company
  Form->>Form: trigger "company"
  Form-->>User: ready
  end
Loading
sequenceDiagram
  autonumber
  actor User
  participant Form as GSTR-1 (frm)
  participant Loader as bundle loader
  participant GSTR as GSTR1 instance

  rect rgba(245,245,230,0.6)
  note over Form: Previous flow (simplified)
  User->>Form: Open GSTR-1
  Form->>Loader: load bundle (returns Promise)
  Loader-->>Form: .then(callback)
  Form->>GSTR: instantiate GSTR1 inside callback
  end

  rect rgba(230,245,245,0.6)
  note over Form: New flow (simplified)
  User->>Form: Open GSTR-1
  Form->>Loader: await load bundle
  Loader-->>Form: bundle loaded
  Form->>GSTR: instantiate GSTR1 (after await)
  Form->>Defaults: get_user_default("Company")
  Defaults-->>Form: default_company
  Form->>Form: set frm.doc.company = default_company
  Form->>Form: trigger "company"
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops in, nose to the key,
I set the Company where it should be.
Await the bundle, then gently I start,
A tiny fix from my hopping heart. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning In addition to the Purchase Reconciliation tool, this PR also modifies gst_invoice_management_system.js and gstr_1.js to set the default company on load, which is outside the scope of issue #3389 that only targeted the Purchase Reconciliation tool. Please limit the default‐company onload logic to the Purchase Reconciliation tool or split the unrelated gst_invoice_management_system and gstr_1 updates into a separate PR with its own linked issue.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “fix: set default company value on onload” succinctly and accurately describes the primary change of applying the session default company during the onload/setup phase, making it clear to reviewers what the PR addresses.
Linked Issues Check ✅ Passed The change in purchase_reconciliation_tool.js now unconditionally assigns the session default company on setup and triggers the company logic, directly fulfilling the requirement in issue #3389 to use the session default company when loading the Purchase Reconciliation tool.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d6ff3f and 8356aad.

📒 Files selected for processing (1)
  • india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js (3)
india_compliance/gst_india/doctype/gstr_1/gstr_1.js (2)
  • frm (3125-3125)
  • frm (3188-3189)
india_compliance/public/js/utils.js (4)
  • frappe (90-93)
  • frappe (99-104)
  • frappe (119-122)
  • frappe (143-146)
india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js (1)
  • frappe (75-78)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Summary

@ljain112 ljain112 force-pushed the fix-pur-reco-company branch from 8356aad to a933e29 Compare September 24, 2025 11:22
@ljain112 ljain112 force-pushed the fix-pur-reco-company branch from a933e29 to 38e83b6 Compare September 24, 2025 11:33
@ljain112 ljain112 changed the title fix: set default company value in purchase reconciliation tool form fix: set default company value on onload Sep 26, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38e83b6 and 8a4506a.

📒 Files selected for processing (3)
  • india_compliance/gst_india/doctype/gst_invoice_management_system/gst_invoice_management_system.js (1 hunks)
  • india_compliance/gst_india/doctype/gstr_1/gstr_1.js (1 hunks)
  • india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • india_compliance/gst_india/doctype/purchase_reconciliation_tool/purchase_reconciliation_tool.js
🧰 Additional context used
🧬 Code graph analysis (1)
india_compliance/gst_india/doctype/gstr_1/gstr_1.js (3)
india_compliance/public/js/utils.js (4)
  • frappe (90-93)
  • frappe (99-104)
  • frappe (119-122)
  • frappe (143-146)
india_compliance/public/js/components/set_gstin_options.js (1)
  • frappe (13-16)
india_compliance/gst_india/doctype/gstr_1/gstr_1.py (1)
  • GSTR1 (31-184)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Summary

@vorasmit vorasmit merged commit 6eb6f8d into resilient-tech:develop Sep 30, 2025
10 checks passed
@vorasmit vorasmit deleted the fix-pur-reco-company branch September 30, 2025 04:31
ljain112 added a commit that referenced this pull request Sep 30, 2025
…tfix/pr-3693

fix: set default company value on onload (backport #3693)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onload set session default company in Purchase Reconciliation tool

2 participants