Skip to content

Commit

Permalink
Merge pull request #30978 from deepeshgarg007/gstr_export_sez_tax_rates
Browse files Browse the repository at this point in the history
fix: Multiple fixes in GST reporting
  • Loading branch information
deepeshgarg007 authored May 15, 2022
2 parents c465016 + 5b02b5b commit c7f4a15
Show file tree
Hide file tree
Showing 11 changed files with 144,546 additions and 17 deletions.
1 change: 1 addition & 0 deletions erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@
"validate": [
"erpnext.regional.india.utils.validate_document_name",
"erpnext.regional.india.utils.update_taxable_values",
"erpnext.regional.india.utils.validate_sez_and_export_invoices",
],
},
"POS Invoice": {"on_submit": ["erpnext.regional.saudi_arabia.utils.create_qr_code"]},
Expand Down
23 changes: 20 additions & 3 deletions erpnext/regional/doctype/gst_hsn_code/gst_hsn_code.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"actions": [],
"autoname": "field:hsn_code",
"creation": "2017-06-21 10:48:56.422086",
"doctype": "DocType",
Expand All @@ -7,6 +8,7 @@
"field_order": [
"hsn_code",
"description",
"gst_rates",
"taxes"
],
"fields": [
Expand All @@ -16,22 +18,37 @@
"in_list_view": 1,
"label": "HSN Code",
"reqd": 1,
"show_days": 1,
"show_seconds": 1,
"unique": 1
},
{
"fieldname": "description",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Description"
"label": "Description",
"show_days": 1,
"show_seconds": 1
},
{
"fieldname": "taxes",
"fieldtype": "Table",
"label": "Taxes",
"options": "Item Tax"
"options": "Item Tax",
"show_days": 1,
"show_seconds": 1
},
{
"fieldname": "gst_rates",
"fieldtype": "Table",
"label": "GST Rates",
"options": "HSN Tax Rate",
"show_days": 1,
"show_seconds": 1
}
],
"modified": "2019-11-01 11:18:59.556931",
"links": [],
"modified": "2022-05-11 13:42:27.286643",
"modified_by": "Administrator",
"module": "Regional",
"name": "GST HSN Code",
Expand Down
8 changes: 7 additions & 1 deletion erpnext/regional/doctype/gst_settings/gst_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@

frappe.ui.form.on('GST Settings', {
refresh: function(frm) {
frm.add_custom_button('Send GST Update Reminder', () => {
frm.add_custom_button(__('Send GST Update Reminder'), () => {
return new Promise((resolve) => {
return frappe.call({
method: 'erpnext.regional.doctype.gst_settings.gst_settings.send_reminder'
}).always(() => { resolve(); });
});
});

frm.add_custom_button(__('Sync HSN Codes'), () => {
frappe.call({
"method": "erpnext.regional.doctype.gst_settings.gst_settings.update_hsn_codes"
});
});

$(frm.fields_dict.gst_summary.wrapper).empty().html(
`<table class="table table-bordered">
<tbody>
Expand Down
31 changes: 30 additions & 1 deletion erpnext/regional/doctype/gst_settings/gst_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# For license information, please see license.txt


import json
import os

import frappe
from frappe import _
from frappe.contacts.doctype.contact.contact import get_default_contact
from frappe.model.document import Document
from frappe.utils import date_diff, get_url, nowdate
from frappe.utils import date_diff, flt, get_url, nowdate


class EmailMissing(frappe.ValidationError):
Expand Down Expand Up @@ -129,3 +130,31 @@ def _send_gstin_reminder(party_type, party, default_email_id=None, sent_to=None)
)

return email_id


@frappe.whitelist()
def update_hsn_codes():
frappe.enqueue(enqueue_update)
frappe.msgprint(_("HSN/SAC Code sync started, this may take a few minutes..."))


def enqueue_update():
with open(os.path.join(os.path.dirname(__file__), "hsn_code_data.json"), "r") as f:
hsn_codes = json.loads(f.read())

for hsn_code in hsn_codes:
try:
hsn_code_doc = frappe.get_doc("GST HSN Code", hsn_code.get("hsn_code"))
hsn_code_doc.set("gst_rates", [])
for rate in hsn_code.get("gst_rates"):
hsn_code_doc.append(
"gst_rates",
{
"minimum_taxable_value": flt(hsn_code.get("minimum_taxable_value")),
"tax_rate": flt(rate.get("tax_rate")),
},
)

hsn_code_doc.save()
except Exception as e:
pass
Loading

0 comments on commit c7f4a15

Please sign in to comment.