mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 23:48:38 +00:00
fix: clear stale payment rows on non-POS returns so they don't surface in bank reconciliation (backport #55903) (#56169)
fix: clear stale payment rows on non-POS returns so they don't surface in bank reconciliation (#55903)
(cherry picked from commit 322d4dff25)
# Conflicts:
# erpnext/accounts/doctype/sales_invoice/sales_invoice.py
# erpnext/accounts/doctype/sales_invoice/services/pos.py
Co-authored-by: Jatin3128 <140256508+Jatin3128@users.noreply.github.com>
This commit is contained in:
@@ -455,8 +455,8 @@ class SalesInvoice(SellingController):
|
|||||||
self.calculate_taxes_and_totals()
|
self.calculate_taxes_and_totals()
|
||||||
|
|
||||||
def before_save(self):
|
def before_save(self):
|
||||||
self.set_account_for_mode_of_payment()
|
|
||||||
self.set_paid_amount()
|
self.set_paid_amount()
|
||||||
|
self.set_account_for_mode_of_payment()
|
||||||
|
|
||||||
def before_submit(self):
|
def before_submit(self):
|
||||||
self.add_remarks()
|
self.add_remarks()
|
||||||
@@ -791,6 +791,13 @@ class SalesInvoice(SellingController):
|
|||||||
def set_paid_amount(self):
|
def set_paid_amount(self):
|
||||||
paid_amount = 0.0
|
paid_amount = 0.0
|
||||||
base_paid_amount = 0.0
|
base_paid_amount = 0.0
|
||||||
|
|
||||||
|
if not cint(self.is_pos) and self.is_return:
|
||||||
|
self.set("payments", [])
|
||||||
|
self.paid_amount = paid_amount
|
||||||
|
self.base_paid_amount = base_paid_amount
|
||||||
|
return
|
||||||
|
|
||||||
for data in self.payments:
|
for data in self.payments:
|
||||||
data.base_amount = flt(data.amount * self.conversion_rate, self.precision("base_paid_amount"))
|
data.base_amount = flt(data.amount * self.conversion_rate, self.precision("base_paid_amount"))
|
||||||
paid_amount += data.amount
|
paid_amount += data.amount
|
||||||
|
|||||||
@@ -1049,6 +1049,21 @@ class TestSalesInvoice(FrappeTestCase):
|
|||||||
self.assertEqual(pos_return.get("payments")[0].amount, -500)
|
self.assertEqual(pos_return.get("payments")[0].amount, -500)
|
||||||
self.assertEqual(pos_return.get("payments")[1].amount, -500)
|
self.assertEqual(pos_return.get("payments")[1].amount, -500)
|
||||||
|
|
||||||
|
def test_non_pos_return_clears_payment_rows(self):
|
||||||
|
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_sales_return
|
||||||
|
|
||||||
|
si = create_sales_invoice(do_not_save=True)
|
||||||
|
si.append("payments", {"mode_of_payment": "Cash", "amount": 100})
|
||||||
|
si.insert()
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
si_return = make_sales_return(si.name)
|
||||||
|
si_return.insert()
|
||||||
|
|
||||||
|
self.assertEqual(si_return.is_pos, 0)
|
||||||
|
self.assertEqual(si_return.get("payments"), [])
|
||||||
|
self.assertEqual(si_return.paid_amount, 0)
|
||||||
|
|
||||||
def test_pos_change_amount(self):
|
def test_pos_change_amount(self):
|
||||||
make_pos_profile(
|
make_pos_profile(
|
||||||
company="_Test Company with perpetual inventory",
|
company="_Test Company with perpetual inventory",
|
||||||
|
|||||||
Reference in New Issue
Block a user