cancel
Showing results for 
Search instead for 
Did you mean: 

DI API: Wrong PriceAfterVAT value in credit note based on A/R invoice

Former Member
0 Kudos
591

Hi all,

I have serious problem with creating Credit Note based on existing A/R Invoice in Sales module.

I use SBO 2004A patch level 32. With SDK I've created A/R Invoice with 2 items. First item has discount percent 0% and price after VAT 1. Second item has 100% discount, this means, doctotal is 1. Document VAT is 7,6% and VAT is calculated correctly in invoice. Then I've created credit note only with 1 item and this row is bounded with 1 row in invoice. After calling oCreditNote.Add, in Business One this credit note has all prices (price, price after VAT, row total) with the same value -> there is no vat calculated although in invoice the vat calculated is.

Is it bug in DI API or do I something wrong?

I use the standard ways to create new invoice and credit note through DI API.

Many thanks for your answers.

Best regards

Libor.

Accepted Solutions (1)

Accepted Solutions (1)

barend_morkel2
Active Contributor
0 Kudos

Hi Libor,

To create a Credit note for a Invoice you should use the Invoice as the base document for the Credit note. Here is an example of how I create a GRPO from a draft GRPO. Try this (for your Invoice - Credit Note) and see if it does not work for you (SAP suggests this way of doing it).

(Draft will be your invoice - GRPO will be your credit note)

Dim oDraft As SAPbobsCOM.Documents

Dim oGRPO As SAPbobsCOM.Documents

If oDraft.GetByKey(YourInvoiceNumber) Then

'Build the GRPO (new GRPO Obj for each GRPO Doc)

oGRPO = oComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes)

oGRPO.DocDate = oDraft.DocDate

oGRPO.DocDueDate = oDraft.DocDueDate

oGRPO.DiscountPercent = oDraft.DiscountPercent

oGRPO.CardCode = oDraft.CardCode

For i = 0 To oDraft.Lines.Count - 1

oDraft.Lines.SetCurrentLine(i)

oGRPO.Lines.BaseType = oDraft.Lines.BaseType

oGRPO.Lines.BaseEntry = oDraft.Lines.BaseEntry

oGRPO.Lines.BaseLine = oDraft.Lines.BaseLine

If i < oDraft.Lines.Count - 1 Then

oGRPO.Lines.Add()

End If

Next i

'Add the GRPO

iRetCode = oGRPO.Add

If iRetCode <> 0 Then

oComp.GetLastError(iRetCode, sErrMsg)

Log.WriteLog("Error Adding GRPO : " & sErrMsg, EventLogEntryType.Warning)

Return False

End If

End If

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Barend,

thanks for your answer. I found the solution, but I don't know, if it is bug in SDK, but immediately, when I filled some user-fields in credit note or other fields with some values (or the same as invoice) and then I bound row in credit note with row in invoice, then the credit note doesn't calculate VAT, although there is VAT group f.e. A1 and VAT percentage 7,6% in row.

When I filled this credit note only with CardCode and bound the rows, then the VAT is calculated (or copied from invoice) correctly.

Best regards

Libor.

Former Member
0 Kudos

Hi Libor!

I have the same problem with A/P Invoice ... How did you solve your problem?

thanks a lot,

francesca