Skip to content

Commit

Permalink
Merge pull request #2087 from resilient-tech/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
vorasmit authored Apr 29, 2024
2 parents cc42c35 + 486ace0 commit 1cdde1c
Show file tree
Hide file tree
Showing 36 changed files with 1,570 additions and 329 deletions.
10 changes: 8 additions & 2 deletions india_compliance/gst_india/client_scripts/e_invoice_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ function show_cancel_e_invoice_dialog(frm, callback) {
: __("Cancel e-Invoice"),
fields: get_cancel_e_invoice_dialog_fields(frm),
primary_action_label: frm.doc.ewaybill
? __("Cancel IRN & e-Waybill")
: __("Cancel IRN"),
? __("Cancel IRN, e-Waybill & Invoice")
: __("Cancel IRN & Invoice"),
primary_action(values) {
frappe.call({
method: "india_compliance.gst_india.utils.e_invoice.cancel_e_invoice",
Expand All @@ -174,6 +174,12 @@ function show_cancel_e_invoice_dialog(frm, callback) {

india_compliance.primary_to_danger_btn(d);
d.show();

$(`
<div class="alert alert-warning" role="alert">
Sales invoice will be cancelled along with the IRN.
</div>
`).prependTo(d.wrapper);
}

function show_mark_e_invoice_as_cancelled_dialog(frm) {
Expand Down
9 changes: 0 additions & 9 deletions india_compliance/gst_india/client_scripts/party.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const TCS_REGEX = /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[C]{1}[0-9A-Z]{1}$/;
const PAN_REGEX = /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/;

function update_gstin_in_other_documents(doctype) {
Expand Down Expand Up @@ -58,14 +57,6 @@ function validate_gstin(doctype) {
frappe.throw(__("GSTIN/UIN should be 15 characters long"));
}

if (TCS_REGEX.test(gstin)) {
frappe.throw(
__(
"e-Commerce Operator (TCS) GSTIN is not allowed to be set in Party/Address"
)
);
}

gstin = india_compliance.validate_gstin(gstin);

frm.doc.gstin = gstin;
Expand Down
6 changes: 2 additions & 4 deletions india_compliance/gst_india/client_scripts/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,9 @@ function is_gst_invoice(frm) {
item.gst_treatment == "Nil-Rated" || item.gst_treatment == "Exempted"
);

if (frm.doc.place_of_supply === "96-Other Countries") {
if (frm.doc.items[0].gst_treatment === "Zero-Rated")
return gst_invoice_conditions && frm.doc.is_export_with_gst;
} else {
return gst_invoice_conditions;
}
else return gst_invoice_conditions;
}

async function contains_gst_account(frm) {
Expand Down
5 changes: 4 additions & 1 deletion india_compliance/gst_india/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

GST_PARTY_TYPES = ("Customer", "Supplier", "Company")

# Map for e-Invoice Supply Type
GST_CATEGORIES = {
"Registered Regular": "B2B",
"Registered Composition": "B2B",
Expand All @@ -27,6 +28,7 @@
"Deemed Export": "DEXP",
"UIN Holders": "B2B",
"Tax Deductor": "B2B",
"Tax Collector": "B2B",
}

EXPORT_TYPES = (
Expand Down Expand Up @@ -1392,6 +1394,7 @@

UNBODY = re.compile(r"^[0-9]{4}[A-Z]{3}[0-9]{5}[UO]{1}[N][A-Z0-9]{1}$")
TDS = re.compile(r"^[0-9]{2}[A-Z]{4}[A-Z0-9]{1}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[D][0-9A-Z]$")
TCS = re.compile(r"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[C]{1}[0-9A-Z]{1}$")

GSTIN_FORMATS = {
"Registered Regular": REGISTERED,
Expand All @@ -1401,9 +1404,9 @@
"Deemed Export": REGISTERED,
"UIN Holders": UNBODY,
"Tax Deductor": TDS,
"Tax Collector": TCS,
}

TCS = re.compile(r"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[C]{1}[0-9A-Z]{1}$")
PAN_NUMBER = re.compile(r"^[A-Z]{5}[0-9]{4}[A-Z]{1}$")
PINCODE_FORMAT = re.compile(r"^[1-9][0-9]{5}$")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,21 @@
{
"PURCHASE_INVOICE": {
"bill_no": "BILL-23-00010",
"company_gstin": "29AABCR1718E1ZL"
"company_gstin": "29AABCR1718E1ZL",
"is_in_state": 0,
"is_out_state": 1
},
"INWARD_SUPPLY": {
"bill_no": "BILL-23-00010",
"company_gstin": "29AABCR1718E1ZL"
"company_gstin": "29AABCR1718E1ZL",
"place_of_supply": "29-Karnataka",
"items": [
{
"taxable_value": 10000,
"rate": 18,
"igst": 1800
}
]
},
"RECONCILED_DATA": {
"action": "No Action",
Expand Down
72 changes: 49 additions & 23 deletions india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ def on_cancel(self):
self.ignore_linked_doctypes = ("GL Entry",)
make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name)

if self.reconciliation_status != "Reconciled":
return

frappe.db.set_value(
"GST Inward Supply",
{"link_doctype": "Bill of Entry", "link_name": self.name},
{
"match_status": "",
"link_name": "",
"link_doctype": "",
"action": "No Action",
},
)

# Code adapted from AccountsController.on_trash
def on_trash(self):
if not frappe.db.get_single_value(
Expand Down Expand Up @@ -250,9 +264,11 @@ def validate_purchase_invoice(self):
def validate_taxes(self):
input_accounts = get_gst_accounts_by_type(self.company, "Input", throw=True)
taxable_value_map = {}
item_qty_map = {}

for row in self.get("items"):
taxable_value_map[row.name] = row.taxable_value
item_qty_map[row.name] = row.qty

for tax in self.taxes:
if not tax.tax_amount:
Expand All @@ -274,33 +290,43 @@ def validate_taxes(self):
[input_accounts.cess_non_advol_account], tax
)

if tax.charge_type == "Actual":
if tax.charge_type != "Actual":
continue

item_wise_tax_rates = json.loads(tax.item_wise_tax_rates)
if not item_wise_tax_rates:
frappe.throw(
_(
"Tax Row #{0}: Charge Type is set to Actual. However, this would"
" not compute item taxes, and your further reporting will be affected."
).format(tax.idx),
title=_("Invalid Charge Type"),
)
item_wise_tax_rates = json.loads(tax.item_wise_tax_rates)
if not item_wise_tax_rates:
frappe.throw(
_(
"Tax Row #{0}: Charge Type is set to Actual. However, this would"
" not compute item taxes, and your further reporting will be affected."
).format(tax.idx),
title=_("Invalid Charge Type"),
)

# validating total tax
total_tax = 0
for item, rate in item_wise_tax_rates.items():
item_taxable_value = taxable_value_map.get(item, 0)
total_tax += item_taxable_value * rate / 100
# validating total tax
total_tax = 0
is_non_cess_advol = (
tax.account_head == input_accounts.cess_non_advol_account
)

for item, rate in item_wise_tax_rates.items():
multiplier = (
item_qty_map.get(item, 0)
if is_non_cess_advol
else taxable_value_map.get(item, 0) / 100
)
total_tax += multiplier * rate

tax_difference = abs(total_tax - tax.tax_amount)
tax_difference = abs(total_tax - tax.tax_amount)

if tax_difference > 1:
frappe.throw(
_(
"Tax Row #{0}: Charge Type is set to Actual. However, Tax Amount {1}"
" is incorrect. Try setting the Charge Type to On Net Total."
).format(row.idx, tax.tax_amount)
)
if tax_difference > 1:
column = "On Item Quantity" if is_non_cess_advol else "On Net Total"
frappe.throw(
_(
"Tax Row #{0}: Charge Type is set to Actual. However, Tax Amount {1}"
" is incorrect. Try setting the Charge Type to {2}."
).format(row.idx, tax.tax_amount, column)
)

def get_gl_entries(self):
# company_currency is required by get_gl_dict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_create_bill_of_entry(self):
pi = create_purchase_invoice(supplier="_Test Foreign Supplier", update_stock=1)

# Create BOE

boe = make_bill_of_entry(pi.name)
boe.items[0].customs_duty = 100
boe.bill_of_entry_no = "123"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def before_save(self):
):
update_docs_for_amendment(self)

def on_trash(self):
frappe.db.set_value(
self.link_doctype, self.link_name, "reconciliation_status", "Unreconciled"
)


def create_inward_supply(transaction):
filters = {
Expand Down
Loading

0 comments on commit 1cdde1c

Please sign in to comment.