Skip to content

Commit

Permalink
Merge pull request #2822 from resilient-tech/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
vorasmit authored Dec 6, 2024
2 parents 26cebc7 + 6265581 commit 3ee6ed4
Show file tree
Hide file tree
Showing 33 changed files with 472 additions and 692 deletions.
10 changes: 5 additions & 5 deletions india_compliance/gst_india/api_classes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def is_ignored_error(self, response_json):
pass

def handle_http_code(self, status_code, response_json):

# GSP connectivity issues
if status_code == 401 or (
status_code == 403
Expand Down Expand Up @@ -268,22 +267,23 @@ def mask_sensitive_info(self, log):
output = log.output
data = log.data
request_body = data and data.get("body")
placeholder = "*****"

for key in self.SENSITIVE_INFO:
if key in request_headers:
request_headers[key] = "*****"
request_headers[key] = placeholder

if output and key in output:
output[key] = "*****"
output[key] = placeholder

if not data:
continue

if key in data:
data[key] = "*****"
data[key] = placeholder

if request_body and key in request_body:
request_body[key] = "*****"
request_body[key] = placeholder


def get_public_ip():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,15 @@ frappe.ui.form.on(DOCTYPE, {
...filters,
supplied_items: get_supplied_items(doc),
},
}

};
else if (row.link_doctype == "Subcontracting Receipt")
return {
query: "india_compliance.gst_india.overrides.subcontracting_transaction.get_subcontracting_receipt_references",
filters: {
...filters,
received_items: get_received_items(doc),
}
}

},
};
});
},
onload(frm) {
Expand Down
8 changes: 4 additions & 4 deletions india_compliance/gst_india/constants/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"fieldtype": "Section Break",
"insert_after": "total",
"hide_border": 1,
"depends_on": "eval: doc.purchase_order && india_compliance.is_e_waybill_generatable_for_subcontracting(doc)",
"depends_on": "eval: doc.purchase_order && india_compliance.is_e_waybill_applicable_for_subcontracting(doc)",
},
],
"Subcontracting Receipt": [
Expand All @@ -66,7 +66,7 @@
"fieldtype": "Section Break",
"insert_after": "total",
"hide_border": 1,
"depends_on": "eval: india_compliance.is_e_waybill_generatable_for_subcontracting(doc)",
"depends_on": "eval: india_compliance.is_e_waybill_applicable_for_subcontracting(doc)",
},
{
"fieldname": "section_break_ref_doc",
Expand Down Expand Up @@ -182,14 +182,14 @@
"label": "Taxes",
"fieldtype": "Section Break",
"insert_after": "get_stock_and_rate",
"depends_on": "eval: india_compliance.is_e_waybill_generatable_for_subcontracting(doc)",
"depends_on": "eval: india_compliance.is_e_waybill_applicable_for_subcontracting(doc)",
},
{
"label": "E-Waybill Info",
"fieldname": "tab_break_ewaybill",
"fieldtype": "Tab Break",
"insert_after": "address_display",
"depends_on": "eval: india_compliance.is_e_waybill_generatable_for_subcontracting(doc)",
"depends_on": "eval: india_compliance.is_e_waybill_applicable_for_subcontracting(doc)",
},
{
"label": "e-Waybill Address",
Expand Down
230 changes: 1 addition & 229 deletions india_compliance/gst_india/doctype/bill_of_entry/bill_of_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,10 @@ frappe.ui.form.on("Bill of Entry Item", {
},
});

frappe.ui.form.on("Bill of Entry Taxes", {
rate(frm, cdt, cdn) {
frm.taxes_controller.update_tax_rate(cdt, cdn);
},

tax_amount(frm, cdt, cdn) {
frm.taxes_controller.update_tax_amount(cdt, cdn);
},

async account_head(frm, cdt, cdn) {
await frm.taxes_controller.set_item_wise_tax_rates(null, cdn);
frm.taxes_controller.update_tax_amount(cdt, cdn);
},

async charge_type(frm, cdt, cdn) {
const row = locals[cdt][cdn];
if (!row.charge_type || row.charge_type === "Actual") {
row.rate = 0;
row.item_wise_tax_rates = "{}";
frm.refresh_field("taxes");
} else {
await frm.taxes_controller.set_item_wise_tax_rates(null, cdn);
frm.taxes_controller.update_tax_amount(cdt, cdn);
}
},

taxes_remove(frm) {
frm.bill_of_entry_controller.update_total_taxes();
},
});

class BillOfEntryController {
constructor(frm) {
this.frm = frm;
this.frm.taxes_controller = new TaxesController(frm);
this.frm.taxes_controller = new india_compliance.taxes_controller(frm);
this.setup();
}

Expand Down Expand Up @@ -191,207 +160,10 @@ class BillOfEntryController {
);
}

update_total_taxes() {
const total_taxes = this.frm.doc.taxes.reduce(
(total, row) => total + row.tax_amount,
0
);
this.frm.set_value("total_taxes", total_taxes);
}

update_total_amount_payable() {
this.frm.set_value(
"total_amount_payable",
this.frm.doc.total_customs_duty + this.frm.doc.total_taxes
);
}
}

