Skip to content

Commit

Permalink
Merge pull request #1468 from resilient-tech/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
mergify[bot] authored Dec 26, 2023
2 parents b80a3b7 + e09d08d commit f534a48
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 169 deletions.
24 changes: 24 additions & 0 deletions india_compliance/gst_india/api_classes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,27 @@ def mask_sensitive_info(self, log):

def get_public_ip():
return requests.get("https://api.ipify.org").text


def check_scheduler_status():
"""
Throw an error if scheduler is disabled
"""

if frappe.flags.in_test or frappe.conf.developer_mode:
return

if frappe.utils.scheduler.is_scheduler_disabled():
frappe.throw(
_(
"The Scheduler is currently disabled, which needs to be enabled to use e-Invoicing and e-Waybill features. "
"Please get in touch with your server administrator to resolve this issue.<br><br>"
"For more information, refer to the following documentation: {0}"
).format(
"""
<a href="https://frappeframework.com/docs/user/en/bench/resources/bench-commands-cheatsheet#scheduler" target="_blank">
Frappe Scheduler Documentation
</a>
"""
)
)
4 changes: 3 additions & 1 deletion india_compliance/gst_india/api_classes/e_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import frappe
from frappe import _

from india_compliance.gst_india.api_classes.base import BaseAPI
from india_compliance.gst_india.api_classes.base import BaseAPI, check_scheduler_status
from india_compliance.gst_india.constants import DISTANCE_REGEX


Expand All @@ -30,6 +30,8 @@ def setup(self, doc=None, *, company_gstin=None):
if not self.settings.enable_e_invoice:
frappe.throw(_("Please enable e-Invoicing in GST Settings first"))

check_scheduler_status()

if doc:
company_gstin = doc.company_gstin
self.default_log_values.update(
Expand Down
4 changes: 3 additions & 1 deletion india_compliance/gst_india/api_classes/e_waybill.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import frappe
from frappe import _

from india_compliance.gst_india.api_classes.base import BaseAPI
from india_compliance.gst_india.api_classes.base import BaseAPI, check_scheduler_status
from india_compliance.gst_india.constants import DISTANCE_REGEX


Expand All @@ -22,6 +22,8 @@ def setup(self, doc=None, *, company_gstin=None):
if not self.settings.enable_e_waybill:
frappe.throw(_("Please enable e-Waybill features in GST Settings first"))

check_scheduler_status()

if doc:
company_gstin = doc.company_gstin
self.default_log_values.update(
Expand Down
4 changes: 4 additions & 0 deletions india_compliance/gst_india/overrides/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def set_gst_category(doc):


def fetch_or_guess_gst_category(doc):
# Any transaction can be treated as deemed export
if doc.gstin and doc.gst_category == "Deemed Export":
return "Deemed Export"

if doc.gstin and is_autofill_party_info_enabled():
gstin_info = _get_gstin_info(doc.gstin, throw_error=False) or {}

Expand Down
11 changes: 11 additions & 0 deletions india_compliance/gst_india/overrides/test_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ def test_validate_new_party(self):

self.assertEqual(party.gst_category, "Registered Regular")

def test_validate_deemed_export_party(self):
party = frappe.new_doc(
"Customer",
customer_name="Resilient Tech",
gstin="24AUTPV8831F1ZZ",
gst_category="Deemed Export",
)
party.save()

self.assertEqual(party.gst_category, "Deemed Export")

def test_validate_new_party_with_tcs(self):
party = frappe.new_doc(
"Customer",
Expand Down
20 changes: 19 additions & 1 deletion india_compliance/gst_india/overrides/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,24 @@ def test_gst_details_set_correctly(self):
},
doc.items[0],
)
append_item(doc, frappe._dict(rate=300))
doc.save()

# test same item multiple times
self.assertDocumentEqual(
{
"gst_treatment": "Taxable",
"igst_rate": 0,
"cgst_rate": 9,
"sgst_rate": 9,
"cess_non_advol_rate": 20,
"igst_amount": 0,
"cgst_amount": 27,
"sgst_amount": 27,
"cess_non_advol_amount": 20,
},
doc.items[1],
)

# test non gst treatment
doc = create_transaction(
Expand Down Expand Up @@ -794,4 +812,4 @@ def create_tax_accounts(account_name):
"parent_account": parent_account,
**defaults,
}
).save()
).insert(ignore_if_duplicate=True)
13 changes: 10 additions & 3 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,13 @@ def set_item_wise_tax_details(self):
for item_name in set(old.keys()):
item_taxes = tax_details.setdefault(item_name, item_defaults.copy())

item_taxes["count"] = self.item_count[item_name]
count = self.item_count.get(item_name, 0)
if not count:
# Do not compute if Item is not present in Item table
# There can be difference in Item Table and Item Wise Tax Details
continue

item_taxes["count"] = count

tax_rate, tax_amount = old[item_name]

Expand Down Expand Up @@ -1090,9 +1096,10 @@ def get_item_tax_detail(self, item):
tax_amount_field = f"{tax}_amount"
precision = self.precision.get(tax_amount_field)

multiplier = item.qty if tax == "cess_non_advol" else item.taxable_value
multiplier = (
item.qty if tax == "cess_non_advol" else item.taxable_value / 100
)
tax_amount = flt(tax_rate * multiplier, precision)
tax_amount = max(tax_amount, item_tax_detail[tax_amount_field])

item_tax_detail[tax_amount_field] -= tax_amount
item_tax_detail["count"] -= 1
Expand Down
Loading

0 comments on commit f534a48

Please sign in to comment.