mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-16 02:11:39 +00:00
Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
@@ -50,7 +50,6 @@ repos:
|
|||||||
cypress/.*|
|
cypress/.*|
|
||||||
.*node_modules.*|
|
.*node_modules.*|
|
||||||
.*boilerplate.*|
|
.*boilerplate.*|
|
||||||
erpnext/public/js/controllers/.*|
|
|
||||||
erpnext/templates/pages/order.js|
|
erpnext/templates/pages/order.js|
|
||||||
erpnext/templates/includes/.*
|
erpnext/templates/includes/.*
|
||||||
)$
|
)$
|
||||||
|
|||||||
@@ -16,13 +16,15 @@ erpnext.accounts.taxes = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onload: function(frm) {
|
onload: function (frm) {
|
||||||
if(frm.get_field("taxes")) {
|
if (frm.get_field("taxes")) {
|
||||||
frm.set_query("account_head", "taxes", function(doc) {
|
frm.set_query("account_head", "taxes", function (doc) {
|
||||||
if(frm.cscript.tax_table == "Sales Taxes and Charges") {
|
let account_type = ["Tax", "Chargeable"];
|
||||||
var account_type = ["Tax", "Chargeable", "Expense Account"];
|
|
||||||
|
if (frm.cscript.tax_table == "Sales Taxes and Charges") {
|
||||||
|
account_type.push("Expense Account");
|
||||||
} else {
|
} else {
|
||||||
var account_type = ["Tax", "Chargeable", "Income Account", "Expenses Included In Valuation"];
|
account_type.push("Income Account", "Expenses Included In Valuation");
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
} else if(tax.charge_type == "On Net Total") {
|
} else if(tax.charge_type == "On Net Total") {
|
||||||
if (tax.account_head in item_tax_map) {
|
if (tax.account_head in item_tax_map) {
|
||||||
current_net_amount = item.net_amount
|
current_net_amount = item.net_amount
|
||||||
};
|
}
|
||||||
current_tax_amount = (tax_rate / 100.0) * item.net_amount;
|
current_tax_amount = (tax_rate / 100.0) * item.net_amount;
|
||||||
} else if(tax.charge_type == "On Previous Row Amount") {
|
} else if(tax.charge_type == "On Previous Row Amount") {
|
||||||
current_net_amount = this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount_for_current_item
|
current_net_amount = this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount_for_current_item
|
||||||
@@ -862,12 +862,13 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
if(["Sales Invoice", "POS Invoice", "Purchase Invoice"].includes(this.frm.doc.doctype)) {
|
if(["Sales Invoice", "POS Invoice", "Purchase Invoice"].includes(this.frm.doc.doctype)) {
|
||||||
let grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
|
let grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
|
||||||
let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;
|
let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;
|
||||||
|
let total_amount_to_pay;
|
||||||
|
|
||||||
if(this.frm.doc.party_account_currency == this.frm.doc.currency) {
|
if(this.frm.doc.party_account_currency == this.frm.doc.currency) {
|
||||||
var total_amount_to_pay = flt((grand_total - this.frm.doc.total_advance
|
total_amount_to_pay = flt((grand_total - this.frm.doc.total_advance
|
||||||
- this.frm.doc.write_off_amount), precision("grand_total"));
|
- this.frm.doc.write_off_amount), precision("grand_total"));
|
||||||
} else {
|
} else {
|
||||||
var total_amount_to_pay = flt(
|
total_amount_to_pay = flt(
|
||||||
(flt(base_grand_total, precision("base_grand_total"))
|
(flt(base_grand_total, precision("base_grand_total"))
|
||||||
- this.frm.doc.total_advance - this.frm.doc.base_write_off_amount),
|
- this.frm.doc.total_advance - this.frm.doc.base_write_off_amount),
|
||||||
precision("base_grand_total")
|
precision("base_grand_total")
|
||||||
@@ -901,14 +902,15 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
|||||||
async set_total_amount_to_default_mop() {
|
async set_total_amount_to_default_mop() {
|
||||||
let grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
|
let grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
|
||||||
let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;
|
let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;
|
||||||
|
let total_amount_to_pay;
|
||||||
|
|
||||||
if (this.frm.doc.party_account_currency == this.frm.doc.currency) {
|
if (this.frm.doc.party_account_currency == this.frm.doc.currency) {
|
||||||
var total_amount_to_pay = flt(
|
total_amount_to_pay = flt(
|
||||||
grand_total - this.frm.doc.total_advance - this.frm.doc.write_off_amount,
|
grand_total - this.frm.doc.total_advance - this.frm.doc.write_off_amount,
|
||||||
precision("grand_total")
|
precision("grand_total")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
var total_amount_to_pay = flt(
|
total_amount_to_pay = flt(
|
||||||
(
|
(
|
||||||
flt(
|
flt(
|
||||||
base_grand_total,
|
base_grand_total,
|
||||||
|
|||||||
@@ -1007,13 +1007,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
|
|
||||||
var set_party_account = function(set_pricing) {
|
var set_party_account = function(set_pricing) {
|
||||||
if (["Sales Invoice", "Purchase Invoice"].includes(me.frm.doc.doctype)) {
|
if (["Sales Invoice", "Purchase Invoice"].includes(me.frm.doc.doctype)) {
|
||||||
if(me.frm.doc.doctype=="Sales Invoice") {
|
let party_type = me.frm.doc.doctype == "Sales Invoice" ? "Customer" : "Supplier";
|
||||||
var party_type = "Customer";
|
let party_account_field = me.frm.doc.doctype == "Sales Invoice" ? "debit_to" : "credit_to";
|
||||||
var party_account_field = 'debit_to';
|
|
||||||
} else {
|
|
||||||
var party_type = "Supplier";
|
|
||||||
var party_account_field = 'credit_to';
|
|
||||||
}
|
|
||||||
|
|
||||||
var party = me.frm.doc[frappe.model.scrub(party_type)];
|
var party = me.frm.doc[frappe.model.scrub(party_type)];
|
||||||
if(party && me.frm.doc.company && (!me.frm.doc.__onload?.load_after_mapping || !me.frm.doc[party_account_field])) {
|
if(party && me.frm.doc.company && (!me.frm.doc.__onload?.load_after_mapping || !me.frm.doc[party_account_field])) {
|
||||||
@@ -1427,7 +1422,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
let first_row = this.frm.doc.items[0];
|
let first_row = this.frm.doc.items[0];
|
||||||
if (!first_row) {
|
if (!first_row) {
|
||||||
return false
|
return false
|
||||||
};
|
}
|
||||||
|
|
||||||
let mapped_rows = mappped_fields.filter(d => first_row[d])
|
let mapped_rows = mappped_fields.filter(d => first_row[d])
|
||||||
|
|
||||||
@@ -1599,7 +1594,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
this.frm.set_currency_labels(["operating_cost", "hour_rate"], this.frm.doc.currency, "operations");
|
this.frm.set_currency_labels(["operating_cost", "hour_rate"], this.frm.doc.currency, "operations");
|
||||||
this.frm.set_currency_labels(["base_operating_cost", "base_hour_rate"], company_currency, "operations");
|
this.frm.set_currency_labels(["base_operating_cost", "base_hour_rate"], company_currency, "operations");
|
||||||
|
|
||||||
var item_grid = this.frm.fields_dict["operations"].grid;
|
let item_grid = this.frm.fields_dict["operations"].grid;
|
||||||
$.each(["base_operating_cost", "base_hour_rate"], function(i, fname) {
|
$.each(["base_operating_cost", "base_hour_rate"], function(i, fname) {
|
||||||
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
||||||
item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency);
|
item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency);
|
||||||
@@ -1610,7 +1605,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
this.frm.set_currency_labels(["rate", "amount"], this.frm.doc.currency, "scrap_items");
|
this.frm.set_currency_labels(["rate", "amount"], this.frm.doc.currency, "scrap_items");
|
||||||
this.frm.set_currency_labels(["base_rate", "base_amount"], company_currency, "scrap_items");
|
this.frm.set_currency_labels(["base_rate", "base_amount"], company_currency, "scrap_items");
|
||||||
|
|
||||||
var item_grid = this.frm.fields_dict["scrap_items"].grid;
|
let item_grid = this.frm.fields_dict["scrap_items"].grid;
|
||||||
$.each(["base_rate", "base_amount"], function(i, fname) {
|
$.each(["base_rate", "base_amount"], function(i, fname) {
|
||||||
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
||||||
item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency);
|
item_grid.set_column_disp(fname, me.frm.doc.currency != company_currency);
|
||||||
@@ -2005,7 +2000,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
row_to_modify[key] = pr_row[key];
|
row_to_modify[key] = pr_row[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.frm.doc.hasOwnProperty("is_pos") && this.frm.doc.is_pos) {
|
if (Object.prototype.hasOwnProperty.call(this.frm.doc, "is_pos") && this.frm.doc.is_pos) {
|
||||||
let r = await frappe.db.get_value("POS Profile", this.frm.doc.pos_profile, "cost_center");
|
let r = await frappe.db.get_value("POS Profile", this.frm.doc.pos_profile, "cost_center");
|
||||||
if (r.message.cost_center) {
|
if (r.message.cost_center) {
|
||||||
row_to_modify["cost_center"] = r.message.cost_center;
|
row_to_modify["cost_center"] = r.message.cost_center;
|
||||||
@@ -2237,8 +2232,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if (!r.exc) {
|
if (!r.exc) {
|
||||||
$.each(me.frm.doc.items || [], function(i, item) {
|
$.each(me.frm.doc.items || [], function (i, item) {
|
||||||
if (item.name && r.message.hasOwnProperty(item.name) && r.message[item.name].item_tax_template) {
|
if (
|
||||||
|
item.name &&
|
||||||
|
Object.prototype.hasOwnProperty.call(r.message, item.name) &&
|
||||||
|
r.message[item.name].item_tax_template
|
||||||
|
) {
|
||||||
item.item_tax_template = r.message[item.name].item_tax_template;
|
item.item_tax_template = r.message[item.name].item_tax_template;
|
||||||
item.item_tax_rate = r.message[item.name].item_tax_rate;
|
item.item_tax_rate = r.message[item.name].item_tax_rate;
|
||||||
me.add_taxes_from_item_tax_template(item.item_tax_rate);
|
me.add_taxes_from_item_tax_template(item.item_tax_rate);
|
||||||
|
|||||||
Reference in New Issue
Block a user