security fix and fix parent pages
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m7s
API CI/CD / Test (PHPUnit) (push) Failing after 5m46s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 49s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -34,6 +34,7 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
@@ -286,6 +287,59 @@ class ReimbursementController extends BaseApiController
|
||||
]);
|
||||
}
|
||||
|
||||
public function createContext(Request $request): JsonResponse
|
||||
{
|
||||
$expenseId = (int) $request->query('expense_id', 0);
|
||||
$prefillAmount = null;
|
||||
$expense = null;
|
||||
|
||||
if ($expenseId > 0) {
|
||||
$expense = DB::table('expenses')
|
||||
->select('id', 'amount', 'description', 'purchased_by', 'receipt_path', 'retailor')
|
||||
->where('id', $expenseId)
|
||||
->first();
|
||||
if ($expense) {
|
||||
$prefillAmount = $expense->amount ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->queryService->index([
|
||||
'school_year' => $request->query('school_year', $this->context->getSchoolYear()),
|
||||
'semester' => $request->query('semester', $this->context->getSemester()),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'users' => ReimbursementRecipientResource::collection($data['users'] ?? []),
|
||||
'expense_id' => $expenseId ?: null,
|
||||
'expense' => $expense ? (array) $expense : null,
|
||||
'prefill_amount' => $prefillAmount,
|
||||
]);
|
||||
}
|
||||
|
||||
public function editData(int $id): JsonResponse
|
||||
{
|
||||
$reimb = Reimbursement::query()->find($id);
|
||||
if (! $reimb) {
|
||||
return response()->json(['ok' => false, 'message' => 'Reimbursement not found.'], 404);
|
||||
}
|
||||
|
||||
$data = $this->queryService->index([
|
||||
'school_year' => $reimb->school_year ?? $this->context->getSchoolYear(),
|
||||
'semester' => $reimb->semester ?? $this->context->getSemester(),
|
||||
]);
|
||||
|
||||
$payload = $reimb->toArray();
|
||||
$payload['receipt_url'] = $this->fileService->receiptUrl($reimb->receipt_path ?? null);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'reimbursement' => new ReimbursementResource($payload),
|
||||
'users' => ReimbursementRecipientResource::collection($data['users'] ?? []),
|
||||
'receipt_url' => $payload['receipt_url'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function sendBatchEmail(ReimbursementBatchEmailRequest $request): JsonResponse
|
||||
{
|
||||
$payload = $request->validated();
|
||||
|
||||
Reference in New Issue
Block a user