Add migration to enhance session_payments table with payment_method_uuid and reference fields for split-payment details
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user