My Products
Help

Not able to update inventory item in PO

by Eirik Morken - Proplan AS

Greetings 😁

We are trying to use the /controller/api/v1/purchaseorder/{purchaseOrderNumber} endpoint to update a line on a Purchase Order. 

We try to use this simple example:

{

    "description": {

        "value": "1 HRS a 890,00"

    },

    "lines": [

        {"project": {

                "value": "X"

            },

            "operation": "Update",

            "lineNumber": {

                "value": 1

            },

            "inventory": {

                "value": "99"

            }}

    ]

}

And we get the error message :

{
  "message": "Error: Updating  'Purchase order line' record raised at least one error. Please review the errors.\r\nError: 'Project' cannot be empty.\r\n"
}

This is kind of understandable as when you change the InventoryItem in the GUI the project is removed and set to null. 

The problem is however that I can't find any way to change the inventory item.  You cant do it in two seperate PUTs (inventory item first and then project) as the first will fail, and if you try to do both in the same PUT like this: 

{

    "description": {

        "value": "1 HRS a 890,00"

    },

    "lines": [

        {

            "operation": "Update",

            "lineNumber": {

                "value": 1

            },

            "inventory": {

                "value": "99"

            },

            "lineDescription": {

                "value": "LN502685/03 - Man hours 50% overtimee"

            },

            "orderQty": {

                "value": 1.0

            },

            "unitCost": {

                "value": 890.0

            }

        },

        {

            "project": {

                "value": "X"

            },

            "operation": "Update",

            "lineNumber": {

                "value": 1

            }

        }

    ]

}

Then the line with the inventory will be ignored.

 

How do you suggest we can solve this? Is the Update operation not able to be used with inventory and we have to insert and delete instead?

4 REPLIES 4
Yıldırım
VISMA

by Yıldırım (Updated ‎11-10-2021 15:30 by Yıldırım VISMA )

Hello again, 

 

We're able to Update the Inventory of the specified Purchase Order Line without the need to set Default Non-Project code "X" in the PUT request, as long as we provide "Order Qty" and "Unit Cost" (If the selected inventory doesn't have the default price).


The default Project should be automatically fetched from ScreenId=PM101000 if it's not overridden. 

project.png

 

Could you retry the request with the following payload and see the result ? 

 

1) PUT >  https://integration.visma.net/API/controller/api/v1/purchaseorder/xxxxx

 

 

{
    "lines": [
        {
            "operation": "Update",
            "lineNumber": {
                "value": 1
            },
            "lineDescription": {
                "value": "Inventory PUT test line 1"
            },
            "inventory": {
                "value": "1"
            },
            "orderQty": {
                "value": 2
            },
            "unitCost": {
                "value": 890.0
            }
        }
    ]
}

 

 

 p1.png

 

Otherwise, as you also mentioned, the best approach would be deleting the Line and Inserting again with the desired information.

I get the same error message. It could be a client issue if you get a standard project X when choosing a new item in the GUI. I do however have the same standard project in the Project accounting preferences. 

EirikMorken_0-1633959062365.png

EirikMorken_1-1633959166397.png

 

 

Accepted solution
Yıldırım
VISMA

by Yıldırım (Updated ‎11-10-2021 18:01 by Yıldırım VISMA )

You've mentioned that,


@Eirik Morken - Proplan AS wrote:

This is kind of understandable as when you change the InventoryItem in the GUI the project is removed and set to null.

It appears being related to these following settings in the company where your integration working at, 

If a supplier or inventory item used in the Purchase Order line and its "Expense Account" connected to a "Project Account Group" then the Non-Project "Project X" will not be automatically fetched, and we have to manually enter a "project" value.

This is OK when working in the Financials UI, but when using the API, especially with PUT > Line > Inventory, we are unable to set this value on the fly.

 

Therefore, you should check the following settings in the UI respectively, 

 

  1. Go to the ScreenId=IN202000 (Non-Stock Item) and open "Inventory: 99"
    (Assuming that this is a Non-Stock Item, "Man hours 50% overtimee")
  2. Go to the General Ledger Accounts tab and check its Expense Account/s fields.
    (Taxable "4700" , "4710" is Non-taxable depending on the Company/Country Chart of accounts template etc)
  3. inventory_expense.png
  4. Find the "Expense Accounts" (Taxable, non-taxable etc. depends on the process details)
  5. Then go to the "Account Groups" page (ScreenId=PM2010PL)
  6. accountgroup.png
  7. It'll look like the image above if there aren't custom groups have been created.
  8. Check "Expense" type groups by clicking on the GroupID in the list.
  9. Search for the Group that contains those Expense Accounts registered under.
  10. account_group.png
  11. account_group2.png
  12. You'll either need to change the "expense account/s" of the Inventory which is associated with any Expense Type Account Group or remove those "Expense Accounts" from the Account Groups. 

Once Inventory > Expense Accounts are not connected to any Account Groups, then the "Project" field will automatically be populated with Non-Project value as "X"

 

Otherwise, as we talked, one can delete the Line and Insert a new line again with the desired information

 

I hope this helps to clarify the situation.

Yıldırım
VISMA

by Yıldırım

Hello Eirik, we will look into this and get back to you soon.