fix: Closing balance entries for period closing voucher
This commit is contained in:
parent
a663df376c
commit
436fc03eda
@ -15,11 +15,10 @@
|
||||
"debit_in_account_currency",
|
||||
"credit_in_account_currency",
|
||||
"project",
|
||||
"is_opening",
|
||||
"fiscal_year",
|
||||
"company",
|
||||
"finance_book",
|
||||
"period_closing_voucher"
|
||||
"period_closing_voucher",
|
||||
"is_period_closing_voucher_entry"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@ -94,24 +93,6 @@
|
||||
"label": "Project",
|
||||
"options": "Project"
|
||||
},
|
||||
{
|
||||
"fieldname": "is_opening",
|
||||
"fieldtype": "Select",
|
||||
"in_filter": 1,
|
||||
"label": "Is Opening",
|
||||
"oldfieldname": "is_opening",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "No\nYes"
|
||||
},
|
||||
{
|
||||
"fieldname": "fiscal_year",
|
||||
"fieldtype": "Link",
|
||||
"in_filter": 1,
|
||||
"label": "Fiscal Year",
|
||||
"oldfieldname": "fiscal_year",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "Fiscal Year"
|
||||
},
|
||||
{
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
@ -136,12 +117,18 @@
|
||||
"in_standard_filter": 1,
|
||||
"label": "Period Closing Voucher",
|
||||
"options": "Period Closing Voucher"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "is_period_closing_voucher_entry",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Period Closing Voucher Entry"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-list",
|
||||
"in_create": 1,
|
||||
"links": [],
|
||||
"modified": "2023-02-24 18:11:11.612395",
|
||||
"modified": "2023-02-27 19:47:36.658224",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Closing Balance",
|
||||
|
@ -35,10 +35,22 @@ class ClosingBalance(Document):
|
||||
self.credit += last_closing_balance[0].credit
|
||||
|
||||
|
||||
def make_closing_entries(closing_entries):
|
||||
def make_closing_entries(
|
||||
closing_entries, is_period_closing_voucher_entry=False, voucher_name=None
|
||||
):
|
||||
accounting_dimensions = get_accounting_dimensions()
|
||||
for entry in closing_entries:
|
||||
cle = frappe.new_doc("Closing Balance")
|
||||
cle.update(entry)
|
||||
|
||||
if is_period_closing_voucher_entry:
|
||||
cle.update(
|
||||
{
|
||||
"closing_date": entry.get("posting_date"),
|
||||
"is_period_closing_voucher_entry": 1,
|
||||
"period_closing_voucher": voucher_name,
|
||||
}
|
||||
)
|
||||
|
||||
cle.aggregate_with_last_closing_balance(accounting_dimensions)
|
||||
cle.submit()
|
||||
|
@ -92,13 +92,13 @@ class PeriodClosingVoucher(AccountsController):
|
||||
gl_entries = self.get_gl_entries()
|
||||
if gl_entries:
|
||||
if len(gl_entries) > 5000:
|
||||
frappe.enqueue(process_gl_entries, gl_entries=gl_entries, queue="long")
|
||||
frappe.enqueue(process_gl_entries, gl_entries=gl_entries, voucher_name=self.name, queue="long")
|
||||
frappe.msgprint(
|
||||
_("The GL Entries will be processed in the background, it can take a few minutes."),
|
||||
alert=True,
|
||||
)
|
||||
else:
|
||||
process_gl_entries(gl_entries)
|
||||
process_gl_entries(gl_entries, voucher_name=self.name)
|
||||
|
||||
def make_closing_entries(self):
|
||||
closing_entries = self.get_grouped_gl_entries()
|
||||
@ -285,11 +285,13 @@ def process_closing_entries(closing_entries):
|
||||
frappe.log_error(e)
|
||||
|
||||
|
||||
def process_gl_entries(gl_entries):
|
||||
def process_gl_entries(gl_entries, voucher_name=None):
|
||||
from erpnext.accounts.doctype.closing_balance.closing_balance import make_closing_entries
|
||||
from erpnext.accounts.general_ledger import make_gl_entries
|
||||
|
||||
try:
|
||||
make_gl_entries(gl_entries, merge_entries=False)
|
||||
make_closing_entries(gl_entries, is_period_closing_voucher_entry=True, voucher_name=voucher_name)
|
||||
frappe.db.set_value(
|
||||
"Period Closing Voucher", gl_entries[0].get("voucher_no"), "gle_processing_status", "Completed"
|
||||
)
|
||||
|
@ -16,6 +16,7 @@ from erpnext.accounts.utils import get_fiscal_year, now
|
||||
class TestPeriodClosingVoucher(unittest.TestCase):
|
||||
def test_closing_entry(self):
|
||||
frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'")
|
||||
frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'")
|
||||
|
||||
company = create_company()
|
||||
cost_center = create_cost_center("Test Cost Center 1")
|
||||
@ -65,6 +66,7 @@ class TestPeriodClosingVoucher(unittest.TestCase):
|
||||
|
||||
def test_cost_center_wise_posting(self):
|
||||
frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'")
|
||||
frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'")
|
||||
|
||||
company = create_company()
|
||||
surplus_account = create_account()
|
||||
@ -128,6 +130,7 @@ class TestPeriodClosingVoucher(unittest.TestCase):
|
||||
|
||||
def test_period_closing_with_finance_book_entries(self):
|
||||
frappe.db.sql("delete from `tabGL Entry` where company='Test PCV Company'")
|
||||
frappe.db.sql("delete from `tabPeriod Closing Voucher` where company='Test PCV Company'")
|
||||
|
||||
company = create_company()
|
||||
surplus_account = create_account()
|
||||
|
Loading…
x
Reference in New Issue
Block a user