My Products
Help
JarlK
PARTNER

Problem with price when sending order lines as input parameter

by JarlK

I have a problem that the priceInCurrency I send is overruled by the price defined on the product in VismaBusinessNxt when sending order lines as input variable. When sending order lines directly in the request with the same field ordering the priceInCurrency is set correctly. I have understood that the ordering of the fields are important and have tried different ordering of the orderline input without success.

 

I will appreciate if anyone have some suggestions. 

 

Example sending orderline as variable (priceInCurrency is overruled by product):

mutation create_orderlines($cid : Int!, $orderLinesInput: [OrderLine_Insert_Input!]!)
{
       useCompany(no : $cid)
      {
         orderLine_create(values: $orderLinesInput)
        {
             affectedRows
             items
            {

              orderNo
              lineNo
           }
      }
   }
}

Variables:

{
"cid": 111111,
"orderLinesInput": [{
"orderNo" : 2356,
"productNo" : "405",
"unit": 1,
"orgUnit1": 1,
"orgUnit2": 1,
"taxCode": 3,
"quantity" : 2.0,
"currencyNo": 47,
"priceInCurrency": 14.0,
"discountPercent1": 0.0,
"description": "Kvikklunsj, 22.04.2023 16:58 - 23.04.2023 12:00, Refnr.:"
}]
}

 

Same request without orderline as input variable (priceInCurrency is set correctly as specified in the request):

mutation create_orderlines($cid : Int!)
{
    useCompany(no : $cid) {
        orderLine_create(values:[{
            orderNo : 2356
            productNo : "405"
            unit: 1
           orgUnit1: 1
           orgUnit2: 1
           taxCode: 3
          quantity : 2.0
         currencyNo: 47
         priceInCurrency: 14.0
         discountPercent1: 0.0
        description: "Kvikklunsj, 22.04.2023 16:58 - 23.04.2023 12:00, Refnr.:"}])
       {
           affectedRows
           items
           { orderNo lineNo }
        }
   }
}
{
"cid": 111111
}

9 REPLIES 9
omelhus
PARTNER

by omelhus (Updated ‎27-04-2023 15:11 by omelhus PARTNER )

Please include the call you use to create the order head as well.

JarlK
PARTNER

by JarlK

Here is the mutation I use for creating the order. This is done in a separate request before creating the order lines:

 

 

mutation create_order($cid : Int!, $orderInput: [Order_Input!]!)
{
	useCompany(no : $cid)
	{
		order_create(values: $orderInput)
		{
			affectedRows
            items
			{
				orderNo
			}
		}
		
	}
}
{
	"cid":xxxxxxxxxx,
	"orderInput":[
	{	
		"customerNo":10290,
        "orderType":2,	
		"orderPreferences":0,
		"information5":"1",
		"information6":null,
		"transactionType":1,
		"ourReference":"test@griegconnect.com",
		"yourReference":"Ref tjeneste"
	}]
}

 



by Marius Bancila

Unfortunately, this is not working as you expect. The reason for that is the framework we are using (graphql-dotnet) parses the input into a dictionary, where there property is the key. However, the dictionary is sorting the keys lexicographically, so they appear in alphabetical order.

 

To change this, we need to make significant changes in the framework, which was not something we were willing to do.

 

The same problem we had when evaluating a request like this:

