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MAAO,GAAG,CAACH,KAAK,2BAA6BC,KAAK,yFAA0FC,WAAY,SAASC,MAAO,IACrRC,qBAAsB,CAAC,UACvBC,KAAK,EACLC,GAAI,YACJC,EAAG,aACHC,EAAG,YAEHC,IAAK,uCAELC,cAAe,iCACfC,GAAI,yBAOArB,EAF4B,yFACXO,EAAQ,MAQzBP,EAF4B,oDACXO,EAAQ,MAMjCe,OAAOC,aAAeD,OAAOC,cAAgB,GAC7CD,OAAOC,aAAazB,QAAO0B,EAAAA,EAAA,GACpBF,OAAOC,aAAazB,SAAW,IAC/BD,EAAQC,SAGXwB,OAAOC,aAAaxB,YAAWyB,EAAAA,EAAA,GAC5BF,OAAOC,aAAaxB,aAAe,IACnCF,EAAQE,c,mBChFnB0B,EAAOC,QAAUC,O,oBCAjBF,EAAOC,QAAUE,W","sources":["webpack://bju-press/./src/actions/get-product-availabilities-for-backorders.ts?1b3a","webpack://bju-press/./lib/homeschool/module-registration.js?f96f","webpack://bju-press/external var \"React\"?0d3b","webpack://bju-press/external var \"ReactDOM\"?853b"],"sourcesContent":["import {\r\n CacheType,\r\n createObservableDataAction,\r\n IAction,\r\n IActionContext,\r\n IActionInput,\r\n IAny,\r\n ICreateActionContext,\r\n IGeneric\r\n} from '@msdyn365-commerce/core';\r\nimport {\r\n ProductAvailableQuantity,\r\n ProductsDataActions,\r\n ProductType,\r\n ProductWarehouseInventoryAvailability,\r\n ReleasedProductType\r\n} from '@msdyn365-commerce/retail-proxy';\r\n\r\nimport {\r\n getSelectedVariant,\r\n SelectedVariantInput,\r\n ArrayExtensions,\r\n getSelectedProductIdFromActionInput,\r\n DeliveryMode,\r\n IProductInventoryInformation,\r\n createInventoryAvailabilitySearchCriteria,\r\n mapAggregatedProductInventoryInformation\r\n} from '@msdyn365-commerce-modules/retail-actions';\r\n\r\nimport { cloneDeep } from 'lodash';\r\n\r\n/**\r\n * Input class for the getProductAvailabilitiesForBackorder Data Action.\r\n */\r\nexport class ProductAvailabilitiesForBackorderInput implements IActionInput {\r\n public productId: number;\r\n\r\n public channelId: number;\r\n\r\n public constructor(productId: number | string, channelId: number) {\r\n this.productId = typeof productId === 'string' ? +productId : productId;\r\n this.channelId = channelId;\r\n }\r\n\r\n /**\r\n * GetCacheKey.\r\n * @returns - Returns string.\r\n */\r\n public getCacheKey = (): string => 'AvailabilitiesBackorder';\r\n\r\n /**\r\n * GetCacheObjectType.\r\n * @returns - Cache Object Type string.\r\n */\r\n public getCacheObjectType = (): string => 'ProductAvailabilitiesForBackorder';\r\n\r\n /**\r\n * DataCacheType.\r\n * @returns - CacheType string.\r\n */\r\n public dataCacheType = (): CacheType => 'none';\r\n}\r\n\r\n/**\r\n * CreateInput method for the getProductAvailabilitiesForBackorder data action.\r\n * @param inputData - The input data passed to the createInput method.\r\n * @returns - ProductAvailabilitiesForBackorder or error.\r\n */\r\nexport const createProductAvailabilitiesForBackorderInput = (\r\n inputData: ICreateActionContext>\r\n): ProductAvailabilitiesForBackorderInput => {\r\n const productId = getSelectedProductIdFromActionInput(inputData);\r\n\r\n if (productId) {\r\n return new ProductAvailabilitiesForBackorderInput(+productId, +inputData.requestContext.apiSettings.channelId);\r\n }\r\n throw new Error('Unable to create ProductAvailabilitiesForBackorderInput, no productId found on module config or query');\r\n};\r\n\r\n/**\r\n * The action method for the getProductAvailabilitiesForBackorder data action.\r\n * @param input - ProductAvailabilitiesForBackorder.\r\n * @param ctx - Action Context.\r\n * @returns - Product inventory information.\r\n */\r\nexport async function getProductAvailabilitiesForBackorderAction(\r\n input: ProductAvailabilitiesForBackorderInput,\r\n ctx: IActionContext\r\n): Promise {\r\n const selectedVariantInput = new SelectedVariantInput(input.productId, input.channelId, undefined, undefined, ctx.requestContext);\r\n const productInventoryInformation: IProductInventoryInformation[] = [];\r\n const cloneCtx = cloneDeep(ctx);\r\n cloneCtx.requestContext.app.config.enableStockCheck = true;\r\n\r\n try {\r\n const productResult = await getSelectedVariant(selectedVariantInput, ctx);\r\n\r\n // Don't get availability if it is service item && enableStockCheck is disbaled.\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Reading config.\r\n if (\r\n productResult &&\r\n productResult.ItemTypeValue !== ReleasedProductType.Service &&\r\n productResult.ProductTypeValue !== ProductType.Master\r\n ) {\r\n\r\n\r\n const shippingSearchCriteria = createInventoryAvailabilitySearchCriteria(\r\n ctx,\r\n [productResult.RecordId],\r\n true,\r\n undefined,\r\n undefined,\r\n DeliveryMode.shipping\r\n );\r\n const pickupSearchCriteria = createInventoryAvailabilitySearchCriteria(\r\n ctx,\r\n [input.productId],\r\n false,\r\n true,\r\n undefined,\r\n DeliveryMode.pickup\r\n );\r\n const shippingAvailability = await ProductsDataActions.getEstimatedAvailabilityAsync(\r\n { callerContext: ctx },\r\n shippingSearchCriteria\r\n );\r\n\r\n if (shippingAvailability.ProductWarehouseInventoryAvailabilities) {\r\n const shippingInventory = mapAggregatedProductInventoryInformation(cloneCtx, shippingAvailability);\r\n if (ArrayExtensions.hasElements(shippingInventory)) {\r\n shippingInventory[0].deliveryType = DeliveryMode.shipping;\r\n productInventoryInformation.push(shippingInventory[0]);\r\n }\r\n }\r\n const pickupAvailability = await ProductsDataActions.getEstimatedAvailabilityAsync(\r\n { callerContext: ctx },\r\n pickupSearchCriteria\r\n );\r\n\r\n\r\n if (pickupAvailability.ProductWarehouseInventoryAvailabilities) {\r\n const pickupInventory = mapAggregatedProductInventoryInformation(cloneCtx, pickupAvailability);\r\n if (ArrayExtensions.hasElements(pickupInventory)) {\r\n pickupInventory[0].deliveryType = DeliveryMode.pickup;\r\n productInventoryInformation.push(pickupInventory[0]);\r\n }\r\n }\r\n return productInventoryInformation;\r\n }\r\n return undefined;\r\n } catch (error) {\r\n ctx.telemetry.exception(error as Error);\r\n ctx.telemetry.debug('[getPriceForSelectedVariantAction]Error executing action');\r\n return undefined;\r\n }\r\n}\r\n\r\n/**\r\n * The function that maps a ProductWareHouse object into a ProductAvailabilityQuantity.\r\n * @param productsWarehouseInventory - Product warehouse inventory.\r\n * @returns Product Available quantity.\r\n */\r\nexport function mergeProductWarehouseToProductAvailabities(\r\n productsWarehouseInventory: ProductWarehouseInventoryAvailability[]\r\n): ProductAvailableQuantity[] {\r\n const productAvailable: ProductAvailableQuantity[] = [];\r\n if (ArrayExtensions.hasElements(productsWarehouseInventory)) {\r\n for (const product of productsWarehouseInventory) {\r\n if (product.TotalAvailable !== undefined && product.ProductId !== undefined) {\r\n productAvailable.push({ ProductId: product.ProductId, AvailableQuantity: product.TotalAvailable });\r\n }\r\n }\r\n }\r\n return productAvailable;\r\n}\r\n\r\n/**\r\n * The complete getProductAvailabilitiesForBackorder data action\r\n * Get the currently selected variant via the getSelectedVariant data action, and\r\n * then gets the availabilities for the variant via the getProductAvailabilities RetailServer API.\r\n */\r\nexport const getProductAvailabilitiesForBackorderActionDataAction = createObservableDataAction({\r\n id: 'get-product-avail-for-backorders',\r\n action: >getProductAvailabilitiesForBackorderAction,\r\n input: createProductAvailabilitiesForBackorderInput\r\n});\r\n\r\nexport default getProductAvailabilitiesForBackorderActionDataAction;\r\n","const binding = { modules: {}, dataActions: {} };\n\n const registerActionId = (actionPath) => {\n if (binding.dataActions[actionPath] &&\n binding.dataActions[actionPath].default &&\n binding.dataActions[actionPath].default.prototype &&\n binding.dataActions[actionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[actionPath].default.prototype.id] = binding.dataActions[actionPath];\n } else {\n Object.keys(binding.dataActions[actionPath] || {}).forEach(exportName => {\n if (binding.dataActions[actionPath][exportName] &&\n binding.dataActions[actionPath][exportName].prototype &&\n binding.dataActions[actionPath][exportName].prototype.Action) {\n binding.dataActions[binding.dataActions[actionPath][exportName].prototype.id] = binding.dataActions[actionPath][exportName];\n }\n })\n }\n };\n\n const registerSanitizedActionPath = (sanitizedActionPath, dataAction) => {\n if (process.env.NODE_ENV === 'development') {\n if (!dataAction.default) {\n throw new Error('Data action path does not have a default export');\n }\n if (!(dataAction.default.prototype.id && binding.dataActions[dataAction.default.prototype.id]) || !binding.dataActions[sanitizedActionPath]) {\n binding.dataActions[sanitizedActionPath] = dataAction;\n }\n } else {\n binding.dataActions[sanitizedActionPath] = dataAction;\n if (!binding.dataActions[sanitizedActionPath].default) {\n throw new Error('Data action path ' + sanitizedActionPath + ' does not have a default export');\n }\n binding.dataActions[sanitizedActionPath].default.prototype.RegistrationId = sanitizedActionPath;\n if (binding.dataActions[sanitizedActionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[sanitizedActionPath].default.prototype.id] = sanitizedActionPath;\n }\n }\n };\n \n\n (binding.modules['homeschool'] = {\n c: () => require('base/index.js'),\n $type: 'themeModule',\n da: [{name:'backorderAvail', path:'actions/get-product-availabilities-for-backorders', moduleName: 'buybox',runOn: 0},{name:'productSpecificationData', path:'@msdyn365-commerce-modules/retail-actions/dist/lib/get-attributes-for-selected-variant', moduleName: 'buybox',runOn: 0}],\n definitionExtensions: ['buybox'],\n iNM: true,\n ns: '__local__',\n n: 'homeschool',\n p: '__local__',\n \n pdp: 'src/themes/base/base.definition.json',\n \n themeSettings: 'homeschool.theme.settings.json',\n md: 'src/themes/homeschool'\n });\n \n\n {\n const sanitizedActionPath = '@msdyn365-commerce-modules/retail-actions/dist/lib/get-attributes-for-selected-variant';\n let dataAction = require('@msdyn365-commerce-modules/retail-actions/dist/lib/get-attributes-for-selected-variant');\n registerSanitizedActionPath(sanitizedActionPath, dataAction);\n }\n \n\n {\n const sanitizedActionPath = 'actions/get-product-availabilities-for-backorders';\n let dataAction = require('partner/actions/get-product-availabilities-for-backorders');\n registerSanitizedActionPath(sanitizedActionPath, dataAction);\n }\n \n\n \n window.__bindings__ = window.__bindings__ || {};\n window.__bindings__.modules = {\n ...window.__bindings__.modules || {},\n ...binding.modules\n };\n \n window.__bindings__.dataActions = {\n ...window.__bindings__.dataActions || {},\n ...binding.dataActions\n };","module.exports = React;","module.exports = ReactDOM;"],"names":["ProductAvailabilitiesForBackorderInput","constructor","productId","channelId","getCacheKey","getCacheObjectType","dataCacheType","this","createProductAvailabilitiesForBackorderInput","inputData","getSelectedProductIdFromActionInput","requestContext","apiSettings","Error","async","getProductAvailabilitiesForBackorderAction","input","ctx","selectedVariantInput","SelectedVariantInput","undefined","productInventoryInformation","cloneCtx","_cloneDeep","app","config","enableStockCheck","productResult","getSelectedVariant","ItemTypeValue","ReleasedProductType","Service","ProductTypeValue","ProductType","Master","shippingSearchCriteria","createInventoryAvailabilitySearchCriteria","RecordId","DeliveryMode","shipping","pickupSearchCriteria","pickup","shippingAvailability","ProductsDataActions","callerContext","ProductWarehouseInventoryAvailabilities","shippingInventory","mapAggregatedProductInventoryInformation","ArrayExtensions","hasElements","deliveryType","push","pickupAvailability","pickupInventory","error","telemetry","exception","debug","mergeProductWarehouseToProductAvailabities","productsWarehouseInventory","productAvailable","product","TotalAvailable","ProductId","AvailableQuantity","getProductAvailabilitiesForBackorderActionDataAction","createObservableDataAction","id","action","binding","modules","dataActions","registerSanitizedActionPath","sanitizedActionPath","dataAction","default","prototype","RegistrationId","c","require","$type","da","name","path","moduleName","runOn","definitionExtensions","iNM","ns","n","p","pdp","themeSettings","md","window","__bindings__","_objectSpread","module","exports","React","ReactDOM"],"sourceRoot":""}