fix: payments duplicate on pos closing entry (#30976)

This commit is contained in:
HarryPaulo 2022-05-13 06:36:02 -03:00 committed by GitHub
parent b0c10102de
commit 328b1b54d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,13 +64,15 @@ frappe.ui.form.on('POS Closing Entry', {
pos_opening_entry(frm) { pos_opening_entry(frm) {
if (frm.doc.pos_opening_entry && frm.doc.period_start_date && frm.doc.period_end_date && frm.doc.user) { if (frm.doc.pos_opening_entry && frm.doc.period_start_date && frm.doc.period_end_date && frm.doc.user) {
reset_values(frm); reset_values(frm);
frm.trigger("set_opening_amounts"); frappe.run_serially([
frm.trigger("get_pos_invoices"); () => frm.trigger("set_opening_amounts"),
() => frm.trigger("get_pos_invoices")
]);
} }
}, },
set_opening_amounts(frm) { set_opening_amounts(frm) {
frappe.db.get_doc("POS Opening Entry", frm.doc.pos_opening_entry) return frappe.db.get_doc("POS Opening Entry", frm.doc.pos_opening_entry)
.then(({ balance_details }) => { .then(({ balance_details }) => {
balance_details.forEach(detail => { balance_details.forEach(detail => {
frm.add_child("payment_reconciliation", { frm.add_child("payment_reconciliation", {
@ -83,7 +85,7 @@ frappe.ui.form.on('POS Closing Entry', {
}, },
get_pos_invoices(frm) { get_pos_invoices(frm) {
frappe.call({ return frappe.call({
method: 'erpnext.accounts.doctype.pos_closing_entry.pos_closing_entry.get_pos_invoices', method: 'erpnext.accounts.doctype.pos_closing_entry.pos_closing_entry.get_pos_invoices',
args: { args: {
start: frappe.datetime.get_datetime_as_string(frm.doc.period_start_date), start: frappe.datetime.get_datetime_as_string(frm.doc.period_start_date),