mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Account for last_audit_date
not being provided
This commit is contained in:
parent
66ba96d531
commit
5f4c964309
|
@ -28,11 +28,16 @@ class StoreAssetRequest extends ImageUploadRequest
|
|||
? Company::getIdForCurrentUser($this->company_id)
|
||||
: $this->company_id;
|
||||
|
||||
if ($this->input('last_audit_date')) {
|
||||
$this->merge([
|
||||
'last_audit_date' => Carbon::parse($this->input('last_audit_date'))->startOfDay()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
$this->merge([
|
||||
'asset_tag' => $this->asset_tag ?? Asset::autoincrement_asset(),
|
||||
'company_id' => $idForCurrentUser,
|
||||
'assigned_to' => $assigned_to ?? null,
|
||||
'last_audit_date' => Carbon::parse($this->input('last_audit_date'))->startOfDay()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,22 @@ class AssetStoreTest extends TestCase
|
|||
$this->assertEquals('00:00:00', $asset->last_audit_date->format('H:i:s'));
|
||||
}
|
||||
|
||||
public function testLastAuditDateCanBeNull()
|
||||
{
|
||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.assets.store'), [
|
||||
// 'last_audit_date' => '2023-09-03 12:23:45',
|
||||
'asset_tag' => '1234',
|
||||
'model_id' => AssetModel::factory()->create()->id,
|
||||
'status_id' => Statuslabel::factory()->create()->id,
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success');
|
||||
|
||||
$asset = Asset::find($response['payload']['id']);
|
||||
$this->assertNull($asset->last_audit_date);
|
||||
}
|
||||
|
||||
public function testArchivedDepreciateAndPhysicalCanBeNull()
|
||||
{
|
||||
$model = AssetModel::factory()->ipadModel()->create();
|
||||
|
|
Loading…
Reference in a new issue