Add migration to enhance session_payments table with payment_method_uuid and reference fields for split-payment details

This commit is contained in:
hamed
2026-07-23 15:37:58 +03:30
parent 1d1c3d5f30
commit a0a2eb1799
23 changed files with 2257 additions and 1432 deletions
@@ -158,6 +158,33 @@ class AppointmentConfirmFlowTest extends ApiTestCase
self::assertTrue($res['data']['session']['is_paid']);
}
public function testConfirmPersistsPerPaymentMethodDetails(): void
{
$doctor = $this->makeDoctor();
$appointment = $this->makeAppointment($doctor);
$res = $this->authJson('POST', "/api/v1/appointment/{$appointment->getUuid()}/confirm", $doctor->getUser(), [
'version' => $appointment->getVersion(),
'payments' => [
['method' => 'pos', 'amount_rials' => 3_000_000, 'payment_method_uuid' => 'pos-uuid-1', 'reference' => 'TRX-42'],
['method' => 'cash', 'amount_rials' => 2_000_000],
],
]);
self::assertSame(200, $this->responseCode());
$session = $this->em->getRepository(PatientSession::class)->findOneBy(['uuid' => $res['data']['session']['uuid']]);
$payments = $this->em->getRepository(\App\Patient\Entity\SessionPayment::class)->findBy(['session' => $session]);
self::assertCount(2, $payments);
$pos = array_values(array_filter($payments, fn($p) => $p->getMethod() === 'pos'))[0];
$cash = array_values(array_filter($payments, fn($p) => $p->getMethod() === 'cash'))[0];
self::assertSame('pos-uuid-1', $pos->getPaymentMethodUuid());
self::assertSame('TRX-42', $pos->getReference());
self::assertNull($cash->getPaymentMethodUuid(), 'روش نقدی جزئیاتِ روش ندارد');
self::assertNull($cash->getReference());
}
// ── پرونده: استفادهٔ مجدد یا ساخت ────────────────────────────────────────
public function testConfirmReusesExistingRecordOfSameDoctor(): void