cancel
Showing results for 
Search instead for 
Did you mean: 

SDK can't create Credit Note based on Invoice if Delivery exists

0 Kudos

Hello

I have the following issue: when I create a CreditNote based on an A/R invoice, without delivery it works fine but when a Delivery exists I receive the following error: Quantity cannot exceed the quantity in the base document, the quantity is the same as the base document, so the quantity is not exceeding the base document for sure.

Any help will be greatly appreciated!

Thanks!

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi jaime.briz,

What happens if you try to create the Credit Note manually using SAP Business One Client?

Do you get the same error message?

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

0 Kudos

Hello Ankit

From Sap Business One Client works fine just copy the invoice to credit note and no errors. On the related documents windows you can see Invoice—> Delivery —> CréditNote.

By the way on the SDK I have also tried using the Delivery instead of the Invoice as base document but I receive an error that the type of document is not supported as a base entry type of document.

I have tried everything with no luck, maybe there is a option or parameter that I will have to enable to somehow refer/use the quantity used in the delivery but use the invoice as a base document. Because the Invoice didn’t got any inventory out it was the delivery, maybe that is why I receive the error that quantity exceeded the quantity in the base document. Any help will be greatly appreciated!

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi jaime.briz,

Have you tested the issue in the DEMO Database?

If the issue is reproducible in the DEMO Database using DI API, kindly share the exact steps to reproduce the issue.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Accepted Solutions (0)

Answers (2)

Answers (2)

andy_bolton
Explorer
0 Kudos

I have logged this with SAP and they have come back with the following which I can confirm does work.

After coping a Reserve Invoice to Delivery, if you want to copy the Reserve Invoice to Credit Memo, you should set the Delivery as the actual base for Credit Memo as in the following DI Code.

SAPbobsCOM.Documents doc = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oCreditNotes);
doc.Lines.BaseEntry = 2; //Reserve Invoice DocEntry
doc.Lines.BaseLine = 0; //Reserve Invoice LineNum

doc.Lines.BaseType = 13;
doc.Lines.ActualBaseEntry = 1; //Delivery DocEntry
doc.Lines.ActualBaseLine = 0; //Delivery LineNum
doc.Lines.Quantity = 1;
doc.Add();

//ActualBase and ActualBaseLine should be set if CM is after a Delivery

andy_bolton
Explorer
0 Kudos

I am having the same issue on SAP 9.3 pl12 (SQL).

The steps are;

1. Add a Reserve Invoice (in UI or SDK). OK.

2. Add a Delivery linked to the Reserve Invoice (in UI or SDK). OK.

3. Add a Credit Note linked to the Reserve Invoice with 'Without Qty Posting' set on or off (SDK). 'Quantity cannot exceed the quantity in the base document' error.

4. Cancel the Delivery (in UI or SDK). OK.

5. Now Add a Credit Note linked to the Reserve Invoice (SDK). OK.

This means that the only way to do the Credit Note with the SDK is to put the stock back first, which may not always be correct.

Do you know if this has been raised as a SAP Issue?

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear andy.bolton & jaime.briz,

I checked this issue in the DEMO Database on SAP Business One Version 10.0 PL02 and added the Credit Memo using the following code:

SAPbobsCOM.Documents oCreditNote = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oCreditNotes);
oCreditNote.CardCode = "C20000";
oCreditNote.Lines.BaseLine = 0;
oCreditNote.Lines.BaseEntry = 361;
oCreditNote.Lines.BaseType = 13;
oCreditNote.Lines.Quantity = 2;
oCreditNote.Lines.ActualBaseEntry = 391; //DocEntry of Delivery Document
oCreditNote.Lines.ActualBaseLine = 0; //Line Number from the Delivery Document Lines
int oCNAdd = oCreditNote.Add();

Kindly check whether the created Credit Memo is as per your expectations or not? Check whether all the documents are in correct order?

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

mario_galeano
Participant
0 Kudos
I followed the example mentioned here, in this case doing it in the service layer, but I receive the following message: {"error":{"code":-5002,"message":{"lang":"en-us","value":"One of the base documents has been closed [DocumentLines.BaseEntry][line: 1]"}}} Verifying the invoice is already closed because the invoice has already been paid in full, in SAP what I do is change the status of the document to "Open" and there, if you allow me, how would it be done from the Credits Notes API?