Skip to content

Commit

Permalink
fix: add overlaping invoice count summary to overview
Browse files Browse the repository at this point in the history
(cherry picked from commit 139895a)
  • Loading branch information
vorasmit authored and mergify[bot] committed Apr 9, 2024
1 parent 03fa127 commit 153a57f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_columns(filters):
"label": _("No. of records"),
"fieldname": "no_of_records",
"width": "120",
"fieldtype": "HTML",
"fieldtype": "Int",
},
{
"label": _("Taxable Value"),
Expand Down
46 changes: 28 additions & 18 deletions india_compliance/gst_india/utils/gstr/gstr_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,6 @@ def get_overview(self):
**amount_fields,
}

nne_invoices = {"Nil-Rated": set(), "Non-GST": set(), "Exempted": set()}
overlap_invoices = {"Nil-Rated": set(), "Non-GST": set(), "Exempted": set()}

for row in invoices:
category_key = summary[
row.get("invoice_sub_category", row["invoice_category"])
Expand All @@ -517,22 +514,35 @@ def get_overview(self):

category_key["unique_records"].add(row.invoice_no)

if category_key["description"] in ["Nil-Rated", "Non-GST", "Exempted"]:
nne_invoices[category_key["description"]].add(row.invoice_no)
for category_key in summary.values():
category_key["no_of_records"] = len(category_key["unique_records"])

for row in summary.values():
for category in ["Nil-Rated", "Non-GST", "Exempted"]:
if row["description"] != category:
overlap_invoices[category].update(
nne_invoices[category].intersection(row["unique_records"])
)
self.update_overlaping_invoice_summary(summary)

for row in summary.values():
row["no_of_records"] = len(row["unique_records"])
return list(summary.values())

if row["description"] in ["Nil-Rated", "Non-GST", "Exempted"]:
row["no_of_records"] = (
f"{row['no_of_records']} <span style='color: red;'>({len(overlap_invoices[row['description']])})</span>"
)
def update_overlaping_invoice_summary(self, summary):
nil_exempt_non_gst = ("Nil-Rated", "Exempted", "Non-GST")

return list(summary.values())
# Get Unique Taxable Invoices
unique_invoices = set()
for category, row in summary.items():
if category in nil_exempt_non_gst:
continue

unique_invoices.update(row["unique_records"])

# Get Overlaping Invoices
overlaping_invoices = set()
for category in nil_exempt_non_gst:
category_invoices = summary[category]["unique_records"]

overlaping_invoices.update(category_invoices.intersection(unique_invoices))
unique_invoices.update(category_invoices)

# Update Summary
if overlaping_invoices:
summary["Overlaping Invoices"] = {
"description": "Overlaping Invoices in Nil-Rated/Exempt/Non-GST",
"no_of_records": -len(overlaping_invoices),
}

0 comments on commit 153a57f

Please sign in to comment.