Skip to content

Commit

Permalink
Merge pull request #34922 from ruthra-kumar/refactor_payment_entry_re…
Browse files Browse the repository at this point in the history
…f_details

refactor: refactor set_missing_values and set_missing_ref_details in Payment Entry
  • Loading branch information
ruthra-kumar authored Apr 20, 2023
2 parents ad662d3 + b7d6e30 commit fc6486d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def setup_party_account_field(self):
def validate(self):
self.setup_party_account_field()
self.set_missing_values()
self.set_missing_ref_details()
self.validate_payment_type()
self.validate_party_details()
self.set_exchange_rate()
Expand Down Expand Up @@ -219,11 +220,16 @@ def set_missing_values(self):
else self.paid_to_account_currency
)

self.set_missing_ref_details()

def set_missing_ref_details(self, force=False):
def set_missing_ref_details(
self, force: bool = False, update_ref_details_only_for: list | None = None
) -> None:
for d in self.get("references"):
if d.allocated_amount:
if update_ref_details_only_for and (
not (d.reference_doctype, d.reference_name) in update_ref_details_only_for
):
continue

ref_details = get_reference_details(
d.reference_doctype, d.reference_name, self.party_account_currency
)
Expand Down Expand Up @@ -1811,6 +1817,7 @@ def get_payment_entry(

pe.setup_party_account_field()
pe.set_missing_values()
pe.set_missing_ref_details()

update_accounting_dimensions(pe, doc)

Expand Down
1 change: 1 addition & 0 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ def update_reference_in_payment_entry(d, payment_entry, do_not_save=False):
payment_entry.flags.ignore_validate_update_after_submit = True
payment_entry.setup_party_account_field()
payment_entry.set_missing_values()
payment_entry.set_missing_ref_details()
payment_entry.set_amounts()

if not do_not_save:
Expand Down

0 comments on commit fc6486d

Please sign in to comment.