Show cached rial and weight balances on balance-claims activity cards and details.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
|||||||
NotFoundException,
|
NotFoundException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import type {
|
import type {
|
||||||
|
ActivityAccountBalanceDto,
|
||||||
ActivityDto,
|
ActivityDto,
|
||||||
ActivityFieldValues,
|
ActivityFieldValues,
|
||||||
ActivityFilter,
|
ActivityFilter,
|
||||||
@@ -15,6 +16,12 @@ import type {
|
|||||||
PaginatedResponse,
|
PaginatedResponse,
|
||||||
UpdateActivityRequest,
|
UpdateActivityRequest,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
|
import {
|
||||||
|
ACCOUNT_BALANCE_CLAIMS_TAG,
|
||||||
|
ACCOUNT_BALANCE_WEIGHT_KEYS,
|
||||||
|
ACCOUNT_BALANCE_WEIGHT_LABELS,
|
||||||
|
parseAccountBalanceWeightFields,
|
||||||
|
} from '@mento/shared';
|
||||||
import { Prisma } from '@prisma/client';
|
import { Prisma } from '@prisma/client';
|
||||||
import { randomUUID } from 'node:crypto';
|
import { randomUUID } from 'node:crypto';
|
||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
@@ -38,6 +45,7 @@ import { tehranDayKey } from '../routines/routine-dates';
|
|||||||
import { buildSearchWhere, ci } from '../common/search';
|
import { buildSearchWhere, ci } from '../common/search';
|
||||||
import { activityPriorWhere } from '../common/prior-archive';
|
import { activityPriorWhere } from '../common/prior-archive';
|
||||||
import { leadsDeepWhere } from '../common/data-access';
|
import { leadsDeepWhere } from '../common/data-access';
|
||||||
|
import { extractMandehRaw } from '../integrations/tahesab/tahesab-methods';
|
||||||
import { ActivityStagesService, type BoardStageContext } from './activity-stages.service';
|
import { ActivityStagesService, type BoardStageContext } from './activity-stages.service';
|
||||||
import {
|
import {
|
||||||
ActivityTypesService,
|
ActivityTypesService,
|
||||||
@@ -363,10 +371,24 @@ export class ActivitiesService {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const ctx = await this.ctx(organizationId);
|
const ctx = await this.ctx(organizationId);
|
||||||
|
const [todayDto, overdueDto, upcomingDto] = await Promise.all([
|
||||||
|
this.withAccountBalances(
|
||||||
|
organizationId,
|
||||||
|
today.map((row) => this.toDto(row, ctx)),
|
||||||
|
),
|
||||||
|
this.withAccountBalances(
|
||||||
|
organizationId,
|
||||||
|
overdue.map((row) => this.toDto(row, ctx)),
|
||||||
|
),
|
||||||
|
this.withAccountBalances(
|
||||||
|
organizationId,
|
||||||
|
upcoming.map((row) => this.toDto(row, ctx)),
|
||||||
|
),
|
||||||
|
]);
|
||||||
return {
|
return {
|
||||||
today: today.map((row) => this.toDto(row, ctx)),
|
today: todayDto,
|
||||||
overdue: overdue.map((row) => this.toDto(row, ctx)),
|
overdue: overdueDto,
|
||||||
upcoming: upcoming.map((row) => this.toDto(row, ctx)),
|
upcoming: upcomingDto,
|
||||||
todayCount,
|
todayCount,
|
||||||
overdueCount,
|
overdueCount,
|
||||||
};
|
};
|
||||||
@@ -418,7 +440,10 @@ export class ActivitiesService {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: rows.map((row) => this.toDto(row, ctx)),
|
items: await this.withAccountBalances(
|
||||||
|
organizationId,
|
||||||
|
rows.map((row) => this.toDto(row, ctx)),
|
||||||
|
),
|
||||||
total,
|
total,
|
||||||
page,
|
page,
|
||||||
limit: take,
|
limit: take,
|
||||||
@@ -689,7 +714,8 @@ export class ActivitiesService {
|
|||||||
orderBy: { fullName: 'asc' },
|
orderBy: { fullName: 'asc' },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return dto;
|
const [enriched] = await this.withAccountBalances(organizationId, [dto]);
|
||||||
|
return enriched;
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(
|
async create(
|
||||||
@@ -1635,6 +1661,105 @@ export class ActivitiesService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** فقط فعالیتهای تگ مطالبات؛ مانده از کش تهحساب بدون فراخوانی زنده */
|
||||||
|
private async withAccountBalances(
|
||||||
|
organizationId: string,
|
||||||
|
items: ActivityDto[],
|
||||||
|
): Promise<ActivityDto[]> {
|
||||||
|
if (!items.length) return items;
|
||||||
|
const claimItems = items.filter((item) =>
|
||||||
|
(item.tags ?? []).includes(ACCOUNT_BALANCE_CLAIMS_TAG),
|
||||||
|
);
|
||||||
|
if (!claimItems.length) return items;
|
||||||
|
|
||||||
|
const personIds = [
|
||||||
|
...new Set(
|
||||||
|
claimItems
|
||||||
|
.map((item) => item.person?.id)
|
||||||
|
.filter((id): id is string => Boolean(id)),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
const balanceByPerson = new Map<string, ActivityAccountBalanceDto | null>();
|
||||||
|
if (personIds.length) {
|
||||||
|
const links = await this.prisma.personAccountingLink.findMany({
|
||||||
|
where: {
|
||||||
|
personId: { in: personIds },
|
||||||
|
person: { organizationId },
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
balanceCache: true,
|
||||||
|
connection: { select: { isDefault: true } },
|
||||||
|
},
|
||||||
|
orderBy: [{ linkedAt: 'desc' }],
|
||||||
|
});
|
||||||
|
const bestByPerson = new Map<string, (typeof links)[number]>();
|
||||||
|
for (const link of links) {
|
||||||
|
const prev = bestByPerson.get(link.personId);
|
||||||
|
if (!prev) {
|
||||||
|
bestByPerson.set(link.personId, link);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const prevScore =
|
||||||
|
(prev.balanceCache ? 2 : 0) + (prev.connection.isDefault ? 1 : 0);
|
||||||
|
const nextScore =
|
||||||
|
(link.balanceCache ? 2 : 0) + (link.connection.isDefault ? 1 : 0);
|
||||||
|
if (nextScore > prevScore) bestByPerson.set(link.personId, link);
|
||||||
|
}
|
||||||
|
for (const personId of personIds) {
|
||||||
|
const link = bestByPerson.get(personId);
|
||||||
|
balanceByPerson.set(
|
||||||
|
personId,
|
||||||
|
link?.balanceCache
|
||||||
|
? this.cacheToAccountBalance(link.balanceCache)
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items.map((item) => {
|
||||||
|
if (!(item.tags ?? []).includes(ACCOUNT_BALANCE_CLAIMS_TAG)) return item;
|
||||||
|
const personId = item.person?.id;
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
accountBalance: personId
|
||||||
|
? (balanceByPerson.get(personId) ?? null)
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private cacheToAccountBalance(cache: {
|
||||||
|
rialBalance: number | null;
|
||||||
|
goldBalance: number | null;
|
||||||
|
rawResponse: unknown;
|
||||||
|
fetchedAt: Date;
|
||||||
|
}): ActivityAccountBalanceDto {
|
||||||
|
const fields = parseAccountBalanceWeightFields(
|
||||||
|
extractMandehRaw(cache.rawResponse).fields,
|
||||||
|
);
|
||||||
|
const weights = ACCOUNT_BALANCE_WEIGHT_KEYS.map((key) => {
|
||||||
|
const value =
|
||||||
|
fields[key] ??
|
||||||
|
(key === 'MandeyeVazni' ? cache.goldBalance : null) ??
|
||||||
|
null;
|
||||||
|
if (value == null || !Number.isFinite(value)) return null;
|
||||||
|
return {
|
||||||
|
key,
|
||||||
|
label: ACCOUNT_BALANCE_WEIGHT_LABELS[key] ?? key,
|
||||||
|
value,
|
||||||
|
};
|
||||||
|
}).filter((row): row is NonNullable<typeof row> => row != null);
|
||||||
|
|
||||||
|
return {
|
||||||
|
rialBalance:
|
||||||
|
cache.rialBalance != null && Number.isFinite(cache.rialBalance)
|
||||||
|
? cache.rialBalance
|
||||||
|
: null,
|
||||||
|
weights,
|
||||||
|
fetchedAt: cache.fetchedAt.toISOString(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private toDto(row: ActivityRow, ctx?: DtoContext): ActivityDto {
|
private toDto(row: ActivityRow, ctx?: DtoContext): ActivityDto {
|
||||||
const fields =
|
const fields =
|
||||||
row.fields && typeof row.fields === 'object' && !Array.isArray(row.fields)
|
row.fields && typeof row.fields === 'object' && !Array.isArray(row.fields)
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ function toCard(item: ActivityDto, stageId: string): PipelineDeal {
|
|||||||
assigneeIds: (item.assignees ?? []).map((a) => a.id),
|
assigneeIds: (item.assignees ?? []).map((a) => a.id),
|
||||||
priority: item.priority,
|
priority: item.priority,
|
||||||
activityStatus: item.status,
|
activityStatus: item.status,
|
||||||
|
accountBalance: item.accountBalance ?? null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { theme } from 'ant-design-vue';
|
||||||
|
import type { ActivityAccountBalanceDto } from '@mento/shared';
|
||||||
|
import { formatTahesabBedBes } from '@/lib/tahesab';
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
balance: ActivityAccountBalanceDto | null | undefined;
|
||||||
|
/** فشردهتر برای کارت کانبان */
|
||||||
|
compact?: boolean;
|
||||||
|
}>(),
|
||||||
|
{ compact: false },
|
||||||
|
);
|
||||||
|
|
||||||
|
const { token } = theme.useToken();
|
||||||
|
|
||||||
|
type Line = {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
text: string;
|
||||||
|
value: number | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const lines = computed<Line[]>(() => {
|
||||||
|
const bal = props.balance;
|
||||||
|
if (!bal) return [];
|
||||||
|
const out: Line[] = [];
|
||||||
|
if (bal.rialBalance != null && Number.isFinite(bal.rialBalance)) {
|
||||||
|
out.push({
|
||||||
|
key: 'rial',
|
||||||
|
label: 'مانده ریالی',
|
||||||
|
text: `${formatTahesabBedBes(bal.rialBalance, 0)} ریال`,
|
||||||
|
value: bal.rialBalance,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (const w of bal.weights ?? []) {
|
||||||
|
if (w.value == null || !Number.isFinite(w.value)) continue;
|
||||||
|
out.push({
|
||||||
|
key: w.key,
|
||||||
|
label: w.label,
|
||||||
|
text: `${formatTahesabBedBes(w.value, 3)} گرم`,
|
||||||
|
value: w.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
});
|
||||||
|
|
||||||
|
const visible = computed(() => lines.value.length > 0);
|
||||||
|
|
||||||
|
function toneColor(value: number | null) {
|
||||||
|
if (value == null || !Number.isFinite(value) || value === 0) {
|
||||||
|
return token.value.colorTextSecondary;
|
||||||
|
}
|
||||||
|
return value < 0 ? token.value.colorError : token.value.colorSuccess;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<a-flex
|
||||||
|
v-if="visible"
|
||||||
|
vertical
|
||||||
|
:gap="compact ? 2 : 4"
|
||||||
|
:style="{ minWidth: 0, width: '100%' }"
|
||||||
|
>
|
||||||
|
<a-typography-text
|
||||||
|
v-for="line in lines"
|
||||||
|
:key="line.key"
|
||||||
|
dir="ltr"
|
||||||
|
:style="{
|
||||||
|
margin: 0,
|
||||||
|
display: 'block',
|
||||||
|
fontSize: `${compact ? token.fontSizeSM : token.fontSize}px`,
|
||||||
|
fontWeight: 600,
|
||||||
|
color: toneColor(line.value),
|
||||||
|
textAlign: 'right',
|
||||||
|
direction: 'rtl',
|
||||||
|
}"
|
||||||
|
:title="`${line.label}: ${line.text}`"
|
||||||
|
>
|
||||||
|
<a-typography-text
|
||||||
|
type="secondary"
|
||||||
|
:style="{
|
||||||
|
fontSize: `${token.fontSizeSM}px`,
|
||||||
|
fontWeight: 500,
|
||||||
|
marginInlineEnd: '6px',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ line.label }}:
|
||||||
|
</a-typography-text>
|
||||||
|
{{ line.text }}
|
||||||
|
</a-typography-text>
|
||||||
|
</a-flex>
|
||||||
|
</template>
|
||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
import { useAuthStore } from '@/stores/auth';
|
import { useAuthStore } from '@/stores/auth';
|
||||||
import { canCollaborateOnActivity, canMutateActivity } from '@/lib/activity-access';
|
import { canCollaborateOnActivity, canMutateActivity } from '@/lib/activity-access';
|
||||||
import ActivityCommentSheet from '@/components/activities/ActivityCommentSheet.vue';
|
import ActivityCommentSheet from '@/components/activities/ActivityCommentSheet.vue';
|
||||||
|
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
|
||||||
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -555,6 +556,16 @@ function openFull() {
|
|||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="activity.accountBalance"
|
||||||
|
:style="{ marginTop: '12px' }"
|
||||||
|
>
|
||||||
|
<a-typography-text type="secondary" :style="{ display: 'block', marginBottom: '4px' }">
|
||||||
|
مانده حساب
|
||||||
|
</a-typography-text>
|
||||||
|
<ActivityAccountBalances :balance="activity.accountBalance" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<a-divider :style="{ margin: '16px 0 12px' }" />
|
<a-divider :style="{ margin: '16px 0 12px' }" />
|
||||||
<a-flex justify="space-between" align="center" :style="{ marginBottom: '8px' }">
|
<a-flex justify="space-between" align="center" :style="{ marginBottom: '8px' }">
|
||||||
<a-typography-text strong>یادداشت</a-typography-text>
|
<a-typography-text strong>یادداشت</a-typography-text>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
theme,
|
theme,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
import DealQuickActivityPopover from '@/components/pipeline/DealQuickActivityPopover.vue';
|
import DealQuickActivityPopover from '@/components/pipeline/DealQuickActivityPopover.vue';
|
||||||
|
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
|
||||||
import { calendarDaysBetween, formatJalaliNumeric } from '@/lib/jalali';
|
import { calendarDaysBetween, formatJalaliNumeric } from '@/lib/jalali';
|
||||||
import { userAvatarSrc } from '@/lib/userAvatars';
|
import { userAvatarSrc } from '@/lib/userAvatars';
|
||||||
import type { PipelineAccent, PipelineDeal, PipelineUiCopy } from '@/lib/pipeline-board';
|
import type { PipelineAccent, PipelineDeal, PipelineUiCopy } from '@/lib/pipeline-board';
|
||||||
@@ -244,6 +245,12 @@ const cardStyle = computed(() => ({
|
|||||||
>
|
>
|
||||||
{{ deal.description }}
|
{{ deal.description }}
|
||||||
</a-typography-text>
|
</a-typography-text>
|
||||||
|
<ActivityAccountBalances
|
||||||
|
v-if="deal.accountBalance"
|
||||||
|
:balance="deal.accountBalance"
|
||||||
|
compact
|
||||||
|
:style="{ marginTop: '6px' }"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span :data-card-id="deal.id">
|
<span :data-card-id="deal.id">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { currencySuffix } from '@/lib/money';
|
import { currencySuffix } from '@/lib/money';
|
||||||
import { matchesSearch } from '@/lib/search';
|
import { matchesSearch } from '@/lib/search';
|
||||||
import type {
|
import type {
|
||||||
|
ActivityAccountBalanceDto,
|
||||||
ActivityPriority,
|
ActivityPriority,
|
||||||
ActivityStatus,
|
ActivityStatus,
|
||||||
DealActivityCue,
|
DealActivityCue,
|
||||||
@@ -39,6 +40,8 @@ export type PipelineDeal = {
|
|||||||
activityCue?: DealActivityCue;
|
activityCue?: DealActivityCue;
|
||||||
/** خلاصه فعالیتها برای پاپآپ دکمهٔ تقویم */
|
/** خلاصه فعالیتها برای پاپآپ دکمهٔ تقویم */
|
||||||
activitySummaries?: DealActivitySummaryDto[];
|
activitySummaries?: DealActivitySummaryDto[];
|
||||||
|
/** مانده ریالی/وزنی فقط برای کارتهای کاریز مطالبات */
|
||||||
|
accountBalance?: ActivityAccountBalanceDto | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PipelineUiCopy = {
|
export type PipelineUiCopy = {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
import UiIcon from '@/components/UiIcon.vue';
|
import UiIcon from '@/components/UiIcon.vue';
|
||||||
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
import ExcelImportFlow from '@/components/ExcelImportFlow.vue';
|
||||||
import ActivitiesKanban from '@/components/activities/ActivitiesKanban.vue';
|
import ActivitiesKanban from '@/components/activities/ActivitiesKanban.vue';
|
||||||
|
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
|
||||||
import ActivityDeskFilters from '@/components/activities/ActivityDeskFilters.vue';
|
import ActivityDeskFilters from '@/components/activities/ActivityDeskFilters.vue';
|
||||||
import ActivityStagesManager from '@/components/activities/ActivityStagesManager.vue';
|
import ActivityStagesManager from '@/components/activities/ActivityStagesManager.vue';
|
||||||
import ActivityTypesManager from '@/components/activities/ActivityTypesManager.vue';
|
import ActivityTypesManager from '@/components/activities/ActivityTypesManager.vue';
|
||||||
@@ -1773,6 +1774,11 @@ onUnmounted(() => {
|
|||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<p v-if="subtitle(item)" class="sub">{{ subtitle(item) }}</p>
|
<p v-if="subtitle(item)" class="sub">{{ subtitle(item) }}</p>
|
||||||
|
<ActivityAccountBalances
|
||||||
|
v-if="item.accountBalance"
|
||||||
|
:balance="item.accountBalance"
|
||||||
|
compact
|
||||||
|
/>
|
||||||
<p v-if="item.tags?.length" class="row-tags">
|
<p v-if="item.tags?.length" class="row-tags">
|
||||||
<span v-for="t in item.tags.slice(0, 3)" :key="t">#{{ t }}</span>
|
<span v-for="t in item.tags.slice(0, 3)" :key="t">#{{ t }}</span>
|
||||||
<span v-if="item.tags.length > 3">+{{ toFaDigits(item.tags.length - 3) }}</span>
|
<span v-if="item.tags.length > 3">+{{ toFaDigits(item.tags.length - 3) }}</span>
|
||||||
@@ -1905,6 +1911,11 @@ onUnmounted(() => {
|
|||||||
<UiIcon name="star" :size="14" class="star" />
|
<UiIcon name="star" :size="14" class="star" />
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<p v-if="subtitle(item)" class="sub">{{ subtitle(item) }}</p>
|
<p v-if="subtitle(item)" class="sub">{{ subtitle(item) }}</p>
|
||||||
|
<ActivityAccountBalances
|
||||||
|
v-if="item.accountBalance"
|
||||||
|
:balance="item.accountBalance"
|
||||||
|
compact
|
||||||
|
/>
|
||||||
<p class="meta-line">
|
<p class="meta-line">
|
||||||
<span v-if="item.person">
|
<span v-if="item.person">
|
||||||
<UiIcon name="user" :size="13" />
|
<UiIcon name="user" :size="13" />
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import JalaliDateInput from '@/components/JalaliDateInput.vue';
|
|||||||
import ActivityCommentSheet from '@/components/activities/ActivityCommentSheet.vue';
|
import ActivityCommentSheet from '@/components/activities/ActivityCommentSheet.vue';
|
||||||
import ActivityPostponeSheet from '@/components/activities/ActivityPostponeSheet.vue';
|
import ActivityPostponeSheet from '@/components/activities/ActivityPostponeSheet.vue';
|
||||||
import ActivityFieldsView from '@/components/activities/ActivityFieldsView.vue';
|
import ActivityFieldsView from '@/components/activities/ActivityFieldsView.vue';
|
||||||
|
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
|
||||||
import StagePathStrip from '@/components/StagePathStrip.vue';
|
import StagePathStrip from '@/components/StagePathStrip.vue';
|
||||||
import { Button as AButton, message, Modal } from 'ant-design-vue';
|
import { Button as AButton, message, Modal } from 'ant-design-vue';
|
||||||
import type {
|
import type {
|
||||||
@@ -1237,6 +1238,9 @@ onUnmounted(() => {
|
|||||||
#{{ t }}
|
#{{ t }}
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="activity.accountBalance" class="claim-balances">
|
||||||
|
<ActivityAccountBalances :balance="activity.accountBalance" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="type-ico" :style="typeColorStyle(draftTypeView!.color)">
|
<span class="type-ico" :style="typeColorStyle(draftTypeView!.color)">
|
||||||
<UiIcon :name="draftTypeView!.icon" :size="22" />
|
<UiIcon :name="draftTypeView!.icon" :size="22" />
|
||||||
@@ -2030,6 +2034,10 @@ onUnmounted(() => {
|
|||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.claim-balances {
|
||||||
|
margin-top: 0.65rem;
|
||||||
|
}
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
background: #f0fdfa;
|
background: #f0fdfa;
|
||||||
color: #0f766e;
|
color: #0f766e;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import ActivityFieldsEditor from '@/components/activities/ActivityFieldsEditor.v
|
|||||||
import { useActivityPriorities } from '@/lib/activity-priorities';
|
import { useActivityPriorities } from '@/lib/activity-priorities';
|
||||||
import { typeColorStyle, useActivityTypes } from '@/lib/activity-types';
|
import { typeColorStyle, useActivityTypes } from '@/lib/activity-types';
|
||||||
import type {
|
import type {
|
||||||
|
ActivityAccountBalanceDto,
|
||||||
ActivityBoardDto,
|
ActivityBoardDto,
|
||||||
ActivityDto,
|
ActivityDto,
|
||||||
ActivityImageDto,
|
ActivityImageDto,
|
||||||
@@ -51,6 +52,7 @@ import type {
|
|||||||
PipelineBoardDto,
|
PipelineBoardDto,
|
||||||
TeamDto,
|
TeamDto,
|
||||||
} from '@mento/shared';
|
} from '@mento/shared';
|
||||||
|
import ActivityAccountBalances from '@/components/activities/ActivityAccountBalances.vue';
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -101,6 +103,8 @@ const keepTypeId = ref('');
|
|||||||
const priority = ref<ActivityPriority>('medium');
|
const priority = ref<ActivityPriority>('medium');
|
||||||
const description = ref('');
|
const description = ref('');
|
||||||
const tagsRaw = ref('');
|
const tagsRaw = ref('');
|
||||||
|
/** فقط فعالیتهای کاریز مطالبات از API میآید */
|
||||||
|
const accountBalance = ref<ActivityAccountBalanceDto | null>(null);
|
||||||
const PHOTO_TOO_LARGE = 'حجم عکس باید زیر 200 کیلوبایت باشد';
|
const PHOTO_TOO_LARGE = 'حجم عکس باید زیر 200 کیلوبایت باشد';
|
||||||
const PHOTO_LIMIT = 8;
|
const PHOTO_LIMIT = 8;
|
||||||
type PendingPhoto = { localId: string; name: string; dataUrl: string; file: File };
|
type PendingPhoto = { localId: string; name: string; dataUrl: string; file: File };
|
||||||
@@ -438,6 +442,7 @@ function resetForm() {
|
|||||||
priority.value = 'medium';
|
priority.value = 'medium';
|
||||||
description.value = '';
|
description.value = '';
|
||||||
tagsRaw.value = '';
|
tagsRaw.value = '';
|
||||||
|
accountBalance.value = null;
|
||||||
clearPhotos();
|
clearPhotos();
|
||||||
createdActivityId.value = '';
|
createdActivityId.value = '';
|
||||||
defaultDue();
|
defaultDue();
|
||||||
@@ -515,6 +520,7 @@ async function load() {
|
|||||||
description.value = data.description ?? '';
|
description.value = data.description ?? '';
|
||||||
needsNote.value = Boolean(data.description?.trim());
|
needsNote.value = Boolean(data.description?.trim());
|
||||||
tagsRaw.value = (data.tags ?? []).join('، ');
|
tagsRaw.value = (data.tags ?? []).join('، ');
|
||||||
|
accountBalance.value = data.accountBalance ?? null;
|
||||||
splitDue(data.dueAt);
|
splitDue(data.dueAt);
|
||||||
durationMinutes.value = data.durationMinutes ?? 30;
|
durationMinutes.value = data.durationMinutes ?? 30;
|
||||||
reminderAt.value = data.reminderAt
|
reminderAt.value = data.reminderAt
|
||||||
@@ -1641,6 +1647,12 @@ watch([id, isNew], () => void load(), { immediate: true });
|
|||||||
<dt>مشتری مرتبط</dt>
|
<dt>مشتری مرتبط</dt>
|
||||||
<dd>{{ selectedPerson?.fullName || '—' }}</dd>
|
<dd>{{ selectedPerson?.fullName || '—' }}</dd>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="accountBalance">
|
||||||
|
<dt>مانده حساب</dt>
|
||||||
|
<dd>
|
||||||
|
<ActivityAccountBalances :balance="accountBalance" />
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<dt>وضعیت انجام</dt>
|
<dt>وضعیت انجام</dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
|||||||
@@ -2253,6 +2253,19 @@ export const ACTIVITY_EDIT_POLICY_LABELS: Record<ActivityEditPolicy, string> = {
|
|||||||
assignees: "همهٔ مسئولان",
|
assignees: "همهٔ مسئولان",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** ماندهٔ کششدهٔ تهحساب برای کارت/جزئیات فعالیت مطالبات */
|
||||||
|
export interface ActivityAccountBalanceWeightDto {
|
||||||
|
key: string;
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActivityAccountBalanceDto {
|
||||||
|
rialBalance: number | null;
|
||||||
|
weights: ActivityAccountBalanceWeightDto[];
|
||||||
|
fetchedAt: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ActivityDto {
|
export interface ActivityDto {
|
||||||
id: string;
|
id: string;
|
||||||
type: ActivityType;
|
type: ActivityType;
|
||||||
@@ -2280,6 +2293,11 @@ export interface ActivityDto {
|
|||||||
importSource?: string;
|
importSource?: string;
|
||||||
promotedFromPriorAt?: string | null;
|
promotedFromPriorAt?: string | null;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
|
/**
|
||||||
|
* فقط برای فعالیتهای کاریز مطالبات (تگ balance_claims):
|
||||||
|
* مانده ریالی/وزنی از کش تهحساب؛ null یعنی لینک/کش نیست.
|
||||||
|
*/
|
||||||
|
accountBalance?: ActivityAccountBalanceDto | null;
|
||||||
person: PersonSummaryDto | null;
|
person: PersonSummaryDto | null;
|
||||||
company: CompanySummaryDto | null;
|
company: CompanySummaryDto | null;
|
||||||
deal: DealSummaryDto | null;
|
deal: DealSummaryDto | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user