cancel
Showing results for 
Search instead for 
Did you mean: 

Credit note in incoming payment

tuonni
Explorer
0 Kudos
554

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

In the Journal entry the credit note will be never included, because you pay against the BusinessPartner....

YOu can check your payment, and even in the payment the Credit note is included, than there is a problem. Also check the Credit note, and look for the PayToDate, it is payed or not. (open balance, Applied Amount field on the form in SAP B1 client)

Regards,

J.

Edited by: János Nagy on Jun 30, 2009 9:23 AM

Answers (4)

Answers (4)

0 Kudos

ok the solution for this problema is this,

you need to put in vPay.Invoices.SumApplied

of the invoice the sum of all your credit note in positive

and sum to the mount in cash and put to the SumApplied of the invoice

and with this SAP do´t check the Check box of Pay to Acount

i goint to explaitn whith a example:

Imaging you have to create a incomingPayment with 3 Credit Note and 1 Invoice

#Doc Type Mount Balance

1 Credit Note -1000 0

2 Credit Note -1000 0

3 Credit Note -1000 0

4 Invoice 15,000 15,000

So , in this example you can see the 3 Credit note are for 1000

so when you select to use for reduce the balance of the invoice

the balance for the invoice result in 12,000

so this 12,000 you want to pay in cash

so in the code you need to do this

Company = obj_SAP.ConectarSap()

vPay = Company.GetBusinessObject(BoObjectTypes.oIncomingPayments)

vPay.DocNum = 100000 'put you own DocNum

vPay.HandWritten = BoYesNoEnum.tYES

----------detail-----------------------------------

--We add the Credit Note

vPay.Invoices.DocLine = 1

vPay.Invoices.DocEntry = 1 'PUT YOUR DOC ENTRE

vPay.Invoices.InvoiceType = BoRcptInvTypes.it_CredItnote ' WITH THIS YOU SPECIFY THAT THIS IS A CREDIT NOTE

vPay.Invoices.SumApplied = -1000 'IT´S VERY IMPORTAND HAVE TO BY NEGATIVE

--We add the Credit Note

vPay.Invoices.DocLine = 2

vPay.Invoices.DocEntry = 2 'PUT YOUR DOC ENTRE

vPay.Invoices.InvoiceType = BoRcptInvTypes.it_CredItnote 'WITH THIS YOU SPECIFY THAT THIS IS A CREDIT NOTE

vPay.Invoices.SumApplied =-1000 'IT´S VERY IMPORTAND HAVE TO BY NEGATIVE

--We add the Credit Note

vPay.Invoices.DocLine = 3

vPay.Invoices.DocEntry = 3 'PUT YOUR DOC ENTRE

vPay.Invoices.InvoiceType = BoRcptInvTypes.it_CredItnote 'WITH THIS YOU SPECIFY THAT THIS IS A CREDIT NOTE

vPay.Invoices.SumApplied = -1000 'IT´S VERY IMPORTAND HAVE TO BY NEGATIVE

--We add the Invoice

vPay.Invoices.DocLine = 4

vPay.Invoices.DocEntry = 4 'PUT YOUR DOC ENTRE

vPay.Invoices.SumApplied = 15,000 'HERE!!! is the solution of the problem, YOU need to put the sum of the mount in Credit notes in positive (3000) and the mount in Cash (12000)the result is 15,000

vPay.Invoices.InvoiceType = BoRcptInvTypes.it_Invoice 'WITH THIS YOU SPECIFY THAT THIS IS A Invoice

----------End detail-----------------------------------

RetVal = vPay.Add()

0 Kudos

why nobody give a good anser for this question' i have the same problema ,i can´t find the solucion

tuonni
Explorer
0 Kudos

Dear mr János Nagy

I folow u recommended code.. the result is same as before the credit note don't deduct the invoice, for the information i'm developing add-ons for sap 2005 B PL 40, are they any bug in the DI or any configuration i have missed?

thank for you attention

tuonni
Explorer
0 Kudos

dear mr János Nagy, when i try in SAP B1 and i create incoming payment ex : i choose customer "A" with customer code "A001"

then appear the data in incoming payment

1.invoice number "10001" with invoice total "$1000" and

2.credit note "101" with "$500"

then i highlight these to data in incoming payment then i click the payment mean then i pay cash "$500" and click ok in payment mean and klick add in the incoming payment form in banking module there are success to close invoice number "10001" and close credit note "101"

but if add from SDK the invoice not close and credit note not deduct the invoice and then the invoice have balance due "$500"

is that any this wrong with my code to add incoming payment?

please help me to solve this problem

Former Member
0 Kudos

HI,

I have tested with a sort code



        Dim vPay As SAPbobsCOM.Payments = oCompany.GetBusinessObject(BoObjectTypes.oIncomingPayments)
        vPay.CardCode = "ACC"
        vPay.CashAccount = "38110100"
        vPay.CashSum = 84
        vPay.DocDate = Date.Today()
        vPay.VatDate = Date.Today()
        vPay.DueDate = Date.Today()
        vPay.TaxDate = Date.Today()
        vPay.LocalCurrency = BoYesNoEnum.tYES

        vPay.Invoices.DocEntry = 13
        vPay.Invoices.DocLine = 0
        vPay.Invoices.InvoiceType = BoRcptInvTypes.it_Invoice
        vPay.Invoices.SumApplied = 96
        vPay.Invoices.Add()
        vPay.Invoices.DocEntry = 3
        vPay.Invoices.DocLine = 1
        vPay.Invoices.InvoiceType = BoRcptInvTypes.it_CredItnote
        vPay.Invoices.SumApplied = -12

        If (vPay.Add() <> 0) Then
            MsgBox(oCompany.GetLastErrorDescription)
        End If

So

1. the 1st line is always added to the payment object.

2. Docline = vPay.Invoices.Count (count of lines)

3. The ivoice is not closed of course, if you see your code

> oline = oline + 1v .Invoices.SetCurrentLine(oline)

correct

If header = False Then

if .Invoices.count > 1 then .Invoices.Add()

end if

...

>oline = oline + 1v .Invoices.SetCurrentLine(oline) is not necessary

Please do not forget: Credit note is has a negativ value !

Regards,

János

tuonni
Explorer
0 Kudos

Dear all expert

please any one know for this solutio... please