Skip to content

Commit

Permalink
fix: ambiguous 'cost_center' on payment reconciliation
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Nov 11, 2022
1 parent 5fdadda commit e9e5ded
Showing 1 changed file with 15 additions and 3 deletions.
Expand Up @@ -47,6 +47,10 @@ def get_nonreconciled_payment_entries(self):
def get_payment_entries(self):
order_doctype = "Sales Order" if self.party_type == "Customer" else "Purchase Order"
condition = self.get_conditions(get_payments=True)

if self.get("cost_center"):
condition += " and cost_center = '{0}' ".format(self.cost_center)

payment_entries = get_advance_payment_entries(
self.party_type,
self.party,
Expand All @@ -61,6 +65,10 @@ def get_payment_entries(self):

def get_jv_entries(self):
condition = self.get_conditions()

if self.get("cost_center"):
condition += " and t2.cost_center = '{0}' ".format(self.cost_center)

dr_or_cr = (
"credit_in_account_currency"
if erpnext.get_party_account_type(self.party_type) == "Receivable"
Expand Down Expand Up @@ -113,6 +121,10 @@ def get_jv_entries(self):

def get_dr_or_cr_notes(self):
condition = self.get_conditions(get_return_invoices=True)

if self.get("cost_center"):
condition += " and doc.cost_center = '{0}' ".format(self.cost_center)

dr_or_cr = (
"credit_in_account_currency"
if erpnext.get_party_account_type(self.party_type) == "Receivable"
Expand Down Expand Up @@ -172,6 +184,9 @@ def get_invoice_entries(self):

condition = self.get_conditions(get_invoices=True)

if self.get("cost_center"):
condition += " and cost_center = '{0}' ".format(self.cost_center)

non_reconciled_invoices = get_outstanding_invoices(
self.party_type, self.party, self.receivable_payable_account, condition=condition
)
Expand Down Expand Up @@ -357,9 +372,6 @@ def validate_allocation(self):
def get_conditions(self, get_invoices=False, get_payments=False, get_return_invoices=False):
condition = " and company = '{0}' ".format(self.company)

if self.get("cost_center"):
condition = " and cost_center = '{0}' ".format(self.cost_center)

if get_invoices:
condition += (
" and posting_date >= {0}".format(frappe.db.escape(self.from_invoice_date))
Expand Down

0 comments on commit e9e5ded

Please sign in to comment.