From 8ed37fb2d7cfddc265bc46e801f014d84ebabb52 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 3 Apr 2023 23:40:57 +1000 Subject: [PATCH] Fixes for adjust product inventory --- app/DataMapper/Tax/TaxModel.php | 4 ++-- app/Jobs/Inventory/AdjustProductInventory.php | 8 ++++---- app/Models/Product.php | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/DataMapper/Tax/TaxModel.php b/app/DataMapper/Tax/TaxModel.php index f127759d69cc..89872290cfd3 100644 --- a/app/DataMapper/Tax/TaxModel.php +++ b/app/DataMapper/Tax/TaxModel.php @@ -13,7 +13,7 @@ namespace App\DataMapper\Tax; class TaxModel { - public string $seller_region = 'US'; + // public string $seller_region = 'US'; public string $seller_subregion = 'CA'; @@ -45,7 +45,7 @@ class TaxModel private function usRegion(): self { $this->regions->US->has_sales_above_threshold = false; - $this->regions->US->tax_all = false; + $this->regions->US->tax_all_subregions = false; $this->usSubRegions(); return $this; diff --git a/app/Jobs/Inventory/AdjustProductInventory.php b/app/Jobs/Inventory/AdjustProductInventory.php index fddf8cabdc7c..e46ac69398f4 100644 --- a/app/Jobs/Inventory/AdjustProductInventory.php +++ b/app/Jobs/Inventory/AdjustProductInventory.php @@ -115,9 +115,9 @@ class AdjustProductInventory implements ShouldQueue $p->in_stock_quantity -= $i->quantity; $p->saveQuietly(); - nlog($p->stock_notification_threshold); - nlog($p->in_stock_quantity); - nlog($p->stock_notification_threshold); + nlog("threshold ".$p->stock_notification_threshold); + nlog("stock q".$p->in_stock_quantity); + nlog("p stock not".$p->stock_notification_threshold); if ($this->company->stock_notification && $p->stock_notification && $p->stock_notification_threshold && $p->in_stock_quantity <= $p->stock_notification_threshold) { $this->notifyStockLevels($p, 'product'); @@ -131,7 +131,7 @@ class AdjustProductInventory implements ShouldQueue private function existingInventoryAdjustment() { - collect($this->invoice->line_items)->filter(function ($item) { + collect($this->old_invoice)->filter(function ($item) { return $item->type_id == '1'; })->each(function ($i) { $p = Product::where('product_key', $i->product_key)->where('company_id', $this->company->id)->first(); diff --git a/app/Models/Product.php b/app/Models/Product.php index b04767ae6146..e360fd145ba7 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -114,7 +114,6 @@ class Product extends BaseModel use SoftDeletes; use Filterable; - public const PRODUCT_TYPE_PHYSICAL = 1; public const PRODUCT_TYPE_SERVICE = 2; public const PRODUCT_TYPE_DIGITAL = 3;