feat: add disabled field to Accounting Period

This commit is contained in:
rehansari26
2025-10-06 16:20:26 +05:30
parent a5a3f52c64
commit bd928e0d56
3 changed files with 15 additions and 2 deletions

View File

@@ -11,6 +11,7 @@
"end_date", "end_date",
"column_break_4", "column_break_4",
"company", "company",
"disabled",
"section_break_7", "section_break_7",
"closed_documents" "closed_documents"
], ],
@@ -49,6 +50,13 @@
"options": "Company", "options": "Company",
"reqd": 1 "reqd": 1
}, },
{
"default": "0",
"fieldname": "disabled",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Disabled"
},
{ {
"fieldname": "section_break_7", "fieldname": "section_break_7",
"fieldtype": "Section Break" "fieldtype": "Section Break"
@@ -62,10 +70,11 @@
} }
], ],
"links": [], "links": [],
"modified": "2024-03-27 13:05:57.388109", "modified": "2025-10-06 15:00:15.568067",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Accounting Period", "name": "Accounting Period",
"naming_rule": "By fieldname",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
@@ -105,6 +114,7 @@
"write": 1 "write": 1
} }
], ],
"row_format": "Dynamic",
"sort_field": "creation", "sort_field": "creation",
"sort_order": "DESC", "sort_order": "DESC",
"states": [], "states": [],

View File

@@ -28,6 +28,7 @@ class AccountingPeriod(Document):
closed_documents: DF.Table[ClosedDocument] closed_documents: DF.Table[ClosedDocument]
company: DF.Link company: DF.Link
disabled: DF.Check
end_date: DF.Date end_date: DF.Date
period_name: DF.Data period_name: DF.Data
start_date: DF.Date start_date: DF.Date
@@ -116,6 +117,7 @@ def validate_accounting_period_on_doc_save(doc, method=None):
.where( .where(
(ap.name == cd.parent) (ap.name == cd.parent)
& (ap.company == doc.company) & (ap.company == doc.company)
& (ap.disabled == 0)
& (cd.closed == 1) & (cd.closed == 1)
& (cd.document_type == doc.doctype) & (cd.document_type == doc.doctype)
& (date >= ap.start_date) & (date >= ap.start_date)

View File

@@ -159,6 +159,7 @@ def validate_accounting_period(gl_map):
WHERE WHERE
ap.name = cd.parent ap.name = cd.parent
AND ap.company = %(company)s AND ap.company = %(company)s
AND ap.disabled = 0
AND cd.closed = 1 AND cd.closed = 1
AND cd.document_type = %(voucher_type)s AND cd.document_type = %(voucher_type)s
AND %(date)s between ap.start_date and ap.end_date AND %(date)s between ap.start_date and ap.end_date