Good day.
i am hoping that someone is able to assist me with an issue that i am facing.
i need to add an item to a transaction from code in the BlankOperations project, the issue i am having is that if it is a new transaction then the code fails. i read the following post that states there is a bug that exists that adding an item to a new transaction has an issue because a new blank customer will need to be added first. (https://cloudblogs.microsoft.com/dynamics365/no-audience/2012/04/22/ax-for-retail-two-bug-fixes-for-the-blank-operation-sell-item/)
This makes sense, however i am not sure where this code fix is supposed to placed. i have tried a few things to try and set a blank customer but that too does not seem to work. i have tried a few variations of code but neither seem to work.
var emptyCustomer = CustomerSystem.GetEmptyCustomer();
LSRetailPosis.Transaction.Customer BlankCustomer = emptyCustomer as LSRetailPosis.Transaction.Customer;
Customer.Customer cc = new Customer.Customer();
cc.AddCustomerToTransaction(BlankCustomer, posTransaction);
var emptyCustomer = CustomerSystem.GetEmptyCustomer();
LSRetailPosis.Transaction.Customer BlankCustomer = emptyCustomer as LSRetailPosis.Transaction.Customer;
((RetailTransaction)posTransaction).Customer = BlankCustomer;
((RetailTransaction)posTransaction).InvoicedCustomer = BlankCustomer;
ITransactionSystem transSys = this.Application.BusinessLogic.TransactionSystem;
transSys.LoadTransactionStatus(posTransaction);
var emptyCustomer = CustomerSystem.GetEmptyCustomer();
LSRetailPosis.Transaction.Customer BlankCustomer = emptyCustomer as LSRetailPosis.Transaction.Customer;
Application.RunOperation(PosisOperations.CustomerAdd, BlankCustomer, posTransaction);
what i am trying to achieve is to add items to the transaction. if there is an existing item in the transaction or a customer has been set to the transaction (from default functionality) then adding an item either by using
Application.RunOperation(PosisOperations.ItemSale, "123");
or by using
LSRetailPosis.POSProcesses.ItemSale iSale = new LSRetailPosis.POSProcesses.ItemSale();
iSale.OperationID = PosisOperations.ItemSale;
iSale.OperationInfo = new LSRetailPosis.POSProcesses.OperationInfo();
iSale.Barcode = "123";
iSale.OperationInfo.NumpadQuantity = 1;
iSale.POSTransaction = (PosTransaction)posTransaction;
iSale.RunOperation();
works correctly and i am able to continue and add my items programmatically. i think its due to the fact that a new transaction object may be null, so my thinking is to create or instantiate a new retail transaction object if one does not already exist. i have tried doing this as well but have had no luck yet.
any assistance in this regard would be appreciated.