From da8999f59a3c88728268bb8a62758eaa8494087d Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Jan 2025 10:21:18 -0800 Subject: [PATCH 1/3] Add failing test --- .../DepreciationReportTransformerTest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/Unit/Transformers/DepreciationReportTransformerTest.php diff --git a/tests/Unit/Transformers/DepreciationReportTransformerTest.php b/tests/Unit/Transformers/DepreciationReportTransformerTest.php new file mode 100644 index 00000000000..7a0017196a4 --- /dev/null +++ b/tests/Unit/Transformers/DepreciationReportTransformerTest.php @@ -0,0 +1,24 @@ +create(); + $depreciation = Depreciation::factory()->create(['months' => 0]); + $asset->model->depreciation()->associate($depreciation); + + $transformer = new DepreciationReportTransformer; + + $result = $transformer->transformAsset($asset); + + $this->assertIsArray($result); + } +} From 1098b8cd9d5534091a0b7d222cfec169836db084 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Jan 2025 10:21:30 -0800 Subject: [PATCH 2/3] Avoid trying to divide by zero --- app/Http/Transformers/DepreciationReportTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Transformers/DepreciationReportTransformer.php b/app/Http/Transformers/DepreciationReportTransformer.php index 33d9a1f5fd4..00eb984fa51 100644 --- a/app/Http/Transformers/DepreciationReportTransformer.php +++ b/app/Http/Transformers/DepreciationReportTransformer.php @@ -61,7 +61,7 @@ public function transformAsset(Asset $asset) /** * 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())); From 36f460d32b930b4fce243cb2875cb95b8dbc7544 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 22 Jan 2025 21:48:03 +0000 Subject: [PATCH 3/3] Default to localStorage for bootstap table cookies Signed-off-by: snipe --- config/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/session.php b/config/session.php index 5c6cb27a9f6..10d0d1acfb9 100644 --- a/config/session.php +++ b/config/session.php @@ -172,7 +172,7 @@ | 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'), /*