Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retain user Selected Year after save in GSTR-3B Report #2982

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 58 additions & 53 deletions india_compliance/gst_india/doctype/gstr_3b_report/gstr_3b_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,62 @@
// 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)
)
);

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;

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: [],
});
});
},
});
});
}
onload: function (frm) {
set_options_for_year_gstr3b(frm);

let current_year = new Date().getFullYear();
let options = [current_year, current_year - 1, current_year - 2];
frm.set_df_property("year", "options", options);
frm.set_value("year", options[0]);
if (frm.doc.company)
india_compliance.set_gstin_options(frm).then(options => {
frm.set_value("company_gstin", options[0]);
});

frappe.realtime.on("gstr3b_report_generation", function () {
frm.reload_doc();
});

append_form(frm);
},

setup: async function (frm) {
await frappe.require(
"assets/india_compliance/js/components/set_gstin_options.js"
);
refresh: function (frm) {
if (frm.is_new()) return;

if (!frm.doc.company) return;
const options = await india_compliance.set_gstin_options(frm);
frm.set_value("company_gstin", options[0]);
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) {
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: [],
});
});
},
});
});

append_form(frm);
},

company: async function (frm) {
Expand All @@ -86,3 +81,13 @@ function append_form(frm) {
})
).appendTo(frm.fields_dict.gstr3b_form.wrapper);
}

function set_options_for_year_gstr3b(frm) {
let current_year = new Date().getFullYear();
let options = [current_year, current_year - 1, current_year - 2];

frm.set_df_property("year", "options", options);

if (!frm.is_new()) return;
frm.set_value("year", options[0]);
}
4 changes: 2 additions & 2 deletions india_compliance/public/js/components/set_gstin_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
frappe.provide("india_compliance");

india_compliance.set_gstin_options = async function (frm, show_all_option=false) {
india_compliance.set_gstin_options = async function (frm, show_all_option = false) {
const { query, params } = india_compliance.get_gstin_query(frm.doc.company);
const { message } = await frappe.call({
method: query,
Expand All @@ -13,4 +13,4 @@ india_compliance.set_gstin_options = async function (frm, show_all_option=false)
const gstin_field = frm.get_field("company_gstin");
gstin_field.set_data(message);
return message;
}
};
3 changes: 1 addition & 2 deletions india_compliance/public/js/gstr1.bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "./components/filter_group";
import "./components/data_table_manager";
import "./components/set_gstin_options";
import "./components/view_group";
import "./components/view_group";
1 change: 1 addition & 0 deletions india_compliance/public/js/india_compliance.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ import "./custom_number_card";
import "./taxes_controller";
import "./help_links";
import "./reconciliation_components/tabs";
import "./components/set_gstin_options";
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "./components/data_table_manager";
import "./components/filter_group";
import "./components/number_card";
import "./components/set_gstin_options";
import "./reconciliation_components/actions";
Loading