feat: Add online share functionality for secretaries
- 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.
This commit is contained in:
@@ -163,6 +163,36 @@ class DoctorSecretaryRepository extends ServiceEntityRepository
|
||||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* رابطههای فعالی که سهم درآمد نوبت آنلاین برایشان روشن است — برای کلینیک همهٔ
|
||||
* منشیهای همان کلینیک، برای مطب شخصی منشیهای همان پزشک.
|
||||
*
|
||||
* @return DoctorSecretary[]
|
||||
*/
|
||||
public function findOnlineShareRows(Doctor $doctor, ?Clinic $clinic): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('s')
|
||||
->addSelect('sec')
|
||||
->join('s.secretary', 'sec')
|
||||
->where('s.active = true')
|
||||
->andWhere('s.onlineShareEnabled = true')
|
||||
->andWhere('s.onlineSharePercent > 0');
|
||||
|
||||
if ($clinic !== null) {
|
||||
$qb->andWhere('s.clinic = :clinic')
|
||||
->andWhere('s.ownerType = :type')
|
||||
->setParameter('clinic', $clinic)
|
||||
->setParameter('type', DoctorSecretary::OWNER_CLINIC);
|
||||
} else {
|
||||
$qb->andWhere('s.doctor = :doctor')
|
||||
->andWhere('s.ownerType = :type')
|
||||
->setParameter('doctor', $doctor)
|
||||
->setParameter('type', DoctorSecretary::OWNER_DOCTOR);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function save(DoctorSecretary $entity, bool $flush = true): void
|
||||
{
|
||||
$this->getEntityManager()->persist($entity);
|
||||
|
||||
Reference in New Issue
Block a user