fix: GSTIN filter for GSTR-1 report
This commit is contained in:
parent
1e9766433a
commit
87b074ac09
@ -17,7 +17,7 @@ frappe.query_reports["GSTR-1"] = {
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Address",
|
"options": "Address",
|
||||||
"get_query": function () {
|
"get_query": function () {
|
||||||
var company = frappe.query_report.get_filter_value('company');
|
let company = frappe.query_report.get_filter_value('company');
|
||||||
if (company) {
|
if (company) {
|
||||||
return {
|
return {
|
||||||
"query": 'frappe.contacts.doctype.address.address.address_query',
|
"query": 'frappe.contacts.doctype.address.address.address_query',
|
||||||
@ -26,6 +26,11 @@ frappe.query_reports["GSTR-1"] = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "company_gstin",
|
||||||
|
"label": __("Company GSTIN"),
|
||||||
|
"fieldtype": "Select"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "from_date",
|
"fieldname": "from_date",
|
||||||
"label": __("From Date"),
|
"label": __("From Date"),
|
||||||
@ -60,10 +65,22 @@ frappe.query_reports["GSTR-1"] = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
onload: function (report) {
|
onload: function (report) {
|
||||||
|
let filters = report.get_values();
|
||||||
|
|
||||||
|
frappe.call({
|
||||||
|
method: 'erpnext.regional.report.gstr_1.gstr_1.get_company_gstins',
|
||||||
|
args: {
|
||||||
|
company: filters.company
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
console.log(r.message);
|
||||||
|
frappe.query_report.page.fields_dict.company_gstin.df.options = r.message;
|
||||||
|
frappe.query_report.page.fields_dict.company_gstin.refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
report.page.add_inner_button(__("Download as JSON"), function () {
|
report.page.add_inner_button(__("Download as JSON"), function () {
|
||||||
var filters = report.get_values();
|
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'erpnext.regional.report.gstr_1.gstr_1.get_json',
|
method: 'erpnext.regional.report.gstr_1.gstr_1.get_json',
|
||||||
args: {
|
args: {
|
||||||
|
|||||||
@ -253,7 +253,8 @@ class Gstr1Report(object):
|
|||||||
for opts in (("company", " and company=%(company)s"),
|
for opts in (("company", " and company=%(company)s"),
|
||||||
("from_date", " and posting_date>=%(from_date)s"),
|
("from_date", " and posting_date>=%(from_date)s"),
|
||||||
("to_date", " and posting_date<=%(to_date)s"),
|
("to_date", " and posting_date<=%(to_date)s"),
|
||||||
("company_address", " and company_address=%(company_address)s")):
|
("company_address", " and company_address=%(company_address)s"),
|
||||||
|
("company_gstin", " and company_gstin=%(company_gstin)s")):
|
||||||
if self.filters.get(opts[0]):
|
if self.filters.get(opts[0]):
|
||||||
conditions += opts[1]
|
conditions += opts[1]
|
||||||
|
|
||||||
@ -1192,3 +1193,23 @@ def is_inter_state(invoice_detail):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_company_gstins(company):
|
||||||
|
address = frappe.qb.DocType("Address")
|
||||||
|
links = frappe.qb.DocType("Dynamic Link")
|
||||||
|
|
||||||
|
addresses = frappe.qb.from_(address).inner_join(links).on(
|
||||||
|
address.name == links.parent
|
||||||
|
).select(
|
||||||
|
address.gstin
|
||||||
|
).where(
|
||||||
|
links.link_doctype == 'Company'
|
||||||
|
).where(
|
||||||
|
links.link_name == company
|
||||||
|
).run(as_dict=1)
|
||||||
|
|
||||||
|
address_list = [''] + [d.gstin for d in addresses]
|
||||||
|
|
||||||
|
return address_list
|
||||||
Loading…
x
Reference in New Issue
Block a user