I am having trouble finding an API that allows me to maintain the Product quantities against the individual job sites. I have an external system which is triggering Completion of a shipping return. I am able to do this fine, and to record product totals against that Return. For some reason, these are not automatically maintaining the product quantities against the job site, whereas performing the completion action via Quantify does.
I have seen other responses in this forum which indicate that this is maintained by creating the ShipmentProduct records against the shipment, but I have tried the code snippets provided, and the job product totals are still not being updated.
I CAN currently maintain the totals in the ToLocation which is at the yard level.
Hello Kirsty. To manage balances at a jobsite you will want to perform deliveries/returns/transfers. These are all accessible through the Shipment object. Would it be possible for you to share your sample code with us? If it’s something proprietary you can email a zip file (no binaries or it will be blocked) to support@avontus.com and let them know of this post and we’ll take a look.
Here is my code snippet of the update. Basically, a Pre-Return is created via the Quantify UI, and then I am trying to sync product returns and complete the pre-return using my code. I have stripped out the error handling for readability, and I am calling the addRDTotals and then CompleteReturnDocket in sequence. This piece of code ONLY handles pre-returns
Hi Kirsty. Below is some sample code on how to correctly add quantities to a shipment. You’ll see in the code that you will load all of the products at the branch, then use the indexer to set the SentQuantity.
// Create shipment then set the from and to locations
Shipment ship = Shipment.NewShipment(ShipmentStatusType.NewDirectShip);
ship.FromStockingLocationID = branchID;
ship.ToStockingLocationID = jobID;
// Load the parts from the branch
ship.ShipmentProducts.AddCatalogParts(branchID, jobID, Guid.Empty);
// If you have some sort of criteria to loop through that
// has a part number, use it here. Be sure to check for null
ship.ShipmentProducts[partNumber, Guid.Empty].SentQuantity = qty;
I have sent an email to the Avontus support email with both my original code, and a test harness where I use the above code. As I stated in that, and above, I need to add the products to an existing pre-return on completion. NOT to create a new shipment as this is not the situation I am handling.
If I use the code above on an existing pre-return shipment, it does not update the product totals against the job. Please tell me how I would alter the above code to ensure job totals are maintained on completion of an existing shipment.
For an existing Pre-Return with Shipment ID as {Shipment-ID}, the following code will add parts to it as well as update the totals at the source and destination correctly.
Thanks for that. We’ve been testing and got that code snippet working. If the job does not already have the product on the shipment, no items are being added though. We need to be able to return products that are not against the shipment, and have negative balances listed against the job site.
To be able to return parts not on the job, please make sure that “Allow balances to go negative” is checked in the Global Options through Quantify client. You should then be able to use the below code (includes an added line) to do it.
Thank you. I have implemented this code. I have found some issues when testing however. If I add damages, the totals are not correctly being updated on the yard and top level organisation.
For each shipment product, I need to set the damage totals first, otherwise the the SentQuantity value gets reset. That is fine, and I have set the values in an order that works. The totals are being set correctly on the job site with both undamaged and damaged values being accounted for.
On the yard however, neither the available nor the total has any change. At the top organisation level, the Available total gets no change (I expect it to increase by the undamaged amount), the At Job total is decreased by both undamaged and damaged as I expect, and the Total value is decreased by both undamaged and damaged when I expect it only to be decreased by damaged.
Is there something that I need to do to ensure the totals are correct when damaged quantities are also updated?
Are the totals being updated in the Out of Service node right below the branch office? This is the expected behavior. The totals should not be updated on the top level organization because they are reflected in Out of Service. Please check to see if the changes are being reflected in the OOS node.
The totals are being update in the Out of Service node. You have misunderstood my problem. Please see the below image.
For Standard O/E 1.0m on a New Direct Ship, I have set 10 To Ship AND 5 items as damages. If I do this through the QUANTIFY UI, I get totals being update in the Out of Service node (as expected). I ALSO get the top level Available total increased by 10 (undamaged amount), and the available and total at the Yard changes, AND the At Job totals change.
If I add the same values shown here (ie 10 To Ship and 5 Damages on a single product) VIA MY CODE, then the following happens:
at the top organisation level, the Available total gets no change (I expect it to increase by the undamaged amount)
on the Yard, neither the available nor the total has any change
the At Job total is decreased by both undamaged and damaged as I expect, AND the Total value is decreased by both undamaged and damaged when I expect it only to be decreased by damaged.
Rather than setting the SentQuantity property on the ShipmentProduct, could you try setting the OutOfServiceStocked property instead? The reason for this is that the SentQuantity is automatically calculated based on the other quantities that are set.
Something like the following code snippet:
Shipment preReturn = Shipment.GetShipmentOfStatus(Shipment.GetShipment("PR", false, false).ShipmentID, true, false, true, ShipmentStatusType.NewDirectShip);
preReturn.ShipmentProducts.AddCatalogParts(preReturn.FromStockingLocationID, preReturn.ToStockingLocationID, preReturn.RateProfileID);
preReturn.ShipmentStatus = ShipmentStatusType.NewDirectShip;
// Set the OOS Repairable/NonRepairable/Lost quantity, totals will be reflected the OOS node
preReturn.ShipmentProducts["PRODUCTNAME", Guid.Empty].OutOfServiceRepairableQuantity = 5;
// Set the OOS Stocked quantity, totals will be reflected in job site's parent nodes
preReturn.ShipmentProducts["PRODUCTNAME", Guid.Empty].OutOfServiceStockedQuantity = 10;
preReturn.ReturnRentStopDate = new SmartDate(DateTime.Today);
Console.WriteLine();
preReturn.ApplyEdit();
preReturn.Save();
We’ve just tested this and confirmed that product totals were being reflected correctly everywhere. When you are doing a pre-return without damages, setting the SentQuantity is fine, else, use the OutOfServiceStockedQuantity instead.