diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index d68220c2e8f..b30966836b0 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1899,7 +1899,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 @@ -1917,6 +1917,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"]); });