-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #846 from resilient-tech/version-14-hotfix
- Loading branch information
Showing
18 changed files
with
843 additions
and
47 deletions.
There are no files selected for viewing
46 changes: 32 additions & 14 deletions
46
india_compliance/gst_india/client_scripts/journal_entry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,35 @@ | ||
frappe.ui.form.on("Journal Entry", { | ||
refresh: function(frm) { | ||
frm.set_query('company_address', function(doc) { | ||
if(!doc.company) { | ||
frappe.throw(__('Please set Company')); | ||
} | ||
company: set_gstin_options, | ||
}); | ||
|
||
async function set_gstin_options(frm) { | ||
const options = await india_compliance.get_gstin_options(frm.doc.company); | ||
frm.get_field("company_gstin").set_data(options); | ||
|
||
return { | ||
query: 'frappe.contacts.doctype.address.address.address_query', | ||
filters: { | ||
link_doctype: 'Company', | ||
link_name: doc.company | ||
} | ||
}; | ||
}); | ||
} | ||
frm.set_value("company_gstin", options.length === 1 ? options[0] : ""); | ||
} | ||
|
||
frappe.ui.form.on("Journal Entry Account", { | ||
account: toggle_company_gstin, | ||
accounts_remove: toggle_company_gstin, | ||
}); | ||
|
||
async function toggle_company_gstin(frm) { | ||
_toggle_company_gstin(frm, await contains_gst_account(frm)); | ||
} | ||
|
||
async function contains_gst_account(frm) { | ||
if (!frm.gst_accounts || frm.company !== frm.doc.company) { | ||
frm.gst_accounts = await india_compliance.get_account_options(frm.doc.company); | ||
frm.company = frm.doc.company; | ||
} | ||
|
||
return frm.doc.accounts.some(row => frm.gst_accounts.includes(row.account)); | ||
} | ||
|
||
function _toggle_company_gstin(frm, reqd) { | ||
if (frm.get_field("company_gstin").df.reqd !== reqd) { | ||
frm.set_df_property("company_gstin", "reqd", reqd); | ||
frm.refresh_field("company_gstin"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import frappe | ||
from frappe import _ | ||
|
||
from india_compliance.gst_india.overrides.transaction import ( | ||
is_indian_registered_company, | ||
) | ||
from india_compliance.gst_india.utils import get_all_gst_accounts | ||
|
||
|
||
def validate(doc, method=None): | ||
if doc.company_gstin or not is_indian_registered_company(doc): | ||
return | ||
|
||
gst_accounts = get_all_gst_accounts(doc.company) | ||
if doc.account not in gst_accounts: | ||
return | ||
|
||
frappe.throw( | ||
_("Company GSTIN is a mandatory field for accounting of GST Accounts.") | ||
) | ||
|
||
|
||
def update_gl_dict_with_regional_fields(doc, gl_dict): | ||
if doc.get("company_gstin"): | ||
gl_dict["company_gstin"] = doc.company_gstin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import frappe | ||
from frappe import _ | ||
|
||
from india_compliance.gst_india.overrides.transaction import ( | ||
is_indian_registered_company, | ||
) | ||
from india_compliance.gst_india.utils import get_all_gst_accounts | ||
|
||
|
||
def validate(doc, method=None): | ||
if doc.company_gstin or not is_indian_registered_company(doc): | ||
return | ||
|
||
# validate company_gstin | ||
contains_gst_account = False | ||
gst_accounts = get_all_gst_accounts(doc.company) | ||
for row in doc.accounts: | ||
if row.account in gst_accounts: | ||
contains_gst_account = True | ||
break | ||
|
||
if contains_gst_account: | ||
frappe.throw(_("Company GSTIN is mandatory if any GST account is present.")) |
Empty file.
Oops, something went wrong.