[Report] GSTR - 1 CDNR Report (#12554)
* [wip] cdnr * [WIP] cdnr with optional data * [wip] Export GSTR-1 * [minor] Minor changes in export * [new] Custom field added for GST * [fix] Minor changes in GSTR1 Report * [minor] Minor changes in gstr1 * [fix] Codacy Fixed * Update setup.py
This commit is contained in:
parent
567623654b
commit
c463c0684d
@ -489,4 +489,5 @@ erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
|
|||||||
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
|
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
|
||||||
erpnext.patches.v10_0.update_assessment_plan
|
erpnext.patches.v10_0.update_assessment_plan
|
||||||
erpnext.patches.v10_0.update_assessment_result
|
erpnext.patches.v10_0.update_assessment_result
|
||||||
|
erpnext.patches.v10_0.added_extra_gst_custom_field
|
||||||
erpnext.patches.v10_0.workflow_leave_application #2018-01-24
|
erpnext.patches.v10_0.workflow_leave_application #2018-01-24
|
9
erpnext/patches/v10_0/added_extra_gst_custom_field.py
Normal file
9
erpnext/patches/v10_0/added_extra_gst_custom_field.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import frappe
|
||||||
|
from erpnext.regional.india.setup import make_custom_fields
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||||
|
if not company:
|
||||||
|
return
|
||||||
|
|
||||||
|
make_custom_fields()
|
@ -103,7 +103,20 @@ def make_custom_fields():
|
|||||||
depends_on='eval:in_list(["SEZ", "Export", "Deemed Export"], doc.invoice_type)',
|
depends_on='eval:in_list(["SEZ", "Export", "Deemed Export"], doc.invoice_type)',
|
||||||
options='\nWith Payment of Tax\nWithout Payment of Tax'),
|
options='\nWith Payment of Tax\nWithout Payment of Tax'),
|
||||||
dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
|
dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN',
|
||||||
fieldtype='Data', insert_after='export_type', print_hide=1)
|
fieldtype='Data', insert_after='export_type', print_hide=1),
|
||||||
|
dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document',
|
||||||
|
fieldtype='Select', insert_after='ecommerce_gstin', print_hide=1,
|
||||||
|
depends_on='eval:doc.is_return==1',
|
||||||
|
options='\n01-Sales Return\n02-Post Sale Discount\n03-Deficiency in services\n04-Correction in Invoice\n05-Change in POS\n06-Finalization of Provisional assessment\n07-Others'),
|
||||||
|
dict(fieldname='port_code', label='Port Code',
|
||||||
|
fieldtype='Data', insert_after='reason_for_issuing_document', print_hide=1,
|
||||||
|
depends_on="eval:doc.invoice_type=='Export' "),
|
||||||
|
dict(fieldname='shipping_bill_number', label=' Shipping Bill Number',
|
||||||
|
fieldtype='Data', insert_after='port_code', print_hide=1,
|
||||||
|
depends_on="eval:doc.invoice_type=='Export' "),
|
||||||
|
dict(fieldname='shipping_bill_date', label='Shipping Bill Date',
|
||||||
|
fieldtype='Date', insert_after='shipping_bill_number', print_hide=1,
|
||||||
|
depends_on="eval:doc.invoice_type=='Export' "),
|
||||||
]
|
]
|
||||||
|
|
||||||
purchase_invoice_gst_fields = [
|
purchase_invoice_gst_fields = [
|
||||||
|
@ -31,7 +31,7 @@ frappe.query_reports["GSTR-1"] = {
|
|||||||
"label": __("Type of Business"),
|
"label": __("Type of Business"),
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"options": ["B2B", "B2C Large", "B2C Small"],
|
"options": ["B2B", "B2C Large", "B2C Small","CDNR", "EXPORT"],
|
||||||
"default": "B2B"
|
"default": "B2B"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, json
|
import frappe, json
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
return Gstr1Report(filters).run()
|
return Gstr1Report(filters).run()
|
||||||
@ -35,13 +36,15 @@ class Gstr1Report(object):
|
|||||||
for rate, items in items_based_on_rate.items():
|
for rate, items in items_based_on_rate.items():
|
||||||
row = []
|
row = []
|
||||||
for fieldname in invoice_fields:
|
for fieldname in invoice_fields:
|
||||||
if fieldname == "invoice_value":
|
if self.filters.get("type_of_business") == "CDNR" and fieldname == "invoice_value":
|
||||||
|
row.append(abs(invoice_details.base_rounded_total) or abs(invoice_details.base_grand_total))
|
||||||
|
elif fieldname == "invoice_value":
|
||||||
row.append(invoice_details.base_rounded_total or invoice_details.base_grand_total)
|
row.append(invoice_details.base_rounded_total or invoice_details.base_grand_total)
|
||||||
else:
|
else:
|
||||||
row.append(invoice_details.get(fieldname))
|
row.append(invoice_details.get(fieldname))
|
||||||
|
|
||||||
row += [rate,
|
row += [rate,
|
||||||
sum([net_amount for item_code, net_amount in self.invoice_items.get(inv).items()
|
sum([abs(net_amount) for item_code, net_amount in self.invoice_items.get(inv).items()
|
||||||
if item_code in items]),
|
if item_code in items]),
|
||||||
self.invoice_cess.get(inv)
|
self.invoice_cess.get(inv)
|
||||||
]
|
]
|
||||||
@ -49,6 +52,10 @@ class Gstr1Report(object):
|
|||||||
if self.filters.get("type_of_business") == "B2C Small":
|
if self.filters.get("type_of_business") == "B2C Small":
|
||||||
row.append("E" if invoice_details.ecommerce_gstin else "OE")
|
row.append("E" if invoice_details.ecommerce_gstin else "OE")
|
||||||
|
|
||||||
|
if self.filters.get("type_of_business") == "CDNR":
|
||||||
|
row.append("Y" if invoice_details.posting_date <= date(2017, 7, 1) else "N")
|
||||||
|
row.append("C" if invoice_details.return_against else "R")
|
||||||
|
|
||||||
self.data.append(row)
|
self.data.append(row)
|
||||||
|
|
||||||
def get_invoice_data(self):
|
def get_invoice_data(self):
|
||||||
@ -66,7 +73,15 @@ class Gstr1Report(object):
|
|||||||
place_of_supply,
|
place_of_supply,
|
||||||
ecommerce_gstin,
|
ecommerce_gstin,
|
||||||
reverse_charge,
|
reverse_charge,
|
||||||
invoice_type
|
invoice_type,
|
||||||
|
return_against,
|
||||||
|
is_return,
|
||||||
|
invoice_type,
|
||||||
|
export_type,
|
||||||
|
port_code,
|
||||||
|
shipping_bill_number,
|
||||||
|
shipping_bill_date,
|
||||||
|
reason_for_issuing_document
|
||||||
from `tabSales Invoice`
|
from `tabSales Invoice`
|
||||||
where docstatus = 1 %s
|
where docstatus = 1 %s
|
||||||
order by posting_date desc
|
order by posting_date desc
|
||||||
@ -85,18 +100,27 @@ class Gstr1Report(object):
|
|||||||
conditions += opts[1]
|
conditions += opts[1]
|
||||||
|
|
||||||
customers = frappe.get_all("Customer", filters={"customer_type": self.customer_type})
|
customers = frappe.get_all("Customer", filters={"customer_type": self.customer_type})
|
||||||
conditions += " and customer in ('{0}')".format("', '".join([frappe.db.escape(c.name)
|
|
||||||
for c in customers]))
|
if self.filters.get("type_of_business") == "B2B":
|
||||||
|
conditions += " and invoice_type != 'Export' and is_return != 1 and customer in ('{0}')".\
|
||||||
|
format("', '".join([frappe.db.escape(c.name) for c in customers]))
|
||||||
|
|
||||||
if self.filters.get("type_of_business") == "B2C Large":
|
if self.filters.get("type_of_business") == "B2C Large":
|
||||||
conditions += """ and SUBSTR(place_of_supply, 1, 2) != SUBSTR(company_gstin, 1, 2)
|
conditions += """ and SUBSTR(place_of_supply, 1, 2) != SUBSTR(company_gstin, 1, 2)
|
||||||
and grand_total > 250000"""
|
and grand_total > 250000 and is_return != 1 and customer in ('{0}')""".\
|
||||||
|
format("', '".join([frappe.db.escape(c.name) for c in customers]))
|
||||||
|
|
||||||
elif self.filters.get("type_of_business") == "B2C Small":
|
elif self.filters.get("type_of_business") == "B2C Small":
|
||||||
conditions += """ and (
|
conditions += """ and (
|
||||||
SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2)
|
SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2)
|
||||||
or grand_total <= 250000
|
or grand_total <= 250000 ) and is_return != 1 and customer in ('{0}')""".\
|
||||||
)"""
|
format("', '".join([frappe.db.escape(c.name) for c in customers]))
|
||||||
|
|
||||||
|
elif self.filters.get("type_of_business") == "CDNR":
|
||||||
|
conditions += """ and is_return = 1 """
|
||||||
|
|
||||||
|
elif self.filters.get("type_of_business") == "EXPORT":
|
||||||
|
conditions += """ and is_return !=1 and invoice_type = 'Export' """
|
||||||
return conditions
|
return conditions
|
||||||
|
|
||||||
def get_invoice_items(self):
|
def get_invoice_items(self):
|
||||||
@ -118,7 +142,7 @@ class Gstr1Report(object):
|
|||||||
where
|
where
|
||||||
parenttype = 'Sales Invoice' and docstatus = 1
|
parenttype = 'Sales Invoice' and docstatus = 1
|
||||||
and parent in (%s)
|
and parent in (%s)
|
||||||
and tax_amount_after_discount_amount > 0
|
|
||||||
order by account_head
|
order by account_head
|
||||||
""" % (', '.join(['%s']*len(self.invoices.keys()))), tuple(self.invoices.keys()))
|
""" % (', '.join(['%s']*len(self.invoices.keys()))), tuple(self.invoices.keys()))
|
||||||
|
|
||||||
@ -152,7 +176,6 @@ class Gstr1Report(object):
|
|||||||
.setdefault(tax_rate, [])
|
.setdefault(tax_rate, [])
|
||||||
if item_code not in rate_based_dict:
|
if item_code not in rate_based_dict:
|
||||||
rate_based_dict.append(item_code)
|
rate_based_dict.append(item_code)
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
if unidentified_gst_accounts:
|
if unidentified_gst_accounts:
|
||||||
@ -185,12 +208,6 @@ class Gstr1Report(object):
|
|||||||
"label": "Taxable Value",
|
"label": "Taxable Value",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"width": 100
|
"width": 100
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "cess_amount",
|
|
||||||
"label": "Cess Amount",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"width": 100
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
self.other_columns = []
|
self.other_columns = []
|
||||||
@ -200,33 +217,39 @@ class Gstr1Report(object):
|
|||||||
{
|
{
|
||||||
"fieldname": "customer_gstin",
|
"fieldname": "customer_gstin",
|
||||||
"label": "GSTIN/UIN of Recipient",
|
"label": "GSTIN/UIN of Recipient",
|
||||||
"fieldtype": "Data"
|
"fieldtype": "Data",
|
||||||
|
"width": 150
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "customer_name",
|
"fieldname": "customer_name",
|
||||||
"label": "Receiver Name",
|
"label": "Receiver Name",
|
||||||
"fieldtype": "Data"
|
"fieldtype": "Data",
|
||||||
|
"width":100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "invoice_number",
|
"fieldname": "invoice_number",
|
||||||
"label": "Invoice Number",
|
"label": "Invoice Number",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Sales Invoice"
|
"options": "Sales Invoice",
|
||||||
|
"width":100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "posting_date",
|
"fieldname": "posting_date",
|
||||||
"label": "Invoice date",
|
"label": "Invoice date",
|
||||||
"fieldtype": "Date"
|
"fieldtype": "Date",
|
||||||
|
"width":80
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "invoice_value",
|
"fieldname": "invoice_value",
|
||||||
"label": "Invoice Value",
|
"label": "Invoice Value",
|
||||||
"fieldtype": "Currency"
|
"fieldtype": "Currency",
|
||||||
|
"width":100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "place_of_supply",
|
"fieldname": "place_of_supply",
|
||||||
"label": "Place of Supply",
|
"label": "Place of Supply",
|
||||||
"fieldtype": "Data"
|
"fieldtype": "Data",
|
||||||
|
"width":100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "reverse_charge",
|
"fieldname": "reverse_charge",
|
||||||
@ -241,9 +264,19 @@ class Gstr1Report(object):
|
|||||||
{
|
{
|
||||||
"fieldname": "ecommerce_gstin",
|
"fieldname": "ecommerce_gstin",
|
||||||
"label": "E-Commerce GSTIN",
|
"label": "E-Commerce GSTIN",
|
||||||
"fieldtype": "Data"
|
"fieldtype": "Data",
|
||||||
|
"width":120
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
self.other_columns = [
|
||||||
|
{
|
||||||
|
"fieldname": "cess_amount",
|
||||||
|
"label": "Cess Amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"width": 100
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
elif self.filters.get("type_of_business") == "B2C Large":
|
elif self.filters.get("type_of_business") == "B2C Large":
|
||||||
self.invoice_columns = [
|
self.invoice_columns = [
|
||||||
{
|
{
|
||||||
@ -278,6 +311,93 @@ class Gstr1Report(object):
|
|||||||
"width": 130
|
"width": 130
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
self.other_columns = [
|
||||||
|
{
|
||||||
|
"fieldname": "cess_amount",
|
||||||
|
"label": "Cess Amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"width": 100
|
||||||
|
}
|
||||||
|
]
|
||||||
|
elif self.filters.get("type_of_business") == "CDNR":
|
||||||
|
self.invoice_columns = [
|
||||||
|
{
|
||||||
|
"fieldname": "customer_gstin",
|
||||||
|
"label": "GSTIN/UIN of Recipient",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "customer_name",
|
||||||
|
"label": "Receiver Name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "return_against",
|
||||||
|
"label": "Invoice/Advance Receipt Number",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Sales Invoice",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "posting_date",
|
||||||
|
"label": "Invoice/Advance Receipt date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "invoice_number",
|
||||||
|
"label": "Invoice/Advance Receipt Number",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Sales Invoice",
|
||||||
|
"width":120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "posting_date",
|
||||||
|
"label": "Invoice/Advance Receipt date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reason_for_issuing_document",
|
||||||
|
"label": "Reason For Issuing document",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 140
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "place_of_supply",
|
||||||
|
"label": "Place of Supply",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "invoice_value",
|
||||||
|
"label": "Invoice Value",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"width": 120
|
||||||
|
}
|
||||||
|
]
|
||||||
|
self.other_columns = [
|
||||||
|
{
|
||||||
|
"fieldname": "cess_amount",
|
||||||
|
"label": "Cess Amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "pre_gst",
|
||||||
|
"label": "PRE GST",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "document_type",
|
||||||
|
"label": "Document Type",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 80
|
||||||
|
}
|
||||||
|
]
|
||||||
elif self.filters.get("type_of_business") == "B2C Small":
|
elif self.filters.get("type_of_business") == "B2C Small":
|
||||||
self.invoice_columns = [
|
self.invoice_columns = [
|
||||||
{
|
{
|
||||||
@ -294,6 +414,12 @@ class Gstr1Report(object):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
self.other_columns = [
|
self.other_columns = [
|
||||||
|
{
|
||||||
|
"fieldname": "cess_amount",
|
||||||
|
"label": "Cess Amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "type",
|
"fieldname": "type",
|
||||||
"label": "Type",
|
"label": "Type",
|
||||||
@ -301,4 +427,50 @@ class Gstr1Report(object):
|
|||||||
"width": 50
|
"width": 50
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
elif self.filters.get("type_of_business") == "EXPORT":
|
||||||
|
self.invoice_columns = [
|
||||||
|
{
|
||||||
|
"fieldname": "export_type",
|
||||||
|
"label": "Export Type",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width":120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "invoice_number",
|
||||||
|
"label": "Invoice Number",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Sales Invoice",
|
||||||
|
"width":120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "posting_date",
|
||||||
|
"label": "Invoice date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "invoice_value",
|
||||||
|
"label": "Invoice Value",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "port_code",
|
||||||
|
"label": "Port Code",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "shipping_bill_number",
|
||||||
|
"label": "Shipping Bill Number",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"width": 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "shipping_bill_date",
|
||||||
|
"label": "Shipping Bill Date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"width": 120
|
||||||
|
}
|
||||||
|
]
|
||||||
self.columns = self.invoice_columns + self.tax_columns + self.other_columns
|
self.columns = self.invoice_columns + self.tax_columns + self.other_columns
|
Loading…
x
Reference in New Issue
Block a user