mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge pull request #16116 from marcusmoore/bug/sc-20259
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run
This commit is contained in:
commit
802fcbafa0
|
@ -61,7 +61,7 @@ class DepreciationReportTransformer
|
||||||
/**
|
/**
|
||||||
* Override the previously set null values if there is a valid model and associated depreciation
|
* 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());
|
$depreciated_value = Helper::formatCurrencyOutput($asset->getDepreciatedValue());
|
||||||
$monthly_depreciation =Helper::formatCurrencyOutput($asset->purchase_cost / $asset->model->depreciation->months);
|
$monthly_depreciation =Helper::formatCurrencyOutput($asset->purchase_cost / $asset->model->depreciation->months);
|
||||||
$diff = Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue()));
|
$diff = Helper::formatCurrencyOutput(($asset->purchase_cost - $asset->getDepreciatedValue()));
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue