Follow

API code example: AddNewItem

When integrating to Visma Severa, adding items is one of the most common needs for the integration. This is because items in Visma Severa can be costs, or something that is invoiced from the customer. Below there are different examples of inserting items using AddNewItem method in the Item interface.

Important

  • Case is required when inserting an item. Items always relate to a case.
  • If inserted item has product selected, price and cost of the item can come from the product.
  • If there isn't a product selected for the item which is inserted, UnitPrice and UnitCost of the item are mandatory.
  • UnitPrice needs to be given in case currency.
  • UnitCost needs to be given in base currency of the organization.

Non-billable item (cost)

To be able to insert an non-billable item, item should have:

  • UnitPrice = 0.
  • UnitPriceInBaseCurrency = 0
  • UnitCost = Cost in base currency.

Billable item

To be able to insert an billable item, the item should have:

  • UnitPrice > 0, in case currency.
  • UnitCost = Cost in base currency.

Special scenarios

  1. If UnitPrice of item is 0, and UnitPriceInBaseCurrency > 0, UnitPriceInBaseCurrency will be 0 after item is inserted to Visma Severa. UnitPriceInBaseCurrency is calculated always from UnitPrice. This is because they need to match when compared with currency rate, otherwise reporting would not show correct values.
  2. It is possible to give a currency parameter to AddNewItem method. This parameter affects the UnitPriceInBaseCurrency, so that calculation of UnitPriceInBaseCurrency = UnitPrice / [currency rate of the given currency]. Notice that unit price will be what was given, the unit price is not converted when currency parameter is used.

Example 1

In the image below items have been inserted to Visma Severa. Items are inserted to organization with base currency EUR, and to a case with currency SEK. Items are inserted with the following information:

  1. Quantity 1, Unit price 0, Unit price in base currency 0.
  2. Quantity 1, Unit price 1000. Case has SEK currency, and Visma Severa has converted value to Unit price in base currency field.
  3. Quantity 1, Unit price 0, Unit price in base currency 100. Unit price in base currency = 0, because it is calculated from Unit price.
  4. Quantity 1, Unit price 150. Currency parameter to AddNewItem method "USD". Currency rate for USD is saved to Visma Severa's settings. Notice that Unit price in base currency has been converted so that 150 USD is converted to euros. Unit price is still 150 SEK, so there is no currency conversion from USD to SEK.

addnewitem_item_report.png

Example 2

Dim itemclient = New SeveraAPI.ItemClient("Severa.API.IItem")
Try

Using ocScope As ServiceModel.OperationContextScope = New ServiceModel.OperationContextScope(itemclient.InnerChannel)
Dim mhMessageHeaders2 As ServiceModel.Channels.MessageHeaders = ServiceModel.OperationContext.Current.OutgoingMessageHeaders
mhMessageHeaders2.Add(ServiceModel.Channels.MessageHeader.CreateHeader("WebServicePassword", itemclient.Endpoint.Contract.Namespace, apiKey))

Dim inserteditem = New SeveraAPI.Item
Dim item1 As New SeveraAPI.Item

item1.Name = "product test1234"
item1.Description = "this is a test description1"
item1.Quantity = 1
item1.UnitCost = 122
item1.UnitPrice = 300
item1.CaseNumber = 2211
item1.ProductCode = "123"

Try
inserteditem = itemclient.AddNewItem(item1, "Eur") 'SEK
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Using

Catch ex As Exception
MsgBox(ex.Message)
End Try

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Powered by Zendesk