Read fixed asset
Shows one fixed asset: its status, asset method, depreciation settings, free texts, transaction lines and which settings Twinfield has locked.
get() throws a DimensionNotFoundException for an unknown code; find() returns null instead.
assetStatusis where the asset is in its life:ToBeActivated,Active,InactiveorSold.statusis the status of the dimension (active, deleted or hidden), as for every dimension.- Periods are
Periodobjects and amounts areAmountobjects (numeric strings, never floats). Both print as Twinfield writes them, e.g.2026/04and2500.00. periodsInheritedis true when the number of periods comes from the asset method.- The asset only has the values of the free texts; their labels are on the asset method, so the example reads that too.
transactionLinesare the purchase and later transactions with the asset as dimension 3. Twinfield links them when you book such a transaction.lockedFieldslists what Twinfield does not allow to change now, e.g. the begin period of an active asset.isLocked(ClassicFixedAssetField::DepreciateFrom)checks one setting.
$twinfield = Example::twinfield();
// The code from the command line, or else the first fixed asset.$code = $argv[1] ?? $twinfield->classicFixedAssets()->search()->limit(1)->get()->items[0]->code ?? exit('The company has no fixed assets.' . PHP_EOL);
try { $asset = $twinfield->classicFixedAssets()->get($code);} catch (DimensionNotFoundException $exception) { echo 'Not found: ', $exception->reason, PHP_EOL;
exit(1);}
echo 'Code: ', $asset->code, ' ', $asset->name, PHP_EOL;echo 'Status: ', $asset->assetStatus->name, $asset->inUse ? ' (in use)' : '', PHP_EOL;echo 'Asset method: ', $asset->method === null ? '-' : $asset->method->code . ' ' . $asset->method->name, PHP_EOL;echo 'Cost center: ', $asset->costCenter->code, ' ', $asset->costCenter->name, PHP_EOL;echo 'Purchase date: ', $asset->purchaseDate?->format('Y-m-d') ?? '-', PHP_EOL;echo 'Depreciate from: ', $asset->depreciateFrom ?? '-', PHP_EOL;echo 'Periods: ', $asset->periods ?? '-', $asset->periodsInherited ? ' (from the asset method)' : '', PHP_EOL;echo 'Residual value: ', $asset->residualValue, PHP_EOL;echo 'Last depreciation: ', $asset->lastDepreciation ?? '-', PHP_EOL;echo 'Sell date: ', $asset->sellDate?->format('Y-m-d') ?? '-', PHP_EOL;echo 'Groups: ', implode(', ', $asset->groups) ?: '-', PHP_EOL;
// The asset method has the labels of the free text fields.if ($asset->method !== null) { $method = $twinfield->classicAssetMethods()->get($asset->method->code);
foreach ($method->freeTexts as $field) { if ($field->label !== null) { echo $field->label, ': ', $asset->freeText($field->id) ?? '-', PHP_EOL; } }}
echo PHP_EOL, 'Transaction lines:', PHP_EOL;
foreach ($asset->transactionLines as $line) { echo ' ', $line->period, ' ', $line->transactionType, ' ', $line->number, '/', $line->line, ' ', $line->account()?->code, ' ', $line->amount, PHP_EOL;}
if ($asset->transactionLines === []) { echo ' none yet', PHP_EOL;}
echo PHP_EOL, 'Locked: ', implode(', ', array_map( static fn (ClassicFixedAssetField $field): string => $field->label(), $asset->lockedFields,)), PHP_EOL;php examples/classic-fixed-assets/read-fixed-asset/example.php 60010Code: 60010 Delivery vanStatus: Active (in use)Asset method: 5YVEH 5 years linear - vehiclesCost center: 00000 GeneralPurchase date: 2026-03-15Depreciate from: 2026/04Periods: 60Residual value: 2500.00Last depreciation: 2026/09Sell date: -Groups: VEHICLESSerial number: WDB9066331S123456
Transaction lines: 2026/03 INK 202600012/2 0300 42000.00
Locked: status, begin period, sell date, transaction lines, last depreciationSource
Section titled “Source”View examples/classic-fixed-assets/read-fixed-asset/example.php on GitHub.
Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.