Skip to content

Commit

Permalink
Merge pull request #29318 from frappe/mergify/bp/version-13-hotfix/pr…
Browse files Browse the repository at this point in the history
…-29182

fix: get project from PO into payment entry (backport #29182)
  • Loading branch information
deepeshgarg007 authored Jan 17, 2022
2 parents c2d58ba + 5da7e28 commit 7542dd3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


import json
from functools import reduce

import frappe
from frappe import ValidationError, _, scrub, throw
Expand Down Expand Up @@ -1524,6 +1525,10 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
pe.received_amount = received_amount
pe.letter_head = doc.get("letter_head")

if dt in ['Purchase Order', 'Sales Order', 'Sales Invoice', 'Purchase Invoice']:
pe.project = (doc.get('project') or
reduce(lambda prev,cur: prev or cur, [x.get('project') for x in doc.get('items')], None)) # get first non-empty project from items

if pe.party_type in ["Customer", "Supplier"]:
bank_account = get_party_bank_account(pe.party_type, pe.party)
pe.set("bank_account", bank_account)
Expand Down

0 comments on commit 7542dd3

Please sign in to comment.