Files
SGF/scripts/invoice-native-negative.php
T
2026-11-04 09:37:20 +02:00

5 lines
892 B
PHP

<?php
use App\Models\{PurchaseAward,User};
use App\Services\PurchaseWorkflow;
if(!($s['invoices']??false)||is_file($s['root'].'/invoice-negative-prepared.json'))throw new LogicException('Fresh invoice negative fixture required');$f=json_decode(file_get_contents($s['root'].'/native-fixture.json'),true);$award=PurchaseAward::withoutGlobalScopes()->findOrFail($f['foreign_award']);$user=User::findOrFail($award->created_by);auth()->setUser($user);$order=app(PurchaseWorkflow::class)->issue($user,$award);$f['foreign_order']=$order->id;$f['foreign_order_line']=$order->items()->firstOrFail()->id;file_put_contents($s['root'].'/native-fixture.json',json_encode($f,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));file_put_contents($s['root'].'/invoice-negative-prepared.json',json_encode(['passed'=>true,'foreign_order_prepared'=>true,'main_book_changed'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));