mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
Merge branch 'develop' into unit-price-contract-2
This commit is contained in:
@@ -150,6 +150,19 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
});
|
||||
}
|
||||
|
||||
if (this.frm.fields_dict["items"].grid.get_field("uom")) {
|
||||
this.frm.set_query("uom", "items", function(doc, cdt, cdn) {
|
||||
let row = locals[cdt][cdn];
|
||||
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_item_uom_query",
|
||||
filters: {
|
||||
"item_code": row.item_code
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if(
|
||||
this.frm.docstatus < 2
|
||||
&& this.frm.fields_dict["payment_terms_template"]
|
||||
@@ -238,6 +251,15 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
}
|
||||
}
|
||||
|
||||
use_serial_batch_fields(frm, cdt, cdn) {
|
||||
const item = locals[cdt][cdn];
|
||||
if (!item.use_serial_batch_fields) {
|
||||
frappe.model.set_value(cdt, cdn, "serial_no", "");
|
||||
frappe.model.set_value(cdt, cdn, "batch_no", "");
|
||||
frappe.model.set_value(cdt, cdn, "rejected_serial_no", "");
|
||||
}
|
||||
}
|
||||
|
||||
set_fields_onload_for_line_item() {
|
||||
if (this.frm.is_new() && this.frm.doc?.items) {
|
||||
this.frm.doc.items.forEach(item => {
|
||||
@@ -335,7 +357,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
let d = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
docstatus: 1,
|
||||
docstatus: ["<", 2],
|
||||
inspection_type: inspection_type,
|
||||
reference_name: doc.name,
|
||||
item_code: d.item_code
|
||||
@@ -765,27 +787,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
});
|
||||
}
|
||||
|
||||
add_taxes_from_item_tax_template(item_tax_map) {
|
||||
let me = this;
|
||||
|
||||
if(item_tax_map && cint(frappe.defaults.get_default("add_taxes_from_item_tax_template"))) {
|
||||
if(typeof (item_tax_map) == "string") {
|
||||
item_tax_map = JSON.parse(item_tax_map);
|
||||
}
|
||||
|
||||
$.each(item_tax_map, function(tax, rate) {
|
||||
let found = (me.frm.doc.taxes || []).find(d => d.account_head === tax);
|
||||
if(!found) {
|
||||
let child = frappe.model.add_child(me.frm.doc, "taxes");
|
||||
child.charge_type = "On Net Total";
|
||||
child.account_head = tax;
|
||||
child.rate = 0;
|
||||
child.set_by_item_tax_template = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
serial_no(doc, cdt, cdn) {
|
||||
var me = this;
|
||||
var item = frappe.get_doc(cdt, cdn);
|
||||
@@ -1041,39 +1042,48 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
}
|
||||
}
|
||||
|
||||
due_date() {
|
||||
due_date(doc, cdt) {
|
||||
// due_date is to be changed, payment terms template and/or payment schedule must
|
||||
// be removed as due_date is automatically changed based on payment terms
|
||||
if (doc.doctype !== cdt) {
|
||||
// triggered by change to the due_date field in payment schedule child table
|
||||
// do nothing to avoid infinite clearing loop
|
||||
return;
|
||||
}
|
||||
|
||||
// if there is only one row in payment schedule child table, set its due date as the due date
|
||||
if (this.frm.doc.payment_schedule.length == 1){
|
||||
this.frm.doc.payment_schedule[0].due_date = this.frm.doc.due_date;
|
||||
if (doc.payment_schedule.length == 1){
|
||||
doc.payment_schedule[0].due_date = doc.due_date;
|
||||
this.frm.refresh_field("payment_schedule");
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
this.frm.doc.due_date &&
|
||||
doc.due_date &&
|
||||
!this.frm.updating_party_details &&
|
||||
!this.frm.doc.is_pos &&
|
||||
!doc.is_pos &&
|
||||
(
|
||||
this.frm.doc.payment_terms_template ||
|
||||
this.frm.doc.payment_schedule?.length
|
||||
doc.payment_terms_template ||
|
||||
doc.payment_schedule?.length
|
||||
)
|
||||
) {
|
||||
const to_clear = [];
|
||||
if (this.frm.doc.payment_terms_template) {
|
||||
to_clear.push("Payment Terms Template");
|
||||
if (doc.payment_terms_template) {
|
||||
to_clear.push(__(frappe.meta.get_label(cdt, "payment_terms_template")));
|
||||
}
|
||||
|
||||
if (this.frm.doc.payment_schedule?.length) {
|
||||
to_clear.push("Payment Schedule Table");
|
||||
if (doc.payment_schedule?.length) {
|
||||
to_clear.push(__(frappe.meta.get_label(cdt, "payment_schedule")));
|
||||
}
|
||||
|
||||
frappe.confirm(
|
||||
__(
|
||||
"Do you want to clear the selected {0}?",
|
||||
[frappe.utils.comma_and(to_clear.map(dt => __(dt)))]
|
||||
"For the new {0} to take effect, would you like to clear the current {1}?",
|
||||
[
|
||||
__(frappe.meta.get_label(cdt, "due_date")),
|
||||
frappe.utils.comma_and(to_clear)
|
||||
],
|
||||
"Clear payment terms template and/or payment schedule when due date is changed"
|
||||
),
|
||||
() => {
|
||||
this.frm.set_value("payment_terms_template", "");
|
||||
@@ -1373,6 +1383,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
() => this.calculate_stock_uom_rate(doc, cdt, cdn),
|
||||
() => this.apply_pricing_rule(item, true)
|
||||
]);
|
||||
} else {
|
||||
this.conversion_factor(doc, cdt, cdn, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1897,7 +1909,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
|
||||
const exist_items = items.map(row => { return {item_code: row.item_code, pricing_rules: row.pricing_rules};});
|
||||
|
||||
args.free_item_data.forEach(pr_row => {
|
||||
args.free_item_data.forEach(async pr_row => {
|
||||
let row_to_modify = {};
|
||||
|
||||
// If there are no free items, or if the current free item doesn't exist in the table, add it
|
||||
@@ -1915,6 +1927,14 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
for (let key in pr_row) {
|
||||
row_to_modify[key] = pr_row[key];
|
||||
}
|
||||
|
||||
if (this.frm.doc.hasOwnProperty("is_pos") && this.frm.doc.is_pos) {
|
||||
let r = await frappe.db.get_value("POS Profile", this.frm.doc.pos_profile, "cost_center");
|
||||
if (r.message.cost_center) {
|
||||
row_to_modify["cost_center"] = r.message.cost_center;
|
||||
}
|
||||
}
|
||||
|
||||
this.frm.script_manager.copy_from_first_row("items", row_to_modify, ["expense_account", "income_account"]);
|
||||
});
|
||||
|
||||
@@ -2514,6 +2534,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
'item_code': item.item_code,
|
||||
'valid_from': ["<=", doc.transaction_date || doc.bill_date || doc.posting_date],
|
||||
'item_group': item.item_group,
|
||||
"base_net_rate": item.base_net_rate,
|
||||
}
|
||||
|
||||
if (doc.tax_category)
|
||||
|
||||
Reference in New Issue
Block a user