From 0aeba565e128f774bbab805f31dcb213dba80dd8 Mon Sep 17 00:00:00 2001 From: Florian Ratz Date: Tue, 10 Jan 2023 08:16:18 +0100 Subject: [PATCH] exclude "last_seen" from touching --- src/AlsoImport.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/AlsoImport.php b/src/AlsoImport.php index c2c7e2b..f95cd24 100644 --- a/src/AlsoImport.php +++ b/src/AlsoImport.php @@ -209,19 +209,21 @@ protected function importLine() $this->writeLog(($productSupplier->id ? 'update' : 'create').' price of: "'.$product->id.' - '.$product->name); $productSupplier->supplier_product_id = $this->line['ProductID']; - $productSupplier->last_seen = now(); $productSupplier->save(); + $productSupplier->setLastSeen(); $vat = Vat::where('rate', $this->line['VatRate'])->first(); if (!$vat) throw new Exception('Tax Rate "'.$this->line['VatRate'].'"" not found', 1); - if ($productSupplier->prices->last()) - if ($productSupplier->prices->last()->amount == $this->line['NetPrice']) + if ($productSupplier->prices->last()) { + if ($productSupplier->prices->last()->amount == $this->line['NetPrice']) { return $this; + } + } - $price = Price::create([ + Price::create([ 'product_supplier_id' => $productSupplier->id, 'amount' => $this->line['NetPrice'], 'vat_id' => $vat->id,