Missing Sales Order Revenue Account when create Sales Order through code.

Hi,

When I created and invoiced Sales Order through code, I have found the logic error is missing Revenue Account value. In my case, the revenue account is 51110000.1781.no.bmp (1.25 MB)

But if I create SO by system form in Sales and Marketing or in Account Receivable, I can see Revenue Account .

7115.no - Copy.bmp (1.25 MB)

Can anyone help me to create Sales Order through code (X++) and don’t miss Revenue Account.

Thanks.

Dat.

So to which account the customer revenue is being posted?

Hi Kranthi,

They are account 33311000 and 13110000.

Generally the invoice should update the sales revenue account. Is it not updated in your case? If so what is happening in your case?

Explain the voucher.

Oh, how can I update again sales revenue account. I think it is automatic when invoice are generated. In my case, I use salesTable.initFromCustTable() function to create SO header and salesLine.createLine() function to create sales order details, and use the SalesFormLetter class to invoice sales order.

There are many available codes for it, I have tried many but it has got the same error. Is my system in error.

Thanks.

Did you try debugging the code ?

You can debug when invoicing through standard process which AX supports and debug your code and try to compare where it is going wrong

Hi Nash,

Thanks for your help, I know how to debug my code, but don’t know debug the standard process, can you tell me how to debug the standard process of AX.

Dat,

Place the breakpoint in sales order invoice button clicked and try to invoice the sales order, then debugger hits the breakpoint then you can debug step by step

You have not explained about the voucher.

But to understand which process has problem.

  1. create sales order through code and post it manually.

  2. Create sales order manually and post it through code.

then debug the fault process.

the posting of invoice happens in \Classes\SalesInvoiceJournalPost

Kranthi,

I also don’t have enough understand about the voucher to explain to you, your suggest is good, I will try and contact you again.

Thanks,

Kranthi,

I try your solution and find the error in my code, that is SalesPrice field in SalesLine table are not init when I call createLine() function.

Thank you very much!

Best Regard,

Dat

Then fill in the salesPrice before creating the salesLine,

eg :

salesLine.SalesPrice = 20.0 ( your desired value)

salesLine.createLine(,);

Hi Nash,

My error code also set salesLine.SalesPrice before call salesLine.createLine, but after call createLine() function, I check again salesLine.SalesPrice, it is zero. May this function reset the value of sales price.

My solution is override the value of sales prices after call createLine, I use select for update statement. It work in fine.

Thanks and Regard,

Dat

Hi Dat,

Can you tell me what are the parameters you are passing, the price changing is also dependent in 6th parameter

which you have to pass it as false if you do not want to override. So this way you dont have to update the price again.

Hi Nash,

I set “true” value for all parameter in createLine() function:

salesLine.createLine(

true, // Validate

true, // initFromSalesTable

true, // initFromInventTable

true, // calcInventQty

true, // searchMarkup

true // searchPrice

);

Thanks,

Dat

salesLine.createLine(

true, // Validate

true, // initFromSalesTable

true, // initFromInventTable

true, // calcInventQty

true, // searchMarkup

false// searchPrice

);

Try the above pass false for searchPrice that way you don’t have to update the price after creating the salesline

Thanks Nash,

I have tried and it work in fine.

Best Regards,

Dat