This commit is contained in:
spencerrlongg 2023-09-13 17:16:17 -05:00
parent 951521dc81
commit 0368b9df43
2 changed files with 3 additions and 12 deletions

View file

@ -98,17 +98,6 @@ class ItemImporter extends Importer
Log::info($e->getMessage()); Log::info($e->getMessage());
$this->log('Unable to parse date: '.$csvMatch); $this->log('Unable to parse date: '.$csvMatch);
} }
} elseif ($this->createOrFetchAssetModel($row) != null) {
if(AssetModel::find($this->createOrFetchAssetModel($row))->eol && $this->findCsvMatch($row, 'purchase_date') != '') {
$eol = AssetModel::find($this->createOrFetchAssetModel($row))->eol;
$months = CarbonImmutable::parse($this->findCsvMatch($row, 'asset_eol_date'))->diffInMonths($this->findCsvMatch($row, 'purchase_date'));
if($months != $eol) {
$this->item['eol_explicit'] = true;
} else {
$this->item['eol_explicit'] = false;
}
$this->item['asset_eol_date'] = CarbonImmutable::parse($this->findCsvMatch($row, 'purchase_date'))->addMonths($eol)->format('Y-m-d');
}
} }
$this->item['qty'] = $this->findCsvMatch($row, 'quantity'); $this->item['qty'] = $this->findCsvMatch($row, 'quantity');

View file

@ -140,7 +140,9 @@ class AssetObserver
} elseif (!is_null($asset->asset_eol_date) && is_null($asset->purchase_date)) { } elseif (!is_null($asset->asset_eol_date) && is_null($asset->purchase_date)) {
$asset->eol_explicit = true; $asset->eol_explicit = true;
} }
if ((!is_null($asset->asset_eol_date)) && (!is_null($asset->purchase_date)) && (is_null($asset->model->eol))) {
$asset->eol_explicit = true;
}
} }
} }