update project
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Finance;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class DownloadPaymentFileRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['mode'=>['nullable','string','in:download,view']]; }
|
||||
public function mode(): string { return (string) ($this->validated('mode') ?: 'download'); }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Finance\DTO\EditPaymentData;
|
||||
use App\Domain\SchoolCore\Finance\DTO\MoneyData;
|
||||
use App\Domain\SchoolCore\Finance\Enums\PaymentMethod;
|
||||
use DateTimeImmutable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class EditPaymentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['amount_minor'=>['nullable','integer','min:1'],'currency'=>['required_with:amount_minor','string','size:3'],'payment_method'=>['nullable','string','in:cash,check,card,bank_transfer,other'],'payment_date'=>['nullable','date'],'reference_number'=>['nullable','string'],'notes'=>['nullable','string'],'replacement_file'=>['nullable','file','max:10240'],'edit_reason'=>['required','string']]; }
|
||||
public function toDTO(): EditPaymentData { $v=$this->validated(); return new EditPaymentData(isset($v['amount_minor']) ? new MoneyData((int)$v['amount_minor'], strtoupper($v['currency'])) : null, isset($v['payment_method']) ? PaymentMethod::from($v['payment_method']) : null, isset($v['payment_date']) ? new DateTimeImmutable($v['payment_date']) : null, $v['reference_number'] ?? null, $v['notes'] ?? null, $this->file('replacement_file'), $v['edit_reason']); }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Finance\DTO\MoneyData;
|
||||
use App\Domain\SchoolCore\Finance\DTO\RecordPaymentData;
|
||||
use App\Domain\SchoolCore\Finance\Enums\PaymentMethod;
|
||||
use DateTimeImmutable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class RecordPaymentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['invoice_id'=>['required','integer','min:1'],'amount_minor'=>['required','integer','min:1'],'currency'=>['required','string','size:3'],'payment_method'=>['required','string','in:cash,check,card,bank_transfer,other'],'payment_date'=>['required','date'],'student_id'=>['nullable','integer'],'guardian_id'=>['nullable','integer'],'reference_number'=>['nullable','string'],'notes'=>['nullable','string'],'idempotency_key'=>['nullable','string'],'uploaded_file'=>['nullable','file','max:10240']]; }
|
||||
public function toDTO(): RecordPaymentData { $v=$this->validated(); return new RecordPaymentData((int)$v['invoice_id'], isset($v['student_id'])?(int)$v['student_id']:null, isset($v['guardian_id'])?(int)$v['guardian_id']:null, new MoneyData((int)$v['amount_minor'], strtoupper($v['currency'])), PaymentMethod::from($v['payment_method']), new DateTimeImmutable($v['payment_date']), $v['reference_number'] ?? null, $v['notes'] ?? null, $v['idempotency_key'] ?? null, $this->file('uploaded_file')); }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Finance\DTO\MoneyData;
|
||||
use App\Domain\SchoolCore\Finance\DTO\RefundPaymentData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class RefundPaymentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['payment_id'=>['required','integer','min:1'],'amount_minor'=>['required','integer','min:1'],'currency'=>['required','string','size:3'],'reason'=>['required','string'],'idempotency_key'=>['nullable','string']]; }
|
||||
public function toDTO(): RefundPaymentData { $v=$this->validated(); return new RefundPaymentData((int)$v['payment_id'], new MoneyData((int)$v['amount_minor'], strtoupper($v['currency'])), $v['reason'], $v['idempotency_key'] ?? null); }
|
||||
}
|
||||
Reference in New Issue
Block a user