Hello, this should be simple but I’m struggling.
This code will create an invoice, and work perfectly.
private ARInvoice CreatePrepaymentInvoice1(SOOrder order, decimal amount)
{
ARInvoiceEntry graph = PXGraph.CreateInstance<ARInvoiceEntry>();
ARInvoice invoice = graph.Document.Insert(new ARInvoice
{
DocType = ARDocType.Invoice,
CustomerID = order.CustomerID,
DocDate = Base.Accessinfo.BusinessDate,
});
graph.Save.Press();
return graph.Document.Current;
}Switch the DocType to Prepayment and now it doesn’t work.
private ARInvoice CreatePrepaymentInvoice1(SOOrder order, decimal amount)
{
ARInvoiceEntry graph = PXGraph.CreateInstance<ARInvoiceEntry>();
ARInvoice invoice = graph.Document.Insert(new ARInvoice
{
DocType = ARDocType.Prepayment,
CustomerID = order.CustomerID,
DocDate = Base.Accessinfo.BusinessDate,
});
graph.Save.Press();
return graph.Document.Current;
}The error is:
“CS Error: Cannot generate the next number for the sequence.”
In the UI, I can open the invoice screen, select Prepayment, select a customer and click save. No problem.
Can anyone explain what is happening? Why this isn’t working? How I should change the code to make it work?