2023-02-23 16:46:37 +05:30
|
|
|
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: MIT. See LICENSE
|
|
|
|
|
|
|
|
|
2023-02-26 16:06:04 +05:30
|
|
|
import frappe
|
|
|
|
|
|
|
|
from erpnext.accounts.utils import get_fiscal_year
|
2023-02-23 16:46:37 +05:30
|
|
|
|
|
|
|
|
|
|
|
def execute():
|
2023-02-26 16:06:04 +05:30
|
|
|
company_wise_order = {}
|
|
|
|
for pcv in frappe.db.get_all(
|
|
|
|
"Period Closing Voucher",
|
|
|
|
fields=["company", "posting_date", "name"],
|
|
|
|
filters={"docstatus": 1},
|
|
|
|
order_by="posting_date",
|
|
|
|
):
|
|
|
|
|
|
|
|
company_wise_order.setdefault(pcv.company, [])
|
|
|
|
if pcv.posting_date not in company_wise_order[pcv.company]:
|
|
|
|
pcv_doc = frappe.get_doc("Period Closing Voucher", pcv.name)
|
|
|
|
pcv_doc.year_start_date = get_fiscal_year(
|
|
|
|
pcv.posting_date, pcv.fiscal_year, company=pcv.company
|
|
|
|
)[1]
|
|
|
|
pcv_doc.make_closing_entries()
|
|
|
|
company_wise_order[pcv.company].append(pcv.posting_date)
|