Barcode Scan Commands: To Add Quantity Support

This activity will walk you through adding the logic that handles input of a quantity.

Story

Suppose that you are creating a custom scan mode for a barcode-driven form. You need to add the logic that handles the input of a quantity in this scan mode. You will use the QtySupport extension defined in the WarehouseManagementSystem<TSelf,TGraph> class. The logic of the QtySupport extension cannot be used until you create an empty descendant for this extension class.

Process Overview

In this activity, you will do the following:
  1. Define an empty descendant of the QtySupport extension.
  2. Override the UseQtyCorrectection method of the barcode scan class.
  3. Add the QtySupport.SetQtyCommand component in the CreateCommands method.

System Preparation

Before you begin performing the step of this activity, do the following:

  1. Prepare an MYOB Acumatica instance by performing the Test Instance: To Deploy an Instance prerequisite activity.
  2. Create a barcode scan class by performing the Barcode Scan Class: To Create a Barcode Scan Class prerequisite activity.
  3. Create the scan mode and define its required properties by performing the Barcode Scan Mode: To Define the Required Properties prerequisite activity.
  4. Define the list of commands for the scan mode by performing the Barcode Scan Commands: To Define the List of Commands prerequisite activity.

Step: Adding the Quantity Support Extension

To add the quantity support extension, do the following:

  1. In the INScanCount class, define an empty descendant of the QtySupport extension, as shown in the following code.
    public class INScanCount : WMSBase
    {
        ...
        public new class QtySupport : WMSBase.QtySupport { }  
        ...
    }
  2. Fix or suppress the PX1016 error that is displayed by Acuminator for the class.
  3. In the INScanCount class, define the Setup data view, as shown in the following code.
    public class INScanCount : WMSBase
    {
        ... 
        public PXSetupOptional<INScanSetup,
            Where<INScanSetup.branchID.IsEqual<
                AccessInfo.branchID.FromCurrent>>> Setup;
        ...
    }
  4. Override the UseQtyCorrectection method, as shown below.
    public class INScanCount : WMSBase
    {
        ...  
        protected override bool UseQtyCorrectection => 
            Setup.Current.UseDefaultQtyInCount != true;  
        ...
    }
  5. Add the QtySupport.SetQtyCommand component to the command list as follows.
    public sealed class CountMode : ScanMode
    {
        ... 
        protected override IEnumerable<ScanCommand<INScanCount>> CreateCommands()
        {
            yield return new RemoveCommand();
            yield return new QtySupport.SetQtyCommand(); 
            yield return new ConfirmCommand();
        }  
        ...
    }