Files
SGF/tests/Support/WorkshopBillingFixture.php
T

14 lines
1.2 KiB
PHP

<?php
namespace Tests\Support;
use App\Modules\Workshop\WorkshopBilling;
use App\Modules\Services\ServiceWorkflow;
use Illuminate\Support\Str;
final class WorkshopBillingFixture {
public static function create(?array $base=null): array {
WorkshopBilling::guard();$f=DirectCostFixture::create($base);
foreach(['manager'=>['view','prepare','generate'],'reader'=>['view','review']] as $who=>$rights){foreach($rights as $right)IdentityFixture::grant($f[$who]->id,$f['tenant'],$f['company'],'workshop_billing.'.$right,$f['unit']);IdentityFixture::grant($f[$who]->id,$f['tenant'],$f['company'],'workshop.view',$f['unit']);}
$service=app(ServiceWorkflow::class)->save('services',null,$f['manager']->id,['name'=>'Serviço comercial exclusivamente sintético'],(string)Str::uuid())['id'];return $f+compact('service');
}
public static function proposal(array $f): array {return ['version'=>1,'previous_id'=>null,'client_id'=>$f['client'],'currency'=>'MZN','evidence'=>'WORKSHOP-SALES-SYNTHETIC-v1: 200/H e 75/UN, revisão comercial distinta.','lines'=>array_map(fn($id,$price)=>['entry_id'=>$id,'entry_version'=>1,'service_id'=>$f['service'],'service_version'=>1,'price'=>$price,'price_source'=>'WORKSHOP-SALES-SYNTHETIC-v1'],[$f['time'],$f['material']],['200','75'])];}
}