mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
cleanup
This commit is contained in:
parent
97d6a34b8c
commit
30dade1fba
|
@ -95,11 +95,10 @@ class ItemImporter extends Importer
|
|||
try {
|
||||
$this->item['asset_eol_date'] = CarbonImmutable::parse($csvMatch)->format('Y-m-d');
|
||||
} catch (\Exception $e) {
|
||||
Log::alert($e->getMessage());
|
||||
$this->log('Error parsing date: '.$csvMatch);
|
||||
Log::info($e->getMessage());
|
||||
$this->log('Unable to parse date: '.$csvMatch);
|
||||
}
|
||||
} elseif ($this->createOrFetchAssetModel($row) != null) {
|
||||
//woof this is ugly
|
||||
if($eol = AssetModel::find($this->createOrFetchAssetModel($row))->eol) {
|
||||
$this->item['asset_eol_date'] = CarbonImmutable::parse($this->findCsvMatch($row, 'purchase_date'))->addMonths($eol)->format('Y-m-d');
|
||||
}
|
||||
|
|
|
@ -130,16 +130,15 @@ class AssetObserver
|
|||
}
|
||||
|
||||
//determine if explicit and set eol_explit to true
|
||||
//conditions might need more work
|
||||
if(!is_null($asset->asset_eol_date) && !is_null($asset->purchase_date)) {
|
||||
if($asset->model->eol) {
|
||||
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
|
||||
if($months != $asset->model->eol) {
|
||||
$asset->eol_explicit = true;
|
||||
}
|
||||
} else {
|
||||
$asset->eol_explicit = true;
|
||||
}
|
||||
} elseif (!is_null($asset->asset_eol_date) && is_null($asset->purchase_date)) {
|
||||
$asset->eol_explicit = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -352,5 +352,4 @@ class AssetFactory extends Factory
|
|||
{
|
||||
return $this->state(['requestable' => false]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue