diff --git a/app/Actions/Assets/UpdateAssetAction.php b/app/Actions/Assets/UpdateAssetAction.php index 11c0085af0..887b4a35ca 100644 --- a/app/Actions/Assets/UpdateAssetAction.php +++ b/app/Actions/Assets/UpdateAssetAction.php @@ -55,8 +55,21 @@ class UpdateAssetAction $asset->status_id = $status_id ?? $asset->status_id; $asset->warranty_months = $warranty_months ?? $asset->warranty_months; $asset->purchase_cost = $purchase_cost ?? $asset->purchase_cost; - $asset->purchase_date = $purchase_date ?? $asset->purchase_date?->format('Y-m-d'); - $asset->next_audit_date = $next_audit_date ?? $asset->next_audit_date; + if ($request->input('null_purchase_date') === '1') { + dump('filled'); + $asset->purchase_date = null; + if (!($asset->eol_explicit)) { + $asset->asset_eol_date = null; + } + } else { + $asset->purchase_date = $purchase_date ?? $asset->purchase_date?->format('Y-m-d'); + } + if ($request->input('null_next_audit_date') == '1') { + $asset->next_audit_date = null; + } else { + $asset->next_audit_date = $next_audit_date ?? $asset->next_audit_date; + } + $asset->last_audit_date = $last_audit_date ?? $asset->last_audit_date; if ($purchase_date && !$asset_eol_date && ($asset->model->eol > 0)) { $asset->purchase_date = $purchase_date ?? $asset->purchase_date?->format('Y-m-d'); @@ -79,7 +92,11 @@ class UpdateAssetAction $asset->eol_explicit = false; } $asset->supplier_id = $supplier_id; - $asset->expected_checkin = $expected_checkin; + if ($request->input('null_expected_checkin_date') == '1') { + $asset->expected_checkin = null; + } else { + $asset->expected_checkin = $expected_checkin ?? $asset->expected_checkin; + } $asset->requestable = $requestable; $asset->location_id = $location_id; diff --git a/tests/Feature/Assets/Ui/BulkEditAssetsTest.php b/tests/Feature/Assets/Ui/BulkEditAssetsTest.php index 7962663cb4..5b6779032b 100644 --- a/tests/Feature/Assets/Ui/BulkEditAssetsTest.php +++ b/tests/Feature/Assets/Ui/BulkEditAssetsTest.php @@ -221,7 +221,7 @@ class BulkEditAssetsTest extends TestCase }); } - public function testBulkEditAssetsRequiresadminToUpdateEncryptedCustomFields() + public function testBulkEditAssetsRequiresAdminToUpdateEncryptedCustomFields() { $this->markIncompleteIfMySQL('Custom Fields tests do not work on mysql'); $edit_user = User::factory()->editAssets()->create(); diff --git a/tests/Unit/DepreciationTest.php b/tests/Unit/DepreciationTest.php index f3d1097e8d..7fa18c3c12 100644 --- a/tests/Unit/DepreciationTest.php +++ b/tests/Unit/DepreciationTest.php @@ -38,7 +38,8 @@ class DepreciationTest extends TestCase ->laptopMbp() ->create( [ - 'category_id' => Category::factory()->assetLaptopCategory()->create(), + //not sure how this ever worked... do these need a category?? + //'category_id' => Category::factory()->assetLaptopCategory()->create(), 'purchase_date' => now()->subDecade()->format("Y-m-d"), 'purchase_cost' => 4000, ]); @@ -62,7 +63,8 @@ class DepreciationTest extends TestCase ->laptopMbp() ->create( [ - 'category_id' => Category::factory()->assetLaptopCategory()->create(), + //not sure how this ever worked... + //'category_id' => Category::factory()->assetLaptopCategory()->create(), 'purchase_date' => now()->subDecade()->format("Y-m-d"), 'purchase_cost' => 4000, ]);