Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2025-01-22 21:49:55 +00:00
commit 5ac6caf257
3 changed files with 26 additions and 2 deletions

View file

@ -61,7 +61,7 @@ class DepreciationReportTransformer
/**
* Override the previously set null values if there is a valid model and associated depreciation
*/
if (($asset->model) && ($asset->model->depreciation)) {
if (($asset->model) && ($asset->model->depreciation) && ($asset->model->depreciation->months !== 0)) {
$depreciated_value = Helper::formatCurrencyOutput($asset->getDepreciatedValue());
$monthly_depreciation =Helper::formatCurrencyOutput($asset->purchase_cost / $asset->model->depreciation->months);
$diff = Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue()));

View file

@ -172,7 +172,7 @@ return [
| More info: https://bootstrap-table.com/docs/extensions/cookie/#cookiestorage
*/
'bs_table_storage' => env('BS_TABLE_STORAGE', 'cookieStorage'),
'bs_table_storage' => env('BS_TABLE_STORAGE', 'localStorage'),
/*

View file

@ -0,0 +1,24 @@
<?php
namespace Tests\Unit\Transformers;
use App\Http\Transformers\DepreciationReportTransformer;
use App\Models\Asset;
use App\Models\Depreciation;
use Tests\TestCase;
class DepreciationReportTransformerTest extends TestCase
{
public function testHandlesModelDepreciationMonthsBeingZero()
{
$asset = Asset::factory()->create();
$depreciation = Depreciation::factory()->create(['months' => 0]);
$asset->model->depreciation()->associate($depreciation);
$transformer = new DepreciationReportTransformer;
$result = $transformer->transformAsset($asset);
$this->assertIsArray($result);
}
}