Which tables should I link or with what query can I determine the current amount of rented products from a detailed project by the shipping number?
Hi Raymond,
You will need to use our API for this. Here is an example C# snippet to help get you going in the right direction. This program will return all of the shipments with sent quantities corresponding to a job site. You can tweak the code to look for reserved quantities instead.
I suggest spending some time playing with the Sample C# project if you haven’t already, as it can be used as a boilerplate for your needs.
/ Initialize variable with Job Site Name
String jobSiteName = "Dawson Station";
// get jobID using the job name
var jobID = StockingLocation.GetStockingLocation(jobSiteName, false).StockingLocationID;
// get list of shipments going to job by jobID
var shipmentList = ShipmentList.GetShipmentList(jobID).Where(x => x.IsBillable && x.ShipmentStatus == ShipmentStatusType.Completed);
Shipment shipment;
foreach (var shipmentListItem in shipmentList)
{
// for each shipment, print total number of products, and quantities for each product
shipment = Shipment.GetShipment(shipmentListItem.ShipmentID, false, false, false);
Console.WriteLine($"Shipment Number: {shipmentListItem.ShipmentNumber}\tProduct Count: {shipment.ShipmentProductProducts.Where(x => x.SentQuantity > 0).Count()}");
Console.WriteLine($"From Location: {StockingLocation.GetStockingLocation(shipmentListItem.FromStockingLocationID, false)}" +
$"\tTo Location: {StockingLocation.GetStockingLocation(shipmentListItem.ToStockingLocationID, false)}");
foreach (var shipmentProduct in shipment.ShipmentProductProducts.Where(x => x.SentQuantity > 0))
{
Console.WriteLine($"Part Number: {shipmentProduct.PartNumber}\tSent Quantity: {shipmentProduct.SentQuantity}");
}
}
Here is what is printed to the console upon running the program on one of our test databases: