commit melhorias1
This commit is contained in:
@@ -61,16 +61,17 @@ final class ComposedLedger
|
||||
$authorize('view');
|
||||
$isolation=fn()=>app(ComposedMaterialIsolation::class)->check($host,$native,$ledgerScope);
|
||||
$stock=new StockValuation($native,$ledgerScope,$actor->id,$person,$authorize,fn()=>$authorize('view'),$isolation);
|
||||
$additional=function($kind,$id)use($host,$hostActor,$stock,$isolation){
|
||||
$additional=function($kind,$id)use($host,$hostActor,$stock,$isolation,$native,$ledgerScope){
|
||||
if(str_starts_with($kind,'stock.'))return $stock->source($kind,$id);
|
||||
if(str_starts_with($kind,'workshop.')||str_starts_with($kind,'industry.'))$isolation();
|
||||
return $this->withHost($host,$hostActor,function()use($hostActor,$kind,$id){
|
||||
return $this->withHost($host,$hostActor,function()use($hostActor,$kind,$id,$native,$ledgerScope){
|
||||
if(str_starts_with($kind,'assets.'))return app(FixedAssetLedgerSource::class)->source($hostActor,$kind,$id,$native,$ledgerScope);
|
||||
if(str_starts_with($kind,'cash.'))return app(CashLedgerSource::class)->source($hostActor,$kind,$id);if(str_starts_with($kind,'workshop.'))return $kind==='workshop.direct_cost.validated'?app(CostLedgerSource::class)->source($hostActor,$id):app(CostLedgerSource::class)->correctionSource($hostActor,$kind,$id);
|
||||
if(str_starts_with($kind,'industry.'))return $kind==='industry.cost.validated'?app(IndustrialLedgerSource::class)->source($hostActor,$id):app(IndustrialLedgerSource::class)->correctionSource($hostActor,$kind,$id);
|
||||
return app(SalesLedgerSource::class)->source($hostActor,$kind,$id);
|
||||
});
|
||||
};
|
||||
$period=function($p)use($host,$hostActor,$stock){$extra=$this->withHost($host,$hostActor,function()use($p,$hostActor){$facts=0;$pending=0;$h=hash_init('sha256');foreach([SalesLedgerSource::class,CostLedgerSource::class,IndustrialLedgerSource::class,CashLedgerSource::class] as $class){$v=app($class)->period($hostActor,$p);$facts+=$v['facts'];$pending+=$v['pending'];hash_update($h,$v['hash']);}return ['facts'=>$facts,'pending'=>$pending,'hash'=>hash_final($h)];});$physical=$stock->period($p);return ['facts'=>$extra['facts']+$physical['facts'],'pending'=>$extra['pending']+$physical['pending'],'hash'=>hash('sha256',$extra['hash'].$physical['hash'])];};
|
||||
$period=function($p)use($host,$hostActor,$stock,$native,$ledgerScope){$extra=$this->withHost($host,$hostActor,function()use($p,$hostActor,$native,$ledgerScope){$facts=0;$pending=0;$h=hash_init('sha256');foreach([SalesLedgerSource::class,CostLedgerSource::class,IndustrialLedgerSource::class,CashLedgerSource::class] as $class){$v=app($class)->period($hostActor,$p);$facts+=$v['facts'];$pending+=$v['pending'];hash_update($h,$v['hash']);}if(config('fixed_assets.enabled')===true){$v=app(FixedAssetLedgerSource::class)->period($hostActor,$p,$native,$ledgerScope);$facts+=$v['facts'];$pending+=$v['pending'];hash_update($h,$v['hash']);}return ['facts'=>$facts,'pending'=>$pending,'hash'=>hash_final($h)];});$physical=$stock->period($p);return ['facts'=>$extra['facts']+$physical['facts'],'pending'=>$extra['pending']+$physical['pending'],'hash'=>hash('sha256',$extra['hash'].$physical['hash'])];};
|
||||
$engine=new PayableJournal($native,$ledgerScope,$actor->id,$person,$authorize,fn()=>$authorize('view'),fn(int $id)=>$this->source($actor,$binding,$financialScope,$id),null,$additional,$period,$financialScope);
|
||||
return $work($engine,$actor,$binding,$origin+['sgf_host_user'=>$hostUser,'sgf_host_scope'=>$scope,'binding_revision'=>$revision],$ledgerScope,$stock,fn(\Closure $read)=>$this->withHost($host,$hostActor,$read));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user