Add per-clinic payment methods (bank accounts + POS/card-reader devices)
under the "مدیریت پرداخت" settings tab at /admin/my-financial, ported from
clinic-pro-tauri's mock-only PaymentManagement tab into a real persisted
feature. These records are referenceable (by uuid) from patient invoices to
record which method a service payment was made with.
Backend (new src/PaymentMethod domain):
- BankAccount + Pos entities, repositories, PaymentMethodService (validation,
ownership scoping, create/update/toggle logic).
- Thin PaymentMethodController exposing /api/v1/my/payment-methods/{bank-accounts,pos}
(GET/POST/PUT + PATCH .../status), guarded to clinic/doctor/secretary/admin.
- Migration for bank_accounts + pos_devices tables.
- Functional tests (success + validation/404/403 + empty boundaries).
- docs/api/payment-method.md.
Frontend:
- Replace MyFinancialPage content with the payment-management UI (two tabs,
tables, add/edit modals, status toggle) using the admin design system.
- usePaymentMethods hook (TanStack Query) + presentational components.
- Update page test to cover tabs, data, empty state and the add modal.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1001 B
PHP
38 lines
1001 B
PHP
<?php
|
|
|
|
namespace App\PaymentMethod\Repository;
|
|
|
|
use App\Auth\Entity\User;
|
|
use App\PaymentMethod\Entity\Pos;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
class PosRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Pos::class);
|
|
}
|
|
|
|
public function findByUuid(string $uuid): ?Pos
|
|
{
|
|
return $this->findOneBy(['uuid' => $uuid]);
|
|
}
|
|
|
|
/** @return Pos[] */
|
|
public function findByUser(User $user): array
|
|
{
|
|
return $this->createQueryBuilder('p')
|
|
->where('p.user = :user')->setParameter('user', $user)
|
|
->orderBy('p.createdAt', 'DESC')
|
|
->getQuery()
|
|
->getResult();
|
|
}
|
|
|
|
public function save(Pos $entity, bool $flush = true): void
|
|
{
|
|
$this->getEntityManager()->persist($entity);
|
|
if ($flush) $this->getEntityManager()->flush();
|
|
}
|
|
}
|