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,