microsoft / Msdyn365.Commerce.Online

Dynamics 365 Commerce online project
Other
51 stars 41 forks source link

Buybox and Cart inventory issue (out of stock) #52

Closed alexmemex closed 2 years ago

alexmemex commented 2 years ago

We are experiencing inventory issues in both the buybox and cart modules in our current version (9.36).

From what we can tell the issue lies in a missing property on the ProductWarehouseInventoryAvailability interface. The product-inventory-utils.ts file uses the MaximumPurchasablePhysicalAvailableQuantity to assign the ProductAvailableQuantity that is returned from the inventory mapping functions. Since the property is not on the interface its assigning an undefined value instead of the actual inventory information.

The add to cart component checks if that available quantity is undefined and if so will show the product as out of stock whether there is valid inventory for the product or not. The cart is checking something similar.

Mapping function where the product quantity is set:

if (productWarehouseInventoryAvailability.ProductId &&
    productWarehouseInventoryAvailability.TotalAvailable !== undefined) {
    // As per the new buffer logic from RS,
    // if code is out of stock then we set the available quantity to 0 regardless of the actual value from API
    let productQuantity: number | undefined = 0;
    if (productWarehouseInventoryAvailability.PhysicalAvailableInventoryLevelCode !== InventoryLevelValues.outOfStock) {
        productQuantity = productWarehouseInventoryAvailability.MaximumPurchasablePhysicalAvailableQuantity;
    }
}

Current ProductWarehouseInventoryAvailability interface:

/**
 * ProductWarehouseInventoryAvailability entity interface.
 */
export interface ProductWarehouseInventoryAvailability {
    ProductId?: number;
    InventLocationId?: string;
    DataAreaId?: string;
    PhysicalInventory?: number;
    PhysicalReserved?: number;
    TotalAvailable?: number;
    TotalAvailableInventoryLevelLabel?: string;
    TotalAvailableInventoryLevelCode?: string;
    OrderedInTotal?: number;
    PhysicalAvailable?: number;
    PhysicalAvailableInventoryLevelLabel?: string;
    PhysicalAvailableInventoryLevelCode?: string;
    LastInventoryTransactionId?: number;
    UnpostedOnlineOrderedQuantity?: number;
    UnpostedFulfilledQuantity?: number;
    IsInventoryAvailabilityQuantityReturned?: boolean;
    UnprocessedQuantity?: number;
    QuantityUnitTypeValue?: number;
    UnitOfMeasure?: string;
    SumUncountedTransactions?: number;
    ExtensionProperties?: CommerceProperty[];
}

Our current package.json dependecies

"dependencies": {
    "@msdyn365-commerce-modules/starter-pack": "9.36",
    "@msdyn365-commerce-modules/fabrikam-design-kit": "9.36",
    "@msdyn365-commerce/bootloader": "^1.0.0",
    "@msdyn365-commerce/retail-proxy": "9.36",
    "@msdyn365-commerce-modules/msdyn365-exp-test-connector": "^1.0.0",
    "@msdyn365-commerce-theme/adventureworks-theme-kit": "9.36",
    "reactstrap": "^6.5.0",
    "stack-trace": "^0.0.10",
    "tslib": "^1.9.3"
}
mkelan commented 2 years ago

@alexmemex can you please create a support ticket to follow up on this?

alexmemex commented 2 years ago

@mkelan I've created a support ticket for this issue.

As an update, it seems as though the interface was fixed in the retail proxy feed in version 9.36.3 this week. However our current version of the CSU (9.36.22161.2) doesn't seem to be populating those fields so the result remains the same.

mkelan commented 2 years ago

@alexmemex Closing as this is a very old request and assuming its resolved. Issues here are not actively monitored. For future reference, kindly use https://community.dynamics.com/365/commerce/f/dynamics-365-commerce-forum.