mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
fix: avoid double reduction of pe reference outstanding (#54193)
Co-authored-by: diptanilsaha <diptanil@frappe.io>
This commit is contained in:
@@ -195,6 +195,30 @@ class TestPaymentEntry(ERPNextTestSuite):
|
|||||||
outstanding_amount = flt(frappe.db.get_value("Sales Invoice", si.name, "outstanding_amount"))
|
outstanding_amount = flt(frappe.db.get_value("Sales Invoice", si.name, "outstanding_amount"))
|
||||||
self.assertEqual(outstanding_amount, 100)
|
self.assertEqual(outstanding_amount, 100)
|
||||||
|
|
||||||
|
def test_reference_outstanding_amount_on_advance_pull(self):
|
||||||
|
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
|
||||||
|
|
||||||
|
so = make_sales_order(qty=1, rate=1000)
|
||||||
|
pe = get_payment_entry("Sales Order", so.name, bank_account="_Test Cash - _TC")
|
||||||
|
pe.paid_amount = pe.received_amount = 500
|
||||||
|
pe.references[0].allocated_amount = 500
|
||||||
|
pe.insert()
|
||||||
|
pe.submit()
|
||||||
|
|
||||||
|
so.reload()
|
||||||
|
self.assertEqual(so.advance_paid, 500)
|
||||||
|
|
||||||
|
si = make_sales_invoice(so.name)
|
||||||
|
si.allocate_advances_automatically = 1
|
||||||
|
si.save()
|
||||||
|
self.assertEqual(si.get("advances")[0].allocated_amount, 500)
|
||||||
|
self.assertEqual(si.get("advances")[0].reference_name, pe.name)
|
||||||
|
si.submit()
|
||||||
|
|
||||||
|
pe.load_from_db()
|
||||||
|
self.assertEqual(pe.references[0].reference_name, si.name)
|
||||||
|
self.assertEqual(pe.references[0].outstanding_amount, si.outstanding_amount)
|
||||||
|
|
||||||
def test_payment_entry_against_pi(self):
|
def test_payment_entry_against_pi(self):
|
||||||
pi = make_purchase_invoice(
|
pi = make_purchase_invoice(
|
||||||
supplier="_Test Supplier USD",
|
supplier="_Test Supplier USD",
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import date, datetime
|
|
||||||
from json import loads
|
from json import loads
|
||||||
from typing import TYPE_CHECKING, Optional
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
@@ -31,6 +30,7 @@ from frappe.utils import (
|
|||||||
nowdate,
|
nowdate,
|
||||||
)
|
)
|
||||||
from frappe.utils.caching import site_cache
|
from frappe.utils.caching import site_cache
|
||||||
|
from frappe.utils.data import DateTimeLikeObject
|
||||||
from pypika import Order
|
from pypika import Order
|
||||||
from pypika.functions import Coalesce
|
from pypika.functions import Coalesce
|
||||||
from pypika.terms import ExistsCriterion
|
from pypika.terms import ExistsCriterion
|
||||||
@@ -61,7 +61,7 @@ OUTSTANDING_DOCTYPES = frozenset(["Sales Invoice", "Purchase Invoice", "Fees"])
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_fiscal_year(
|
def get_fiscal_year(
|
||||||
date: str | datetime | None = None,
|
date: DateTimeLikeObject | None = None,
|
||||||
fiscal_year: str | None = None,
|
fiscal_year: str | None = None,
|
||||||
label: str = "Date",
|
label: str = "Date",
|
||||||
verbose: int = 1,
|
verbose: int = 1,
|
||||||
@@ -201,7 +201,7 @@ def validate_fiscal_year(date, fiscal_year, company, label="Date", doc=None):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_balance_on(
|
def get_balance_on(
|
||||||
account: str | None = None,
|
account: str | None = None,
|
||||||
date: str | date | None = None,
|
date: DateTimeLikeObject | None = None,
|
||||||
party_type: str | None = None,
|
party_type: str | None = None,
|
||||||
party: str | None = None,
|
party: str | None = None,
|
||||||
company: str | None = None,
|
company: str | None = None,
|
||||||
@@ -547,7 +547,7 @@ def reconcile_against_document(
|
|||||||
skip_ref_details_update_for_pe=skip_ref_details_update_for_pe,
|
skip_ref_details_update_for_pe=skip_ref_details_update_for_pe,
|
||||||
dimensions_dict=dimensions_dict,
|
dimensions_dict=dimensions_dict,
|
||||||
)
|
)
|
||||||
if referenced_row.get("outstanding_amount"):
|
if referenced_row.get("outstanding_amount") and entry.get("outstanding_amount") is None:
|
||||||
referenced_row.outstanding_amount -= flt(entry.allocated_amount)
|
referenced_row.outstanding_amount -= flt(entry.allocated_amount)
|
||||||
|
|
||||||
reposting_rows.append(referenced_row)
|
reposting_rows.append(referenced_row)
|
||||||
|
|||||||
Reference in New Issue
Block a user