Files
clinicpro/migrations/Version20260716094319.php
T
hamedandClaude Opus 4.8 27d088c6dd feat: port tauri create-service payment flow to admin session settlement
Port the tauri /files/create-service page (payment mode) to the admin SPA
and back it with real multi-part session settlement:

Backend:
- New SessionPayment entity (session_payments table): partial payments
  per session with method (wallet/pos/cash/card), amount, paid_at, actor
- PatientSession: settlement discount (percent/fixed), discount_rials,
  paid_at, payments relation; remaining debt derived from
  final - discount - paid total
- POST /api/v1/session/{uuid}/payments: register a partial payment;
  wallet method debits the patient wallet; zero remaining marks paid
- PATCH /api/v1/session/{uuid}: accepts discount_type/discount_value
  (null removes) and paid_at, backward compatible
- New error codes: ERR_SESSION_PAYMENT_INVALID/_EXCEEDS,
  ERR_SESSION_DISCOUNT_INVALID
- Migration + 14 functional tests (partial/full/wallet/exceed/discount)

Frontend (admin):
- SessionPaymentPage: two-step stepper (پرداخت ← جزییات) ported from
  tauri AddService payment mode — service cost, settlement discount
  input, Jalali payment date, wallet balance, 4-method payment accordion,
  paid-list box, details summary
- SessionStepper + stepper/payment icons ported verbatim from tauri SVGs
- «تکمیل پرداخت» on SessionServiceCard now navigates to the payment page
  (replaces the small settle modal on PatientDetailPage)
- Routes for patients/ and my-patients/ variants; vitest coverage
- docs/api/patient.md updated

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-16 13:32:06 +03:30

38 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260716094319 extends AbstractMigration
{
public function getDescription(): string
{
return 'Session settlement: session_payments table + discount/paid_at columns on patient_sessions';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE session_payments (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, method VARCHAR(15) NOT NULL, amount_rials INT NOT NULL, paid_at INT NOT NULL, created_by_name VARCHAR(255) DEFAULT NULL, created_at INT NOT NULL, session_id INT NOT NULL, created_by_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_EE7EFB5AD17F50A6 (uuid), INDEX IDX_EE7EFB5A613FECDF (session_id), INDEX IDX_EE7EFB5AB03A8386 (created_by_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
$this->addSql('ALTER TABLE session_payments ADD CONSTRAINT FK_EE7EFB5A613FECDF FOREIGN KEY (session_id) REFERENCES patient_sessions (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE session_payments ADD CONSTRAINT FK_EE7EFB5AB03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE patient_sessions ADD discount_type VARCHAR(10) DEFAULT NULL, ADD discount_value INT DEFAULT 0 NOT NULL, ADD discount_rials INT DEFAULT 0 NOT NULL, ADD paid_at INT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE session_payments DROP FOREIGN KEY FK_EE7EFB5A613FECDF');
$this->addSql('ALTER TABLE session_payments DROP FOREIGN KEY FK_EE7EFB5AB03A8386');
$this->addSql('DROP TABLE session_payments');
$this->addSql('ALTER TABLE patient_sessions DROP discount_type, DROP discount_value, DROP discount_rials, DROP paid_at');
}
}