Add Tahesab jewelry accounting integration with multi-DB connections.

Encrypt tokens server-side, sync customers both ways, show balances/documents on the person Assets tab, and push sanads with idempotent Factor_Code logging.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-04 22:00:23 +03:30
co-authored by Cursor
parent d2f66d11fc
commit 4b47b753c3
26 changed files with 13784 additions and 8 deletions
+87
View File
@@ -1461,6 +1461,93 @@ export interface CreateAutomationRuleRequest {
export type UpdateAutomationRuleRequest = Partial<CreateAutomationRuleRequest>;
// —— ته‌حساب / حسابداری ——
export const TAHSAB_SANAD_TYPES = [
"buy_sale_gold",
"buy_sale_sekeh",
"talab_bedehi",
"vkh_gold",
"vkh_bank",
] as const;
export type TahesabSanadType = (typeof TAHSAB_SANAD_TYPES)[number];
export const TAHSAB_SANAD_LABELS: Record<TahesabSanadType, string> = {
buy_sale_gold: "خرید/فروش آبشده",
buy_sale_sekeh: "خرید/فروش سکه",
talab_bedehi: "طلب/بدهی",
vkh_gold: "واریز/خروج طلا",
vkh_bank: "واریز/خروج بانکی",
};
export interface TahesabConnectionDto {
id: string;
organizationId: string;
provider: string;
label: string;
baseUrl: string;
dbName: string;
tokenMasked: string;
enabled: boolean;
isDefault: boolean;
allowInsecureTls: boolean;
lastHealthAt: string | null;
lastHealthOk: boolean | null;
lastError: string | null;
createdAt: string;
updatedAt: string;
}
export interface CreateTahesabConnectionRequest {
label: string;
baseUrl: string;
dbName: string;
token: string;
enabled?: boolean;
isDefault?: boolean;
allowInsecureTls?: boolean;
}
export type UpdateTahesabConnectionRequest = Partial<CreateTahesabConnectionRequest>;
export interface PersonAccountingLinkDto {
id: string;
personId: string;
connectionId: string;
moshtariCode: number;
matchMethod: string;
linkedAt: string;
lastBalanceSyncedAt: string | null;
connectionLabel?: string;
dbName?: string;
isDefaultConnection?: boolean;
}
export interface MandehValueDto {
amount: string | number;
unit: string;
status: "بس" | "بد";
}
export interface MandehDetailItemDto {
Name: string;
values: MandehValueDto[];
}
export interface PersonAssetsDto {
connectionId: string;
connectionLabel: string;
dbName: string;
moshtariCode: number;
goldBalance: number | null;
rialBalance: number | null;
currencyBalance: number | null;
totalGoldEquiv: number | null;
mandehDetail: MandehDetailItemDto[];
fetchedAt: string;
}
export const APP_NAME = "Mento CRM";
export const APP_NAME_FA = "منتو";
export const API_PREFIX = "api";