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:
- Define an empty descendant of the QtySupport extension.
- Override the UseQtyCorrectection method of the barcode scan class.
- Add the QtySupport.SetQtyCommand component in the CreateCommands method.
System Preparation
Before you begin performing the step of this activity, do the following:
- Prepare an MYOB Acumatica instance by performing the Test Instance: To Deploy an Instance prerequisite activity.
- Create a barcode scan class by performing the Barcode Scan Class: To Create a Barcode Scan Class prerequisite activity.
- Create the scan mode and define its required properties by performing the Barcode Scan Mode: To Define the Required Properties prerequisite activity.
- 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:
- 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 { } ... }
- Fix or suppress the PX1016 error that is displayed by Acuminator for the class.
- In the
INScanCount
class, define theSetup
data view, as shown in the following code.public class INScanCount : WMSBase { ... public PXSetupOptional<INScanSetup, Where<INScanSetup.branchID.IsEqual< AccessInfo.branchID.FromCurrent>>> Setup; ... }
- Override the UseQtyCorrectection method, as shown
below.
public class INScanCount : WMSBase { ... protected override bool UseQtyCorrectection => Setup.Current.UseDefaultQtyInCount != true; ... }
- 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(); } ... }