Browse Source

fix(admin-ui): Allow stockOnHand to match outOfStockThreshold

Fixes #1483
Michael Bromley 3 years ago
parent
commit
f89bfbe52d

+ 1 - 1
packages/admin-ui/src/lib/catalog/src/components/product-variants-list/product-variants-list.component.html

@@ -137,7 +137,7 @@
                                         [class.inventory-untracked]="inventoryIsNotTracked(formGroup)"
                                         clrInput
                                         type="number"
-                                        min="0"
+                                        [min]="getStockOnHandMinValue(formGroup)"
                                         step="1"
                                         formControlName="stockOnHand"
                                         [readonly]="!(updatePermission | hasPermission)"

+ 7 - 0
packages/admin-ui/src/lib/catalog/src/components/product-variants-list/product-variants-list.component.ts

@@ -147,6 +147,13 @@ export class ProductVariantsListComponent implements OnChanges, OnInit, OnDestro
         return '';
     }
 
+    getStockOnHandMinValue(variant: FormGroup) {
+        const effectiveOutOfStockThreshold = variant.get('useGlobalOutOfStockThreshold')?.value
+            ? this.globalOutOfStockThreshold
+            : variant.get('outOfStockThreshold')?.value;
+        return effectiveOutOfStockThreshold;
+    }
+
     getSaleableStockLevel(variant: ProductVariant.Fragment) {
         const effectiveOutOfStockThreshold = variant.useGlobalOutOfStockThreshold
             ? this.globalOutOfStockThreshold