mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
Merge remote-tracking branch 'upstream/version-13-hotfix' into dev-quality-inspection-accounts
This commit is contained in:
@@ -570,7 +570,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
weight_uom: item.weight_uom,
|
||||
manufacturer: item.manufacturer,
|
||||
stock_uom: item.stock_uom,
|
||||
pos_profile: me.frm.doc.doctype == 'Sales Invoice' ? me.frm.doc.pos_profile : '',
|
||||
pos_profile: cint(me.frm.doc.is_pos) ? me.frm.doc.pos_profile : '',
|
||||
cost_center: item.cost_center,
|
||||
tax_category: me.frm.doc.tax_category,
|
||||
item_tax_template: item.item_tax_template,
|
||||
@@ -648,6 +648,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
let key = item.name;
|
||||
me.apply_rule_on_other_items({key: item});
|
||||
}
|
||||
},
|
||||
() => {
|
||||
var company_currency = me.get_company_currency();
|
||||
me.update_item_grid_labels(company_currency);
|
||||
}
|
||||
]);
|
||||
}
|
||||
@@ -957,15 +961,15 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
(this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length)) {
|
||||
var message1 = "";
|
||||
var message2 = "";
|
||||
var final_message = "Please clear the ";
|
||||
var final_message = __("Please clear the") + " ";
|
||||
|
||||
if (this.frm.doc.payment_terms_template) {
|
||||
message1 = "selected Payment Terms Template";
|
||||
message1 = __("selected Payment Terms Template");
|
||||
final_message = final_message + message1;
|
||||
}
|
||||
|
||||
if ((this.frm.doc.payment_schedule || []).length) {
|
||||
message2 = "Payment Schedule Table";
|
||||
message2 = __("Payment Schedule Table");
|
||||
if (message1.length !== 0) message2 = " and " + message2;
|
||||
final_message = final_message + message2;
|
||||
}
|
||||
@@ -1111,6 +1115,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
to_currency: to_currency,
|
||||
args: args
|
||||
},
|
||||
freeze: true,
|
||||
freeze_message: __("Fetching exchange rates ..."),
|
||||
callback: function(r) {
|
||||
callback(flt(r.message));
|
||||
}
|
||||
@@ -1327,13 +1333,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
change_grid_labels: function(company_currency) {
|
||||
var me = this;
|
||||
|
||||
this.frm.set_currency_labels(["base_rate", "base_net_rate", "base_price_list_rate", "base_amount", "base_net_amount", "base_rate_with_margin"],
|
||||
company_currency, "items");
|
||||
this.update_item_grid_labels(company_currency);
|
||||
|
||||
this.frm.set_currency_labels(["rate", "net_rate", "price_list_rate", "amount", "net_amount", "stock_uom_rate", "rate_with_margin"],
|
||||
this.frm.doc.currency, "items");
|
||||
this.toggle_item_grid_columns(company_currency);
|
||||
|
||||
if(this.frm.fields_dict["operations"]) {
|
||||
if (this.frm.doc.operations && this.frm.doc.operations.length > 0) {
|
||||
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");
|
||||
|
||||
@@ -1344,7 +1348,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
});
|
||||
}
|
||||
|
||||
if(this.frm.fields_dict["scrap_items"]) {
|
||||
if (this.frm.doc.scrap_items && this.frm.doc.scrap_items.length > 0) {
|
||||
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");
|
||||
|
||||
@@ -1355,17 +1359,50 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
});
|
||||
}
|
||||
|
||||
if(this.frm.fields_dict["taxes"]) {
|
||||
if (this.frm.doc.taxes && this.frm.doc.taxes.length > 0) {
|
||||
this.frm.set_currency_labels(["tax_amount", "total", "tax_amount_after_discount"], this.frm.doc.currency, "taxes");
|
||||
|
||||
this.frm.set_currency_labels(["base_tax_amount", "base_total", "base_tax_amount_after_discount"], company_currency, "taxes");
|
||||
}
|
||||
|
||||
if(this.frm.fields_dict["advances"]) {
|
||||
if (this.frm.doc.advances && this.frm.doc.advances.length > 0) {
|
||||
this.frm.set_currency_labels(["advance_amount", "allocated_amount"],
|
||||
this.frm.doc.party_account_currency, "advances");
|
||||
}
|
||||
|
||||
this.update_payment_schedule_grid_labels(company_currency);
|
||||
},
|
||||
|
||||
update_item_grid_labels: function(company_currency) {
|
||||
this.frm.set_currency_labels([
|
||||
"base_rate", "base_net_rate", "base_price_list_rate",
|
||||
"base_amount", "base_net_amount", "base_rate_with_margin"
|
||||
], company_currency, "items");
|
||||
|
||||
this.frm.set_currency_labels([
|
||||
"rate", "net_rate", "price_list_rate", "amount",
|
||||
"net_amount", "stock_uom_rate", "rate_with_margin"
|
||||
], this.frm.doc.currency, "items");
|
||||
},
|
||||
|
||||
update_payment_schedule_grid_labels: function(company_currency) {
|
||||
const me = this;
|
||||
if (this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length > 0) {
|
||||
this.frm.set_currency_labels(["base_payment_amount", "base_outstanding", "base_paid_amount"],
|
||||
company_currency, "payment_schedule");
|
||||
this.frm.set_currency_labels(["payment_amount", "outstanding", "paid_amount"],
|
||||
this.frm.doc.currency, "payment_schedule");
|
||||
|
||||
var schedule_grid = this.frm.fields_dict["payment_schedule"].grid;
|
||||
$.each(["base_payment_amount", "base_outstanding", "base_paid_amount"], function(i, fname) {
|
||||
if (frappe.meta.get_docfield(schedule_grid.doctype, fname))
|
||||
schedule_grid.set_column_disp(fname, me.frm.doc.currency != company_currency);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
toggle_item_grid_columns: function(company_currency) {
|
||||
const me = this;
|
||||
// toggle columns
|
||||
var item_grid = this.frm.fields_dict["items"].grid;
|
||||
$.each(["base_rate", "base_price_list_rate", "base_amount", "base_rate_with_margin"], function(i, fname) {
|
||||
@@ -1385,9 +1422,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
if(frappe.meta.get_docfield(item_grid.doctype, fname))
|
||||
item_grid.set_column_disp(fname, (show && (me.frm.doc.currency != company_currency)));
|
||||
});
|
||||
|
||||
// set labels
|
||||
var $wrapper = $(this.frm.wrapper);
|
||||
},
|
||||
|
||||
recalculate: function() {
|
||||
@@ -2120,11 +2154,14 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
terms_template: doc.payment_terms_template,
|
||||
posting_date: posting_date,
|
||||
grand_total: doc.rounded_total || doc.grand_total,
|
||||
base_grand_total: doc.base_rounded_total || doc.base_grand_total,
|
||||
bill_date: doc.bill_date
|
||||
},
|
||||
callback: function(r) {
|
||||
if(r.message && !r.exc) {
|
||||
me.frm.set_value("payment_schedule", r.message);
|
||||
const company_currency = me.get_company_currency();
|
||||
me.update_payment_schedule_grid_labels(company_currency);
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -2132,6 +2169,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
},
|
||||
|
||||
payment_term: function(doc, cdt, cdn) {
|
||||
const me = this;
|
||||
var row = locals[cdt][cdn];
|
||||
if(row.payment_term) {
|
||||
frappe.call({
|
||||
@@ -2140,12 +2178,15 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
term: row.payment_term,
|
||||
bill_date: this.frm.doc.bill_date,
|
||||
posting_date: this.frm.doc.posting_date || this.frm.doc.transaction_date,
|
||||
grand_total: this.frm.doc.rounded_total || this.frm.doc.grand_total
|
||||
grand_total: this.frm.doc.rounded_total || this.frm.doc.grand_total,
|
||||
base_grand_total: this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total
|
||||
},
|
||||
callback: function(r) {
|
||||
if(r.message && !r.exc) {
|
||||
for (var d in r.message) {
|
||||
frappe.model.set_value(cdt, cdn, d, r.message[d]);
|
||||
const company_currency = me.get_company_currency();
|
||||
me.update_payment_schedule_grid_labels(company_currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user