orderLine_create(values:[{
      orderNo : 855
      productNo : "405"
      unit: 1
      orgUnit1: 1
      orgUnit2: 1
      taxCode: 3
      quantity : 2.0
      currencyNo: 47
      priceInCurrency: 14.0
      discountPercent1: 0.0
      description: "Kvikklunsj, 22.04.2023 16:58 - 23.04.2023 12:00, Refnr.:"
    }]

The framework read all these object properties and put them in a dictionary. We fixed this by ditching the graphql-dotnet parsing and do it all explicit (which led to some bugs over time). 

 

Bottom line is, we will add this to the backlog and see what we can do to make it work.

 

There is a workaround in the meantime. Don't pass an object as variables, but individual properties:

query:

mutation create_order($cid : Int!,
                      $custno : Int,
                      $ordType : Int,
                      $ordPref : Int,
                      $info5 : String,
                      $info6 : String,
                      $ttype : Int,
                      $ourref : String,
                      $yourref : String)
{
  useCompany(no : $cid)
  {
    order_create(values: [{
      customerNo : $custno
      orderType : $ordType
      orderPreferences : $ordPref
      information5 : $info5
      information6 : $info6,
      transactionType : $ttype,
      ourReference : $ourref,
      yourReference : $yourref
    }])
    {
      affectedRows
      items
      {
        orderNo
      }
    }
  }
}

variables:

{
	"cid":xxxxxxxxxx,
	"custno":10290,
	"ordType":2,
	"ordPref":0,
	"info5":"1",
	"info6":null,
	"ttype":1,
	"ourref":"test@griegconnect.com",
	"yourref":"Ref tjeneste"
}

 This should work as expected.

omelhus
PARTNER

by omelhus

So you are saying that the functionality with suggesting values for entities using null is moot when you are using variables?

 

When I create or update entities I almost exclusively use variables for inputs. Using parameters for all just doesn't make any sense.

 

Please disable the suggest-functionality for entities in a variable, that is not enabled by suggest: { field: true }.

by Marius Bancila

I was told that you should set price as last, since price can be affected by many other fields.

 

I have tried reproducing your problem, but without success. It's probably because my test data is not reproducing what you have there.

I set the priceQuantity to 42 and priceUnit to 1 on the product with number "405" and then executed the query that you pasted. This is what I get:

{
  "data": {
    "useCompany": {
      "orderLine_create": {
        "affectedRows": 1,
        "items": [
          {
            "orderNo": 855,
            "lineNo": 1,
            "priceDomestic": 14,
            "priceInCurrency": 14
          }
        ]
      }
    }
  }
}

If you describe more precisely what values you have set on what records, then I can try it again.

JarlK
PARTNER

by JarlK

Have you tried including some of the orgUnit fields? My request includes orgUnit1 and orgUnit2. When I exclude these fields the price is set correctly, but when included  the price is set from product no matter where I place the PriceInCurrency.

JarlK_0-1682600713700.png

 

petwob
PARTNER

by petwob

Hi,

I'm experiencing the exact same issue. To me it seemed that the api doesn't respect the order of the fields when being send in as an [OrderLine_Insert_Input!]! object in variables. But also in my case, when orgUnit2 is removed from the object, priceInCurrency is set from the object.

Works as expected when setting orderline directly as value and not as object.

petwob
PARTNER

by petwob

@Marius Bancila 

is this is a bug?

can you try the variables example from @JarlK 

by Marius Bancila (Updated ‎27-04-2023 20:55 by Marius Bancila VISMA )

@JarlK I have executed the exact query you shown (except for the orderNo which was different).

 

For the order:

mutation create_order($cid : Int!)
{
  useCompany(no : $cid)
  {
    order_create(values: [{
      customerNo : 12332
      orderType:2
      orderPreferences:0
      information5:"1"
      transactionType:1
    }])
    {
      affectedRows
      items
      {
        orderNo
      }
    }
  }
}

For the order lines:

mutation create_orderlines($cid : Int!)
{
   useCompany(no : $cid) {
   orderLine_create(values:[{
      orderNo : 855
      productNo : "405"
      unit: 1
      orgUnit1: 1
      orgUnit2: 1
      taxCode: 3
      quantity : 2.0
      currencyNo: 47
      priceInCurrency: 14.0
      discountPercent1: 0.0
      description: "Kvikklunsj, 22.04.2023 16:58 - 23.04.2023 12:00, Refnr.:"
    }])
    {
      affectedRows
      items
      {
         orderNo
         lineNo
         priceDomestic
         priceInCurrency
      }
    }
  }
}

 

Don't pass in null values explicitly. There is no need for that. If you want a field to have a default value (null, zero, etc.), don't specify it at all.

 

With the new suggest value feature we released today, to allow you to specify the fields in the right order in a create operation, null means "suggest". So if you say 

"information6":null

that this will tell the system to "suggest value for field information6".

 

You can read all about that here: https://docs.business.visma.net/docs/schema/mutations/inserts#suggested-values.