Aplicar Pint e formatação de frontend; delimitar o âmbito do lint
Só formatação automática (pint, vp check --fix), sem alterar comportamento. Excluídos da formatação os registos e artefactos com bytes fixos: docs/, integrations/, storage/, tmp/, output/, resources/data/, tests/Fixtures/, compras-release.json e AGENTS*.md. Scripts operacionais, integrations e auxiliares de teste ficam fora do lint (usam new Function; limpeza na fase 2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,14 +43,21 @@ final class WarehouseReturnController extends Controller
|
||||
}
|
||||
|
||||
/** @param callable():array<string,mixed> $run */
|
||||
private function response(callable $run,bool $readOnly=false): JsonResponse
|
||||
private function response(callable $run, bool $readOnly = false): JsonResponse
|
||||
{
|
||||
try {
|
||||
$result=$readOnly?DB::transaction(function()use($run){if(DB::getDriverName()==='pgsql'&&DB::transactionLevel()===1)DB::statement('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY');return $run();}):$run();
|
||||
$result = $readOnly ? DB::transaction(function () use ($run) {
|
||||
if (DB::getDriverName() === 'pgsql' && DB::transactionLevel() === 1) {
|
||||
DB::statement('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY');
|
||||
}
|
||||
|
||||
return $run();
|
||||
}) : $run();
|
||||
|
||||
return response()->json($result)->header('Cache-Control', 'no-store');
|
||||
} catch (QueryException $e) {
|
||||
if (($e->errorInfo[0] ?? null) === '55P03') {
|
||||
return response()->json(['code'=>'warehouse_return_busy','message' => 'Devolução ocupada. Aguarde e repita manualmente a conferência.'], 423)->header('Cache-Control', 'no-store');
|
||||
return response()->json(['code' => 'warehouse_return_busy', 'message' => 'Devolução ocupada. Aguarde e repita manualmente a conferência.'], 423)->header('Cache-Control', 'no-store');
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
@@ -83,12 +90,25 @@ final class WarehouseReturnController extends Controller
|
||||
$d['version'] = (int) $d['version'];
|
||||
$d['received_in_warehouse'] = true;
|
||||
|
||||
return $this->response(fn () => $flow->confirm($this->actor($r),$id,$d));
|
||||
return $this->response(fn () => $flow->confirm($this->actor($r), $id, $d));
|
||||
}
|
||||
public function withdraw(Request $r,int $id,WarehouseReturns $flow): JsonResponse {return $this->close($r,$id,$flow,'withdrawn');}
|
||||
public function reject(Request $r,int $id,WarehouseReturns $flow): JsonResponse {return $this->close($r,$id,$flow,'rejected');}
|
||||
private function close(Request $r,int $id,WarehouseReturns $flow,string $state): JsonResponse
|
||||
|
||||
public function withdraw(Request $r, int $id, WarehouseReturns $flow): JsonResponse
|
||||
{
|
||||
$d=$r->validate(['version'=>'required|integer|min:1','reason'=>'required|string|min:10|max:1000']);abort_if(array_diff(array_keys($r->all()),array_keys($d))!==[],422);$d['version']=(int)$d['version'];return $this->response(fn()=>$flow->close($this->actor($r),$id,$d,$state));
|
||||
return $this->close($r, $id, $flow, 'withdrawn');
|
||||
}
|
||||
|
||||
public function reject(Request $r, int $id, WarehouseReturns $flow): JsonResponse
|
||||
{
|
||||
return $this->close($r, $id, $flow, 'rejected');
|
||||
}
|
||||
|
||||
private function close(Request $r, int $id, WarehouseReturns $flow, string $state): JsonResponse
|
||||
{
|
||||
$d = $r->validate(['version' => 'required|integer|min:1', 'reason' => 'required|string|min:10|max:1000']);
|
||||
abort_if(array_diff(array_keys($r->all()), array_keys($d)) !== [], 422);
|
||||
$d['version'] = (int) $d['version'];
|
||||
|
||||
return $this->response(fn () => $flow->close($this->actor($r), $id, $d, $state));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user