class TaxesController {
constructor(frm) {
this.frm = frm;
this.setup();
}

setup() {
this.fetch_round_off_accounts();
this.set_item_tax_template_query();
this.set_account_head_query();
}

fetch_round_off_accounts() {
if (this.frm.doc.docstatus !== 0 || !this.frm.doc.company) return;

frappe.call({
method: "erpnext.controllers.taxes_and_totals.get_round_off_applicable_accounts",
args: {
company: this.frm.doc.company,
account_list: [],
},
callback(r) {
if (r.message) {
frappe.flags.round_off_applicable_accounts = r.message;
}
},
});
}

set_item_tax_template_query() {
this.frm.set_query("item_tax_template", "items", () => {
return {
filters: {
company: this.frm.doc.company,
},
};
});
}

set_account_head_query() {
this.frm.set_query("account_head", "taxes", () => {
return {
filters: {
company: this.frm.doc.company,
is_group: 0,
},
};
});
}

async set_item_wise_tax_rates(item_name, tax_name) {
/**
* This method is used to set item wise tax rates from the server
* and update the item_wise_tax_rates field in the taxes table.
*
* @param {string} item_name - Item row name for which the tax rates are to be fetched.
* @param {string} tax_name - Tax row name for which the tax rates are to be fetched.
*/

if (!this.frm.taxes || !this.frm.taxes.length) return;

await this.frm.call("set_item_wise_tax_rates", {
item_name: item_name,
tax_name: tax_name,
});
}

update_item_wise_tax_rates(tax_row) {
/**
* This method is used to update the item_wise_tax_rates field in the taxes table when
* - Item tax template is removed from the item row.
* - Tax rate is changed in the tax row.
*
* It will update item rate with default tax rate.
*
* @param {object} tax_row - Tax row object.
*/

let taxes;
if (tax_row) taxes = [tax_row];
else taxes = this.frm.doc.taxes;

taxes.forEach(tax => {
const item_wise_tax_rates = JSON.parse(tax.item_wise_tax_rates || "{}");
this.frm.doc.items.forEach(item => {
if (item.item_tax_template) return;
item_wise_tax_rates[item.name] = tax.rate;
});
tax.item_wise_tax_rates = JSON.stringify(item_wise_tax_rates);
});
}

async update_tax_rate(cdt, cdn) {
const row = locals[cdt][cdn];
if (!row.charge_type || row.charge_type === "Actual") row.rate = 0;
else {
this.update_item_wise_tax_rates(row);
await this.update_tax_amount(cdt, cdn);
}
}

async update_tax_amount(cdt, cdn) {
/**
* This method is used to update the tax amount in the tax row
* - Update for all tax rows when cdt is null.
* - Update for a single tax row when cdt and cdn are passed.
*
* @param {string} cdt - DocType of the tax row.
* @param {string} cdn - Name of the tax row.
*/

let taxes;
if (cdt) taxes = [locals[cdt][cdn]];
else taxes = this.frm.doc.taxes;

taxes.forEach(async row => {
if (!row.charge_type || row.charge_type === "Actual") return;

let tax_amount = 0;

if (row.charge_type === "On Net Total") {
tax_amount = this.get_tax_on_net_total(row);
}

if (row.charge_type == "On Item Quantity") {
tax_amount = this.get_tax_on_item_quantity(row);
}

// update if tax amount is changed manually
if (tax_amount !== row.tax_amount) {
row.tax_amount = tax_amount;
}

if (
frappe.flags.round_off_applicable_accounts?.includes(row.account_head)
) {
row.tax_amount = Math.round(row.tax_amount);
}
});

this.update_total_amount();
this.frm.bill_of_entry_controller.update_total_taxes();
}

update_total_amount() {
this.frm.doc.taxes.reduce((total, row) => {
const total_amount = total + row.tax_amount;
row.total = total_amount;

return total_amount;
}, this.frm.doc.total_taxable_value);

this.frm.refresh_field("taxes");
}

get_tax_on_net_total(tax_row) {
/**
* This method is used to calculate the tax amount on net total
* based on the item wise tax rates.
*
* @param {object} tax_row - Tax row object.
*/

const item_wise_tax_rates = JSON.parse(tax_row.item_wise_tax_rates || "{}");
return this.frm.doc.items.reduce((total, item) => {
return (
total +
(item.taxable_value *
(item_wise_tax_rates[item.name] || tax_row.rate)) /
100
);
}, 0);
}

get_tax_on_item_quantity(tax_row) {
/**
* This method is used to calculate the tax amount on item quntity (cess non advol)
* based on the item wise tax rates and item quantity.
*
* @param {object} tax_row - Tax row object.
*/

const item_wise_tax_rates = JSON.parse(tax_row.item_wise_tax_rates || "{}");
return this.frm.doc.items.reduce((total, item) => {
return total + item.qty * (item_wise_tax_rates[item.name] || tax_row.rate);
}, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
{
"fieldname": "taxes",
"fieldtype": "Table",
"options": "Bill of Entry Taxes",
"options": "India Compliance Taxes and Charges",
"reqd": 1
},
{
Expand Down Expand Up @@ -297,7 +297,7 @@
"link_fieldname": "link_name"
}
],
"modified": "2023-12-13 16:43:40.501418",
"modified": "2024-08-12 15:48:43.769450",
"modified_by": "Administrator",
"module": "GST India",
"name": "Bill of Entry",
Expand Down
Loading

0 comments on commit 3ee6ed4

Please sign in to comment.