Add account balance claims board with opt-in module and range settings.
EOF Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -153,6 +153,7 @@ export type OrgModuleKey =
|
||||
| "reports"
|
||||
| "notes"
|
||||
| "tahesab"
|
||||
| "account_balances"
|
||||
| "custom_fields"
|
||||
| "currencies"
|
||||
| "team_settings"
|
||||
@@ -197,6 +198,7 @@ export const ORG_MODULE_KEYS: OrgModuleKey[] = [
|
||||
"reports",
|
||||
"notes",
|
||||
"tahesab",
|
||||
"account_balances",
|
||||
"custom_fields",
|
||||
"currencies",
|
||||
"team_settings",
|
||||
@@ -241,6 +243,7 @@ export const ORG_MODULE_LABELS: Record<OrgModuleKey, string> = {
|
||||
reports: "گزارشها",
|
||||
notes: "یادداشتها",
|
||||
tahesab: "تهحساب (اتصال و گزارش فروش)",
|
||||
account_balances: "مانده حساب",
|
||||
custom_fields: "فیلدهای سفارشی",
|
||||
currencies: "ارزها",
|
||||
team_settings: "تیم و تنظیمات سازمان",
|
||||
@@ -266,7 +269,7 @@ export const ORG_MODULE_GROUPS: Array<{
|
||||
title: string;
|
||||
keys: OrgModuleKey[];
|
||||
}> = [
|
||||
{ title: "مشتریان", keys: ["customers"] },
|
||||
{ title: "مشتریان", keys: ["customers", "account_balances"] },
|
||||
{ title: "لیدها", keys: ["leads", "lead_forms"] },
|
||||
{
|
||||
title: "فروش",
|
||||
@@ -329,6 +332,7 @@ export function isOrgModuleKey(value: string): value is OrgModuleKey {
|
||||
export const OPT_IN_ORG_MODULES: OrgModuleKey[] = [
|
||||
"workflow_automations_advanced",
|
||||
"prior_data_archive",
|
||||
"account_balances",
|
||||
];
|
||||
|
||||
export function defaultEnabledModules(): OrgModuleKey[] {
|
||||
@@ -1355,8 +1359,10 @@ export interface CustomerGroupDto {
|
||||
/** گروه اصلی؛ خالی یعنی خودش اصلی است */
|
||||
parentId?: string | null;
|
||||
parentName?: string | null;
|
||||
/** مسئولان گروه (اختیاری) */
|
||||
/** مسئولان گروه به ترتیب انتخاب در فرم */
|
||||
assignees: CustomerGroupAssigneeDto[];
|
||||
/** شناسهٔ مسئولان به همان ترتیب انتخاب (منبع ترتیب) */
|
||||
assigneeIds?: string[];
|
||||
}
|
||||
|
||||
export interface CreateCustomerGroupRequest {
|
||||
@@ -1979,6 +1985,9 @@ export const ACTIVITY_STAGE_KIND_LABELS: Record<ActivityStatus, string> = {
|
||||
canceled: "لغو شده",
|
||||
};
|
||||
|
||||
/** کلید سیستمی گروه فعالیت مطالبات مانده حساب */
|
||||
export const ACTIVITY_BOARD_SYSTEM_BALANCE_CLAIMS = "balance_claims";
|
||||
|
||||
/** گروه فعالیت (مثل مسیر فروش): هر گروه ستونهای خودش را دارد */
|
||||
export interface ActivityBoardDto {
|
||||
id: string;
|
||||
@@ -1987,6 +1996,8 @@ export interface ActivityBoardDto {
|
||||
position: number;
|
||||
/** خالی = گروه برای همهٔ اعضای محیط باز است */
|
||||
memberIds: string[];
|
||||
/** مثلاً balance_claims — گروه سیستمی غیرقابل حذف/تغییر نام */
|
||||
systemKey?: string | null;
|
||||
}
|
||||
|
||||
export interface CreateActivityBoardRequest {
|
||||
@@ -4819,6 +4830,107 @@ export interface PersonAssetsDto {
|
||||
fetchedAt: string;
|
||||
}
|
||||
|
||||
/** تگ فعالیتهای ساختهشده از مانده حساب */
|
||||
export const ACCOUNT_BALANCE_CLAIMS_TAG = "balance_claims";
|
||||
|
||||
export const ACCOUNT_BALANCE_WEIGHT_KEYS = [
|
||||
"MandeyeVazni",
|
||||
"MandeyeVazniNoghre",
|
||||
] as const;
|
||||
|
||||
export type AccountBalanceWeightKey = (typeof ACCOUNT_BALANCE_WEIGHT_KEYS)[number] | string;
|
||||
|
||||
export const ACCOUNT_BALANCE_WEIGHT_LABELS: Record<string, string> = {
|
||||
MandeyeVazni: "مانده وزنی (طلا)",
|
||||
MandeyeVazniNoghre: "مانده وزنی نقره",
|
||||
};
|
||||
|
||||
export interface AccountBalanceRangeDto {
|
||||
min: number;
|
||||
max: number;
|
||||
}
|
||||
|
||||
export interface AccountBalanceSettingsDto {
|
||||
/** عنوان ستون اول کاریز مطالبات */
|
||||
firstStageName: string;
|
||||
/** بازه مانده مالی؛ null = خاموش */
|
||||
rial: AccountBalanceRangeDto | null;
|
||||
/** بازه بهازای هر کلید مانده وزنی؛ نبود کلید = خاموش */
|
||||
weights: Record<string, AccountBalanceRangeDto>;
|
||||
}
|
||||
|
||||
export interface UpdateAccountBalanceSettingsRequest {
|
||||
firstStageName?: string;
|
||||
rial?: AccountBalanceRangeDto | null;
|
||||
weights?: Record<string, AccountBalanceRangeDto | null>;
|
||||
}
|
||||
|
||||
export type UpdateAccountBalanceSettingsDto = UpdateAccountBalanceSettingsRequest;
|
||||
|
||||
export const DEFAULT_ACCOUNT_BALANCE_FIRST_STAGE = "مطالبه مشتریان";
|
||||
|
||||
export function defaultAccountBalanceSettings(): AccountBalanceSettingsDto {
|
||||
return {
|
||||
firstStageName: DEFAULT_ACCOUNT_BALANCE_FIRST_STAGE,
|
||||
rial: null,
|
||||
weights: {},
|
||||
};
|
||||
}
|
||||
|
||||
export function parseAccountBalanceRange(raw: unknown): AccountBalanceRangeDto | null {
|
||||
if (!raw || typeof raw !== "object") return null;
|
||||
const min = Number((raw as { min?: unknown }).min);
|
||||
const max = Number((raw as { max?: unknown }).max);
|
||||
if (!Number.isFinite(min) || !Number.isFinite(max)) return null;
|
||||
return { min, max: Math.max(min, max) };
|
||||
}
|
||||
|
||||
export function parseAccountBalanceSettings(raw: unknown): AccountBalanceSettingsDto {
|
||||
const base = defaultAccountBalanceSettings();
|
||||
if (!raw || typeof raw !== "object") return base;
|
||||
const obj = raw as Record<string, unknown>;
|
||||
const firstStageName =
|
||||
typeof obj.firstStageName === "string" && obj.firstStageName.trim()
|
||||
? obj.firstStageName.trim().slice(0, 80)
|
||||
: base.firstStageName;
|
||||
const rial = parseAccountBalanceRange(obj.rial);
|
||||
const weights: Record<string, AccountBalanceRangeDto> = {};
|
||||
if (obj.weights && typeof obj.weights === "object") {
|
||||
for (const [key, value] of Object.entries(obj.weights as Record<string, unknown>)) {
|
||||
const range = parseAccountBalanceRange(value);
|
||||
if (range) weights[key] = range;
|
||||
}
|
||||
}
|
||||
return { firstStageName, rial, weights };
|
||||
}
|
||||
|
||||
export function accountBalanceInRange(
|
||||
value: number | null | undefined,
|
||||
range: AccountBalanceRangeDto | null | undefined,
|
||||
): boolean {
|
||||
if (!range || value == null || !Number.isFinite(value)) return false;
|
||||
return value >= range.min && value <= range.max;
|
||||
}
|
||||
|
||||
export function parseAccountBalanceNumber(raw: unknown): number | null {
|
||||
if (raw == null || raw === "") return null;
|
||||
const n = Number(String(raw).replace(/,/g, "").trim());
|
||||
return Number.isFinite(n) ? n : null;
|
||||
}
|
||||
|
||||
export function parseAccountBalanceWeightFields(
|
||||
fields: Array<{ key: string; value: unknown }> | null | undefined,
|
||||
): Record<string, number> {
|
||||
const out: Record<string, number> = {};
|
||||
for (const field of fields ?? []) {
|
||||
const key = String(field.key ?? "").trim();
|
||||
if (!key) continue;
|
||||
const value = parseAccountBalanceNumber(field.value);
|
||||
if (value != null) out[key] = value;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// —— پیام خودکار (جدا از اتوماسیون گردش کار) ——
|
||||
|
||||
export type MessageAutomationTrigger =
|
||||
|
||||
Reference in New Issue
Block a user