Microsoft Dynamics Forums Homepage

Forum Home Forum Home > Microsoft Dynamics RMS & Microsoft Dynamics POS > POS
  New Posts New Posts RSS Feed - How insert an item into POS transaction   CODE C#
  FAQ FAQ  Forum Search   Register Register  Login Login


How insert an item into POS transaction CODE C#

 Post Reply Post Reply
Author
Message
honof11 View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: March 05 2012
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote honof11 Quote  Post ReplyReply Direct Link To This Post Topic: How insert an item into POS transaction CODE C#
    Posted: March 05 2012 at 3:56am

Hi Community,

 

I must simulate a transaction, programmatically, insert an object inside the cart , for example, when I press a custom button.

I have extended BlankOperation  (under the code): I insert an item (0113 for example) but in the POS the panel is empty. Do you know why?

 

 

I think  that I  may have to call a method to calculate the total amount of my current transaction but I don’t know which one…

 

My Code:

public void BlankOperation(IBlankOperationInfo operationInfo, IPosTransaction posTransaction)

        {

            decimal quantity= 1;

            string itemID = "0113";

 

            posTransaction = new RetailTransaction(posTransaction.StoreId, ApplicationSettings.Terminal.StoreCurrency,

                   ApplicationSettings.Terminal.TaxIncludedInPrice, BlankOperations.InternalApplication.Services.Rounding);

            BlankOperations.InternalApplication.BusinessLogic.TransactionSystem.LoadTransactionStatus(posTransaction);

 

 

            RetailTransaction retailTransaction = posTransaction as RetailTransaction;

 

            // Creating a new instance of an item

            SaleLineItem saleLineItem = new SaleLineItem(ApplicationSettings.Terminal.StoreCurrency,

                BlankOperations.InternalApplication.Services.Rounding, retailTransaction);

 

            // Creating a barcode info object with the item ID

            IBarcodeInfo barCodeInfo = BlankOperations.InternalApplication.BusinessLogic.Utility.CreateBarcodeInfo();

            barCodeInfo.BarcodeId = itemID;

 

            // Making a call to the Barcode service to handle the barcode if neccessary

            barCodeInfo = BlankOperations.InternalApplication.Services.Barcode.ProcessBarcode(saleLineItem, null, barCodeInfo, itemID);

 

            // Here the salelineitem object is being processed

            BlankOperations.InternalApplication.Services.Item.ProcessItem(saleLineItem);

 

            // If the item is not found some action can be taken

            if (!saleLineItem.Found)

            {

                using (frmMessage dialog = new frmMessage(3157, false))

                {

                    POSFormsManager.ShowPOSForm(dialog);

                    return;

                }

            }

 

            // Specify the quantity

            saleLineItem.Quantity = quantity;

 

            // Add the item to the transaction

            retailTransaction.Add(saleLineItem, AggregateItemsModes.None);

 

            // Get the price, tax and discount info

            IItemSystem itemSystem = BlankOperations.InternalApplication.BusinessLogic.ItemSystem;

            itemSystem.CalculatePriceTaxDiscount(posTransaction);

 

            // Calculating all totals in the tranaction.

            retailTransaction.CalcTotals();

 

            // Show a message in the POS Message Panel

            POSFormsManager.ShowPOSStatusPanelText(ApplicationLocalizer.Language.Translate(3152, saleLineItem.Quantity, saleLineItem.SalesOrderUnitOfMeasure, saleLineItem.Description));

            BlankOperations.InternalApplication.Services.Peripherals.LineDisplay.DisplayItem(saleLineItem);

          }

 

 

 

Thank you

Back to Top
Sponsored Links


Back to Top
raghu_mallya View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: March 09 2012
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote raghu_mallya Quote  Post ReplyReply Direct Link To This Post Posted: March 09 2012 at 12:37pm
Hi
 
Which version of POS are you using?
 

With AX2012, you can use Application.RunOperation() to invoke the ItemSale operation.

e.g.

Application.RunOperation(PosisOperations.ItemSale, “0113”, posTransaction);

 

 

Back to Top
honof11 View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: March 05 2012
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote honof11 Quote  Post ReplyReply Direct Link To This Post Posted: March 12 2012 at 5:18am

