Skip to content

Commit

Permalink
Merge pull request #42477 from ruthra-kumar/incorrect_cost_center_on_…
Browse files Browse the repository at this point in the history
…AR_AP_report

fix: incorrect cost_center on AR/AP report
  • Loading branch information
ruthra-kumar authored Jul 26, 2024
2 parents 723ac0f + 9a0894f commit 0d77e0b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def init_voucher_balance(self):
paid_in_account_currency=0.0,
credit_note_in_account_currency=0.0,
outstanding_in_account_currency=0.0,
cost_center=ple.cost_center,
)
self.get_invoices(ple)

Expand Down Expand Up @@ -253,7 +254,7 @@ def update_voucher_balance(self, ple):
row.paid -= amount
row.paid_in_account_currency -= amount_in_account_currency

if ple.cost_center:
if not row.cost_center and ple.cost_center:
row.cost_center = str(ple.cost_center)

def update_sub_total_row(self, row, party):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ def create_sales_invoice(self, no_payment_schedule=False, do_not_submit=False):
si = si.submit()
return si

def create_payment_entry(self, docname):
def create_payment_entry(self, docname, do_not_submit=False):
pe = get_payment_entry("Sales Invoice", docname, bank_account=self.cash, party_amount=40)
pe.paid_from = self.debit_to
pe.insert()
pe.submit()
if not do_not_submit:
pe.submit()
return pe

def create_credit_note(self, docname, do_not_submit=False):
credit_note = create_sales_invoice(
Expand Down Expand Up @@ -984,3 +986,40 @@ def test_accounts_receivable_output_for_minor_outstanding(self):
expected_data_after_payment,
[row.invoice_grand_total, row.invoiced, row.paid, row.outstanding],
)

def test_cost_center_on_report_output(self):
filters = {
"company": self.company,
"report_date": today(),
"range1": 30,
"range2": 60,
"range3": 90,
"range4": 120,
}

# check invoice grand total and invoiced column's value for 3 payment terms
si = self.create_sales_invoice(no_payment_schedule=True, do_not_submit=True)
si.cost_center = self.cost_center
si.save().submit()

new_cc = frappe.get_doc(
{
"doctype": "Cost Center",
"cost_center_name": "East Wing",
"parent_cost_center": self.company + " - " + self.company_abbr,
"company": self.company,
}
)
new_cc.save()

# check invoice grand total, invoiced, paid and outstanding column's value after payment
pe = self.create_payment_entry(si.name, do_not_submit=True)
pe.cost_center = new_cc.name
pe.save().submit()
report = execute(filters)

expected_data_after_payment = [si.name, si.cost_center, 60]

self.assertEqual(len(report[1]), 1)
row = report[1][0]
self.assertEqual(expected_data_after_payment, [row.voucher_no, row.cost_center, row.outstanding])

0 comments on commit 0d77e0b

Please sign in to comment.