mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
fix: Add method to get invoices liable to reverse charge
This commit is contained in:
@@ -129,21 +129,12 @@ class GSTR3BReport(Document):
|
|||||||
WHERE p.docstatus = 1 and p.name = i.parent
|
WHERE p.docstatus = 1 and p.name = i.parent
|
||||||
and p.is_opening = 'No'
|
and p.is_opening = 'No'
|
||||||
and p.gst_category != 'Registered Composition'
|
and p.gst_category != 'Registered Composition'
|
||||||
and (i.is_nil_exempt = 1 or i.is_non_gst = 1) and
|
and (i.is_nil_exempt = 1 or i.is_non_gst = 1 or p.gst_catgory = 'Registered Composition') and
|
||||||
month(p.posting_date) = %s and year(p.posting_date) = %s
|
month(p.posting_date) = %s and year(p.posting_date) = %s
|
||||||
and p.company = %s and p.company_gstin = %s
|
and p.company = %s and p.company_gstin = %s
|
||||||
GROUP BY p.place_of_supply, i.is_nil_exempt, i.is_non_gst""",
|
GROUP BY p.place_of_supply, i.is_nil_exempt, i.is_non_gst""",
|
||||||
(self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
|
(self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
|
||||||
|
|
||||||
inward_nil_exempt += frappe.db.sql("""
|
|
||||||
SELECT sum(base_net_total) as base_amount, gst_category, place_of_supply
|
|
||||||
FROM `tabPurchase Invoice`
|
|
||||||
WHERE docstatus = 1 and is_opening = 'No'
|
|
||||||
and gst_category = 'Registered Composition'
|
|
||||||
and month(posting_date) = %s and year(posting_date) = %s
|
|
||||||
and company = %s and company_gstin = %s
|
|
||||||
group by place_of_supply""", (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
|
|
||||||
|
|
||||||
inward_nil_exempt_details = {
|
inward_nil_exempt_details = {
|
||||||
"gst": {
|
"gst": {
|
||||||
"intra": 0.0,
|
"intra": 0.0,
|
||||||
@@ -168,14 +159,18 @@ class GSTR3BReport(Document):
|
|||||||
|
|
||||||
return inward_nil_exempt_details
|
return inward_nil_exempt_details
|
||||||
|
|
||||||
def get_outward_supply_details(self, doctype):
|
def get_outward_supply_details(self, doctype, reverse_charge=None):
|
||||||
self.get_outward_tax_invoices(doctype)
|
self.get_outward_tax_invoices(doctype, reverse_charge=reverse_charge)
|
||||||
self.get_outward_items(doctype)
|
self.get_outward_items(doctype)
|
||||||
self.get_outward_tax_details(doctype)
|
self.get_outward_tax_details(doctype)
|
||||||
|
|
||||||
def get_outward_tax_invoices(self, doctype):
|
def get_outward_tax_invoices(self, doctype, reverse_charge=None):
|
||||||
self.invoices = []
|
self.invoices = []
|
||||||
self.invoice_detail_map = {}
|
self.invoice_detail_map = {}
|
||||||
|
condition = ''
|
||||||
|
|
||||||
|
if reverse_charge:
|
||||||
|
condition += 'AND reverse_charge = Y'
|
||||||
|
|
||||||
invoice_details = frappe.db.sql("""
|
invoice_details = frappe.db.sql("""
|
||||||
SELECT
|
SELECT
|
||||||
@@ -189,8 +184,10 @@ class GSTR3BReport(Document):
|
|||||||
AND company = %s
|
AND company = %s
|
||||||
AND company_gstin = %s
|
AND company_gstin = %s
|
||||||
AND is_opening = 'No'
|
AND is_opening = 'No'
|
||||||
|
{reverse_charge}
|
||||||
ORDER BY name
|
ORDER BY name
|
||||||
""".format(doctype=doctype), (self.month_no, self.year, self.company, self.gst_details.get("gstin")), as_dict=1)
|
""".format(doctype=doctype, reverse_charge=condition), (self.month_no, self.year,
|
||||||
|
self.company, self.gst_details.get("gstin")), as_dict=1)
|
||||||
|
|
||||||
for d in invoice_details:
|
for d in invoice_details:
|
||||||
self.invoice_detail_map.setdefault(d.name, d)
|
self.invoice_detail_map.setdefault(d.name, d)
|
||||||
@@ -320,6 +317,10 @@ class GSTR3BReport(Document):
|
|||||||
|
|
||||||
self.set_inter_state_supply(inter_state_supply_details)
|
self.set_inter_state_supply(inter_state_supply_details)
|
||||||
|
|
||||||
|
def set_supplies_liable_to_reverse_charge(self):
|
||||||
|
# ToDo:
|
||||||
|
pass
|
||||||
|
|
||||||
def set_inter_state_supply(self, inter_state_supply):
|
def set_inter_state_supply(self, inter_state_supply):
|
||||||
for key, value in iteritems(inter_state_supply):
|
for key, value in iteritems(inter_state_supply):
|
||||||
if key[0] == "Unregistered":
|
if key[0] == "Unregistered":
|
||||||
|
|||||||
Reference in New Issue
Block a user