fix(crm): honor open data scopes and role assignees
Unset sections on a saved role policy were still filtered as own-only, so full lead access showed nothing. Activities can now be assigned by org role, and the Tahesab sales report reads as a result instead of a tag wall. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -81,6 +81,59 @@ const period = ref<'custom' | 'week' | 'month' | 'season'>('month');
|
||||
const overview = ref<TahesabSalesOverviewDto | null>(null);
|
||||
const auth = useAuthStore();
|
||||
const canGroups = computed(() => canManageSettings(auth.user?.role));
|
||||
const showInternet = computed(() => {
|
||||
const mods = auth.user?.enabledModules;
|
||||
return Boolean(mods?.includes('montify'));
|
||||
});
|
||||
|
||||
function normDocTitle(raw: string) {
|
||||
return raw.replace(/\u064A/g, '\u06CC').replace(/\u0643/g, '\u06A9');
|
||||
}
|
||||
|
||||
const otherDocGroups = computed(() => {
|
||||
const buckets: Array<{ title: string; hint: string; test: (title: string) => boolean; names: string[] }> = [
|
||||
{
|
||||
title: 'درصد اجرت',
|
||||
hint: 'نرخ اجرت روی سند است. وزن فروش نیست و در چهار بخش کالا جمع نمیشود.',
|
||||
test: (title) => title.includes('درصد'),
|
||||
names: [],
|
||||
},
|
||||
{
|
||||
title: 'بانک، نقد و چک',
|
||||
hint: 'جابهجایی پول است، فروش کالا نیست.',
|
||||
test: (title) => /بانک|وجه نقد|چک|برداشت|واریز/.test(title),
|
||||
names: [],
|
||||
},
|
||||
{
|
||||
title: 'طلب، بدهی، تخفیف و تبدیل',
|
||||
hint: 'حساب مشتری یا تبدیل پول و وزن است، فروش کالا نیست.',
|
||||
test: (title) => /طلب|بدهی|تخفیف|پولی کردن/.test(title),
|
||||
names: [],
|
||||
},
|
||||
{
|
||||
title: 'فروش و خرید بدون نام کالا',
|
||||
hint: 'این سند فروش یا خرید است، اما نوع کالا در عنوان آن نیامده. وزن آن در ردیف «سایر عنوانها» محاسبه شده است.',
|
||||
test: (title) => /فروش|خرید|کالا|آبشده|متفرقه/.test(title),
|
||||
names: [],
|
||||
},
|
||||
];
|
||||
const rest: string[] = [];
|
||||
for (const name of overview.value?.otherNos ?? []) {
|
||||
const title = normDocTitle(name);
|
||||
const bucket = buckets.find((item) => item.test(title));
|
||||
if (bucket) bucket.names.push(name);
|
||||
else rest.push(name);
|
||||
}
|
||||
if (rest.length) {
|
||||
buckets.push({
|
||||
title: 'عنوانهای دیگر',
|
||||
hint: 'در چهار بخش کالا جا نگرفتهاند.',
|
||||
test: () => true,
|
||||
names: rest,
|
||||
});
|
||||
}
|
||||
return buckets.filter((item) => item.names.length);
|
||||
});
|
||||
const childGroupId = ref<string | undefined>();
|
||||
const parentGroupId = ref<string | undefined>();
|
||||
const overviewError = ref('');
|
||||
@@ -226,12 +279,12 @@ function formatNum(n: number | null | undefined) {
|
||||
}
|
||||
|
||||
function formatMali(n: number | null | undefined) {
|
||||
return formatTahesabBedBes(n);
|
||||
return formatTahesabBedBes(n, 0);
|
||||
}
|
||||
|
||||
const columns: TableColumnsType<TahesabAsnadLineDto> = [
|
||||
{
|
||||
title: 'تاریخ',
|
||||
title: 'تاریخ سند',
|
||||
dataIndex: 'tarikh',
|
||||
key: 'tarikh',
|
||||
width: 110,
|
||||
@@ -513,7 +566,7 @@ onUnmounted(() => stopPoll());
|
||||
گزارش فروش تهحساب
|
||||
</a-typography-title>
|
||||
<a-typography-text type="secondary">
|
||||
وزن خالص فروش و خرید بعد از مرجوعی، به تفکیک گروه، کارشناس و فروش اینترنتی
|
||||
وزن خالص فروش و خرید بعد از مرجوعی، به تفکیک گروه و کارشناس{{ showInternet ? ' و فروش اینترنتی' : '' }}
|
||||
</a-typography-text>
|
||||
</div>
|
||||
<a-space :size="8" wrap>
|
||||
@@ -716,25 +769,30 @@ onUnmounted(() => stopPoll());
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<SalesReportBoard :overview="overview" />
|
||||
<SalesReportBoard :overview="overview" :show-internet="showInternet" />
|
||||
</a-col>
|
||||
|
||||
<a-col v-if="summary" :span="24">
|
||||
<a-typography-paragraph type="secondary" :style="{ marginBottom: 0 }">
|
||||
سه عدد زیر جمع همهٔ سندهای بازه است، از جمله بانک و درصد. نتیجهٔ فروش کالا جدول «نتیجهٔ این بازه» است.
|
||||
</a-typography-paragraph>
|
||||
</a-col>
|
||||
<a-col v-if="summary" :xs="24" :sm="8">
|
||||
<a-card :bordered="false">
|
||||
<a-statistic
|
||||
title="تعداد ردیف"
|
||||
title="تعداد ردیف سند"
|
||||
:value="toFaDigits(String(summary.totalLines))"
|
||||
/>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col v-if="summary" :xs="24" :sm="8">
|
||||
<a-card :bordered="false">
|
||||
<a-statistic title="جمع مبلغ" :value="formatMali(summary.maliSum)" />
|
||||
<a-statistic title="جمع مبلغ همهٔ سندها" :value="formatMali(summary.maliSum)" />
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col v-if="summary" :xs="24" :sm="8">
|
||||
<a-card :bordered="false">
|
||||
<a-statistic title="جمع وزن" :value="formatNum(summary.vaznSum)" />
|
||||
<a-statistic title="جمع وزن همهٔ سندها" :value="formatNum(summary.vaznSum)" />
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
@@ -774,12 +832,30 @@ onUnmounted(() => stopPoll());
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
||||
<a-col v-if="summary?.distinctNos?.length" :span="24">
|
||||
<a-card :bordered="false" title="انواع سند خام (NO)">
|
||||
<a-space wrap>
|
||||
<a-tag v-for="no in summary.distinctNos" :key="no">{{ no }}</a-tag>
|
||||
</a-space>
|
||||
</a-card>
|
||||
<a-col v-if="(overview?.otherNos?.length ?? 0) > 0" :span="24">
|
||||
<a-collapse :bordered="false">
|
||||
<a-collapse-panel
|
||||
key="other"
|
||||
:header="`سندهایی که نوع کالا مشخص نیست (${toFaDigits(String(overview?.otherNos.length ?? 0))} عنوان)`"
|
||||
>
|
||||
<a-typography-paragraph type="secondary">
|
||||
جدول بالا فقط کارساخته، اتیکت، شمش و سکه است. بقیهٔ عنوانها اینجا دستهبندی شدهاند.
|
||||
</a-typography-paragraph>
|
||||
<a-list :data-source="otherDocGroups" item-layout="vertical">
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item>
|
||||
<a-list-item-meta
|
||||
:title="`${item.title} (${toFaDigits(String(item.names.length))})`"
|
||||
:description="item.hint"
|
||||
/>
|
||||
<a-space wrap>
|
||||
<a-tag v-for="name in item.names" :key="name">{{ name }}</a-tag>
|
||||
</a-space>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</a-collapse-panel>
|
||||
</a-collapse>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
|
||||
Reference in New Issue
Block a user