@@ -322,6 +322,23 @@ test('warehouse shortage carries the original destination and equipment and is n
|
||||
$this->actingAs($this->f['issuer'])->get('/requisicoes/'.$r->id)->assertOk()->assertInertia(fn (Assert $p) => $p->where('automaticSource.origins.0.destination', 'Oficina central, bancada de montagem'));
|
||||
});
|
||||
|
||||
test('production shortage retains the declared production reference in the native purchase origin', function () {
|
||||
activateAutomaticRule($this);
|
||||
supplyGrant($this->f['issuer'], ['warehouse_request_prepare']);
|
||||
supplyGrant($this->f['receiver'], ['warehouse_request_review']);
|
||||
$this->actingAs($this->f['issuer']);
|
||||
$request = app(WarehouseRequests::class)->draft($this->f['issuer'], ['operation_key' => (string) Str::uuid(), 'warehouse_id' => $this->f['warehouse']->id, 'cost_center_id' => $this->f['r']->cost_center_id,
|
||||
'destination' => 'Linha de produção QA', 'reason' => 'Insumos sintéticos para a produção.', 'priority' => 'normal',
|
||||
'lines' => [['stock_item_id' => $this->f['stock']->id, 'quantity' => '125.000', 'use' => 'production', 'equipment_id' => null, 'production_reference' => 'OP-QA-001']]]);
|
||||
app(WarehouseFulfilment::class)->command($this->f['issuer'], $request->id, ['operation_key' => (string) Str::uuid(), 'version' => 0, 'action' => 'submit', 'reason' => 'Submissão de teste da produção.', 'partial_allowed' => true]);
|
||||
$this->actingAs($this->f['receiver']);
|
||||
app(WarehouseFulfilment::class)->command($this->f['receiver'], $request->id, ['operation_key' => (string) Str::uuid(), 'version' => 1, 'action' => 'authorize', 'reason' => 'Autorização de teste da produção.', 'partial_allowed' => true]);
|
||||
app(AutomaticPurchases::class)->evaluate($this->f['receiver'], $this->f['stock']->id, $this->f['warehouse']->id);
|
||||
$need = app(SupplyPlanning::class)->latest('auto_need')->sole();
|
||||
$r = Requisition::query()->findOrFail($need->data['purchases'][0]['id']);
|
||||
expect(app(AutomaticPurchases::class)->origin($r)['origins'][0]['production'])->toBe(['reference' => 'OP-QA-001', 'verification' => 'user_supplied']);
|
||||
});
|
||||
|
||||
test('revoked requester authority or expired work context cannot be borrowed for automatic purchases', function () {
|
||||
activateAutomaticRule($this);
|
||||
DB::table('organization_memberships')->where('user_id', $this->f['issuer']->id)->update(['expires_at' => now()->subMinute()]);
|
||||
|
||||
Reference in New Issue
Block a user