0
votes

I was trying to place sales order through Web API and wanted to uncheck the "Manual Discount" checkbox so I tried to use following code:

        SO301000Content SO301000 = context.SO301000GetSchema();
        context.SO301000Clear();

        List<Command> cmds = new List<Command>();

        cmds.Add(new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType });
        cmds.Add(new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr });
        cmds.Add(new Value { Value = orderInfo.OrderCustomerInfo.AcctCD, LinkedCommand = SO301000.OrderSummary.Customer });
        cmds.Add(new Value { Value = orderInfo.OrderLocationInfo.ID, LinkedCommand = SO301000.OrderSummary.Location });

        cmds.Add(new Value { Value = orderInfo.ShippingTotal.ToString(), LinkedCommand = SO301000.Totals.PremiumFreight });

        cmds.Add(new Value { Value = "30D", LinkedCommand = SO301000.FinancialSettingsFinancialInformation.Terms});
        cmds.Add(new Value { Value = orderInfo.PromoCode, LinkedCommand = SO301000.DocumentDetails.DiscountCode });


        //add line items
        foreach (OrderItem item in orderInfo.OrderItems)
        {
            cmds.Add(SO301000.DocumentDetails.ServiceCommands.NewRow);
            cmds.Add(new Value { Value = item.InventoryCD, LinkedCommand = SO301000.DocumentDetails.InventoryID });
            cmds.Add(new Value { Value = item.Quantity.ToString(), LinkedCommand = SO301000.DocumentDetails.Quantity });
            cmds.Add(new Value { Value = "Server", LinkedCommand = SO301000.DocumentDetails.Warehouse });
            cmds.Add(new Value { Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount});
            cmds.Add(new Value { Value = "Discount1", LinkedCommand = SO301000.DocumentDetails.DiscountCode});
            cmds.Add(new Value { Value = "20", LinkedCommand = SO301000.DocumentDetails.DiscountPercent });                
        }

        cmds.Add(SO301000.Actions.Save);
        cmds.Add(SO301000.OrderSummary.OrderNbr);
        cmds.Add(SO301000.OrderSummary.OrderTotal);
        cmds.Add(SO301000.OrderSummary.TaxTotal);
        cmds.Add(SO301000.OrderSummary.Location);
        cmds.Add(SO301000.OrderSummary.Customer);

        SO301000Content[] SO30100content = context.SO301000Submit(cmds.ToArray());
        .......................

however, after the sales order is placed, I found the "Manual Discount" checkbox was still checked and discount I have set to automatically be applied was not applied at all.

I found an old thread about this issue at http://forum.acumatica.com/forum/acumatica-reseller-and-isv-community/development-and-customization/895-order-creation-through-soap-call-with-manual-discosunt-false-not-working, in which a guy said this was a bug, however, that was about 3 years ago. so I assume this bug should have been fixed already...if it is not bug any more, can somebody tell me what I did wrong?

Thanks.

Just did more testing following the suggestion from @Gabriel but the "Manual Discount" was still checked after the order is placed through web service, however, when I tried to place a new order through screen and add same item, the "Manual Discount" was not checked by default. I don't know what was wrong in my code.

Here is the code I just tried and no luck to get discount automatically applied:

        SO301000Content SO301000 = context.SO301000GetSchema();
        context.SO301000Clear();

        List<Command> cmds = new List<Command>();

        cmds.Add(new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType });
        cmds.Add(new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr });
        cmds.Add(new Value { Value = orderInfo.OrderCustomerInfo.AcctCD, LinkedCommand = SO301000.OrderSummary.Customer });
        cmds.Add(new Value { Value = orderInfo.OrderLocationInfo.ID, LinkedCommand = SO301000.OrderSummary.Location });

        cmds.Add(new Value { Value = orderInfo.ShippingTotal.ToString(), LinkedCommand = SO301000.Totals.PremiumFreight });

        cmds.Add(new Value { Value = "30D", LinkedCommand = SO301000.FinancialSettingsFinancialInformation.Terms});
        //cmds.Add(new Value { Value = orderInfo.PromoCode, LinkedCommand = SO301000.DocumentDetails.DiscountCode });


        //add line items
        foreach (OrderItem item in orderInfo.OrderItems)
        {
            cmds.Add(SO301000.DocumentDetails.ServiceCommands.NewRow);
            cmds.Add(new Value { Value = item.InventoryCD, LinkedCommand = SO301000.DocumentDetails.InventoryID });
            cmds.Add(new Value { Value = item.Quantity.ToString(), LinkedCommand = SO301000.DocumentDetails.Quantity });
            //cmds.Add(new Value { Value = "Server", LinkedCommand = SO301000.DocumentDetails.Warehouse });
            //cmds.Add(new Value { Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount});
            //cmds.Add(new Value { Value = "VOLWHMIS", LinkedCommand = SO301000.DocumentDetails.DiscountCode});
            //cmds.Add(new Value { Value = "100", LinkedCommand = SO301000.DocumentDetails.DiscountPercent });                
        }

        cmds.Add(SO301000.Actions.Save);
        cmds.Add(SO301000.OrderSummary.OrderNbr);
        cmds.Add(SO301000.OrderSummary.OrderTotal);
        cmds.Add(SO301000.OrderSummary.TaxTotal);
        cmds.Add(SO301000.OrderSummary.Location);
        cmds.Add(SO301000.OrderSummary.Customer);

        SO301000Content[] SO30100content = context.SO301000Submit(cmds.ToArray());
