feat: add invoice builder with line detail, address, and person picker.

Enrich invoice line items and previews, migrate several CRM surfaces to Ant, and wire shared money/picker helpers.
This commit is contained in:
2026-11-30 14:34:47 +03:30
parent f1bcb232ee
commit 33c95d72a8
64 changed files with 5813 additions and 2737 deletions
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { computed, onMounted, ref } from 'vue';
import axios from 'axios';
import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Checkbox as ACheckbox,
Col as ACol,
Divider as ADivider,
Empty as AEmpty,
@@ -13,12 +14,21 @@ import {
FormItem as AFormItem,
Input as AInput,
List as AList,
Modal as AModal,
Row as ARow,
Select as ASelect,
Space as ASpace,
Switch as ASwitch,
Tag as ATag,
Typography,
message,
} from 'ant-design-vue';
import { AppstoreOutlined, FileTextOutlined, ScheduleOutlined } from '@/icons/ant-bridge';
import {
AppstoreOutlined,
EditOutlined,
FileTextOutlined,
ScheduleOutlined,
} from '@/icons/ant-bridge';
import { api } from '@/lib/api';
import MoneyInput from '@/components/MoneyInput.vue';
import JalaliDateInput from '@/components/JalaliDateInput.vue';
@@ -27,7 +37,7 @@ import TreasuryListPagination from '@/components/treasury/TreasuryListPagination
import { toman } from './treasury-format';
import { useTreasuryListPaging } from './useTreasuryListPaging';
import { useTreasuryMobile } from './useTreasuryMobile';
import { formatJalaliNumeric } from '@/lib/jalali';
import { formatJalaliNumeric, formatLocalDateInput, toFaDigits } from '@/lib/jalali';
import { parseMoneyNumber } from '@/lib/money';
const { Text: ATypographyText } = Typography;
@@ -42,13 +52,93 @@ type Row = {
kind: string;
amount: string;
interval: string;
startDate: string;
nextDue: string;
isActive: boolean;
reminderDaysBefore: number | null;
reminderRepeatDaily: boolean;
reminderNotifyApp: boolean;
reminderNotifySms: boolean;
};
type FormState = {
title: string;
kind: string;
amount: string;
interval: string;
dueDate: string;
reminderDaysBefore: string;
reminderRepeatDaily: string;
reminderNotifyApp: boolean;
reminderNotifySms: boolean;
isActive: boolean;
};
const REMINDER_DAY_OPTIONS = [
{ value: '', label: 'بدون یادآور' },
{ value: '0', label: 'روز سررسید' },
{ value: '1', label: '۱ روز قبل' },
{ value: '2', label: '۲ روز قبل' },
{ value: '3', label: '۳ روز قبل' },
{ value: '5', label: '۵ روز قبل' },
{ value: '7', label: '۷ روز قبل' },
];
const REMINDER_FREQ_OPTIONS = [
{ value: 'once', label: 'فقط یک‌بار' },
{ value: 'daily', label: 'هر روز تا سررسید' },
];
const INTERVAL_LABEL: Record<string, string> = {
weekly: 'هفتگی',
monthly: 'ماهانه',
yearly: 'سالانه',
};
function emptyForm(): FormState {
return {
title: '',
kind: 'expense',
amount: '',
interval: 'monthly',
dueDate: '',
reminderDaysBefore: '3',
reminderRepeatDaily: 'once',
reminderNotifyApp: true,
reminderNotifySms: true,
isActive: true,
};
}
function reminderToSelect(days: number | null | undefined) {
return days == null ? '' : String(days);
}
function reminderFromSelect(value: string) {
return value === '' ? null : Number(value);
}
function freqToSelect(daily: boolean | undefined) {
return daily === false ? 'once' : 'daily';
}
function freqFromSelect(value: string) {
return value === 'daily';
}
function reminderLabel(days: number | null | undefined, daily: boolean | undefined) {
if (days == null) return 'بدون یادآور';
const when = days === 0 ? 'روز سررسید' : `${toFaDigits(days)} روز قبل`;
if (days === 0) return when;
return daily === false ? `${when} · یک‌بار` : `${when} · هر روز`;
}
const rows = ref<Row[]>([]);
const error = ref('');
const ok = ref('');
const saving = ref(false);
const editOpen = ref(false);
const editingId = ref<string | null>(null);
const form = ref(emptyForm());
const editForm = ref(emptyForm());
const {
page,
pageSize,
@@ -58,17 +148,49 @@ const {
onPageSizeChange,
showTotal,
} = useTreasuryListPaging(() => rows.value, 'treasury.recurring');
const form = ref({ title: '', kind: 'expense', amount: '', interval: 'monthly', startDate: '' });
const createReminderEnabled = computed(() => form.value.reminderDaysBefore !== '');
const editReminderEnabled = computed(() => editForm.value.reminderDaysBefore !== '');
const modalWidth = computed(() => (isMobile.value ? '100%' : 720));
async function load() {
const { data } = await api.get<Row[]>('/treasury/recurring');
rows.value = data;
}
function reminderPayload(state: FormState) {
const days = reminderFromSelect(state.reminderDaysBefore);
return {
reminderDaysBefore: days,
reminderRepeatDaily: days == null ? true : freqFromSelect(state.reminderRepeatDaily),
reminderNotifyApp: days == null ? false : state.reminderNotifyApp,
reminderNotifySms: days == null ? false : state.reminderNotifySms,
};
}
function onFinishFailed() {
message.warning('لطفاً فیلدهای الزامی را کامل کنید.');
}
function openEdit(item: Row) {
error.value = '';
ok.value = '';
editingId.value = item.id;
editForm.value = {
title: item.title,
kind: item.kind,
amount: String(item.amount ?? ''),
interval: item.interval,
dueDate: formatLocalDateInput(new Date(item.nextDue)),
reminderDaysBefore: reminderToSelect(item.reminderDaysBefore),
reminderRepeatDaily: freqToSelect(item.reminderRepeatDaily),
reminderNotifyApp: item.reminderNotifyApp,
reminderNotifySms: item.reminderNotifySms,
isActive: item.isActive,
};
editOpen.value = true;
}
async function createItem() {
error.value = '';
ok.value = '';
@@ -80,11 +202,14 @@ async function createItem() {
return;
}
await api.post('/treasury/recurring', {
...form.value,
title: form.value.title,
kind: form.value.kind,
amount,
startDate: form.value.startDate || undefined,
interval: form.value.interval,
startDate: form.value.dueDate || undefined,
...reminderPayload(form.value),
});
form.value = { title: '', kind: 'expense', amount: '', interval: 'monthly', startDate: '' };
form.value = emptyForm();
ok.value = 'الگو ثبت شد. در سررسید فقط سند باز ساخته می‌شود.';
await load();
} catch (e) {
@@ -96,6 +221,45 @@ async function createItem() {
}
}
async function saveEdit() {
if (!editingId.value) return;
error.value = '';
saving.value = true;
try {
if (!editForm.value.title.trim()) {
error.value = 'عنوان الزامی است.';
throw new Error(error.value);
}
const amount = parseMoneyNumber(String(editForm.value.amount ?? ''), 0);
if (amount == null || amount <= 0) {
error.value = 'مبلغ معتبر نیست.';
throw new Error(error.value);
}
await api.patch(`/treasury/recurring/${editingId.value}`, {
title: editForm.value.title,
kind: editForm.value.kind,
amount,
interval: editForm.value.interval,
nextDue: editForm.value.dueDate || undefined,
isActive: editForm.value.isActive,
...reminderPayload(editForm.value),
});
editOpen.value = false;
editingId.value = null;
message.success('الگو ذخیره شد.');
await load();
} catch (e) {
if (!error.value) {
error.value = axios.isAxiosError(e)
? String((e.response?.data as { message?: string })?.message ?? 'ذخیره ناموفق بود.')
: 'ذخیره ناموفق بود.';
}
throw e;
} finally {
saving.value = false;
}
}
onMounted(() => {
void load();
});
@@ -103,7 +267,7 @@ onMounted(() => {
<template>
<a-flex vertical :gap="16">
<a-alert v-if="error" type="error" show-icon :message="error" />
<a-alert v-if="error && !editOpen" type="error" show-icon :message="error" />
<a-alert v-if="ok" type="success" show-icon :message="ok" />
<a-card :bordered="false">
@@ -119,7 +283,9 @@ onMounted(() => {
<a-form-item
name="title"
:rules="[{ required: true, message: 'عنوان الزامی است' }]"
label="عنوان"><a-input v-model:value="form.title">
label="عنوان"
>
<a-input v-model:value="form.title">
<template #prefix><FileTextOutlined /></template>
</a-input>
</a-form-item>
@@ -138,7 +304,9 @@ onMounted(() => {
<a-form-item
name="amount"
:rules="[{ required: true, message: 'مبلغ الزامی است' }]"
label="مبلغ"><MoneyInput addon-after="تومان" v-model="form.amount" :decimals="0" />
label="مبلغ"
>
<MoneyInput addon-after="تومان" v-model="form.amount" :decimals="0" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
@@ -153,11 +321,47 @@ onMounted(() => {
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item name="startDate" label="شروع"><JalaliDateInput v-model="form.startDate" />
<a-form-item name="dueDate" label="شروع / سررسید بعدی">
<JalaliDateInput v-model="form.dueDate" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label="زمان یادآور">
<SelectWithIcon :icon="ScheduleOutlined">
<a-select
v-model:value="form.reminderDaysBefore"
style="width: 100%"
:options="REMINDER_DAY_OPTIONS"
/>
</SelectWithIcon>
</a-form-item>
</a-col>
<a-col v-if="createReminderEnabled" :xs="24" :md="8">
<a-form-item label="تکرار یادآور">
<SelectWithIcon :icon="ScheduleOutlined">
<a-select
v-model:value="form.reminderRepeatDaily"
style="width: 100%"
:options="REMINDER_FREQ_OPTIONS"
/>
</SelectWithIcon>
</a-form-item>
</a-col>
<a-col v-if="createReminderEnabled" :span="24">
<a-form-item label="کانال یادآور">
<a-space :size="24" wrap>
<a-checkbox v-model:checked="form.reminderNotifyApp">ناتیفیکیشن</a-checkbox>
<a-checkbox v-model:checked="form.reminderNotifySms">پیامک</a-checkbox>
</a-space>
</a-form-item>
</a-col>
</a-row>
<a-button type="primary" html-type="submit" :loading="saving">ثبت الگو</a-button>
<a-flex vertical :gap="12" align="flex-start">
<a-typography-text type="secondary">
مثلاً «۲ روز قبل · فقط یک‌بار»: یک پیام در همان روز؛ «۳ روز قبل · هر روز»: هر روز تا سررسید برای مالک.
</a-typography-text>
<a-button type="primary" html-type="submit" :loading="saving">ثبت الگو</a-button>
</a-flex>
</a-form>
<a-divider orientation="right">فهرست الگوها</a-divider>
@@ -166,14 +370,41 @@ onMounted(() => {
<template #renderItem="{ item }">
<a-list-item>
<template #actions>
<a-button type="link" @click="openEdit(item)">
<template #icon><EditOutlined /></template>
ویرایش
</a-button>
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text>
</template>
<a-list-item-meta>
<template #title>{{ item.title }}</template>
<template #title>
<a-flex :gap="8" align="center" wrap="wrap">
<span>{{ item.title }}</span>
<a-tag v-if="!item.isActive" color="default">غیرفعال</a-tag>
</a-flex>
</template>
<template #description>
{{ item.kind === 'income' ? 'درآمد' : 'هزینه' }}
· {{ item.interval }}
· بعدی {{ formatJalaliNumeric(new Date(item.nextDue)) }}
<a-flex vertical :gap="4">
<a-typography-text type="secondary">
{{ item.kind === 'income' ? 'درآمد' : 'هزینه' }}
· {{ INTERVAL_LABEL[item.interval] || item.interval }}
· بعدی {{ formatJalaliNumeric(new Date(item.nextDue)) }}
</a-typography-text>
<a-typography-text type="secondary">
{{ reminderLabel(item.reminderDaysBefore, item.reminderRepeatDaily) }}
<template v-if="item.reminderDaysBefore != null">
·
{{
[
item.reminderNotifyApp ? 'ناتیف' : null,
item.reminderNotifySms ? 'پیامک' : null,
]
.filter(Boolean)
.join(' و ') || 'بدون کانال'
}}
</template>
</a-typography-text>
</a-flex>
</template>
</a-list-item-meta>
</a-list-item>
@@ -188,5 +419,98 @@ onMounted(() => {
@update:page-size="onPageSizeChange"
/>
</a-card>
<a-modal
v-model:open="editOpen"
title="ویرایش الگو"
ok-text="ذخیره"
cancel-text="انصراف"
:confirm-loading="saving"
:width="modalWidth"
:centered="isMobile"
destroy-on-close
@ok="saveEdit"
>
<a-flex vertical :gap="12">
<a-alert v-if="error && editOpen" type="error" show-icon :message="error" />
<a-form layout="vertical" :model="editForm" @finish="saveEdit" @finishFailed="onFinishFailed">
<a-row :gutter="[16, 0]">
<a-col :xs="24" :md="12">
<a-form-item label="عنوان" name="title" :rules="[{ required: true, message: 'عنوان الزامی است' }]">
<a-input v-model:value="editForm.title">
<template #prefix><FileTextOutlined /></template>
</a-input>
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label="نوع" name="kind" :rules="[{ required: true }]">
<SelectWithIcon :icon="AppstoreOutlined">
<a-select show-search option-filter-prop="label" v-model:value="editForm.kind" style="width: 100%">
<a-select-option value="expense" label="هزینه">هزینه</a-select-option>
<a-select-option value="income" label="درآمد">درآمد</a-select-option>
</a-select>
</SelectWithIcon>
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label="مبلغ" name="amount" :rules="[{ required: true, message: 'مبلغ الزامی است' }]">
<MoneyInput addon-after="تومان" v-model="editForm.amount" :decimals="0" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label="دوره" name="interval" :rules="[{ required: true }]">
<SelectWithIcon :icon="ScheduleOutlined">
<a-select show-search option-filter-prop="label" v-model:value="editForm.interval" style="width: 100%">
<a-select-option value="monthly" label="ماهانه">ماهانه</a-select-option>
<a-select-option value="weekly" label="هفتگی">هفتگی</a-select-option>
<a-select-option value="yearly" label="سالانه">سالانه</a-select-option>
</a-select>
</SelectWithIcon>
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label="سررسید بعدی" name="dueDate">
<JalaliDateInput v-model="editForm.dueDate" />
</a-form-item>
</a-col>
<a-col :xs="24" :md="8">
<a-form-item label="زمان یادآور">
<SelectWithIcon :icon="ScheduleOutlined">
<a-select
v-model:value="editForm.reminderDaysBefore"
style="width: 100%"
:options="REMINDER_DAY_OPTIONS"
/>
</SelectWithIcon>
</a-form-item>
</a-col>
<a-col v-if="editReminderEnabled" :xs="24" :md="8">
<a-form-item label="تکرار یادآور">
<SelectWithIcon :icon="ScheduleOutlined">
<a-select
v-model:value="editForm.reminderRepeatDaily"
style="width: 100%"
:options="REMINDER_FREQ_OPTIONS"
/>
</SelectWithIcon>
</a-form-item>
</a-col>
<a-col v-if="editReminderEnabled" :span="24">
<a-form-item label="کانال یادآور">
<a-space :size="24" wrap>
<a-checkbox v-model:checked="editForm.reminderNotifyApp">ناتیفیکیشن</a-checkbox>
<a-checkbox v-model:checked="editForm.reminderNotifySms">پیامک</a-checkbox>
</a-space>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="فعال">
<a-switch v-model:checked="editForm.isActive" />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-flex>
</a-modal>
</a-flex>
</template>
@@ -5,23 +5,38 @@ import {
Alert as AAlert,
Button as AButton,
Card as ACard,
Col as ACol,
Divider as ADivider,
Empty as AEmpty,
Flex as AFlex,
Form as AForm,
FormItem as AFormItem,
List as AList,
Descriptions as ADescriptions,
DescriptionsItem as ADescriptionsItem,
Row as ARow,
Space as ASpace,
Table as ATable,
Tabs as ATabs,
Typography,
message,
} from 'ant-design-vue';
import type { TableColumnsType } from 'ant-design-vue';
import { DownloadOutlined } from '@/icons/ant-bridge';
import { DownloadOutlined, SearchOutlined } from '@/icons/ant-bridge';
import * as XLSX from 'xlsx';
import type { TreasuryPartyBalanceDto } from '@mento/shared';
import { api } from '@/lib/api';
import JalaliDateInput from '@/components/JalaliDateInput.vue';
import TreasuryListPagination from '@/components/treasury/TreasuryListPagination.vue';
import TreasuryPartyBalanceTable from '@/components/treasury/TreasuryPartyBalanceTable.vue';
import {
dateToJalali,
formatJalaliNumeric,
formatLocalDateInput,
jalaliMonthName,
jalaliToDate,
toFaDigits,
} from '@/lib/jalali';
import { toman } from './treasury-format';
import { useTreasuryListPaging } from './useTreasuryListPaging';
import { useTreasuryMobile } from './useTreasuryMobile';
@@ -51,13 +66,23 @@ type MetricRow = {
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 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 debtors = ref<TreasuryPartyBalanceDto[]>([]);
const creditors = ref<TreasuryPartyBalanceDto[]>([]);
const reportTab = ref('periods');
const loading = ref(false);
const error = ref('');
const balanceError = ref('');
@@ -78,6 +103,17 @@ const lines = [
['خالص جریان نقدی', 'cashNet'],
] as const;
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: TableColumnsType<MetricRow> = [
{ title: 'شاخص', dataIndex: 'label', key: 'label' },
{ title: 'این دوره', dataIndex: 'current', key: 'current' },
@@ -127,17 +163,84 @@ const {
'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() {
const { data } = await api.get<{
current: Period;
previous: Period;
payablesByMonth: Array<{ month: string; amount: string }>;
receivablesByParty: Array<{ name: string; amount: string }>;
}>('/treasury/reports');
current.value = data.current;
previous.value = data.previous;
payablesByMonth.value = data.payablesByMonth;
receivablesByParty.value = data.receivablesByParty;
loading.value = true;
error.value = '';
try {
const { data } = await api.get<{
from?: string;
to?: string;
previousFrom?: string;
previousTo?: string;
current: Period;
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[]) {
@@ -185,7 +288,13 @@ async function loadBalances() {
}
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 link = document.createElement('a');
link.href = url;
@@ -195,9 +304,7 @@ async function download() {
}
onMounted(() => {
void load().catch(() => {
error.value = 'گزارش بارگذاری نشد.';
});
void load();
void loadBalances().catch((e: unknown) => {
if (axios.isAxiosError(e) && (e.response?.status === 404 || e.response?.status === 403)) {
debtors.value = [];
@@ -211,12 +318,42 @@ onMounted(() => {
<template>
<a-flex vertical :gap="16">
<a-flex justify="flex-end">
<a-button @click="download">
<template #icon><DownloadOutlined /></template>
خروجی اکسل
</a-button>
</a-flex>
<a-card :bordered="false">
<a-form layout="vertical" @finish="applyRange">
<a-row :gutter="[16, 0]">
<a-col :xs="24" :sm="12" :md="8">
<a-form-item label="از تاریخ">
<JalaliDateInput v-model="fromDate" />
</a-form-item>
</a-col>
<a-col :xs="24" :sm="12" :md="8">
<a-form-item label="تا تاریخ">
<JalaliDateInput v-model="toDate" />
</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="balanceError" type="error" show-icon :message="balanceError" />
@@ -225,14 +362,25 @@ onMounted(() => {
<a-tabs v-model:activeKey="reportTab">
<a-tab-pane key="periods" tab="مقایسه دوره‌ها">
<a-flex vertical :gap="16">
<a-descriptions bordered :column="isMobile ? 1 : 2">
<a-descriptions-item label="این دوره">{{ currentRangeLabel }}</a-descriptions-item>
<a-descriptions-item label="دوره قبل">{{ previousRangeLabel }}</a-descriptions-item>
</a-descriptions>
<a-list v-if="isMobile && metricRows.length" :data-source="metricRows">
<template #renderItem="{ item }">
<a-list-item>
<a-card :title="item.label" style="width: 100%">
<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-flex vertical :gap="8">
<a-flex justify="space-between" align="center" :gap="8">
<a-typography-text type="secondary">این دوره</a-typography-text>
<a-typography-text strong>{{ item.current }}</a-typography-text>
</a-flex>
<a-flex justify="space-between" align="center" :gap="8">
<a-typography-text type="secondary">دوره قبل</a-typography-text>
<a-typography-text>{{ item.previous }}</a-typography-text>
</a-flex>
</a-flex>
</a-card>
</a-list-item>
</template>
@@ -242,6 +390,7 @@ onMounted(() => {
:columns="metricColumns"
:data-source="metricRows"
:pagination="false"
:loading="loading"
row-key="key"
/>
<a-empty v-else description="داده‌ای برای نمایش نیست." />
@@ -269,7 +418,7 @@ onMounted(() => {
@update:page-size="onPartyPageSizeChange"
/>
<a-divider orientation="right">تعهدات به تفکیک ماه</a-divider>
<a-divider orientation="right">تعهدات به تفکیک ماه شمسی</a-divider>
<a-empty v-if="!payablesByMonth.length" description="تعهد بازی نیست." />
<a-list v-else :item-layout="isMobile ? 'vertical' : 'horizontal'" :data-source="pagedMonthRows">
<template #renderItem="{ item }">
@@ -278,7 +427,7 @@ onMounted(() => {
<a-typography-text strong>{{ toman(item.amount) }}</a-typography-text>
</template>
<a-list-item-meta>
<template #title>{{ item.month }}</template>
<template #title>{{ monthTitle(item) }}</template>
</a-list-item-meta>
</a-list-item>
</template>
@@ -293,7 +442,7 @@ onMounted(() => {
/>
<template v-if="current">
<a-divider orientation="right">سهم هزینه‌ها</a-divider>
<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 }">