- Introduced `online_share_enabled` and `online_share_percent` fields in the `doctor_secretaries` table to manage secretary shares from online appointments. - Added `bank_account` field in the `profiles` table to store user-level IBANs for settlements. - Created `secretary_earnings` table to track earnings per secretary from online appointments, including a foreign key relationship with `financial_breakdowns`. - Implemented `SecretaryEarning` entity and repository for managing secretary earnings. - Developed `SecretaryShareResolver` service to determine which secretaries earn from online payments. - Added `UserIbanResolver` service to handle user IBAN retrieval and management. - Created `HasIbansTrait` for entities to manage IBANs in a JSON format. - Implemented tests for secretary earnings and API endpoints for managing secretary shares and IBANs.
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { api } from '../lib/api';
|
|
import type { ApiResponse } from '../lib/api';
|
|
|
|
export interface SecretaryEarningsSummary {
|
|
enabled: boolean;
|
|
share_percent: number;
|
|
today_rials: number;
|
|
this_month_rials: number;
|
|
total_rials: number;
|
|
appointments_count: number;
|
|
wallet_balance_rials: number;
|
|
}
|
|
|
|
/**
|
|
* خلاصهٔ درآمد منشی از نوبتهای آنلاین. `enabled` تنها منبع تصمیم برای نمایش
|
|
* آیتمهای مالی منشی است؛ سرور همان قاعده را اعمال میکند.
|
|
*/
|
|
export function useSecretaryEarnings(enabled = true) {
|
|
const { data, isLoading } = useQuery<ApiResponse<{ data: SecretaryEarningsSummary }>>({
|
|
queryKey: ['secretary-earnings-summary'],
|
|
queryFn: () => api.get('/api/v1/secretary/earnings/summary'),
|
|
staleTime: 5 * 60 * 1000,
|
|
enabled,
|
|
});
|
|
|
|
const summary = (data?.data as any)?.data ?? data?.data;
|
|
|
|
return { summary: summary as SecretaryEarningsSummary | undefined, isLoading };
|
|
}
|