From b25ce8f3cf9bd49f4b2ba7684a5fe46d35402d0d Mon Sep 17 00:00:00 2001 From: Sanket Shah <113279972+Sanket322@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:11:53 +0530 Subject: [PATCH] fix: Take up Company type from GSTIN portal automatically (#2770) Co-authored-by: Sanket322 --- india_compliance/public/js/quick_entry.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/india_compliance/public/js/quick_entry.js b/india_compliance/public/js/quick_entry.js index 3b203157f..ab54f3629 100644 --- a/india_compliance/public/js/quick_entry.js +++ b/india_compliance/public/js/quick_entry.js @@ -4,6 +4,10 @@ class GSTQuickEntryForm extends frappe.ui.form.QuickEntryForm { this.skip_redirect_on_error = true; this.api_enabled = india_compliance.is_api_enabled() && gst_settings.autofill_party_info; + this.gstin_to_party_type_map = { + F: "Partnership", + C: "Company", + }; } async setup() { @@ -92,6 +96,14 @@ class GSTQuickEntryForm extends frappe.ui.form.QuickEntryForm { ignore_validation: true, onchange: () => { const d = this.dialog; + + if (["Customer", "Supplier"].includes(this.doctype)) { + d.set_value( + `${this.doctype.toLowerCase()}_type`, + this.gstin_to_party_type_map[d.doc._gstin[5]] || "Individual" + ); + } + if (this.api_enabled && !gst_settings.sandbox_mode) return autofill_fields(d);