-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: GSTR3B Enhancements for better ux (#2590)
* fix: use company_gstin instead of company_address * fix: returns can be quarterly or monthly * fix: show gstr3b form in doctype only * fix: implement functionality considering its references * fix: update test case * fix: update options * chore: consistent formatting with `spaces` * fix: fields repositioned for gstr-3b report * fix: clear extra column at start * fix: autoupdate gstin * chore: formatting * fix: set query on setup * fix: patch existing data with company_gstin and month_or_quarter * fix: moving function to utilities * fix: month or quarter for gstr3b_details * fix: updated patches * fix: migrate 3b fields in post install --------- Co-authored-by: Smit Vora <smitvora203@gmail.com> (cherry picked from commit bd4eba3) # Conflicts: # india_compliance/gst_india/doctype/gstr_3b_report/gstr_3b_report.json
- Loading branch information
1 parent
9f1bb2a
commit fa76452
Showing
10 changed files
with
297 additions
and
151 deletions.
There are no files selected for viewing
128 changes: 72 additions & 56 deletions
128
india_compliance/gst_india/doctype/gstr_3b_report/gstr_3b_report.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,84 @@ | ||
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.ui.form.on('GSTR 3B Report', { | ||
refresh : function(frm) { | ||
frm.doc.__unsaved = 1; | ||
if(!frm.is_new()) { | ||
frm.set_intro(__("Please save the report again to rebuild or update")); | ||
frm.add_custom_button(__('Download JSON'), function() { | ||
var w = window.open( | ||
frappe.urllib.get_full_url( | ||
"/api/method/india_compliance.gst_india.doctype.gstr_3b_report.gstr_3b_report.make_json?" | ||
+"name="+encodeURIComponent(frm.doc.name))); | ||
frappe.ui.form.on("GSTR 3B Report", { | ||
refresh: function (frm) { | ||
frm.doc.__unsaved = 1; | ||
if (!frm.is_new()) { | ||
frm.set_intro(__("Please save the report again to rebuild or update")); | ||
frm.add_custom_button(__("Download JSON"), function () { | ||
var w = window.open( | ||
frappe.urllib.get_full_url( | ||
"/api/method/india_compliance.gst_india.doctype.gstr_3b_report.gstr_3b_report.make_json?" + | ||
"name=" + | ||
encodeURIComponent(frm.doc.name) | ||
) | ||
); | ||
|
||
if(!w) { | ||
frappe.msgprint(__("Please enable pop-ups")); return; | ||
} | ||
}); | ||
frm.add_custom_button(__('View Form'), function() { | ||
frappe.call({ | ||
"method" : "india_compliance.gst_india.doctype.gstr_3b_report.gstr_3b_report.view_report", | ||
"args" : { | ||
name : frm.doc.name, | ||
}, | ||
"callback" : function(r){ | ||
if (!w) { | ||
frappe.msgprint(__("Please enable pop-ups")); | ||
return; | ||
} | ||
}); | ||
frm.add_custom_button(__("View Form"), function () { | ||
frappe.call({ | ||
method: "india_compliance.gst_india.doctype.gstr_3b_report.gstr_3b_report.view_report", | ||
args: { | ||
name: frm.doc.name, | ||
}, | ||
callback: function (r) { | ||
let data = r.message; | ||
|
||
let data = r.message; | ||
frappe.ui.get_print_settings(false, print_settings => { | ||
frappe.render_grid({ | ||
template: "gstr_3b_report", | ||
title: __(this.doctype), | ||
print_settings: print_settings, | ||
data: data, | ||
columns: [], | ||
}); | ||
}); | ||
}, | ||
}); | ||
}); | ||
} | ||
|
||
frappe.ui.get_print_settings(false, print_settings => { | ||
let current_year = new Date().getFullYear(); | ||
let options = [current_year, current_year - 1, current_year - 2]; | ||
frm.set_df_property("year", "options", options); | ||
|
||
frappe.render_grid({ | ||
template: 'gstr_3b_report', | ||
title: __(this.doctype), | ||
print_settings: print_settings, | ||
data: data, | ||
columns:[] | ||
}); | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
frappe.realtime.on("gstr3b_report_generation", function () { | ||
frm.reload_doc(); | ||
}); | ||
|
||
let current_year = new Date().getFullYear(); | ||
let options = [current_year, current_year-1, current_year-2]; | ||
frm.set_df_property('year', 'options', options); | ||
append_form(frm); | ||
}, | ||
|
||
frappe.realtime.on("gstr3b_report_generation", function(){ | ||
frm.reload_doc(); | ||
}); | ||
}, | ||
setup: async function (frm) { | ||
await frappe.require( | ||
"assets/india_compliance/js/components/set_gstin_options.js" | ||
); | ||
|
||
setup: function(frm) { | ||
frm.set_query('company_address', function(doc) { | ||
if(!doc.company) { | ||
frappe.throw(__('Please set Company')); | ||
} | ||
if (!frm.doc.company) return; | ||
await india_compliance.set_gstin_options(frm); | ||
}, | ||
|
||
return { | ||
query: 'frappe.contacts.doctype.address.address.address_query', | ||
filters: { | ||
link_doctype: 'Company', | ||
link_name: doc.company | ||
} | ||
}; | ||
}); | ||
}, | ||
company: async function (frm) { | ||
if (!frm.doc.company) { | ||
frm.set_value("company_gstin", ""); | ||
return; | ||
} | ||
|
||
const options = await india_compliance.set_gstin_options(frm); | ||
frm.set_value("company_gstin", options[0]); | ||
}, | ||
}); | ||
|
||
function append_form(frm) { | ||
$(frm.fields_dict.gstr3b_form.wrapper).empty(); | ||
$( | ||
frappe.render_template("gstr_3b_report", { | ||
data: JSON.parse(frm.doc.json_output), | ||
}) | ||
).appendTo(frm.fields_dict.gstr3b_form.wrapper); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.