Page 1 of 1

Low Inventory Product report does not work correctly

Posted: Fri Jul 05, 2013 7:30 am
by owain.jones@cmc.ca
We are running AbleCommerce Gold R4 (build 5410) and we've noticed that the low inventory product report (Reports -> Products -> Low Inventory) does not display products unless their "Availability Date" is set. We sell training event registrations which have limited seats, but "Availability Date" does not make sense for these as they are usually unique one-time training events.

Owain

Re: Low Inventory Product report does not work correctly

Posted: Wed Jul 10, 2013 1:25 pm
by AbleMods
More specifically, the Count method specified on the gridview data source is bugged. It includes a restriction for AvailabilityDate which is causing the RowCount() to return 0. This in turn causes the gridview control to not display the result dataset even though the dataset does contain rows of data.

There is no need for restriction on availability date with regards to determining inclusion in low product inventory.

Note the additional restriction of availabilitydate for the count1 variable

Code: Select all

/// <summary>
        /// Gets the number of items that are at or below the reorder point.
        /// </summary>
        /// <returns>The number of items that are at or below the reorder point.</returns>
        public static int GetLowProductInventoryCount()
        {
            int count1 = NHibernateHelper.CreateCriteria<Product>()
                .Add(Restrictions.LeProperty("InStock", "InStockWarningLevel"))
                .Add(Restrictions.LeProperty("AvailabilityDate", "AvailabilityDate"))
                .Add(Restrictions.Eq("InventoryModeId", (byte)InventoryMode.Product))
                .SetProjection(Projections.RowCount())
                .UniqueResult<int>();

            int count2 = NHibernateHelper.CreateCriteria<ProductVariant>("PV")
                .CreateCriteria("Product", "P", NHibernate.SqlCommand.JoinType.InnerJoin)
                .Add(Restrictions.Eq("P.InventoryModeId", (byte)InventoryMode.Variant))
                .Add(Restrictions.LeProperty("PV.InStock", "PV.InStockWarningLevel"))
                .SetProjection(Projections.RowCount())
                .UniqueResult<int>();

            return count1 + count2;
        }