Skip to Content
Former Member
May 23, 2014 at 12:05 PM

Add Discount % In AR Invoice


How can i add Discount% in AR Invoice Document.I had set the discount % in Document. But after Adding The discounted amount not correctly updated in The Invoice.How can i set.My code as follows.

Dim RetCode As Integer Dim OInvoice As SAPbobsCOM.Documents Dim TPrice As Double = 0 Dim Disc As Double OInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices) For Each row As DataGridViewRow In dgvitem.Rows TPrice = TPrice + ((CType(row.Cells("Price").Value, Double) * CType(row.Cells("Quantity").Value, Double))) Next Disc = (TPrice * CType(txtper.Text, Double) / 100) With OInvoice .Series = My.Settings.Series .CardCode = txtcustcode.Text .DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items .DiscountPercent = CType(txtper.Text, Double) .UserFields.Fields.Item("U_Mode").Value = "CA" With .Lines For Each row As DataGridViewRow In dgvitem.Rows .ItemCode = row.Cells("PartNo").Value .Quantity = CType(row.Cells("Quantity").Value, Double) .WarehouseCode = My.Settings.MWhscode .Add() Next End With .DocTotal = TPrice - Disc RetCode = .Add() If RetCode <> 0 Then MsgBox(oCompany.GetLastErrorDescription) Return Nothing Else

Return oCompany.GetNewObjectKey() End If

End With

How can fix the error, Please help