Skip to content

Commit

Permalink
Merge pull request #2492 from resilient-tech/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
sagarvora authored Aug 4, 2024
2 parents 0e1a8b2 + 5c30b53 commit 306afc0
Show file tree
Hide file tree
Showing 34 changed files with 831 additions and 488 deletions.
19 changes: 19 additions & 0 deletions india_compliance/gst_india/api_classes/taxpayer_e_invoice.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import frappe
from frappe import _

from india_compliance.gst_india.api_classes.taxpayer_base import TaxpayerBaseAPI


Expand All @@ -12,6 +15,22 @@ class EInvoiceAPI(TaxpayerBaseAPI):
"EINV30109": "queued",
}

def setup(self, doc=None, *, company_gstin=None):
if doc:
company_gstin = doc.company_gstin
self.default_log_values.update(
reference_doctype=doc.doctype,
reference_name=doc.name,
)

if self.sandbox_mode:
frappe.throw(_("Sandbox mode is not supported for Taxpayer e-Invoice API"))

if not company_gstin:
frappe.throw(_("Company GSTIN is required to use the e-Invoice API"))

super().setup(company_gstin=company_gstin)

def get_irn_list(
self,
return_period,
Expand Down
11 changes: 9 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 @@ -49,8 +49,15 @@ frappe.ui.form.on("Sales Invoice", {
frappe.call({
method: "india_compliance.gst_india.utils.e_invoice.generate_e_invoice",
args: { docname: frm.doc.name, force: true },
callback: () => {
return frm.refresh();
callback: async (r) => {
if (r.message?.error_type == "otp_requested") {
await india_compliance.authenticate_otp(frm.doc.company_gstin);
await frappe.call({
method: "india_compliance.gst_india.utils.e_invoice.handle_duplicate_irn_error",
args: r.message
});
}
frm.refresh();
},
});
},
Expand Down
24 changes: 3 additions & 21 deletions india_compliance/gst_india/client_scripts/sales_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ frappe.ui.form.on(DOCTYPE, {
});

async function gst_invoice_warning(frm) {
if (is_gst_invoice(frm) && !(await contains_gst_account(frm))) {
const contains_gst_account = frm.doc.taxes.some(row => row.gst_tax_type);

if (is_gst_invoice(frm) && !contains_gst_account) {
frm.dashboard.add_comment(
__(
`GST is applicable for this invoice but no tax accounts specified in <a href="/app/gst-settings">
Expand Down Expand Up @@ -94,23 +96,3 @@ function is_gst_invoice(frm) {
else return gst_invoice_conditions;
}

async function contains_gst_account(frm) {
const gst_accounts = await _get_account_options(frm.doc.company);
const accounts = frm.doc.taxes.map(taxes => taxes.account_head);

return accounts.some(account => gst_accounts.includes(account));
}

async function _get_account_options(company) {
if (!frappe.flags.gst_accounts) {
frappe.flags.gst_accounts = {};
}

if (!frappe.flags.gst_accounts[company]) {
frappe.flags.gst_accounts[company] = await india_compliance.get_account_options(
company
);
}

return frappe.flags.gst_accounts[company];
}
13 changes: 7 additions & 6 deletions india_compliance/gst_india/client_scripts/stock_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ frappe.ui.form.on(DOCTYPE, {
});

set_address_display_events();
},

onload(frm) {
frm.taxes_controller = new india_compliance.taxes_controller(frm, {
total_taxable_value: "total_taxable_value",
});

on_change_set_address(
frm,
"supplier_address",
Expand All @@ -39,12 +46,6 @@ frappe.ui.form.on(DOCTYPE, {
);
},

onload(frm) {
frm.taxes_controller = new india_compliance.taxes_controller(frm, {
total_taxable_value: "total_taxable_value",
});
},

refresh(frm) {
if (!gst_settings.enable_e_waybill || !gst_settings.enable_e_waybill_for_sc)
return;
Expand Down
4 changes: 2 additions & 2 deletions india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
},
{
"fieldname": "bill_from_gst_category",
"label": "GST Category",
"label": "Bill From GST Category",
"fieldtype": "Data",
"insert_after": "bill_from_gstin",
"read_only": 1,
Expand Down Expand Up @@ -249,7 +249,7 @@
},
{
"fieldname": "bill_to_gst_category",
"label": "GST Category",
"label": "Bill To GST Category",
"fieldtype": "Data",
"insert_after": "bill_to_gstin",
"read_only": 1,
Expand Down
Loading

0 comments on commit 306afc0

Please sign in to comment.