Add migration to enhance session_payments table with payment_method_uuid and reference fields for split-payment details
This commit is contained in:
@@ -35,6 +35,14 @@ class SessionPayment
|
||||
#[ORM\Column(name: 'amount_rials', type: 'integer')]
|
||||
private int $amountRials;
|
||||
|
||||
/** uuid یک کارتخوان (Pos) یا حساب بانکی (BankAccount) ثبتشده — برای pos/card. */
|
||||
#[ORM\Column(name: 'payment_method_uuid', type: 'string', length: 36, nullable: true)]
|
||||
private ?string $paymentMethodUuid = null;
|
||||
|
||||
/** شناسه تراکنش / شماره پیگیری پرداخت (اختیاری). */
|
||||
#[ORM\Column(name: 'reference', type: 'string', length: 255, nullable: true)]
|
||||
private ?string $reference = null;
|
||||
|
||||
#[ORM\Column(name: 'paid_at', type: 'integer')]
|
||||
private int $paidAt;
|
||||
|
||||
@@ -63,6 +71,8 @@ class SessionPayment
|
||||
public function getSession(): PatientSession { return $this->session; }
|
||||
public function getMethod(): string { return $this->method; }
|
||||
public function getAmountRials(): int { return $this->amountRials; }
|
||||
public function getPaymentMethodUuid(): ?string { return $this->paymentMethodUuid; }
|
||||
public function getReference(): ?string { return $this->reference; }
|
||||
public function getPaidAt(): int { return $this->paidAt; }
|
||||
public function getCreatedBy(): ?User { return $this->createdBy; }
|
||||
public function getCreatedByName(): ?string { return $this->createdByName; }
|
||||
@@ -72,17 +82,21 @@ class SessionPayment
|
||||
public function setCreatedByName(?string $n): self { $this->createdByName = $n; return $this; }
|
||||
public function setMethod(string $m): self { $this->method = $m; return $this; }
|
||||
public function setAmountRials(int $v): self { $this->amountRials = $v; return $this; }
|
||||
public function setPaymentMethodUuid(?string $v): self { $this->paymentMethodUuid = $v; return $this; }
|
||||
public function setReference(?string $v): self { $this->reference = $v; return $this; }
|
||||
public function setPaidAt(int $v): self { $this->paidAt = $v; return $this; }
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'method' => $this->method,
|
||||
'amount_rials' => $this->amountRials,
|
||||
'paid_at' => $this->paidAt,
|
||||
'created_by_name' => $this->createdByName,
|
||||
'created_at' => $this->createdAt,
|
||||
'uuid' => $this->uuid,
|
||||
'method' => $this->method,
|
||||
'amount_rials' => $this->amountRials,
|
||||
'payment_method_uuid' => $this->paymentMethodUuid,
|
||||
'reference' => $this->reference,
|
||||
'paid_at' => $this->paidAt,
|
||||
'created_by_name' => $this->createdByName,
|
||||
'created_at' => $this->createdAt,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,6 +596,8 @@ class PatientService
|
||||
int $amountRials,
|
||||
?int $paidAt = null,
|
||||
?User $actor = null,
|
||||
?string $paymentMethodUuid = null,
|
||||
?string $reference = null,
|
||||
): SessionPayment {
|
||||
if (!in_array($method, SessionPayment::METHODS, true)) {
|
||||
throw new AppException(ErrorCodes::ERR_SESSION_PAYMENT_INVALID, null, 422, 'method');
|
||||
@@ -627,7 +629,9 @@ class PatientService
|
||||
|
||||
$payment = new SessionPayment($session, $method, $amountRials, $paidAt);
|
||||
$payment->setCreatedBy($actor)
|
||||
->setCreatedByName($this->walletService->resolveActorName($actor));
|
||||
->setCreatedByName($this->walletService->resolveActorName($actor))
|
||||
->setPaymentMethodUuid($paymentMethodUuid !== null && $paymentMethodUuid !== '' ? $paymentMethodUuid : null)
|
||||
->setReference($reference !== null && $reference !== '' ? $reference : null);
|
||||
$this->sessionPaymentRepo->save($payment);
|
||||
$session->addPayment($payment);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user