fixed last audit date + test

This commit is contained in:
spencerrlongg 2024-03-27 14:39:23 -05:00
parent 1d4a7a7b02
commit cec84b857b
2 changed files with 5 additions and 1 deletions

View file

@ -645,6 +645,9 @@ class AssetsController extends Controller
if ($request->has('rtd_location_id') && !$request->has('location_id')) {
$asset->location_id = $request->validated()['rtd_location_id'];
}
if ($request->input('last_audit_date')) {
$asset->last_audit_date = Carbon::parse($request->input('last_audit_date'))->startOfDay()->format('Y-m-d H:i:s');
}
/**
* this is here just legacy reasons. Api\AssetController

View file

@ -60,7 +60,7 @@ class AssetUpdateTest extends TestCase
'asset_tag' => 'random_string',
'assigned_user' => $userAssigned->id,
'company_id' => $company->id,
'last_audit_date' => '2023-09-03',
'last_audit_date' => '2023-09-03 12:23:45',
'location_id' => $location->id,
'model_id' => $model->id,
'name' => 'A New Asset',
@ -98,6 +98,7 @@ class AssetUpdateTest extends TestCase
$this->assertTrue($updatedAsset->assetstatus->is($status));
$this->assertTrue($updatedAsset->supplier->is($supplier));
$this->assertEquals(10, $updatedAsset->warranty_months);
$this->assertEquals('2023-09-03 00:00:00', $updatedAsset->last_audit_date->format('Y-m-d H:i:s'));
}
public function testAssetEolDateIsCalculatedIfPurchaseDateUpdated()