Low Inventory Product report does not work correctly

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
owain.jones@cmc.ca
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 36
Joined: Fri Feb 05, 2010 3:02 pm

Low Inventory Product report does not work correctly

Post by owain.jones@cmc.ca » Fri Jul 05, 2013 7:30 am

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

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Low Inventory Product report does not work correctly

Post by AbleMods » Wed Jul 10, 2013 1:25 pm

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;
        }
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply