Skip to content

Commit b45fc59

Browse files
authored
Merge branch 'frappe:develop' into develop
2 parents c93c0e5 + 1e297a0 commit b45fc59

306 files changed

Lines changed: 71330 additions & 38575 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

erpnext/accounts/doctype/accounts_settings/accounts_settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@
691691
}
692692
],
693693
"grid_page_length": 50,
694-
"hide_toolbar": 1,
694+
"hide_toolbar": 0,
695695
"icon": "icon-cog",
696696
"idx": 1,
697697
"index_web_pages_for_search": 1,

erpnext/accounts/doctype/bank_transaction/bank_transaction.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def before_update_after_submit(self):
139139
self.set_status()
140140

141141
def on_cancel(self):
142+
self.ignore_linked_doctypes = ["GL Entry"]
143+
142144
for payment_entry in self.payment_entries:
143145
self.delink_payment_entry(payment_entry)
144146

@@ -373,11 +375,12 @@ def get_clearance_details(transaction, payment_entry, bt_allocations, gl_entries
373375
("unallocated_amount", "bank_account"),
374376
as_dict=True,
375377
)
378+
bt_bank_account = frappe.db.get_value("Bank Account", bt.bank_account, "account")
376379

377-
if bt.bank_account != gl_bank_account:
380+
if bt_bank_account != gl_bank_account:
378381
frappe.throw(
379382
_("Bank Account {} in Bank Transaction {} is not matching with Bank Account {}").format(
380-
bt.bank_account, payment_entry.payment_entry, gl_bank_account
383+
bt_bank_account, payment_entry.payment_entry, gl_bank_account
381384
)
382385
)
383386

erpnext/accounts/doctype/financial_report_template/financial_report_engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from frappe.query_builder import Case
1616
from frappe.query_builder.functions import Sum
1717
from frappe.utils import cstr, date_diff, flt, getdate
18-
from pypika.terms import LiteralValue
18+
from pypika.terms import Bracket, LiteralValue
1919

2020
from erpnext import get_company_currency
2121
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
@@ -732,7 +732,7 @@ def _execute_with_permissions(self, query, doctype):
732732
user_conditions = build_match_conditions(doctype)
733733

734734
if user_conditions:
735-
query = query.where(LiteralValue(user_conditions))
735+
query = query.where(Bracket(LiteralValue(user_conditions)))
736736

737737
return query.run(as_dict=True)
738738

erpnext/accounts/doctype/fiscal_year/fiscal_year.py

Lines changed: 32 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import frappe
66
from dateutil.relativedelta import relativedelta
7-
from frappe import _
7+
from frappe import _, cint
88
from frappe.model.document import Document
99
from frappe.utils import add_days, add_years, cstr, getdate
1010

@@ -33,24 +33,6 @@ def validate(self):
3333
self.validate_dates()
3434
self.validate_overlap()
3535

36-
if not self.is_new():
37-
year_start_end_dates = frappe.db.sql(
38-
"""select year_start_date, year_end_date
39-
from `tabFiscal Year` where name=%s""",
40-
(self.name),
41-
)
42-
43-
if year_start_end_dates:
44-
if (
45-
getdate(self.year_start_date) != year_start_end_dates[0][0]
46-
or getdate(self.year_end_date) != year_start_end_dates[0][1]
47-
):
48-
frappe.throw(
49-
_(
50-
"Cannot change Fiscal Year Start Date and Fiscal Year End Date once the Fiscal Year is saved."
51-
)
52-
)
53-
5436
def validate_dates(self):
5537
self.validate_from_to_dates("year_start_date", "year_end_date")
5638
if self.is_short_year:
@@ -66,28 +48,20 @@ def validate_dates(self):
6648
frappe.exceptions.InvalidDates,
6749
)
6850

69-
def on_update(self):
70-
check_duplicate_fiscal_year(self)
71-
frappe.cache().delete_value("fiscal_years")
51+
def validate_overlap(self):
52+
fy = frappe.qb.DocType("Fiscal Year")
7253

73-
def on_trash(self):
74-
frappe.cache().delete_value("fiscal_years")
54+
name = self.name or self.year
7555

76-
def validate_overlap(self):
77-
existing_fiscal_years = frappe.db.sql(
78-
"""select name from `tabFiscal Year`
79-
where (
80-
(%(year_start_date)s between year_start_date and year_end_date)
81-
or (%(year_end_date)s between year_start_date and year_end_date)
82-
or (year_start_date between %(year_start_date)s and %(year_end_date)s)
83-
or (year_end_date between %(year_start_date)s and %(year_end_date)s)
84-
) and name!=%(name)s""",
85-
{
86-
"year_start_date": self.year_start_date,
87-
"year_end_date": self.year_end_date,
88-
"name": self.name or "No Name",
89-
},
90-
as_dict=True,
56+
existing_fiscal_years = (
57+
frappe.qb.from_(fy)
58+
.select(fy.name)
59+
.where(
60+
(fy.year_start_date <= self.year_end_date)
61+
& (fy.year_end_date >= self.year_start_date)
62+
& (fy.name != name)
63+
)
64+
.run(as_dict=True)
9165
)
9266

9367
if existing_fiscal_years:
@@ -110,44 +84,41 @@ def validate_overlap(self):
11084
frappe.throw(
11185
_(
11286
"Year start date or end date is overlapping with {0}. To avoid please set company"
113-
).format(existing.name),
87+
).format(frappe.get_desk_link("Fiscal Year", existing.name, open_in_new_tab=True)),
11488
frappe.NameError,
11589
)
11690

11791

118-
@frappe.whitelist()
119-
def check_duplicate_fiscal_year(doc):
120-
year_start_end_dates = frappe.db.sql(
121-
"""select name, year_start_date, year_end_date from `tabFiscal Year` where name!=%s""",
122-
(doc.name),
92+
def auto_create_fiscal_year():
93+
fy = frappe.qb.DocType("Fiscal Year")
94+
95+
# Skipped auto-creating Short Year, as it has very rare use case.
96+
# Reference: https://www.irs.gov/businesses/small-businesses-self-employed/tax-years (US)
97+
follow_up_date = add_days(getdate(), days=3)
98+
fiscal_year = (
99+
frappe.qb.from_(fy)
100+
.select(fy.name)
101+
.where((fy.year_end_date == follow_up_date) & (fy.is_short_year == 0))
102+
.run()
123103
)
124-
for fiscal_year, ysd, yed in year_start_end_dates:
125-
if (getdate(doc.year_start_date) == ysd and getdate(doc.year_end_date) == yed) and (
126-
not frappe.in_test
127-
):
128-
frappe.throw(
129-
_(
130-
"Fiscal Year Start Date and Fiscal Year End Date are already set in Fiscal Year {0}"
131-
).format(fiscal_year)
132-
)
133104

134-
135-
@frappe.whitelist()
136-
def auto_create_fiscal_year():
137-
for d in frappe.db.sql(
138-
"""select name from `tabFiscal Year` where year_end_date = date_add(current_date, interval 3 day)"""
139-
):
105+
for d in fiscal_year:
140106
try:
141107
current_fy = frappe.get_doc("Fiscal Year", d[0])
142108

143-
new_fy = frappe.copy_doc(current_fy, ignore_no_copy=False)
109+
new_fy = frappe.new_doc("Fiscal Year")
110+
new_fy.disabled = cint(current_fy.disabled)
144111

145112
new_fy.year_start_date = add_days(current_fy.year_end_date, 1)
146113
new_fy.year_end_date = add_years(current_fy.year_end_date, 1)
147114

148115
start_year = cstr(new_fy.year_start_date.year)
149116
end_year = cstr(new_fy.year_end_date.year)
150117
new_fy.year = start_year if start_year == end_year else (start_year + "-" + end_year)
118+
119+
for row in current_fy.companies:
120+
new_fy.append("companies", {"company": row.company})
121+
151122
new_fy.auto_created = 1
152123

153124
new_fy.insert(ignore_permissions=True)

erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@
1515
"ignore_user_permissions": 1,
1616
"in_list_view": 1,
1717
"label": "Company",
18-
"options": "Company"
18+
"options": "Company",
19+
"reqd": 1
1920
}
2021
],
2122
"index_web_pages_for_search": 1,
2223
"istable": 1,
2324
"links": [],
24-
"modified": "2024-03-27 13:09:44.659251",
25+
"modified": "2026-02-20 23:02:26.193606",
2526
"modified_by": "Administrator",
2627
"module": "Accounts",
2728
"name": "Fiscal Year Company",
2829
"owner": "Administrator",
2930
"permissions": [],
31+
"row_format": "Dynamic",
3032
"sort_field": "creation",
3133
"sort_order": "DESC",
3234
"states": [],
3335
"track_changes": 1
34-
}
36+
}

erpnext/accounts/doctype/fiscal_year_company/fiscal_year_company.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class FiscalYearCompany(Document):
1414
if TYPE_CHECKING:
1515
from frappe.types import DF
1616

17-
company: DF.Link | None
17+
company: DF.Link
1818
parent: DF.Data
1919
parentfield: DF.Data
2020
parenttype: DF.Data

erpnext/accounts/doctype/journal_entry/journal_entry.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,6 @@ erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Contro
303303
erpnext.accounts.dimensions.setup_dimension_filters(this.frm, this.frm.doctype);
304304
}
305305

306-
onload_post_render() {
307-
this.frm.get_field("accounts").grid.set_multiple_add("account");
308-
}
309-
310306
load_defaults() {
311307
//this.frm.show_print_first = true;
312308
if (this.frm.doc.__islocal && this.frm.doc.company) {

0 commit comments

Comments
 (0)