Solved

Error "Unable to generate next number for ARINVOICE sequence"

  • 25 November 2020
  • 11 replies
  • 95 views

Userlevel 1

Hello,

I created and confirmed SOShipment via this code. It works well.

The problem persists when I want to create an invoice from this shipment.

I want to create the invoice from the application.

Error Message: “Unable to generate next number for ARINVOICE sequence”.

SOShipmentEntry soShipmentGraph = PXGraph.CreateInstance<SOShipmentEntry>();
             soShipmentGraph.Clear();
             DocumentList<SOShipment> created = new DocumentList<SOShipment>(soShipmentGraph);
             soShipmentGraph.CreateShipment(order, shipment.SiteID, order.OrderDate, false, SOOperation.Issue, created);
             soShipmentGraph.ShipPackages(shipment);

            PXAutomation.CompleteSimple(soShipmentGraph.Document.View);
            PXAdapter adapter2 = new PXAdapter(new DummyView(soShipmentGraph, soShipmentGraph.Document.View.BqlSelect,
                         new List<object> { soShipmentGraph.Document.Current }));
            adapter2.Menu = SOShipmentEntryActionsAttribute.Messages.ConfirmShipment;
            adapter2.Arguments = new Dictionary<string, object>
                {
                        {"actionID", SOShipmentEntryActionsAttribute.ConfirmShipment}
                };
            adapter2.Searches = new object[] { soShipmentGraph.Document.Current.ShipmentNbr };
            adapter2.SortColumns = new[] { "ShipmentNbr" };
            soShipmentGraph.action.PressButton(adapter2);

Best regards.

 

 

 
icon

Best answer by mohamed1walha 26 November 2020, 14:34

 Resolved.

It’s necessary to have an accounting period at the company to create an invoice.
I changed the company and the error disappeared.

Thank you @naveenb74  for your valuable assistance.

View original

11 replies

Userlevel 4
Badge +1

Hi @mohamed1walha ,

 

Can you please verify below details configured for IN order type in Order Types screen ?

 

Userlevel 1

Thank you @naveenb74  for your reply.


In fact when I create an order with a shipment and confirmation of shipment from the app all is functional, and I can create an invoice.
On the other hand, when I will create an order with a shipment and confirmation of the shipment from the code, I cannot create an invoice.

Example of an shipment create via code when i want to create invoice:

Best regards.

Userlevel 4
Badge +1

Hi @mohamed1walha,

To confirm the shipment, can you please try with the below code and try to create invoice. If the above is NOT same as this?

Please ignore this code, if it is same as above
 

SOShipLine sOShipLine= PXSelect<SOShipLine, Where<SOShipLine.shipmentNbr, Equal<Required<SOShipment.shipmentNbr>>>, OrderBy<Asc<SOShipLine.shipmentNbr, Asc<SOShipLine.sortOrder>>>>.Select(soShipmentGraph, soShipmentGraph.Document.Current.ShipmentNbr);
SOShipLineSplit sOShipLineSplit = PXSelect<SOShipLineSplit, Where<SOShipLineSplit.shipmentNbr, Equal<Required<SOShipLine.shipmentNbr>>, And<SOShipLineSplit.lineNbr, Equal<Required<SOShipLine.lineNbr>>>>>.Select(soShipmentGraph, soShipmentGraph.Document.Current.ShipmentNbr, sOShipLine.LineNbr);
PXAutomation.CompleteSimple(soShipmentGraph.Document.View);
PXAdapter adapter2 = new PXAdapter(new DummyView(soShipmentGraph, soShipmentGraph.Document.View.BqlSelect,
new List<object> { soShipmentGraph.Document.Current }));
adapter2.Menu = "Confirm Shipment";
adapter2.Arguments = new Dictionary<string, object>();
adapter2.Arguments.Add("actionID", 1);
soShipmentGraph.action.PressButton(adapter2);
TimeSpan timespan;
Exception ex;
while (PXLongOperation.GetStatus(soShipmentGraph.UID, out timespan, out ex) == PXLongRunStatus.InProcess)
{ }

 

Userlevel 1

Thank you @naveenb74 for your reply. 

The same error appeared. 

I want to know is there any other data in other tables, that will be saved on the database when I create a shipment.

Best regards.

Userlevel 4
Badge +1

@mohamed1walha, How you are creating a shipment? is it through code level or screen level.

if it is code level, can you please share the code here?

Userlevel 1

@naveenb74   I created the shipment with the code level.

Code for create Shipment:

 SOShipmentEntry soShipmentGraph = PXGraph.CreateInstance<SOShipmentEntry>();
soShipmentGraph.Clear();
DocumentList<SOShipment> created = new DocumentList<SOShipment>(soShipmentGraph);
soShipmentGraph.CreateShipment(order, shipment.SiteID, order.OrderDate, false, SOOperation.Issue, created);
soShipmentGraph.ShipPackages(shipment);

Code for Confirm Shipment:

 SOShipLine sOShipLine = PXSelect<SOShipLine, Where<SOShipLine.shipmentNbr, Equal<Required<SOShipment.shipmentNbr>>>, OrderBy<Asc<SOShipLine.shipmentNbr, Asc<SOShipLine.sortOrder>>>>.Select(soShipmentGraph, soShipmentGraph.Document.Current.ShipmentNbr);
SOShipLineSplit sOShipLineSplit = PXSelect<SOShipLineSplit, Where<SOShipLineSplit.shipmentNbr, Equal<Required<SOShipLine.shipmentNbr>>, And<SOShipLineSplit.lineNbr, Equal<Required<SOShipLine.lineNbr>>>>>.Select(soShipmentGraph, soShipmentGraph.Document.Current.ShipmentNbr, sOShipLine.LineNbr);
PXAdapter adapter2 = new PXAdapter(new DummyView(soShipmentGraph, soShipmentGraph.Document.View.BqlSelect,
new List<object> { soShipmentGraph.Document.Current }));
adapter2.Menu = "Confirm Shipment";
PXAutomation.CompleteSimple(soShipmentGraph.Document.View);

adapter2.Arguments = new Dictionary<string, object>();
adapter2.Arguments.Add("actionID", 1);
soShipmentGraph.action.PressButton(adapter2);
TimeSpan timespan;
Exception ex;
while (PXLongOperation.GetStatus(soShipmentGraph.UID, out timespan, out ex) == PXLongRunStatus.InProcess)
{ }

 

Userlevel 4
Badge +1

@mohamed1walha I’m NOT sure, why you are getting that issue. We are using the below code to Create and Confirm the Shipment and the code is working as expected.

Please find the code here

 

private void CreateAndConfirmShipment(int? siteID, string orderNbr, SSShipNotice shipNotice, SSSetup settings, SSLoggerProperties loggerProperties)
{
SOShipmentEntry newshipmentGraph = CreateInstance<SOShipmentEntry>();
DocumentList<SOShipment> created = new DocumentList<SOShipment>(newshipmentGraph);
SOOrder order = PXSelectReadonly<SOOrder, Where<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>, And<SOOrder.behavior, Equal<SOOrderTypeConstants.salesOrder>>>>.Select(newshipmentGraph, orderNbr);
newshipmentGraph.CreateShipment(order, siteID, Accessinfo.BusinessDate, false, SOOperation.Issue, created);

SOOrderEntry soOrderGraph = CreateInstance<SOOrderEntry>();
order = PXSelectReadonly<SOOrder, Where<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>, And<SOOrder.behavior, Equal<SOOrderTypeConstants.salesOrder>>>>.Select(soOrderGraph, shipNotice.OrderId.Text);
soOrderGraph.Document.Current = order;
PXAutomation.CompleteSimple(soOrderGraph.Document.View);
soOrderGraph.Save.Press();
string ShipmentStatus = string.Empty;

ConfirmShipment(created.FirstOrDefault().ShipmentNbr, out ShipmentStatus);

}



private void ConfirmShipment(string ShipmentNbr, out string status)
{
var graph = CreateInstance<SOShipmentEntry>();
graph.Document.Current = graph.Document.Search<SOShipment.shipmentNbr>(ShipmentNbr);
graph.lsselect.UnattendedMode = false;
PXAutomation.CompleteSimple(graph.Document.View);
PXAdapter adapter = new PXAdapter(new DummyView(graph, graph.Document.View.BqlSelect,
new List<object> { graph.Document.Current }));
adapter.Menu = SSConstants.ConfirmShipments;
adapter.Arguments = new Dictionary<string, object>();
adapter.Arguments.Add(SSConstants.Action, 1);
graph.action.PressButton(adapter);
TimeSpan timespan;
Exception ex;
while (PXLongOperation.GetStatus(graph.UID, out timespan, out ex) == PXLongRunStatus.InProcess)
{ }

if (graph.Document.Current.Status == SOShipmentStatus.Open)
{
bool? iscompleted = false;
foreach (PXResult<SOOrderShipment, SOOrder> result in graph.OrderList.Select())
{
SOOrder order = result;
if (order.Status == SOOrderStatus.Completed)
iscompleted = true;
}
if (iscompleted == true && graph.Document.Current.Confirmed == true && (graph.Document.Current.ShipmentType == INDocType.Issue && graph.Document.Current.UnbilledOrderCntr > 0 && graph.Document.Current.BilledOrderCntr == 0 && graph.Document.Current.ReleasedOrderCntr == 0 || graph.Document.Current.ShipmentType == INDocType.Transfer))
{
graph.Document.Current.Status = SOShipmentStatus.Confirmed;
graph.Document.Update(graph.Document.Current);
graph.Save.Press();
}
}
}
Userlevel 1

@naveenb74  My code is working fine. I looked at the fields in the database, everything is fine. I will try to create the invoice from another location with other shipping data.


Thank you for your patience. 

Userlevel 4
Badge +1

Sure. But we do not have any issues with above. You can try and verify and create the Invoice because this code is working for us.

Userlevel 4
Badge +1

@mohamed1walha You can update here what is the change you have done on this.

 

Userlevel 1

 Resolved.

It’s necessary to have an accounting period at the company to create an invoice.
I changed the company and the error disappeared.

Thank you @naveenb74  for your valuable assistance.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2020  Acumatica, Inc. All rights reserved