Thank you for your help.

I am very inexpert…

I have download the “Retail POS Plug-ins” and I have see the class Microsoft.Dynamics.Retail.Pos.BlankOperations.SupportClasses.ItemSale.SellItem:

to add an item to the Cart it checks the postransaction object and if it’s not and RetailTransaction  it re-assigning it to a new variable.

 

In any case I have tested yours code, and now works but only  if my cart is not empty.

if my cart is empty I have this error "this operation is not valid for this type of transaction"

 

 

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Grandfather")]

public void BlankOperation(IBlankOperationInfo operationInfo, IPosTransaction posTransaction)

{

      LSRetailPosis.POSProcesses.ItemSale itemSale = new LSRetailPosis.POSProcesses.ItemSale();

      itemSale.OperationID = PosisOperations.ItemSale;

      itemSale.OperationInfo = new LSRetailPosis.POSProcesses.OperationInfo();

      itemSale.Barcode = "0099";

      itemSale.POSTransaction = (PosTransaction)posTransaction;

      itemSale.RunOperation();           

}

Back to Top
raghu_mallya View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: March 09 2012
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote raghu_mallya Quote  Post ReplyReply Direct Link To This Post Posted: March 20 2012 at 2:42pm
You can try code if the cart is not empty
 
Application.RunOperation(PosisOperations.ItemSale,“0113”)
 
this should also work in your case
Back to Top
honof11 View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: March 05 2012
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote honof11 Quote  Post ReplyReply Direct Link To This Post Posted: March 23 2012 at 7:26am
Thank you. this code works if the cart is empty! thank you!!
Back to Top
alphaprolix View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: October 20 2012
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote alphaprolix Quote  Post ReplyReply Direct Link To This Post Posted: October 21 2012 at 5:02am
Hi,

I am new to AX 2012 POS customization, I am tying to figure out how can I use the object "posTransaction" in another form. I have a form added in my blank operations project, I dont know how to define posTransaction in my form constructor.

Also tell me how would I get detailed documentation about these objects like you mentioned

Application.RunOperation(PosisOperations.ItemSale,“0113”)

I want to learn about these properties so I can use these in my customizations.

Any Help would be greatly appreciated.

Thanks.
Back to Top
alleypick View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: May 17 2013
Location: NA
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote alleypick Quote  Post ReplyReply Direct Link To This Post Posted: May 17 2013 at 2:14am
Having some problems with coding and looks like this can be of great help. Will try to check this one out too. Thanks guys!
http://www.hlaustralia.com.au/solutions-pos - My restaurant point of sale solution is doing wonders, organizing everything.
Back to Top
rahulgdesai View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: July 19 2014
Location: India
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote rahulgdesai Quote  Post ReplyReply Direct Link To This Post Posted: July 19 2014 at 7:30am
Hi,
I need to post an item which have dimensions like Color,Style,Size from c# . and I dont have barcode assigned to it Nor I can use ItemId for the IBarcodeInfo.BarcodId, I have tried this but does not worked. So the current may not fit to my problem.
I have tried to create an object of SaleLineItem with dimensdetails as below

                        SaleLineItem item = new SaleLineItem();

                        item.ItemId = "0140"; //line.ItemId;

                        Dimensions dm = new Dimensions();

                        dm.VariantId = "VN-000234";

                        dm.ColorId = "Black";

                        dm.SizeId = "L";

                        dm.ColorName = "Black";

                        dm.SizeName = "Large";

                        dm.DistinctProductVariantId = 22565421355;

                        item.Dimension = dm;

                         item.Quantity = 4; //line.Quantity;

                        retailposTransaction.Add(item);

Thanks in advance

Back to Top
longwest View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: March 05 2015
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote longwest Quote  Post ReplyReply Direct Link To This Post Posted: March 08 2015 at 7:27pm
I cannot help you solve your problem, but thank you a lot for the C# code, I just need such a C# code for creating bar code info object with the item ID.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down


Copyright 2013 microsoftdynamicsforums.com. All rights reserved. MicrosoftDynamicsForums.com is an independent non-Microsoft website.
Email: contact AT microsoftdynamicsforums DOT com