mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-29 22:58:25 +00:00
fix(selling): recompute proforma amount for all rows on qty change
Refreshing a single grid row only updates the active row, so the derived amount for rows after the edited one went stale. Recompute every row's amount from qty x rate and re-render the grid.
This commit is contained in:
@@ -123,11 +123,15 @@ Object.assign(erpnext.proforma, {
|
||||
label: __("Qty"),
|
||||
in_list_view: 1,
|
||||
onchange: function () {
|
||||
// In Quantity basis, Amount is derived (qty x rate). In Amount basis
|
||||
// both are user-entered, so leave Amount alone.
|
||||
if (this.doc && dialog.get_value("based_on") === "Quantity") {
|
||||
this.doc.amount = flt(this.doc.qty) * flt(this.doc.rate);
|
||||
this.grid_row?.refresh_field("amount");
|
||||
// In Quantity basis, Amount is derived (qty x rate). Recompute across
|
||||
// all rows and re-render — refreshing a single row only updates the
|
||||
// active one, so rows beyond the edited one would go stale.
|
||||
if (dialog.get_value("based_on") === "Quantity") {
|
||||
const grid = dialog.get_field("items").grid;
|
||||
(grid.grid_rows || []).forEach((row) => {
|
||||
if (row.doc) row.doc.amount = flt(row.doc.qty) * flt(row.doc.rate);
|
||||
});
|
||||
grid.refresh();
|
||||
}
|
||||
erpnext.proforma.update_warning(dialog);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user