ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Enhancement Request] Codeunit 1002 Job Create-Invoice

Open bleisibach opened this issue 7 years ago • 1 comments

Referencing Issue #700

As function CreateSalesInvoiceLines is accesible from external as requested, we ask you to move the COMMIT and MESSAGE code to the calling function CreateSalesInvoice. The MESSAGE and COMMIT are breaking UI and transaction when the function is called from external.

Move Code from

[External] CreateSalesInvoiceLines(JobNo : Code[20];VAR JobPlanningLine : Record "Job Planning Line";InvoiceNo : Code[20];NewInvoice : Boolean;PostingDate : Date;CreditMemo : Boolean)
OnBeforeCreateSalesInvoiceLines(JobPlanningLine,InvoiceNo,NewInvoice,PostingDate,CreditMemo);
.
.
.
IF NoOfSalesLinesCreated = 0 THEN
  ERROR(Text002,JobPlanningLine.TABLECAPTION,JobPlanningLine.FIELDCAPTION("Qty. to Transfer to Invoice"));

>>> Re/moveCode 
//COMMIT;
//
//IF CreditMemo THEN
//  MESSAGE(Text008)
//ELSE
//  MESSAGE(Text000);
<<< Re/move Code End

OnAfterCreateSalesInvoiceLines(SalesHeader,NewInvoice);

Move Code to

[External] CreateSalesInvoice(VAR JobPlanningLine : Record "Job Planning Line";CrMemo : Boolean)
IF NOT CrMemo THEN BEGIN
  GetSalesInvoiceNo.SetCustomer(JobPlanningLine."Job No.");
  GetSalesInvoiceNo.RUNMODAL;
  GetSalesInvoiceNo.GetInvoiceNo(Done,NewInvoice,PostingDate,InvoiceNo);
END ELSE BEGIN
  GetSalesCrMemoNo.SetCustomer(JobPlanningLine."Job No.");
  GetSalesCrMemoNo.RUNMODAL;
  GetSalesCrMemoNo.GetCreditMemoNo(Done,NewInvoice,PostingDate,InvoiceNo);
END;

IF Done THEN BEGIN
  IF (PostingDate = 0D) AND NewInvoice THEN
    ERROR(Text007,SalesHeader.FIELDCAPTION("Posting Date"));
  IF (InvoiceNo = '') AND NOT NewInvoice THEN BEGIN
    IF CrMemo THEN
      ERROR(Text005);
    ERROR(Text004);
  END;
  CreateSalesInvoiceLines(
    JobPlanningLine."Job No.",JobPlanningLine,InvoiceNo,NewInvoice,PostingDate,CrMemo);
END;

>>> New Code
COMMIT;

IF CrMemo THEN
  MESSAGE(Text008)
ELSE
  MESSAGE(Text000);
<<< New Code End

bleisibach avatar Jan 21 '19 09:01 bleisibach

Seems this is completed already. I suggest to close the issue.

bleisibach avatar Dec 10 '19 07:12 bleisibach