Merge pull request #36844 from ruthra-kumar/validation_error_on_payment_entry
fix: allocation error on partial payment against sales order
This commit is contained in:
commit
9895bc3246
@ -1993,10 +1993,15 @@ def get_reference_details(reference_doctype, reference_name, party_account_curre
|
|||||||
if not total_amount:
|
if not total_amount:
|
||||||
if party_account_currency == company_currency:
|
if party_account_currency == company_currency:
|
||||||
# for handling cases that don't have multi-currency (base field)
|
# for handling cases that don't have multi-currency (base field)
|
||||||
total_amount = ref_doc.get("base_grand_total") or ref_doc.get("grand_total")
|
total_amount = (
|
||||||
|
ref_doc.get("base_rounded_total")
|
||||||
|
or ref_doc.get("rounded_total")
|
||||||
|
or ref_doc.get("base_grand_total")
|
||||||
|
or ref_doc.get("grand_total")
|
||||||
|
)
|
||||||
exchange_rate = 1
|
exchange_rate = 1
|
||||||
else:
|
else:
|
||||||
total_amount = ref_doc.get("grand_total")
|
total_amount = ref_doc.get("rounded_total") or ref_doc.get("grand_total")
|
||||||
if not exchange_rate:
|
if not exchange_rate:
|
||||||
# Get the exchange rate from the original ref doc
|
# Get the exchange rate from the original ref doc
|
||||||
# or get it based on the posting date of the ref doc.
|
# or get it based on the posting date of the ref doc.
|
||||||
|
@ -1244,6 +1244,24 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
template.allocate_payment_based_on_payment_terms = 1
|
template.allocate_payment_based_on_payment_terms = 1
|
||||||
template.save()
|
template.save()
|
||||||
|
|
||||||
|
def test_allocation_validation_for_sales_order(self):
|
||||||
|
so = make_sales_order(do_not_save=True)
|
||||||
|
so.items[0].rate = 99.55
|
||||||
|
so.save().submit()
|
||||||
|
self.assertGreater(so.rounded_total, 0.0)
|
||||||
|
pe = get_payment_entry("Sales Order", so.name, bank_account="_Test Cash - _TC")
|
||||||
|
pe.paid_from = "Debtors - _TC"
|
||||||
|
pe.paid_amount = 45.55
|
||||||
|
pe.references[0].allocated_amount = 45.55
|
||||||
|
pe.save().submit()
|
||||||
|
pe = get_payment_entry("Sales Order", so.name, bank_account="_Test Cash - _TC")
|
||||||
|
pe.paid_from = "Debtors - _TC"
|
||||||
|
# No validation error should be thrown here.
|
||||||
|
pe.save().submit()
|
||||||
|
|
||||||
|
so.reload()
|
||||||
|
self.assertEqual(so.advance_paid, so.rounded_total)
|
||||||
|
|
||||||
|
|
||||||
def create_payment_entry(**args):
|
def create_payment_entry(**args):
|
||||||
payment_entry = frappe.new_doc("Payment Entry")
|
payment_entry = frappe.new_doc("Payment Entry")
|
||||||
|
Loading…
Reference in New Issue
Block a user