Files
SGF/scripts/sgf-asset-depreciation-proof.php
T
2026-11-11 15:04:01 +02:00

3 lines
2.1 KiB
PHP

<?php
require __DIR__.'/sgf-single-bootstrap.php';use App\Modules\Accounting\AssetDepreciation as A;$checks=[];$ok=function($v,$n)use(&$checks){if(!$v)throw new LogicException($n);$checks[]=$n;};$reject=function($fn,$n)use($ok){try{$fn();throw new LogicException('Expected rejection');}catch(Symfony\Component\HttpKernel\Exception\HttpExceptionInterface$e){$ok($e->getStatusCode()===422,$n);}};$a=A::quota('1200.00','0.00',12,1);$ok($a['quota_cents']==='10000'&&$a['carrying_cents']==='110000','proposed1200/12 first quota100 carrying1100');$b=A::quota('1200.00','0.00',12,12);$ok($b['accumulated_cents']==='120000'&&$b['carrying_cents']==='0','last month exhausts depreciable amount exactly');$one=A::quota('100.00','0.00',3,1);$last=A::quota('100.00','0.00',3,3);$ok($one['quota_cents']==='3333'&&$one['difference_cents']==='1/3'&&$last['quota_cents']==='3334'&&$last['difference_cents']==='-2/3','cent adjustment and signed rational differences preserved');$sum=0;for($i=1;$i<=3;$i++)$sum+=(int)A::quota('100.00','0.00',3,$i)['quota_cents'];$ok($sum===10000,'sum of monthly quotas equals basis');$ok(A::quota('1200.00','200.00',12,12)['carrying_cents']==='20000','residual value preserved');$ok(A::quota('1200.00','1200.00',12,1)['quota_cents']==='0','explicit zero depreciable basis not unknown');foreach([[null,'0.00',12],['1200.00',null,12],['1200.00','0.00',null]]as[$c,$r,$m]){$q=A::quota($c,$r,$m,1);$ok(!$q['complete']&&$q['quota_cents']===null,'missing input remains unknown '.count($checks));}$reject(fn()=>A::quota('100.00','101.00',12,1),'residual greater than cost refused');$reject(fn()=>A::quota('1e3','0.00',12,1),'non documentary amount refused');$reject(fn()=>A::quota('100.00','0.00',12,13),'month beyond declared life refused');$ok($a['legal_tax_treatment']===null,'no legal depreciation rate or tax deduction asserted');file_put_contents($work.'/asset-depreciation-core.json',json_encode(['passed'=>true,'checks'=>$checks,'pure_arithmetic_only'=>true,'new_assets'=>0,'new_grants'=>0,'new_journals'=>0,'installed'=>false],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'checks'=>count($checks),'proof'=>$work.'/asset-depreciation-core.json']).PHP_EOL;