Skip to Content
0
Feb 01, 2016 at 06:13 PM

invoice + Multiple Incoming Payment

268 Views

Hi Experts ,

i have the code below that only works for the First Payment method CASH and doesn't (LOOP) work for the Rest . It obtains the Doc entry of an invoice already posted in SAP business one attempts to apply Separated Incoming payments Documents to the Invoice tagged to a Customer . But it only applies the First amount what am i doing wrong

For Each row As DataGridViewRow In DgrApMultiplepayment.Rows

If Not row.IsNewRow Then

PAYMENTTYPE = row.Cells.Item("PAYMENTTYPE").Value.ToString()

ACCOUNT = row.Cells.Item("ACCOUNT").Value.ToString()

AMOUNT = row.Cells.Item("AMOUNT").Value.ToString()

TRSFRDATE = row.Cells.Item("TRSFRDATE").Value.ToString()

TRSFRREF = row.Cells.Item("REFERENCE").Value.ToString()

CREDITCARD = row.Cells.Item("CREDITCARDNAME").Value.ToString()

CREDITCARDNUMBER = row.Cells.Item("CREDITCARDNUMBER").Value.ToString()

CARDVALIDUNTIL = row.Cells.Item("CARDVALIDUNTIL").Value.ToString()

Dim oPmt As SAPbobsCOM.Payments = Nothing

'

Dim InvoiceObject As Recordset = DirectCast(vCompany.GetBusinessObject(BoObjectTypes.BoRecordset), Recordset)

InvoiceObject.DoQuery("SELECT TOP 1 DocEntry FROM OINV WHERE Comments = '" & Trim(UNIQUEID) & "' ORDER BY DocEntry DESC ")

sNum = InvoiceObject.Fields.Item(0).Value.ToString()

oPmt = vCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)

Select Case PAYMENTTYPE

Case "CASH"

oPmt.Invoices.DocEntry = sNum

oPmt.CardCode = oDoc.CardCode

oPmt.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer

oPmt.TaxDate = TRSFRDATE

oPmt.CashAccount = ACCOUNT

oPmt.CashSum = AMOUNT

oPmt.ApplyVAT = SAPbobsCOM.BoYesNoEnum.tNO

oPmt.Add()

Case "CRDCARD"

oPmt.Invoices.DocEntry = sNum

oPmt.CardCode = oDoc.CardCode

oPmt.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer

oPmt.CreditCards.CardValidUntil = Month(Now) & "/" & Year(Now)

oPmt.CreditCards.CreditAcct = ACCOUNT

oPmt.CreditCards.CreditCard = 1

oPmt.CreditCards.VoucherNum = VOUCHERNUMBER

oPmt.CreditCards.CreditSum = AMOUNT

oPmt.CreditCards.FirstPaymentDue = Date.Now

oPmt.CreditCards.NumOfPayments = 1

oPmt.Add()

Case "CHEQUE"

oPmt.Invoices.DocEntry = sNum

oPmt.CardCode = oDoc.CardCode

oPmt.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer

oPmt.Checks.CheckAccount = ACCOUNT

oPmt.Checks.DueDate = TRSFRDATE

oPmt.Checks.CheckNumber = TRSFRREF

oPmt.Checks.BankCode = "36"

oPmt.Checks.CheckSum = AMOUNT

oPmt.ApplyVAT = BoYesNoEnum.tNO

oPmt.Add()

END SELECT

NEXT