fix accounting fails

This commit is contained in:
2026-08-27 16:15:11 +03:30
parent da5b113406
commit 827adfe756
12 changed files with 937 additions and 166 deletions
+44 -3
View File
@@ -2,17 +2,21 @@ import useAxios from '@core/utils/useAxios'
import type { TableInput } from '@core/type/baseTable'
export interface TahesabRecord {
id: number
id?: number | null
customer_id?: number
amount?: number
desc?: string
type?: string
sync_status?: 'pending' | 'success' | 'failed'
sync_status?: 'pending' | 'success' | 'failed' | 'missing'
sync_log?: string | null
tahesab_id?: string | null
data?: string | null
res?: string | null
created_at?: string
withdraw_id?: number | null
order_id?: number | null
issue_kind?: 'failed' | 'missing'
sync_target?: { type: 'row' | 'withdraw' | 'order'; id: number }
customer?: {
id?: number
name?: string
@@ -21,7 +25,7 @@ export interface TahesabRecord {
}
}
export const getTahesabTable = async (params: TableInput) =>
export const getTahesabTable = async (params: TableInput & { view?: string }) =>
await useAxios.post<TahesabRecord[]>('/admin/tahesab/table', params)
export const getTahesabDetail = async (id: number) =>
@@ -30,6 +34,43 @@ export const getTahesabDetail = async (id: number) =>
export const retryTahesabSanad = async (id: number) =>
await useAxios.post<{ ok: boolean; message: string; tahesab?: TahesabRecord }>(`/admin/tahesab/${id}/retry`)
export interface TahesabPendingSummary {
failed_rows: number
missing_withdraws: number
missing_orders: number
total: number
}
export interface TahesabSyncAllResult {
ok: boolean
retried: number
backfilled_withdraws: number
backfilled_orders: number
failed: number
errors: string[]
summary: TahesabPendingSummary
}
export const getTahesabPendingSummary = async (customerId?: number) =>
await useAxios.get<TahesabPendingSummary>('/admin/tahesab/pending-summary', {
params: customerId ? { customer_id: customerId } : undefined
})
export const getTahesabPendingDocs = async (customerId?: number, limit = 200) =>
await useAxios.get<{ rows: TahesabRecord[]; summary: TahesabPendingSummary }>(
'/admin/tahesab/pending-docs',
{ params: { ...(customerId ? { customer_id: customerId } : {}), limit } }
)
export const syncOneTahesab = async (type: 'row' | 'withdraw' | 'order', id: number) =>
await useAxios.post<{ ok: boolean; message: string }>('/admin/tahesab/sync-one', { type, id })
export const syncAllTahesabPending = async (limit = 80, customerId?: number) =>
await useAxios.post<TahesabSyncAllResult>('/admin/tahesab/sync-all-pending', {
limit,
...(customerId ? { customer_id: customerId } : {})
})
export const registerCustomerInTahesab = async (customerId: number) =>
await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string | number }>(
`/admin/customer/${customerId}/tahesab/register`