commit14
This commit is contained in:
@@ -29,7 +29,12 @@ class RequisitionWorkflow
|
||||
unset($data['operation_key'], $data['process_version']);
|
||||
$result = $this->execute($user, 'save', $existing?->id, $version, $key, $data);
|
||||
|
||||
return Requisition::query()->whereKey($result['id'])->firstOrFail();
|
||||
$record = Requisition::query()->whereKey($result['id'])->firstOrFail();
|
||||
if ($existing !== null) {
|
||||
app(AutomaticPurchases::class)->requisitionChanged($user, $record);
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +56,7 @@ class RequisitionWorkflow
|
||||
{
|
||||
return DB::transaction(function () use ($user, $data, $existing, $automaticRule) {
|
||||
app(ConflictGuard::class)->lockCompany($user);
|
||||
$user = app(CurrentActor::class)->lock($user);
|
||||
$user = $automaticRule === null ? app(CurrentActor::class)->lock($user) : app(AutomaticPurchases::class)->lockExecutor($user);
|
||||
$executor = $user;
|
||||
if ($automaticRule !== null) {
|
||||
abort_unless($existing === null, 403);
|
||||
@@ -116,23 +121,27 @@ class RequisitionWorkflow
|
||||
});
|
||||
}
|
||||
|
||||
/** Only an independently activated rule may create a draft on behalf of its designated requester. */
|
||||
/** Only an independently activated rule may create a draft on behalf of its designated requester.
|
||||
* @param array<string,mixed> $data
|
||||
*/
|
||||
public function automaticDraft(User $executor, SupplyRecord $rule, array $data): Requisition
|
||||
{
|
||||
$process = new InternalRequisitions(new InternalRequisitionPort($executor, fn (array $input, ?Requisition $existing) => $this->persistDraft($executor, $input, $existing, $rule), $rule));
|
||||
$result = $process->command('save', null, null, null, $data);
|
||||
|
||||
return Requisition::query()->findOrFail($result['id']);
|
||||
return Requisition::query()->whereKey($result['id'])->firstOrFail();
|
||||
}
|
||||
|
||||
public function submit(User $user, Requisition $requisition, ?string $operationKey = null, ?int $version = null): void
|
||||
{
|
||||
$this->execute($user, 'submit', $requisition->id, $version, $operationKey);
|
||||
app(AutomaticPurchases::class)->requisitionChanged($user, $requisition);
|
||||
}
|
||||
|
||||
public function decide(User $user, Requisition $requisition, string $decision, ?string $comment, ?string $operationKey = null, ?int $version = null): void
|
||||
{
|
||||
$this->execute($user, 'decide', $requisition->id, $version, $operationKey, ['decision' => $decision, 'comment' => $comment]);
|
||||
app(AutomaticPurchases::class)->requisitionChanged($user, $requisition);
|
||||
}
|
||||
|
||||
/** @param array<string, mixed>|null $before
|
||||
@@ -143,7 +152,7 @@ class RequisitionWorkflow
|
||||
AuditLog::query()->create([
|
||||
'tenant_id' => $user->tenant_id, 'user_id' => $user->id,
|
||||
'requisition_id' => $requisition?->id, 'action' => $action,
|
||||
'ip_address' => request()->ip(), 'before' => $before, 'after' => $after,
|
||||
'ip_address' => app(ReplenishmentRun::class)->tenantId() === null ? request()->ip() : null, 'before' => $before, 'after' => $after + (app(ReplenishmentRun::class)->tenantId() === null ? [] : ['execution' => app(ReplenishmentRun::class)->evidence()]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user