fix: POS Closing Entry load all invoices with one request on save (#35819)
fix: POS Closing Entry load all invoices with one request on save (#35819)
fix: load all invoices with one request
(cherry picked from commit 1e20016059)
Co-authored-by: HarryPaulo <paulo_fabris@hotmail.com>
This commit is contained in:
@@ -123,22 +123,29 @@ frappe.ui.form.on('POS Closing Entry', {
|
|||||||
row.expected_amount = row.opening_amount;
|
row.expected_amount = row.opening_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pos_inv_promises = frm.doc.pos_transactions.map(
|
await Promise.all([
|
||||||
row => frappe.db.get_doc("POS Invoice", row.pos_invoice)
|
frappe.call({
|
||||||
);
|
method: 'erpnext.accounts.doctype.pos_closing_entry.pos_closing_entry.get_pos_invoices',
|
||||||
|
args: {
|
||||||
const pos_invoices = await Promise.all(pos_inv_promises);
|
start: frappe.datetime.get_datetime_as_string(frm.doc.period_start_date),
|
||||||
|
end: frappe.datetime.get_datetime_as_string(frm.doc.period_end_date),
|
||||||
for (let doc of pos_invoices) {
|
pos_profile: frm.doc.pos_profile,
|
||||||
frm.doc.grand_total += flt(doc.grand_total);
|
user: frm.doc.user
|
||||||
frm.doc.net_total += flt(doc.net_total);
|
},
|
||||||
frm.doc.total_quantity += flt(doc.total_qty);
|
callback: (r) => {
|
||||||
refresh_payments(doc, frm);
|
let pos_invoices = r.message;
|
||||||
refresh_taxes(doc, frm);
|
for (let doc of pos_invoices) {
|
||||||
refresh_fields(frm);
|
frm.doc.grand_total += flt(doc.grand_total);
|
||||||
set_html_data(frm);
|
frm.doc.net_total += flt(doc.net_total);
|
||||||
}
|
frm.doc.total_quantity += flt(doc.total_qty);
|
||||||
|
refresh_payments(doc, frm);
|
||||||
|
refresh_taxes(doc, frm);
|
||||||
|
refresh_fields(frm);
|
||||||
|
set_html_data(frm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
])
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user