3
Could you provide the rest of the code for the line items? Manual discount may be set to true by system based on other fields you set there. Just setting quantity and inventory CD shouldn't make it TRUE however, and you would have no need to set it to False anywhere. Have you tried commenting the rest of the code?Gabriel
@Gabriel, I have added those lines to my code. Please note the discount works when I explicitly passed "Discount Code" or "Discount Percentage" as shown in my code, however, that doesn't change the fact that "Manual Discount" checkbox is still checked after the sales order is completed. My goal is to automatically get discount code applied without explicitly passing either code or percentage through API, since that discount code was set to automatically apply to a certain group of products and I thought if I could somehow set "Manual Discount" to false I should get it work as I expect.Gladiator
Setting the discount percentage or the discount code on the screen will automatically check Manual Discount. Are you doing that because the discount don't get automatically set? Are they set automatically if you add a similar order from the screen?Gabriel
Yes, I explicitly added "discount code" and "discount percentage" in my code after I couldn't get discount automatically applied I guess because the "ManualDiscount" by default is on, although I explicitly set it to "False". The discount has been set up in Acumatica to automatically be applied when a certain product item is in the order. On the screen, I could manually check/uncheck the "Manual Discount" checkbox and when I unchecked the checkbox, the discount was automatically applied.Gladiator
There's nothing in the code which should make ManualDiscount on by default - if you just set InventoryID and quantity, does system set it on???Gabriel

3 Answers

0
votes

This is a bug in the product. It was initially meant as a solution to avoid recalculation of discounts when you use the copy/paste feature, but it also affected the use of web services with this screen. There's simply no way to force it to FALSE - system will also put TRUE in the field.

We have already fixed the problem internally, and the fix will be available in builds starting from 5.20.1071.

0
votes
            SO301000Content SO301000 = context.SO301000GetSchema();
        context.SO301000Clear();            

        try
        {
            SO301000Content[] SO301000Content = context.SO301000Submit(
                new Command[]
                {
                    SO301000.Actions.Insert,
                    new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },                        
                    new Value { Value = "='new'", LinkedCommand = SO301000.OrderSummary.OrderNbr },
                    new Value { Value = "ABARTENDE", LinkedCommand = SO301000.OrderSummary.Customer },                    
                    //new Value { Value = DateTime.UtcNow.ToShortDateString(), LinkedCommand = SO301000.OrderSummary.Date },
                    new Value { Value = "this is a test order", LinkedCommand = SO301000.OrderSummary.Description },

                    SO301000.DocumentDetails.ServiceCommands.NewRow,
                    new Value {Value = "CPU00001", LinkedCommand = SO301000.DocumentDetails.InventoryID},
                    new Value {Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse},
                    new Value {Value = "BOX", LinkedCommand = SO301000.DocumentDetails.UOM},
                    new Value {Value = "1", LinkedCommand = SO301000.DocumentDetails.Quantity},                        
                    new Value {Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount },
                    new Value {Value = "1.01", LinkedCommand = SO301000.DocumentDetails.UnitPrice, Commit = true },

                    SO301000.DocumentDetails.ServiceCommands.NewRow,
                    new Value {Value = "CPU00004", LinkedCommand = SO301000.DocumentDetails.InventoryID},
                    new Value {Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse},
                    new Value {Value = "BOX", LinkedCommand = SO301000.DocumentDetails.UOM},
                    new Value {Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity},
                    new Value {Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount},
                    new Value {Value = "2.02", LinkedCommand = SO301000.DocumentDetails.UnitPrice, Commit = true},

                    SO301000.DocumentDetails.ServiceCommands.NewRow,
                    new Value {Value = "CPU00008", LinkedCommand = SO301000.DocumentDetails.InventoryID},
                    new Value {Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse},
                    new Value {Value = "PC", LinkedCommand = SO301000.DocumentDetails.UOM},
                    new Value {Value = "3", LinkedCommand = SO301000.DocumentDetails.Quantity},                   
                    new Value {Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount},
                    new Value {Value = "3.03", LinkedCommand = SO301000.DocumentDetails.UnitPrice, Commit = true},                        

                    SO301000.Actions.Save,                  
                    SO301000.OrderSummary.OrderNbr                                  
                }
            );
            Console.WriteLine(SO301000Content[0].OrderSummary.OrderNbr.Value);
        }
        catch (Exception ex)
        {

        }
0
votes

I clarified regarding this checkbox.

well, when you use API or Copy-Paste methods this checkbox will always has value - true, it's by design.

I suggest to use second call to remove this values and/or set proper discount code.