fix: adding cost center on pos invoice items while applying product discount (backport #46082) (#46322)

fix: adding cost center on pos invoice items while applying product discount (#46082)

(cherry picked from commit 926e4ecc4f)

Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
mergify[bot]
2025-03-05 15:22:46 +05:30
committed by GitHub
parent e3ce17bd6e
commit 9a433a6750

View File

@@ -1857,7 +1857,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
@@ -1875,6 +1875,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"]);
});