fix: GSTR-1 Reports not showing any data

This commit is contained in:
Deepesh Garg
2021-09-07 11:07:22 +05:30
parent 88c9fe35bd
commit e1f55df4d7

View File

@@ -50,6 +50,7 @@ class Gstr1Report(object):
self.gst_accounts = get_gst_accounts(self.filters.company, only_non_reverse_charge=1) self.gst_accounts = get_gst_accounts(self.filters.company, only_non_reverse_charge=1)
self.get_invoice_data() self.get_invoice_data()
print(self.invoices, "$#$#$#$#$#")
if self.invoices: if self.invoices:
self.get_invoice_items() self.get_invoice_items()
self.get_items_based_on_tax_rate() self.get_items_based_on_tax_rate()
@@ -96,13 +97,14 @@ class Gstr1Report(object):
def get_b2c_data(self): def get_b2c_data(self):
b2cs_output = {} b2cs_output = {}
if self.invoices:
for inv, items_based_on_rate in self.items_based_on_tax_rate.items(): for inv, items_based_on_rate in self.items_based_on_tax_rate.items():
invoice_details = self.invoices.get(inv) invoice_details = self.invoices.get(inv)
for rate, items in items_based_on_rate.items(): for rate, items in items_based_on_rate.items():
place_of_supply = invoice_details.get("place_of_supply") place_of_supply = invoice_details.get("place_of_supply")
ecommerce_gstin = invoice_details.get("ecommerce_gstin") ecommerce_gstin = invoice_details.get("ecommerce_gstin")
b2cs_output.setdefault((rate, place_of_supply, ecommerce_gstin),{ b2cs_output.setdefault((rate, place_of_supply, ecommerce_gstin), {
"place_of_supply": "", "place_of_supply": "",
"ecommerce_gstin": "", "ecommerce_gstin": "",
"rate": "", "rate": "",
@@ -173,6 +175,7 @@ class Gstr1Report(object):
company_gstins = get_company_gstin_number(self.filters.get('company'), all_gstins=True) company_gstins = get_company_gstin_number(self.filters.get('company'), all_gstins=True)
if company_gstins:
self.filters.update({ self.filters.update({
'company_gstins': company_gstins 'company_gstins': company_gstins
}) })
@@ -185,7 +188,7 @@ class Gstr1Report(object):
and is_opening = 'No' and is_opening = 'No'
order by posting_date desc order by posting_date desc
""".format(select_columns=self.select_columns, doctype=self.doctype, """.format(select_columns=self.select_columns, doctype=self.doctype,
where_conditions=conditions), self.filters, as_dict=1) where_conditions=conditions), self.filters, as_dict=1, debug=1)
for d in invoice_data: for d in invoice_data:
self.invoices.setdefault(d.invoice_number, d) self.invoices.setdefault(d.invoice_number, d)
@@ -1050,6 +1053,7 @@ def get_company_gstin_number(company, address=None, all_gstins=False):
["Dynamic Link", "link_doctype", "=", "Company"], ["Dynamic Link", "link_doctype", "=", "Company"],
["Dynamic Link", "link_name", "=", company], ["Dynamic Link", "link_name", "=", company],
["Dynamic Link", "parenttype", "=", "Address"], ["Dynamic Link", "parenttype", "=", "Address"],
["gstin", "!=", '']
] ]
gstin = frappe.get_all("Address", filters=filters, pluck="gstin", order_by="is_primary_address desc") gstin = frappe.get_all("Address", filters=filters, pluck="gstin", order_by="is_primary_address desc")
if gstin and not all_gstins: if gstin and not all_gstins: