This commit is contained in:
spencerrlongg 2023-09-06 17:01:00 -05:00
parent 97d6a34b8c
commit 30dade1fba
3 changed files with 8 additions and 11 deletions

View file

@ -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');
}

View file

@ -130,17 +130,16 @@ 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) {
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;
}
}

View file

@ -352,5 +352,4 @@ class AssetFactory extends Factory
{
return $this->state(['requestable' => false]);
}
}