فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

Validate Jalali report ranges and company-owned fiscal periods

davoodmehraban89 committed Oct 13, 2026 at 13:25 UTC 5c328c3ba125e75f021bbe07cb36095e1d3206f7
1 file changed +7 -1
src/core/AccountingService.js
+7 -1
@@ -36,7 +36,13 @@ const cleanLines = lines => (lines || []).map(line => ({
36 class AccountingServiceImpl {
37 async financialReports(filter = {}) {
38 const companyId = await DataScope.companyId();
39 - return StorageService.transaction(['account_chart', 'journal_entries', 'journal_lines'], async tx => {
39 + if (filter.from) assertJalaliDate(filter.from);
40 + if (filter.to) assertJalaliDate(filter.to);
41 + return StorageService.transaction(['account_chart', 'journal_entries', 'journal_lines', 'fiscal_periods'], async tx => {
42 + if (filter.periodId) {
43 + const period = await tx.get('fiscal_periods', filter.periodId);
44 + if (!period || period.companyId !== companyId) throw new Error('دوره مالی انتخاب‌شده متعلق به شرکت فعال نیست');
45 + }
46 const accounts = await tx.getAllByIndex('account_chart', 'companyId', companyId);
47 const journals = await tx.getAllByIndex('journal_entries', 'companyId', companyId);
48 const lines = await tx.getAllByIndex('journal_lines', 'companyId', companyId);