Make treasury report periods Jalali-aware with full previous month and custom range.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-25 14:40:37 +03:30
co-authored by Cursor
parent db47fa4c0c
commit 6c0995e355
2 changed files with 395 additions and 159 deletions
+76 -9
View File
@@ -3,6 +3,15 @@ import { Cron } from '@nestjs/schedule';
import { Prisma } from '@prisma/client'; import { Prisma } from '@prisma/client';
import ExcelJS from 'exceljs'; import ExcelJS from 'exceljs';
import type { TreasuryPartyBalanceDto } from '@mento/shared'; import type { TreasuryPartyBalanceDto } from '@mento/shared';
import {
addJalaliMonths,
dateToJalali,
endOfJalaliMonth,
formatTehranJalali,
jalaliMonthKey,
jalaliMonthName,
startOfJalaliMonth,
} from '../common/jalali';
import { PrismaService } from '../prisma/prisma.service'; import { PrismaService } from '../prisma/prisma.service';
import type { Actor } from '../common/record-scope'; import type { Actor } from '../common/record-scope';
import { invoiceSalesInPeriod } from './invoice-ledger'; import { invoiceSalesInPeriod } from './invoice-ledger';
@@ -22,6 +31,29 @@ function parseDate(iso?: string | null) {
const d = new Date(iso); const d = new Date(iso);
return Number.isNaN(d.getTime()) ? null : d; return Number.isNaN(d.getTime()) ? null : d;
} }
/** روز محلی از YYYY-MM-DD (بدون جابه‌جایی UTC) */
function parseDay(iso?: string | null) {
if (!iso) return null;
const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso.trim());
if (match) {
return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
}
return parseDate(iso);
}
function startOfDay(d: Date) {
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0);
}
function endOfDay(d: Date) {
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);
}
function faDigits(value: string | number) {
return String(value).replace(/\d/g, (d) => '۰۱۲۳۴۵۶۷۸۹'[Number(d)] ?? d);
}
function jalaliMonthLabel(key: string) {
const match = /^(\d{4})-(\d{2})$/.exec(key);
if (!match) return key;
return `${jalaliMonthName(Number(match[2]))} ${faDigits(match[1])}`;
}
function payrollStatus(payable: Prisma.Decimal, paid: Prisma.Decimal) { function payrollStatus(payable: Prisma.Decimal, paid: Prisma.Decimal) {
if (paid.lessThanOrEqualTo(0)) return 'open'; if (paid.lessThanOrEqualTo(0)) return 'open';
if (paid.greaterThanOrEqualTo(payable)) return 'settled'; if (paid.greaterThanOrEqualTo(payable)) return 'settled';
@@ -449,15 +481,32 @@ export class TreasuryOpsService {
} }
async report(actor: Actor, fromIso?: string, toIso?: string) { async report(actor: Actor, fromIso?: string, toIso?: string) {
const to = parseDate(toIso) ?? new Date(); const now = new Date();
const from = parseDate(fromIso) ?? new Date(to.getFullYear(), to.getMonth(), 1); const jalaliNow = dateToJalali(now);
const span = to.getTime() - from.getTime(); const to = endOfDay(parseDay(toIso) ?? now);
const prevTo = new Date(from.getTime() - 1); const from = startOfDay(
const prevFrom = new Date(prevTo.getTime() - span); parseDay(fromIso) ?? startOfJalaliMonth(jalaliNow.jy, jalaliNow.jm),
);
if (from.getTime() > to.getTime()) {
throw new BadRequestException('بازهٔ تاریخ نامعتبر است.');
}
// دوره قبل = ماه شمسی کاملِ قبل از ماهی که «از تاریخ» در آن است
const fromJalali = dateToJalali(from);
const prevMonth = addJalaliMonths(fromJalali.jy, fromJalali.jm, -1);
const prevFrom = startOfDay(startOfJalaliMonth(prevMonth.jy, prevMonth.jm));
const prevTo = endOfDay(endOfJalaliMonth(prevMonth.jy, prevMonth.jm));
const current = await this.period(actor.organizationId, from, to); const current = await this.period(actor.organizationId, from, to);
const previous = await this.period(actor.organizationId, prevFrom, prevTo); const previous = await this.period(actor.organizationId, prevFrom, prevTo);
const breakdown = await this.breakdown(actor.organizationId); const breakdown = await this.breakdown(actor.organizationId);
return { from: from.toISOString(), to: to.toISOString(), current, previous, ...breakdown }; return {
from: from.toISOString(),
to: to.toISOString(),
previousFrom: prevFrom.toISOString(),
previousTo: prevTo.toISOString(),
current,
previous,
...breakdown,
};
} }
async reportExcel( async reportExcel(
@@ -469,6 +518,15 @@ export class TreasuryOpsService {
const data = await this.report(actor, from, to); const data = await this.report(actor, from, to);
const book = new ExcelJS.Workbook(); const book = new ExcelJS.Workbook();
const sheet = book.addWorksheet('گزارش مالی'); const sheet = book.addWorksheet('گزارش مالی');
sheet.addRow([
'بازه این دوره',
`${formatTehranJalali(new Date(data.from))} تا ${formatTehranJalali(new Date(data.to))}`,
]);
sheet.addRow([
'بازه دوره قبل',
`${formatTehranJalali(new Date(data.previousFrom))} تا ${formatTehranJalali(new Date(data.previousTo))}`,
]);
sheet.addRow([]);
sheet.addRow(['شاخص', 'این دوره', 'دوره قبل']); sheet.addRow(['شاخص', 'این دوره', 'دوره قبل']);
const rows: Array<[string, string, string]> = [ const rows: Array<[string, string, string]> = [
['درآمد ثبت‌شده', data.current.bookedIncome, data.previous.bookedIncome], ['درآمد ثبت‌شده', data.current.bookedIncome, data.previous.bookedIncome],
@@ -591,7 +649,7 @@ export class TreasuryOpsService {
]); ]);
const payablesByMonth = new Map<string, Prisma.Decimal>(); const payablesByMonth = new Map<string, Prisma.Decimal>();
const addMonth = (date: Date, amount: Prisma.Decimal) => { const addMonth = (date: Date, amount: Prisma.Decimal) => {
const key = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`; const key = jalaliMonthKey(date);
payablesByMonth.set(key, (payablesByMonth.get(key) ?? new Prisma.Decimal(0)).plus(amount)); payablesByMonth.set(key, (payablesByMonth.get(key) ?? new Prisma.Decimal(0)).plus(amount));
}; };
for (const doc of docs) { for (const doc of docs) {
@@ -611,8 +669,17 @@ export class TreasuryOpsService {
receivablesByParty.set(name, (receivablesByParty.get(name) ?? new Prisma.Decimal(0)).plus(left)); receivablesByParty.set(name, (receivablesByParty.get(name) ?? new Prisma.Decimal(0)).plus(left));
} }
return { return {
payablesByMonth: [...payablesByMonth.entries()].map(([month, amount]) => ({ month, amount: money(amount) })), payablesByMonth: [...payablesByMonth.entries()]
receivablesByParty: [...receivablesByParty.entries()].map(([name, amount]) => ({ name, amount: money(amount) })), .sort((a, b) => b[0].localeCompare(a[0]))
.map(([month, amount]) => ({
month,
label: jalaliMonthLabel(month),
amount: money(amount),
})),
receivablesByParty: [...receivablesByParty.entries()].map(([name, amount]) => ({
name,
amount: money(amount),
})),
}; };
} }
@@ -5,23 +5,38 @@ import {
Alert as AAlert, Alert as AAlert,
Button as AButton, Button as AButton,
Card as ACard, Card as ACard,
Col as ACol,
Divider as ADivider, Divider as ADivider,
Empty as AEmpty, Empty as AEmpty,
Flex as AFlex, Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
List as AList, List as AList,
Descriptions as ADescriptions, Descriptions as ADescriptions,
DescriptionsItem as ADescriptionsItem, DescriptionsItem as ADescriptionsItem,
Row as ARow,
Space as ASpace,
Table as ATable, Table as ATable,
Tabs as ATabs, Tabs as ATabs,
Typography, Typography,
message,
} from 'ant-design-vue'; } from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue'; import type { TableColumnsType } from 'ant-design-vue';
import { DownloadOutlined } from '@ant-design/icons-vue'; import { DownloadOutlined, SearchOutlined } from '@ant-design/icons-vue';
import * as XLSX from 'xlsx'; import * as XLSX from 'xlsx';
import type { TreasuryPartyBalanceDto } from '@mento/shared'; import type { TreasuryPartyBalanceDto } from '@mento/shared';
import { api } from '@/lib/api'; import { api } from '@/lib/api';
import JalaliDateInput from '@/components/JalaliDateInput.vue';
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue'; import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
import TreasuryPartyBalanceTable from '@/components/treasury/TreasuryPartyBalanceTable.vue'; import TreasuryPartyBalanceTable from '@/components/treasury/TreasuryPartyBalanceTable.vue';
import {
dateToJalali,
formatJalaliNumeric,
formatLocalDateInput,
jalaliMonthName,
jalaliToDate,
toFaDigits,
} from '@/lib/jalali';
import { toman } from './treasury-format'; import { toman } from './treasury-format';
import { useTreasuryListPaging } from './useTreasuryListPaging'; import { useTreasuryListPaging } from './useTreasuryListPaging';
import { useTreasuryMobile } from './useTreasuryMobile'; import { useTreasuryMobile } from './useTreasuryMobile';
@@ -51,13 +66,23 @@ type MetricRow = {
previous: string; previous: string;
}; };
type PayableMonth = { month: string; label?: string; amount: string };
const todayJalali = dateToJalali(new Date());
const fromDate = ref(formatLocalDateInput(jalaliToDate(todayJalali.jy, todayJalali.jm, 1)));
const toDate = ref(formatLocalDateInput(new Date()));
const rangeFrom = ref('');
const rangeTo = ref('');
const previousFrom = ref('');
const previousTo = ref('');
const current = ref<Period | null>(null); const current = ref<Period | null>(null);
const previous = ref<Period | null>(null); const previous = ref<Period | null>(null);
const payablesByMonth = ref<Array<{ month: string; amount: string }>>([]); const payablesByMonth = ref<PayableMonth[]>([]);
const receivablesByParty = ref<Array<{ name: string; amount: string }>>([]); const receivablesByParty = ref<Array<{ name: string; amount: string }>>([]);
const debtors = ref<TreasuryPartyBalanceDto[]>([]); const debtors = ref<TreasuryPartyBalanceDto[]>([]);
const creditors = ref<TreasuryPartyBalanceDto[]>([]); const creditors = ref<TreasuryPartyBalanceDto[]>([]);
const reportTab = ref('periods'); const reportTab = ref('periods');
const loading = ref(false);
const error = ref(''); const error = ref('');
const balanceError = ref(''); const balanceError = ref('');
@@ -78,11 +103,30 @@ const lines = [
['خالص جریان نقدی', 'cashNet'], ['خالص جریان نقدی', 'cashNet'],
] as const; ] as const;
const metricColumns: TableColumnsType<MetricRow> = [ const currentRangeLabel = computed(() =>
rangeFrom.value && rangeTo.value
? `${formatJalaliNumeric(new Date(rangeFrom.value))} تا ${formatJalaliNumeric(new Date(rangeTo.value))}`
: '—',
);
const previousRangeLabel = computed(() =>
previousFrom.value && previousTo.value
? `${formatJalaliNumeric(new Date(previousFrom.value))} تا ${formatJalaliNumeric(new Date(previousTo.value))}`
: '—',
);
const metricColumns = computed<TableColumnsType<MetricRow>>(() => [
{ title: 'شاخص', dataIndex: 'label', key: 'label' }, { title: 'شاخص', dataIndex: 'label', key: 'label' },
{ title: 'این دوره', dataIndex: 'current', key: 'current' }, {
{ title: 'دوره قبل', dataIndex: 'previous', key: 'previous' }, title: `این دوره (${currentRangeLabel.value})`,
]; dataIndex: 'current',
key: 'current',
},
{
title: `دوره قبل (${previousRangeLabel.value})`,
dataIndex: 'previous',
key: 'previous',
},
]);
const metricRows = computed<MetricRow[]>(() => { const metricRows = computed<MetricRow[]>(() => {
if (!current.value || !previous.value) return []; if (!current.value || !previous.value) return [];
@@ -127,17 +171,84 @@ const {
'treasury.reports-expense-cats', 'treasury.reports-expense-cats',
); );
function monthTitle(item: PayableMonth) {
if (item.label) return item.label;
const match = /^(\d{4})-(\d{2})$/.exec(item.month);
if (!match) return item.month;
const year = Number(match[1]);
const month = Number(match[2]);
if (year > 1700) {
const j = dateToJalali(new Date(year, month - 1, 15));
return `${jalaliMonthName(j.jm)} ${toFaDigits(j.jy)}`;
}
return `${jalaliMonthName(month)} ${toFaDigits(year)}`;
}
async function load() { async function load() {
const { data } = await api.get<{ loading.value = true;
current: Period; error.value = '';
previous: Period; try {
payablesByMonth: Array<{ month: string; amount: string }>; const { data } = await api.get<{
receivablesByParty: Array<{ name: string; amount: string }>; from?: string;
}>('/treasury/reports'); to?: string;
current.value = data.current; previousFrom?: string;
previous.value = data.previous; previousTo?: string;
payablesByMonth.value = data.payablesByMonth; current: Period;
receivablesByParty.value = data.receivablesByParty; previous: Period;
payablesByMonth: PayableMonth[];
receivablesByParty: Array<{ name: string; amount: string }>;
}>('/treasury/reports', {
params: {
from: fromDate.value || undefined,
to: toDate.value || undefined,
},
});
const fromIso = data.from || `${fromDate.value}T00:00:00`;
const toIso = data.to || `${toDate.value}T23:59:59`;
const fromJ = dateToJalali(new Date(fromIso));
const prevMonth = {
jy: fromJ.jm === 1 ? fromJ.jy - 1 : fromJ.jy,
jm: fromJ.jm === 1 ? 12 : fromJ.jm - 1,
};
const fallbackPrevFrom = jalaliToDate(prevMonth.jy, prevMonth.jm, 1);
const nextOfPrev = jalaliToDate(
prevMonth.jm === 12 ? prevMonth.jy + 1 : prevMonth.jy,
prevMonth.jm === 12 ? 1 : prevMonth.jm + 1,
1,
);
const fallbackPrevTo = new Date(nextOfPrev.getTime() - 1);
rangeFrom.value = fromIso;
rangeTo.value = toIso;
previousFrom.value = data.previousFrom || fallbackPrevFrom.toISOString();
previousTo.value = data.previousTo || fallbackPrevTo.toISOString();
current.value = data.current;
previous.value = data.previous;
payablesByMonth.value = data.payablesByMonth;
receivablesByParty.value = data.receivablesByParty;
} catch {
error.value = 'گزارش بارگذاری نشد.';
} finally {
loading.value = false;
}
}
function applyRange() {
if (!fromDate.value || !toDate.value) {
message.warning('از تاریخ و تا تاریخ را مشخص کنید.');
return;
}
if (fromDate.value > toDate.value) {
message.warning('بازهٔ تاریخ نامعتبر است.');
return;
}
void load();
}
function resetToCurrentJalaliMonth() {
const today = dateToJalali(new Date());
fromDate.value = formatLocalDateInput(jalaliToDate(today.jy, today.jm, 1));
toDate.value = formatLocalDateInput(new Date());
void load();
} }
function sumRemaining(rows: TreasuryPartyBalanceDto[]) { function sumRemaining(rows: TreasuryPartyBalanceDto[]) {
@@ -185,7 +296,13 @@ async function loadBalances() {
} }
async function download() { async function download() {
const { data } = await api.get<Blob>('/treasury/reports/export', { responseType: 'blob' }); const { data } = await api.get<Blob>('/treasury/reports/export', {
responseType: 'blob',
params: {
from: fromDate.value || undefined,
to: toDate.value || undefined,
},
});
const url = URL.createObjectURL(data); const url = URL.createObjectURL(data);
const link = document.createElement('a'); const link = document.createElement('a');
link.href = url; link.href = url;
@@ -195,9 +312,7 @@ async function download() {
} }
onMounted(() => { onMounted(() => {
void load().catch(() => { void load();
error.value = 'گزارش بارگذاری نشد.';
});
void loadBalances().catch((e: unknown) => { void loadBalances().catch((e: unknown) => {
if (axios.isAxiosError(e) && (e.response?.status === 404 || e.response?.status === 403)) { if (axios.isAxiosError(e) && (e.response?.status === 404 || e.response?.status === 403)) {
debtors.value = []; debtors.value = [];
@@ -211,152 +326,206 @@ onMounted(() => {
<template> <template>
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-flex justify="flex-end"> <a-card :bordered="false">
<a-button @click="download"> <a-form layout="vertical" @finish="applyRange">
<template #icon><DownloadOutlined /></template> <a-row :gutter="[16, 0]">
خروجی اکسل <a-col :xs="24" :sm="12" :md="8">
</a-button> <a-form-item label="از تاریخ">
</a-flex> <JalaliDateInput v-model="fromDate" style="width: 100%" />
</a-form-item>
</a-col>
<a-col :xs="24" :sm="12" :md="8">
<a-form-item label="تا تاریخ">
<JalaliDateInput v-model="toDate" style="width: 100%" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label=" ">
<a-space :size="8" wrap>
<a-button type="primary" html-type="submit" :loading="loading">
<template #icon><SearchOutlined /></template>
اعمال بازه
</a-button>
<a-button :disabled="loading" @click="resetToCurrentJalaliMonth">
ماه جاری شمسی
</a-button>
<a-button :disabled="loading" @click="download">
<template #icon><DownloadOutlined /></template>
خروجی اکسل
</a-button>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
<a-typography-text type="secondary">
پیش‌فرض: از اول ماه شمسی جاری تا امروز. «دوره قبل» همیشه ماه شمسی کاملِ قبل (اول تا آخر ماه) است.
</a-typography-text>
</a-card>
<a-alert v-if="error" type="error" show-icon :message="error" /> <a-alert v-if="error" type="error" show-icon :message="error" />
<a-alert v-if="balanceError" type="error" show-icon :message="balanceError" /> <a-alert v-if="balanceError" type="error" show-icon :message="balanceError" />
<a-card :bordered="false"> <a-card :bordered="false">
<a-tabs v-model:activeKey="reportTab"> <a-tabs v-model:activeKey="reportTab">
<a-tab-pane key="periods" tab="مقایسه دوره‌ها"> <a-tab-pane key="periods" tab="مقایسه دوره‌ها">
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-list v-if="isMobile && metricRows.length" :data-source="metricRows"> <a-descriptions bordered :column="isMobile ? 1 : 2">
<template #renderItem="{ item }"> <a-descriptions-item label="این دوره">{{ currentRangeLabel }}</a-descriptions-item>
<a-list-item> <a-descriptions-item label="دوره قبل">{{ previousRangeLabel }}</a-descriptions-item>
<a-card :title="item.label" style="width: 100%"> </a-descriptions>
<a-descriptions :column="1" bordered>
<a-descriptions-item label="این دوره">{{ item.current }}</a-descriptions-item>
<a-descriptions-item label="دوره قبل">{{ item.previous }}</a-descriptions-item>
</a-descriptions>
</a-card>
</a-list-item>
</template>
</a-list>
<a-table
v-else-if="metricRows.length"
:columns="metricColumns"
:data-source="metricRows"
:pagination="false"
row-key="key"
/>
<a-empty v-else description="داده‌ای برای نمایش نیست." />
<a-divider orientation="right">مطالبات به تفکیک طرف حساب</a-divider> <a-list v-if="isMobile && metricRows.length" :data-source="metricRows">
<a-empty v-if="!receivablesByParty.length" description="مورد بازی نیست." /> <template #renderItem="{ item }">
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedPartyRows"> <a-list-item>
<template #renderItem="{ item }"> <a-card :title="item.label" style="width: 100%">
<a-list-item> <a-descriptions :column="1" bordered>
<template #actions> <a-descriptions-item :label="`این دوره (${currentRangeLabel})`">
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text> {{ item.current }}
</a-descriptions-item>
<a-descriptions-item :label="`دوره قبل (${previousRangeLabel})`">
{{ item.previous }}
</a-descriptions-item>
</a-descriptions>
</a-card>
</a-list-item>
</template> </template>
<a-list-item-meta> </a-list>
<template #title>{{ item.name }}</template> <a-table
</a-list-item-meta> v-else-if="metricRows.length"
</a-list-item> :columns="metricColumns"
</template> :data-source="metricRows"
</a-list> :pagination="false"
<TreasuryListPagination :loading="loading"
v-model:page="partyPage" row-key="key"
:total="partyTotal" />
:page-size="partyPageSize" <a-empty v-else description="داده‌ای برای نمایش نیست." />
:page-size-options="partyPageSizeOptions"
:show-total="partyShowTotal"
@update:page-size="onPartyPageSizeChange"
/>
<a-divider orientation="right">تعهدات به تفکیک ماه</a-divider> <a-divider orientation="right">مطالبات به تفکیک طرف حساب</a-divider>
<a-empty v-if="!payablesByMonth.length" description="تعهد بازی نیست." /> <a-empty v-if="!receivablesByParty.length" description="مورد بازی نیست." />
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedMonthRows"> <a-list
<template #renderItem="{ item }"> v-else
<a-list-item> :item-layout="isMobile ? 'vertical' : 'horizontal'"
<template #actions> :data-source="pagedPartyRows"
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text> >
<template #renderItem="{ item }">
<a-list-item>
<template #actions>
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text>
</template>
<a-list-item-meta>
<template #title>{{ item.name }}</template>
</a-list-item-meta>
</a-list-item>
</template> </template>
<a-list-item-meta> </a-list>
<template #title>{{ item.month }}</template> <TreasuryListPagination
</a-list-item-meta> v-model:page="partyPage"
</a-list-item> :total="partyTotal"
</template> :page-size="partyPageSize"
</a-list> :page-size-options="partyPageSizeOptions"
<TreasuryListPagination :show-total="partyShowTotal"
v-model:page="monthPage" @update:page-size="onPartyPageSizeChange"
:total="monthTotal" />
:page-size="monthPageSize"
:page-size-options="monthPageSizeOptions"
:show-total="monthShowTotal"
@update:page-size="onMonthPageSizeChange"
/>
<template v-if="current"> <a-divider orientation="right">تعهدات به تفکیک ماه شمسی</a-divider>
<a-divider orientation="right">سهم هزینه‌ها</a-divider> <a-empty v-if="!payablesByMonth.length" description="تعهد بازی نیست." />
<a-empty v-if="!current.expenseCategories.length" description="دسته‌ای نیست." /> <a-list
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedExpenseCats"> v-else
<template #renderItem="{ item }"> :item-layout="isMobile ? 'vertical' : 'horizontal'"
<a-list-item> :data-source="pagedMonthRows"
<template #actions> >
<a-typography-text strong> <template #renderItem="{ item }">
{{ toman(item.amount) }} · {{ item.share }}٪ <a-list-item>
</a-typography-text> <template #actions>
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text>
</template>
<a-list-item-meta>
<template #title>{{ monthTitle(item) }}</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list>
<TreasuryListPagination
v-model:page="monthPage"
:total="monthTotal"
:page-size="monthPageSize"
:page-size-options="monthPageSizeOptions"
:show-total="monthShowTotal"
@update:page-size="onMonthPageSizeChange"
/>
<template v-if="current">
<a-divider orientation="right">سهم هزینه‌ها (این دوره)</a-divider>
<a-empty v-if="!current.expenseCategories.length" description="دسته‌ای نیست." />
<a-list
v-else
:item-layout="isMobile ? 'vertical' : 'horizontal'"
:data-source="pagedExpenseCats"
>
<template #renderItem="{ item }">
<a-list-item>
<template #actions>
<a-typography-text strong>
{{ toman(item.amount) }} · {{ item.share }}٪
</a-typography-text>
</template>
<a-list-item-meta>
<template #title>{{ item.name }}</template>
</a-list-item-meta>
</a-list-item>
</template> </template>
<a-list-item-meta> </a-list>
<template #title>{{ item.name }}</template> <TreasuryListPagination
</a-list-item-meta> v-model:page="expenseCatPage"
</a-list-item> :total="expenseCatTotal"
:page-size="expenseCatPageSize"
:page-size-options="expenseCatPageSizeOptions"
:show-total="expenseCatShowTotal"
@update:page-size="onExpenseCatPageSizeChange"
/>
</template> </template>
</a-list> </a-flex>
<TreasuryListPagination </a-tab-pane>
v-model:page="expenseCatPage"
:total="expenseCatTotal"
:page-size="expenseCatPageSize"
:page-size-options="expenseCatPageSizeOptions"
:show-total="expenseCatShowTotal"
@update:page-size="onExpenseCatPageSizeChange"
/>
</template>
</a-flex>
</a-tab-pane>
<a-tab-pane key="debtors" tab="بدهکاران"> <a-tab-pane key="debtors" tab="بدهکاران">
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-typography-text type="secondary">
ماندهٔ فاکتور صادرشده و اسناد دریافتِ باز. صدور فاکتور سند درآمد جدا نمی‌سازد.
</a-typography-text>
<a-flex justify="space-between" align="center">
<a-typography-text type="secondary"> <a-typography-text type="secondary">
ماندهٔ فاکتور صادرشده و اسناد دریافتِ باز. صدور فاکتور سند درآمد جدا نمی‌سازد. {{ debtors.length }} طرف حساب · جمع مانده {{ toman(sumRemaining(debtors)) }}
</a-typography-text> </a-typography-text>
<a-flex justify="space-between" align="center"> <a-button @click="exportParties(debtors, 'بدهکاران', 'دریافت‌شده', 'debtors.xlsx')">
<a-typography-text type="secondary"> <template #icon><DownloadOutlined /></template>
{{ debtors.length }} طرف حساب · جمع مانده {{ toman(sumRemaining(debtors)) }} خروجی اکسل
</a-typography-text> </a-button>
<a-button @click="exportParties(debtors, 'بدهکاران', 'دریافت‌شده', 'debtors.xlsx')">
<template #icon><DownloadOutlined /></template>
خروجی اکسل
</a-button>
</a-flex>
<TreasuryPartyBalanceTable :rows="debtors" settled-label="دریافت‌شده" />
</a-flex> </a-flex>
</a-tab-pane> <TreasuryPartyBalanceTable :rows="debtors" settled-label="دریافت‌شده" />
</a-flex>
</a-tab-pane>
<a-tab-pane key="creditors" tab="بستانکاران"> <a-tab-pane key="creditors" tab="بستانکاران">
<a-flex vertical :gap="16"> <a-flex vertical :gap="16">
<a-typography-text type="secondary">
ماندهٔ فاکتور برگشتی و اسناد هزینهٔ باز. برگشتی سند هزینهٔ جدا نمی‌سازد.
</a-typography-text>
<a-flex justify="space-between" align="center">
<a-typography-text type="secondary"> <a-typography-text type="secondary">
ماندهٔ فاکتور برگشتی و اسناد هزینهٔ باز. برگشتی سند هزینهٔ جدا نمی‌سازد. {{ creditors.length }} طرف حساب · جمع مانده {{ toman(sumRemaining(creditors)) }}
</a-typography-text> </a-typography-text>
<a-flex justify="space-between" align="center"> <a-button
<a-typography-text type="secondary"> @click="exportParties(creditors, 'بستانکاران', 'پرداخت‌شده', 'creditors.xlsx')"
{{ creditors.length }} طرف حساب · جمع مانده {{ toman(sumRemaining(creditors)) }} >
</a-typography-text> <template #icon><DownloadOutlined /></template>
<a-button @click="exportParties(creditors, 'بستانکاران', 'پرداخت‌شده', 'creditors.xlsx')"> خروجی اکسل
<template #icon><DownloadOutlined /></template> </a-button>
خروجی اکسل
</a-button>
</a-flex>
<TreasuryPartyBalanceTable :rows="creditors" settled-label="پرداخت‌شده" />
</a-flex> </a-flex>
</a-tab-pane> <TreasuryPartyBalanceTable :rows="creditors" settled-label="پرداخت‌شده" />
</a-tabs> </a-flex>
</a-card> </a-tab-pane>
</a-tabs>
</a-card>
</a-flex> </a-flex>
</template> </template>