From 40d14043d200154e87ba46db6f63e67abffd5398 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Fri, 17 Dec 2021 12:37:09 -0500 Subject: [PATCH 1/5] Updated CHANGELOG.md --- packages/js/api/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/js/api/CHANGELOG.md b/packages/js/api/CHANGELOG.md index ea1d2914f4b..1c84d6494f1 100644 --- a/packages/js/api/CHANGELOG.md +++ b/packages/js/api/CHANGELOG.md @@ -1,5 +1,9 @@ # Unreleased +## Added + +- Added low stock threshold field to for products + # 0.2.0 ## Added From 8078b0cdafdae61e4f530cbc1a42c1e501f90afe Mon Sep 17 00:00:00 2001 From: jamelreid Date: Fri, 17 Dec 2021 12:38:19 -0500 Subject: [PATCH 2/5] Added low stock threshold --- .../js/api/src/models/products/abstract/inventory.ts | 9 ++++++++- packages/js/api/src/models/products/shared/types.ts | 2 +- packages/js/api/src/models/products/simple-product.ts | 3 ++- packages/js/api/src/models/products/variable-product.ts | 3 ++- packages/js/api/src/models/products/variation.ts | 1 + packages/js/api/src/repositories/rest/products/shared.ts | 2 ++ 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/js/api/src/models/products/abstract/inventory.ts b/packages/js/api/src/models/products/abstract/inventory.ts index 9a477bda9dd..fec5c26d091 100644 --- a/packages/js/api/src/models/products/abstract/inventory.ts +++ b/packages/js/api/src/models/products/abstract/inventory.ts @@ -34,7 +34,7 @@ abstract class AbstractProductInventory extends Model { * * @type {StockStatus} */ - public readonly stockStatus: StockStatus = '' + public readonly stockStatus: StockStatus = ''; /** * The status of backordering for a product. @@ -56,6 +56,13 @@ abstract class AbstractProductInventory extends Model { * @type {boolean} */ public readonly isOnBackorder: boolean = false; + + /** + * Indicates when the threshold for when low stock notification will be sent to the store admin. + * + * @type {boolean} + */ + public readonly lowStockThreshold: number = -1; } export interface IProductInventory extends AbstractProductInventory {} diff --git a/packages/js/api/src/models/products/shared/types.ts b/packages/js/api/src/models/products/shared/types.ts index d127181b445..c72b92cffa8 100644 --- a/packages/js/api/src/models/products/shared/types.ts +++ b/packages/js/api/src/models/products/shared/types.ts @@ -53,7 +53,7 @@ export type ProductGroupedUpdateParams = 'groupedProducts'; * Properties related to tracking inventory. */ export type ProductInventoryUpdateParams = 'backorderStatus' | 'canBackorder' | 'trackInventory' - | 'onePerOrder' | 'remainingStock'; + | 'onePerOrder' | 'remainingStock' | 'lowStockThreshold'; /** * Properties related to sales tax. diff --git a/packages/js/api/src/models/products/simple-product.ts b/packages/js/api/src/models/products/simple-product.ts index dd12635b8cf..b774ae84c57 100644 --- a/packages/js/api/src/models/products/simple-product.ts +++ b/packages/js/api/src/models/products/simple-product.ts @@ -130,10 +130,11 @@ export class SimpleProduct extends AbstractProduct implements public readonly onePerOrder: boolean = false; public readonly trackInventory: boolean = false; public readonly remainingStock: number = -1; - public readonly stockStatus: StockStatus = '' + public readonly stockStatus: StockStatus = ''; public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed; public readonly canBackorder: boolean = false; public readonly isOnBackorder: boolean = false; + public readonly lowStockThreshold: number = -1; /** * @see ./abstracts/price.ts diff --git a/packages/js/api/src/models/products/variable-product.ts b/packages/js/api/src/models/products/variable-product.ts index 6433502d8ac..55346f53b33 100644 --- a/packages/js/api/src/models/products/variable-product.ts +++ b/packages/js/api/src/models/products/variable-product.ts @@ -115,10 +115,11 @@ export class VariableProduct extends AbstractProduct implements public readonly onePerOrder: boolean = false; public readonly trackInventory: boolean = false; public readonly remainingStock: number = -1; - public readonly stockStatus: StockStatus = '' + public readonly stockStatus: StockStatus = ''; public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed; public readonly canBackorder: boolean = false; public readonly isOnBackorder: boolean = false; + public readonly lowStockThreshold: number = -1; /** * @see ./abstracts/sales-tax.ts diff --git a/packages/js/api/src/models/products/variation.ts b/packages/js/api/src/models/products/variation.ts index beb1bad8071..61279b0e524 100644 --- a/packages/js/api/src/models/products/variation.ts +++ b/packages/js/api/src/models/products/variation.ts @@ -118,6 +118,7 @@ export class ProductVariation extends AbstractProductData implements public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed; public readonly canBackorder: boolean = false; public readonly isOnBackorder: boolean = false; + public readonly lowStockThreshold: number = -1; /** * @see ./abstracts/price.ts diff --git a/packages/js/api/src/repositories/rest/products/shared.ts b/packages/js/api/src/repositories/rest/products/shared.ts index 8105a270734..9cd81bde891 100644 --- a/packages/js/api/src/repositories/rest/products/shared.ts +++ b/packages/js/api/src/repositories/rest/products/shared.ts @@ -345,6 +345,7 @@ export function createProductInventoryTransformation(): ModelTransformation[] { onePerOrder: PropertyType.Boolean, stockStatus: PropertyType.String, backOrderStatus: PropertyType.String, + lowStockThreshold: PropertyType.Integer, }, ), new KeyChangeTransformation< IProductInventory >( @@ -356,6 +357,7 @@ export function createProductInventoryTransformation(): ModelTransformation[] { backorderStatus: 'backorders', canBackorder: 'backorders_allowed', isOnBackorder: 'backordered', + lowStockThreshold: 'low_stock_amount', }, ), ]; From 8920b4686ec3844b3a77e65c9f39670b1543a67f Mon Sep 17 00:00:00 2001 From: Jamel Noel Reid Date: Mon, 20 Dec 2021 11:51:43 -0500 Subject: [PATCH 3/5] Update CHANGELOG.md --- packages/js/api/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/api/CHANGELOG.md b/packages/js/api/CHANGELOG.md index 1c84d6494f1..5dfbc182b10 100644 --- a/packages/js/api/CHANGELOG.md +++ b/packages/js/api/CHANGELOG.md @@ -2,7 +2,7 @@ ## Added -- Added low stock threshold field to for products +- Added low stock threshold field for products # 0.2.0 From 35784f2f3aebab3fd72ee06a390e356030fceddf Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 23 Dec 2021 10:18:50 -0500 Subject: [PATCH 4/5] Updated JSDoc type --- packages/js/api/src/models/products/abstract/inventory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/api/src/models/products/abstract/inventory.ts b/packages/js/api/src/models/products/abstract/inventory.ts index fec5c26d091..f7f68a91e1d 100644 --- a/packages/js/api/src/models/products/abstract/inventory.ts +++ b/packages/js/api/src/models/products/abstract/inventory.ts @@ -60,7 +60,7 @@ abstract class AbstractProductInventory extends Model { /** * Indicates when the threshold for when low stock notification will be sent to the store admin. * - * @type {boolean} + * @type {number} */ public readonly lowStockThreshold: number = -1; } From d83a83ae0c3c32ea9c694a7bf2c4f67e6a176fe5 Mon Sep 17 00:00:00 2001 From: jamelreid Date: Thu, 23 Dec 2021 10:20:40 -0500 Subject: [PATCH 5/5] Updated JSDoc to description --- packages/js/api/src/models/products/abstract/inventory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/api/src/models/products/abstract/inventory.ts b/packages/js/api/src/models/products/abstract/inventory.ts index f7f68a91e1d..7fb6dac7a57 100644 --- a/packages/js/api/src/models/products/abstract/inventory.ts +++ b/packages/js/api/src/models/products/abstract/inventory.ts @@ -58,7 +58,7 @@ abstract class AbstractProductInventory extends Model { public readonly isOnBackorder: boolean = false; /** - * Indicates when the threshold for when low stock notification will be sent to the store admin. + * Indicates the threshold for when the low stock notification will be sent to the merchant. * * @type {number} */