Skip to Content
0
Jun 30, 2009 at 04:26 AM

Credit note in incoming payment

400 Views

Dear all friend i have a problem to add credit note to incoming payment, i have success to add credit note in to incoming payment but in the where i check in journal entry there is not including credit note.. mean while in the in the incoming payment already added but the credit note not deduct the invoice... this is my code to execute the the data to incoming payment. <br>

With opaymemnt <br>

If header = True Then <br>

.DocType = SAPbobsCOM.BoRcptTypes.rCustomer <br>

.CardCode = CStr(crd.Item("U_AU_Customercode")) <br>

.CardName = CStr(crd.Item("U_AU_Customername")) <br>

.DocDate = billdate <br>

.TaxDate = billdate <br>

.Remarks = "Posted By " & cls_Declaration.Loginname & vbCrLf & " Posted by invoice billing " & billnumber <br>

.LocalCurrency = SAPbobsCOM.BoYesNoEnum.tYES <br>

.CashAccount = CStr(crd.Item("U_AU_Account")) <br>

.CashSum = CDbl(IIf(IsDBNull(crd.Item("TotalCash")), 0, crd.Item("TotalCash"))) <br>

.TransferAccount = CStr(crd.Item("U_AU_Account")) <br>

.TransferDate = billdate <br>

.TransferSum = CDbl(IIf(IsDBNull(crd.Item("TotalTransfer")), 0, crd.Item("TotalTransfer"))) <br>

credit = CDbl(IIf(IsDBNull(crd.Item("TotalDiscount")), 0, crd.Item("TotalDiscount"))) <br>

If credit <> 0 Then <br>

sqlstring = "SELECT CREDITCARD,Acctcode FROM OCRC WHERE CARDNAME ='" & <br>

cls_Declaration.AreaLogin & " - PENDAPATAN LAIN'" <br>

If con2.State = ConnectionState.Open Then <br>

con2.Close() <br>

End If <br>

con2.ConnectionString = cls_Declaration.constring <br>

con2.Open() <br>

cmd2 = New SqlClient.SqlCommand(sqlstring, con2) <br>

cmd2.CommandType = CommandType.Text <br>

crd2 = cmd2.ExecuteReader <br>

If crd2.HasRows Then <br>

crd2.Read() <br>

.CreditCards.CreditCard = crd2.Item("CREDITCARD") <br>

.CreditCards.CreditAcct = crd2.Item("Acctcode") <br>

.CreditCards.CreditSum = CDbl(IIf(IsDBNull(crd.Item("TotalDiscount")), 0, crd.Item("TotalDiscount"))) <br>

End If <br>

crd2.Close() <br>

con2.Close() <br>

End If <br>

header = False <br>

End If <br>

If header = False Then <br>

.Invoices.Add() <br>

oline = oline + 1v

.Invoices.SetCurrentLine(oline) <br>

End If <br>

.Invoices.DocLine = oline <br>

.Invoices.DocEntry = CInt(crd.Item("U_AU_Docentry")) <br>

If CDbl(IIf(IsDBNull(crd.Item("U_AU_InvoiceTotal")), 0, crd.Item("U_AU_InvoiceTotal"))) > 0 Then <br>

.Invoices.SumApplied = CDbl(IIf(IsDBNull(crd.Item("TotalPaymen")), 0, crd.Item("TotalPaymen"))) <br>

Else <br>

.Invoices.SumApplied = CDbl(IIf(IsDBNull(crd.Item("U_AU_InvoiceTotal")), 0, crd.Item("U_AU_InvoiceTotal"))) <br>

End If <br>

'.CreditCards.CreditCard = CDbl(IIf(IsDBNull(crd.Item("U_AU_Discount")), 0, crd.Item("U_AU_Discount")) + <br>

CDbl(IIf(IsDBNull(crd.Item("U_AU_Discountcash")),0,crd.Item("U_AU_Discountcash")))) <br>

If CDbl(IIf(IsDBNull(crd.Item("U_AU_InvoiceTotal")), 0, crd.Item("U_AU_InvoiceTotal"))) > 0 Then <br>

.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice <br>

Else <br>

.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_CredItnote <br>

End If <br>

End With <br>

End While <br>

crd.Close() <br>

con.Close() <br>

iretcode = opaymemnt.Add <br>

please did any one know to solve this problem <br>

thnks

Edited by: Tony Tony on Jun 30, 2009 6:31 AM