commit melhorias compras1
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-21 21:04:40 +02:00
parent 976271f948
commit 12dd6df28a
108 changed files with 4391 additions and 408 deletions
+32 -1
View File
@@ -15,6 +15,7 @@ use App\Models\Quotation;
use App\Models\RecommendationAttempt;
use App\Models\Requisition;
use App\Models\Supplier;
use App\Models\SupplierBankDetail;
use App\Models\SupplierEvaluation;
use App\Models\SupplierImprovement;
use App\Models\SupplierResponse;
@@ -26,6 +27,36 @@ use Illuminate\Support\Facades\Schema;
/** Current tasks delegated to the existing module authorities, never another workflow. */
class WorkflowTaskInbox
{
/** @return list<array<string,mixed>> */
private function bankReviews(User $actor): array
{
if (! $actor->hasFunctions(['finance']) || ! Schema::hasTable('supplier_bank_details')) {
return [];
}
$workflow = app(SupplierBankWorkflow::class);
$multiple = $workflow->multipleReady();
$query = SupplierBankDetail::query()->whereNotExists(function ($q) use ($multiple) {
$q->selectRaw('1')->from('supplier_bank_details as newer')->whereColumn('newer.tenant_id', 'supplier_bank_details.tenant_id')
->whereColumn('newer.supplier_id', 'supplier_bank_details.supplier_id')->whereColumn('newer.revision', '>', 'supplier_bank_details.revision');
if ($multiple) {
$q->where(fn ($scope) => $scope->whereColumn('newer.account_key', 'supplier_bank_details.account_key')
->orWhere(fn ($legacy) => $legacy->whereNull('newer.account_key')->whereNull('supplier_bank_details.account_key')));
}
});
$rows = [];
foreach ($query->lazyById(100) as $detail) {
if (! $workflow->canReview($actor, $detail)) {
continue;
}
$rows[] = ['id' => 'supplier-bank:'.$detail->id.':review', 'module' => 'finance', 'reference' => 'Fornecedor #'.$detail->supplier_id,
'label' => 'Conferir dados bancários · versão '.$detail->revision, 'task' => 'supplier_bank_review', 'status' => 'pending', 'blocked' => false,
'created_at' => $this->date($detail->created_at), 'due_on' => null,
'href' => '/fornecedores/'.$detail->supplier_id.'/dados-bancarios'.($detail->account_key === null ? '' : '?account='.rawurlencode($detail->account_key))];
}
return $rows;
}
/** @return list<array<string,mixed>> */
public function build(User $actor, string $area): array
{
@@ -36,7 +67,7 @@ class WorkflowTaskInbox
}
$rows = $area === 'people' ? $this->people($actor) : [...$this->purchases($actor), ...$this->suppliers($actor), ...$this->quotations($actor), ...$this->documentary($actor), ...$this->formalReviews($actor), ...$this->supply($actor), ...$this->suggestions($actor), ...$this->awards($actor), ...$this->warehouse($actor), ...$this->inventoryCorrections($actor), ...$this->lotSetups($actor), ...$this->finance($actor)];
if ($area === 'procurement') {
$rows = [...$rows, ...$this->supplierImprovements($actor), ...$this->supplierQuality($actor), ...$this->supplyFollowUp($actor), ...$this->lotQuality($actor)];
$rows = [...$rows, ...$this->supplierImprovements($actor), ...$this->supplierQuality($actor), ...$this->supplyFollowUp($actor), ...$this->lotQuality($actor), ...$this->bankReviews($actor)];
if (config('order_cancellation.enabled') && Schema::hasTable('order_cancellations')) {
foreach (OrderCancellation::query()->where('status', 'pending')->lazyById(100) as $record) {
if (app(OrderCancellationWorkflow::class)->canDecide($actor, $record)) {