Skip to content

Commit

Permalink
Merge pull request #507 from resilient-tech/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
sagarvora authored Mar 10, 2023
2 parents 3f98e87 + 2868c76 commit df9c29d
Show file tree
Hide file tree
Showing 21 changed files with 164 additions and 84 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@

# sort lines in hooks
dec2438be2d63eff24da45d6c936ec846d8ab0df

# refactor window.ic => window.india_compliance
0907e8a6105c42293e7c7a2eb51024f9f6040baf
4 changes: 2 additions & 2 deletions india_compliance/gst_india/client_scripts/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set_gst_category(DOCTYPE);

frappe.ui.form.on(DOCTYPE, {
country(frm) {
ic.set_state_options(frm);
india_compliance.set_state_options(frm);

if (!frm.doc.country) return;

Expand All @@ -20,7 +20,7 @@ frappe.ui.form.on(DOCTYPE, {
}
},
async refresh(frm) {
ic.set_state_options(frm);
india_compliance.set_state_options(frm);

// set default values for GST fields
if (!frm.is_new() || !frm.doc.links || frm.doc.gstin) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ frappe.ui.form.on("Sales Invoice", {
resolve();
};

if (!is_irn_cancellable(frm) || !ic.is_e_invoice_enabled()) {
if (!is_irn_cancellable(frm) || !india_compliance.is_e_invoice_enabled()) {
const d = frappe.warn(
__("Cannot Cancel IRN"),
__(
Expand Down Expand Up @@ -159,7 +159,7 @@ function show_cancel_e_invoice_dialog(frm, callback) {

function is_e_invoice_applicable(frm) {
return (
ic.is_e_invoice_enabled() &&
india_compliance.is_e_invoice_enabled() &&
frm.doc.docstatus == 1 &&
frm.doc.company_gstin &&
frm.doc.gst_category != "Unregistered" &&
Expand Down
12 changes: 6 additions & 6 deletions india_compliance/gst_india/client_scripts/e_waybill_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function setup_e_waybill_actions(doctype) {
frm.set_value("gst_vehicle_type", get_vehicle_type(frm.doc));
},
setup(frm) {
if (!ic.is_api_enabled()) return;
if (!india_compliance.is_api_enabled()) return;

frappe.realtime.on("e_waybill_pdf_update", message => {
frappe.model.sync_docinfo(message);
Expand Down Expand Up @@ -59,7 +59,7 @@ function setup_e_waybill_actions(doctype) {
return;
}

if (!ic.is_api_enabled() || !is_e_waybill_generated_using_api(frm)) {
if (!india_compliance.is_api_enabled() || !is_e_waybill_generated_using_api(frm)) {
return;
}

Expand Down Expand Up @@ -118,7 +118,7 @@ function setup_e_waybill_actions(doctype) {
frm.doc.ewaybill ||
frm.doc.is_return ||
frm.doc.is_debit_note ||
!ic.is_api_enabled() ||
!india_compliance.is_api_enabled() ||
!gst_settings.auto_generate_e_waybill ||
is_e_invoice_applicable(frm) ||
!is_e_waybill_applicable(frm)
Expand All @@ -134,7 +134,7 @@ function setup_e_waybill_actions(doctype) {
},
before_cancel(frm) {
// if IRN is present, e-Waybill gets cancelled in e-Invoice action
if (!ic.is_api_enabled() || frm.doc.irn || !frm.doc.ewaybill) return;
if (!india_compliance.is_api_enabled() || frm.doc.irn || !frm.doc.ewaybill) return;

frappe.validated = false;

Expand Down Expand Up @@ -332,7 +332,7 @@ function show_generate_e_waybill_dialog(frm) {
});
}

const api_enabled = ic.is_api_enabled();
const api_enabled = india_compliance.is_api_enabled();

const d = new frappe.ui.Dialog({
title: __("Generate e-Waybill"),
Expand Down Expand Up @@ -668,7 +668,7 @@ function update_generation_dialog(dialog) {
}

function get_primary_action_label_for_generation(doc) {
const label = ic.is_api_enabled() ? __("Generate") : __("Download JSON");
const label = india_compliance.is_api_enabled() ? __("Generate") : __("Download JSON");

if (are_transport_details_available(doc)) {
return label;
Expand Down
4 changes: 2 additions & 2 deletions india_compliance/gst_india/client_scripts/party.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function set_gstin_query(doctype) {
frm._gstin_options_set_for = frm.doc.name;
const field = frm.get_field("gstin");
field.df.ignore_validation = true;
field.set_data(await ic.get_gstin_options(frm.doc.name, doctype));
field.set_data(await india_compliance.get_gstin_options(frm.doc.name, doctype));
},
});
}
Expand All @@ -132,7 +132,7 @@ function set_gst_category(doctype) {
gstin(frm) {
frm.set_value(
"gst_category",
ic.guess_gst_category(frm.doc.gstin, frm.doc.country)
india_compliance.guess_gst_category(frm.doc.gstin, frm.doc.country)
);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ frappe.listview_settings[DOCTYPE].onload = function (list_view) {
generate_e_waybill_json
);

if (ic.is_e_invoice_enabled())
if (india_compliance.is_e_invoice_enabled())
add_bulk_action_for_submitted_invoices(
list_view,
__("Enqueue Bulk e-Invoice Generation"),
Expand Down
21 changes: 17 additions & 4 deletions india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
gst_category_options = "\n".join(GST_CATEGORIES)
default_gst_category = "Unregistered"


def get_place_of_supply_options():
options = []

for state_name, state_number in STATE_NUMBERS.items():
options.append(f"{state_number}-{state_name}")

options.append("96-Other Countries")
return "\n".join(sorted(options))


party_fields = [
{
"fieldname": "tax_details_section",
Expand Down Expand Up @@ -83,10 +94,11 @@
{
"fieldname": "place_of_supply",
"label": "Place of Supply",
"fieldtype": "Data",
"fieldtype": "Autocomplete",
"options": get_place_of_supply_options(),
"insert_after": "company_gstin",
"print_hide": 1,
"read_only": 1,
"read_only": 0,
"translatable": 0,
},
{
Expand Down Expand Up @@ -164,10 +176,11 @@
{
"fieldname": "place_of_supply",
"label": "Place of Supply",
"fieldtype": "Data",
"fieldtype": "Autocomplete",
"options": get_place_of_supply_options(),
"insert_after": "gst_category",
"print_hide": 1,
"read_only": 1,
"read_only": 0,
"length": 50,
"translatable": 0,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ frappe.ui.form.on("GST Settings", {
frm.set_query("company", "credentials", company_query);
frm.set_query("gstin", "credentials", (_, cdt, cdn) => {
const row = frappe.get_doc(cdt, cdn);
return ic.get_gstin_query(row.company);
return india_compliance.get_gstin_query(row.company);
});
},
onload: show_ic_api_promo,
Expand Down
20 changes: 10 additions & 10 deletions india_compliance/gst_india/doctype/gst_settings/gst_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"label": "Accounts"
},
{
"depends_on": "eval: ic.is_api_enabled(doc)",
"depends_on": "eval: india_compliance.is_api_enabled(doc)",
"fieldname": "credentials_tab",
"fieldtype": "Tab Break",
"label": "Credentials"
Expand Down Expand Up @@ -124,22 +124,22 @@
},
{
"default": "1",
"depends_on": "eval: ic.is_api_enabled(doc) && doc.enable_e_waybill",
"depends_on": "eval: india_compliance.is_api_enabled(doc) && doc.enable_e_waybill",
"description": "If checked, a PDF of the e-Waybill will be automatically attached to the transaction after it's generation",
"fieldname": "attach_e_waybill_print",
"fieldtype": "Check",
"label": "Attach e-Waybill Print After Generation"
},
{
"default": "0",
"depends_on": "eval: ic.can_enable_api(doc)",
"depends_on": "eval: india_compliance.can_enable_api(doc)",
"description": "Enable this to use API features like e-Waybill / e-Invoice generation from your ERP",
"fieldname": "enable_api",
"fieldtype": "Check",
"label": "Enable API Features"
},
{
"depends_on": "eval: ic.is_api_enabled(doc)",
"depends_on": "eval: india_compliance.is_api_enabled(doc)",
"fieldname": "e_invoice_section",
"fieldtype": "Section Break",
"label": "e-Invoice"
Expand All @@ -166,16 +166,16 @@
},
{
"default": "1",
"depends_on": "eval: ic.is_api_enabled(doc) && doc.enable_e_waybill",
"depends_on": "eval: india_compliance.is_api_enabled(doc) && doc.enable_e_waybill",
"description": "e-Waybill will be automatically generated after Sales Invoice submission if the invoice value threshold is met, and data is available and valid",
"fieldname": "auto_generate_e_waybill",
"fieldtype": "Check",
"label": "Automatically Generate e-Waybill on Invoice Submission",
"read_only_depends_on": "eval: ic.is_api_enabled(doc) && doc.enable_e_invoice"
"read_only_depends_on": "eval: india_compliance.is_api_enabled(doc) && doc.enable_e_invoice"
},
{
"default": "1",
"depends_on": "eval: ic.is_api_enabled(doc) && doc.enable_e_waybill",
"depends_on": "eval: india_compliance.is_api_enabled(doc) && doc.enable_e_waybill",
"description": "Automatically fetch e-Waybill data after it's generation for printing or logging purposes. This will lead to one additional API request.",
"fieldname": "fetch_e_waybill_data",
"fieldtype": "Check",
Expand Down Expand Up @@ -217,7 +217,7 @@
"label": "Enable SEZ / Overseas Transactions"
},
{
"depends_on": "eval: ic.is_api_enabled(doc)",
"depends_on": "eval: india_compliance.is_api_enabled(doc)",
"fieldname": "other_apis_section",
"fieldtype": "Section Break",
"label": "Other APIs"
Expand All @@ -240,7 +240,7 @@
},
{
"default": "0",
"depends_on": "eval: ic.is_api_enabled(doc)",
"depends_on": "eval: india_compliance.is_api_enabled(doc)",
"description": "Enable this to explore GST API features in a test environment. API actions executed in sandbox mode won't affect your actual business data on the GST portal.",
"fieldname": "sandbox_mode",
"fieldtype": "Check",
Expand All @@ -250,7 +250,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-01-03 02:39:59.034386",
"modified": "2023-03-09 04:10:39.690511",
"modified_by": "Administrator",
"module": "GST India",
"name": "GST Settings",
Expand Down
23 changes: 22 additions & 1 deletion india_compliance/gst_india/overrides/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,34 @@ def test_purchase_from_unregistered_supplier(self):
doc.insert,
)

def test_purchase_with_different_place_of_supply(self):
if self.is_sales_doctype:
return

doc = create_transaction(
**self.transaction_details,
is_out_state=True,
do_not_save=True,
)

doc.place_of_supply = "96-Other Countries"
doc.save()

# place of supply shouldn't get overwritten
self.assertEqual(doc.place_of_supply, "96-Other Countries")

# IGST should get applied
self.assertIn("IGST", doc.taxes[-1].description)

def test_invalid_gst_account_type(self):
doc = create_transaction(**self.transaction_details, do_not_save=True)
doc.append(
"taxes",
{
"charge_type": "On Net Total",
"account_head": f"{'Input' if self.is_sales_doctype else 'Output'} Tax IGST - _TIRC",
"account_head": (
f"{'Input' if self.is_sales_doctype else 'Output'} Tax IGST - _TIRC"
),
"description": "IGST",
"rate": 18,
"cost_center": "Main - _TIRC",
Expand Down
28 changes: 20 additions & 8 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ def validate_items(doc):


def set_place_of_supply(doc, method=None):
doc.place_of_supply = get_place_of_supply(doc, doc.doctype)
if not doc.place_of_supply:
doc.place_of_supply = get_place_of_supply(doc, doc.doctype)


def is_inter_state_supply(doc):
Expand Down Expand Up @@ -479,11 +480,13 @@ def get_regional_round_off_accounts(company, account_list):


def update_party_details(party_details, doctype, company):
party_details.update(get_gst_details(party_details, doctype, company))
party_details.update(
get_gst_details(party_details, doctype, company, update_place_of_supply=True)
)


@frappe.whitelist()
def get_gst_details(party_details, doctype, company):
def get_gst_details(party_details, doctype, company, *, update_place_of_supply=False):
"""
This function does not check for permissions since it returns insensitive data
based on already sensitive input (party details)
Expand All @@ -506,11 +509,17 @@ def get_gst_details(party_details, doctype, company):
)
if not party_details.get(party_address_field):
party_gst_details = get_party_gst_details(party_details, is_sales_transaction)
# updating party details to get correct place of supply
party_details.update(party_gst_details)
gst_details.update(party_gst_details)

gst_details.place_of_supply = get_place_of_supply(party_details, doctype)
# updating party details to get correct place of supply
if party_gst_details:
party_details.update(party_gst_details)
gst_details.update(party_gst_details)

gst_details.place_of_supply = (
party_details.place_of_supply
if (not update_place_of_supply and party_details.place_of_supply)
else get_place_of_supply(party_details, doctype)
)

if is_sales_transaction:
source_gstin = party_details.company_gstin
Expand Down Expand Up @@ -589,9 +598,12 @@ def get_party_gst_details(party_details, is_sales_transaction):
"billing_address_gstin" if is_sales_transaction else "supplier_gstin"
)

if not (party := party_details.get(party_type.lower())):
return

return frappe.db.get_value(
party_type,
party_details[party_type.lower()],
party,
("gst_category", f"gstin as {gstin_fieldname}"),
as_dict=True,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ frappe.pages["india-compliance-account"].on_page_load = async function (wrapper)
"india_compliance_account.bundle.css",
]);

new ic.pages.IndiaComplianceAccountPage(wrapper);
new india_compliance.pages.IndiaComplianceAccountPage(wrapper);
};
2 changes: 1 addition & 1 deletion india_compliance/gst_india/report/gstr_1/gstr_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ frappe.query_reports["GSTR-1"] = {
"fieldtype": "Autocomplete",
"get_query": function () {
const company = frappe.query_report.get_filter_value('company');
return ic.get_gstin_query(company);
return india_compliance.get_gstin_query(company);
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion india_compliance/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[post_model_sync]
india_compliance.patches.v14.set_default_for_overridden_accounts_setting
execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #5
execute:from india_compliance.gst_india.setup import create_custom_fields; create_custom_fields() #6
execute:from india_compliance.gst_india.setup import create_property_setters; create_property_setters()
india_compliance.patches.post_install.update_custom_role_for_e_invoice_summary
india_compliance.patches.v14.remove_ecommerce_gstin_from_purchase_invoice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default {
if (!value) return set_error("GSTIN is required");
value = ic.validate_gstin(value);
value = india_compliance.validate_gstin(value);
if (!value) return set_error("Invalid GSTIN detected");
const { message, error } = await check_free_trial_eligibility(value);
Expand Down
Loading

0 comments on commit df9c29d

Please sign in to comment.