Skip to content

Commit

Permalink
fix: GSTR3B Enhancements for better ux (#2590)
Browse files Browse the repository at this point in the history
* 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
Ninad1306 authored and mergify[bot] committed Sep 10, 2024
1 parent 9f1bb2a commit fa76452
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 151 deletions.
128 changes: 72 additions & 56 deletions india_compliance/gst_india/doctype/gstr_3b_report/gstr_3b_report.js
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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
"engine": "InnoDB",
"field_order": [
"company",
"company_address",
"year",
"month",
"column_break_jhew",
"enqueue_report",
"column_break_pvct",
"company_gstin",
"generation_status",
"column_break_ddqq",
"year",
"column_break_vtyi",
"month_or_quarter",
"section_break_yqh7",
"gstr3b_form",
"json_output",
"missing_field_invoices"
],
Expand All @@ -24,26 +27,15 @@
"label": "Company",
"options": "Company"
},
{
"fieldname": "company_address",
"fieldtype": "Link",
"label": "Company Address",
"options": "Address"
},
{
"fieldname": "year",
"fieldtype": "Select",
"label": "Year"
},
{
"fieldname": "month",
"fieldtype": "Select",
"label": "Month",
"options": "January\nFebruary\nMarch\nApril\nMay\nJune\nJuly\nAugust\nSeptember\nOctober\nNovember\nDecember"
},
{
"fieldname": "json_output",
"fieldtype": "Code",
"hidden": 1,
"label": "JSON Output"
},
{
Expand All @@ -52,10 +44,6 @@
"label": "Invoices with no Place Of Supply",
"read_only": 1
},
{
"fieldname": "column_break_jhew",
"fieldtype": "Column Break"
},
{
"default": "0",
"description": "Generate report in the background.",
Expand All @@ -73,12 +61,45 @@
{
"fieldname": "generation_status",
"fieldtype": "Data",
"hidden": 1,
"label": "Status",
"read_only": 1
},
{
"fieldname": "company_gstin",
"fieldtype": "Autocomplete",
"label": "Company GSTIN"
},
{
"fieldname": "column_break_ddqq",
"fieldtype": "Column Break"
},
{
"fieldname": "column_break_vtyi",
"fieldtype": "Column Break"
},
{
"fieldname": "column_break_pvct",
"fieldtype": "Column Break"
},
{
"fieldname": "gstr3b_form",
"fieldtype": "HTML",
"label": "GSTR-3B Form"
},
{
"fieldname": "month_or_quarter",
"fieldtype": "Select",
"label": "Month or Quarter",
"options": "Apr - Jun\nJul - Sep\nOct - Dec\nJan - Mar\nJanuary\nFebruary\nMarch\nApril\nMay\nJune\nJuly\nAugust\nSeptember\nOctober\nNovember\nDecember"
}
],
"links": [],
<<<<<<< HEAD
"modified": "2024-01-02 14:09:31.230340",
=======
"modified": "2024-09-09 08:37:11.799168",
>>>>>>> bd4eba3b (fix: GSTR3B Enhancements for better ux (#2590))
"modified_by": "Administrator",
"module": "GST India",
"name": "GSTR 3B Report",
Expand Down
Loading

0 comments on commit fa76452

Please sign in to comment.