From 03b08e7a91428d21b48e41b5a503a285ab2085b7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 May 2016 16:28:39 +0530 Subject: [PATCH] [fix] Period closing voucher --- .../accounts/doctype/journal_entry/test_journal_entry.py | 4 ++-- .../period_closing_voucher/period_closing_voucher.py | 5 +++-- .../period_closing_voucher/test_period_closing_voucher.py | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index db295f450d..3e609ce291 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -172,9 +172,9 @@ class TestJournalEntry(unittest.TestCase): jv.submit() -def make_journal_entry(account1, account2, amount, cost_center=None, exchange_rate=1, save=True, submit=False): +def make_journal_entry(account1, account2, amount, cost_center=None, posting_date=None, exchange_rate=1, save=True, submit=False): jv = frappe.new_doc("Journal Entry") - jv.posting_date = "2013-02-14" + jv.posting_date = posting_date or "2013-02-14" jv.company = "_Test Company" jv.user_remark = "test" jv.multi_currency = 1 diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index d22f4d323d..04d4ed7078 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -55,6 +55,7 @@ class PeriodClosingVoucher(AccountsController): if flt(acc.balance_in_company_currency): gl_entries.append(self.get_gl_dict({ "account": acc.account, + "cost_center": acc.cost_center, "account_currency": acc.account_currency, "debit_in_account_currency": abs(flt(acc.balance_in_account_currency)) \ if flt(acc.balance_in_account_currency) < 0 else 0, @@ -84,12 +85,12 @@ class PeriodClosingVoucher(AccountsController): """Get balance for pl accounts""" return frappe.db.sql(""" select - t1.account, t2.account_currency, + t1.account, t1.cost_center, t2.account_currency, sum(t1.debit_in_account_currency) - sum(t1.credit_in_account_currency) as balance_in_account_currency, sum(t1.debit) - sum(t1.credit) as balance_in_company_currency from `tabGL Entry` t1, `tabAccount` t2 where t1.account = t2.name and t2.report_type = 'Profit and Loss' and t2.docstatus < 2 and t2.company = %s and t1.posting_date between %s and %s - group by t1.account + group by t1.account, t1.cost_center """, (self.company, self.get("year_start_date"), self.posting_date), as_dict=1) diff --git a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py index 1fdf002ec9..6f5a663e49 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import unittest import frappe from frappe.utils import flt, today -from erpnext.accounts.utils import get_fiscal_year +from erpnext.accounts.utils import get_fiscal_year, now from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry class TestPeriodClosingVoucher(unittest.TestCase): @@ -14,10 +14,10 @@ class TestPeriodClosingVoucher(unittest.TestCase): year_start_date = get_fiscal_year(today())[1] make_journal_entry("_Test Bank - _TC", "Sales - _TC", 400, - "_Test Cost Center - _TC", submit=True) + "_Test Cost Center - _TC", posting_date=now(), submit=True) make_journal_entry("_Test Account Cost for Goods Sold - _TC", - "_Test Bank - _TC", 600, "_Test Cost Center - _TC", submit=True) + "_Test Bank - _TC", 600, "_Test Cost Center - _TC", posting_date=now(), submit=True) random_expense_account = frappe.db.sql(""" select t1.account,