Get StockingLocations By EmployeeID

can you help me on this .??

y need all the stocking locations of the distinct EmployeeID on system , then y need to get All the Productos of the Stockinglocations by Category .
to get te TOTAL COST , and the TOTAL WEIGTH by Employee ID,

that is the issue GET the TotalCost and TotalWeigth by Employee ID.

can anyone give me a hint on this ?

Thanks ,

Hi Marveen,

Here is some simple code to get you started. You may want to throw this inside of a loop where you iterate through usernames.

    var user = AvontusUser.GetUser("username");
    var assignedStockingLocations = StockingLocationUserAssignmentList.GetStockingLocationUserAssignmentList(user.UserID);
    var productCategories = ProductCategoryComboList.GetProductCategoryComboList(ProductType.Product);
    decimal totalCost = 0;
    double totalWeight = 0;

    foreach (var assignedLocation in assignedStockingLocations)
    {
        // only count totals for jobsites
        if (!assignedLocation.AssignedToJob) continue;

        
        foreach (var cat in productCategories)
        {
            var products = StockedProductList.GetStockedProductList(assignedLocation.StockingLocationID, cat.ProductCategoryID, ProductType.Product);

            if (products.Count() == 0) continue;

            totalWeight += (products.Select(x => x.Weight).Sum() ?? 0);
            totalCost += (products.Select(x => x.AverageCost).Sum() ?? 0);

            Console.WriteLine($"{user.Username}\n\tProduct Catgory: {cat.Name}\tWeight: {totalWeight}\tCost: {totalCost}");
        }
    }

Also, we used the AverageCost column to total the cost. You may want to use another column or tweak the code a bit to get what you need.

Let us know if that helps or if you have additional questions.

-AvontusDev

1 Like