My Products
Help
KonsultVn
CHAMPION ***

Cannot use discount on POST /controller/api/v2/customerinvoice after update

by KonsultVn

Hi, 

 

After the update that was on tuesday we are experiencing problem with POST /controller/api/v2/customerinvoice. When sending in our invoice with a discount percentage the percentage is added on the invoiceLine in the UI but the discount is not calculated (nothing happens with the sum). In other cases we cannot ad a discount percentage unless we also have this value in the JSON:

 

"manualDiscount": {
"value": 0

 

We have had no problem with this field before and invoices went through as they should have before the 13th. 

 

With this call I do not get the discountPercentage to land in the UI:

 

{

"documentDueDate": {
"value": "2021-07-15T14:33:07.062Z"
},

"invoiceLines": [
{

"operation": "Insert",
"inventoryNumber": {
"value": "A"
},
"lineNumber": {
"value": 0
},

"quantity": {
"value": 1
},
"unitPriceInCurrency": {
"value": 100
},

"discountPercent": {
"value": 10
},
"discountAmountInCurrency": {
"value": 15
}

}
],
"customerNumber": {
"value": "10001"
},
"documentDate": {
"value": "2021-07-15T14:33:07.062Z"
},


"invoiceText": {
"value": "test rabatt"
}

}

 

But if I add "manual discount" it works, this gives me a discount in the UI:

{

"documentDueDate": {
"value": "2021-07-15T14:33:07.062Z"
},

"invoiceLines": [
{

"operation": "Insert",
"inventoryNumber": {
"value": "A"
},
"lineNumber": {
"value": 0
},

"quantity": {
"value": 1
},
"unitPriceInCurrency": {
"value": 100
},

"discountPercent": {
"value": 10
},
"discountAmountInCurrency": {
"value": 15
},
"manualDiscount": {
"value": 0
}

}
],


"customerNumber": {
"value": "10001"
},
"documentDate": {
"value": "2021-07-15T14:33:07.062Z"
},
"invoiceText": {
"value": "test rabatt"
}

}

 

I can see no problem in the UI when I do this manually, it's just when I do it through the API that the discountPercentage does not work as it has done before. 

 

This is quite urgent because we have multiple customers that uses this invoice and everyday there are thousands of invoices that are created wrong and we need to know if this is a bugg or something that has changed?

 

/Frida

 

9 REPLIES 9

by Magnus Johnsen

Hi,

This issue was resolved in v8.63:
[Release Notes] - Visma.Net API 8.63.0 - 31.08.2021

 

We recommend that you follow the news page for changes /fixes to the API.

 

Thank you. 

by Magnus Johnsen

There seems to be a general issue with the v2 endpoints at the moment that we are currently looking into.

As soon as this is resolved we will test your scenario. 

 

Is there a reason for sending both discountAmount & discountPercentage?

When setting the manualDiscount to 0, the intended behaviour is to not use the fields for discount on the lines that you manually enter, only the discounts set in the Discounts screen(ScreenId=AR2095PL), I.e the automatic discounts.

 

What behaviour are you expecting when sending these values?

We have tested this in our local company and found the following:
Sending discountPercentage without setting manualDiscount to 1 or true results in it being omitted, skipping this line will also not include the discount.

discountAmount seems to be omitted with or without setting the manualDiscount field. 

 

Could you please confirm this is what you are seeing on your end as well?

We are reporting this to the development team. 

Anonymous
Not applicable

by Anonymous

(Don't know what happens sometimes when I make posts, the user konsultVn is me anyway) 

 

I forgot to remove the discountAmt, did some testing to se if that triggered it in some way. This field I cannot get to work at all but in this case we don't use this field. DiscountPercentage is more important for us in this case. 

 

If I send only discountPercentage I can see the discount percentage in the UI on the line but the total amount takes no consideration to whatever discount percentage I have sent in. 

 

If I sen discountPercentage + manualDiscount=1 I can see the percentage in the UI and the line total takes that percentage in consideration and reduces the amount automatically on the line. 

 

Before this problem we sent in our POSTS without the manualDiscount and only a discountPercentage and when we did that the percentage was put on the line and the total for the line amount was automatically reduced with the percentage. 

by Magnus Johnsen

Hi,

Ok, we have reported this to the development team, both that the discountAmount is omitted in any scenario, and that you know have to set the manualDiscount. We'll let you know as soon as we get a reply if this is intentional or if it will be treated as a bug.

For now, the workaround is to set manualDiscount to 1 or true if a discountPercentage is included in the JSON.

Anonymous
Not applicable

by Anonymous

Hi,

 

Any updates on this one?

 

Found out today that a customer is missing the discount on more than 500 invoices and it increases every day...

We are using the field discountAmountInCurrency and manualDiscount is always set to true.

by Magnus Johnsen

Hi,

The case is currently in the backlog with a high priority.

For now, the workaround is the same, including the "manualDiscount" field and setting the value to "1" or "true" should allow you to send the discount.

Anonymous
Not applicable

by Anonymous

Yes, setting manualDiscount to 1/true helps if you use the discountPercent field, but I use the discountAmountInCurrency field and according to my tests it doesn't help to set manualDiscount = 1/true in that case. 

 

This fails:

{
	"customerNumber": {
		"value": "10000"
	},
	"invoiceLines": [
		{
			"operation": "Insert",
			"quantity": {
				"value": 1
			},
			"unitPriceInCurrency": {
				"value": 1000
			},
			"inventoryNumber": {
				"value": "1"
			},
			"discountAmountInCurrency": {
				"value": 200
			},
			"manualDiscount": {
				"value": true
			}
		}
	]
}

This works:

{
	"customerNumber": {
		"value": "10000"
	},
	"invoiceLines": [
		{
			"operation": "Insert",
			"quantity": {
				"value": 1
			},
			"unitPriceInCurrency": {
				"value": 1000
			},
			"inventoryNumber": {
				"value": "1"
			},
			"discountPercent": {
				"value": 30
			},
			"manualDiscount": {
				"value": true
			}
		}
	]
}

 

As far as I can see the only workaround in my case is to switch from using discountAmountInCurrency to discountPercent.

 

Yıldırım
VISMA

by Yıldırım

Hello, 


we're currently looking into this. We'll get back to you as soon as possible.