Loading ...

Overriding logic for creating packages for Shipment screen by Weight_Volume or Weight and Volume

We are doing this logic change because customer gonna use Master Boxes this boxes will just contain other boxes and default Acumatica as I research doesn’t support such logic.

Let’s begin with changing logic for CreateShipment, first of all we need to override this method
[PXOverride]

public virtual void CreateShipment(CreateShipmentArgs args, CreateShipmentDelegate baseMethod)

{

}
before main logic for creating new packages, you can put any logic that will suit your needs. In my way I am taking all boxes that belongs to customer like this on Customer screen -> Packaging tab

But then we are facing a little problem. When you are creating a shipment Acumatica creates packages by default with type “Auto”. We need to delete them if you want to spread item by yourself through packages

Then I am taking all shipment lines that need to be spread through packages and going line by line to make the correct spread. Also I created a separate method for each packaging option. In my way there is no need to override the Volume method because customer will not use it. In that case we have such code

And inside those methods you can create your own logic for creating packages and spreading items through those packages. As an example I will show CreatePackagesByWeight

 

 

    var lastPackage = Base.Packages.Select().FirstTableItems?.LastOrDefault(); // Get the last package from the current list of packages

As you can see in this code I am creating package base on weight of current item, packing as many as can to box and if some items are left we creating a new max suitable box and doing the same for other item that left after packing for the previous time. For Weight and Volume you are gonna do the same steps but also need to calculate how many items can be packed by volume and also weight and base on that value do exactly the same steps.