Skip to content

Commit

Permalink
fix: Take up Company type from GSTIN portal automatically (#2770)
Browse files Browse the repository at this point in the history
Co-authored-by: Sanket322 <shahsanket322003.com>
  • Loading branch information
Sanket322 authored Nov 28, 2024
1 parent 1e8e6be commit b25ce8f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions india_compliance/public/js/quick_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b25ce8f

Please sign in to comment.