microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
771 stars 610 forks source link

page 254 "Purchase Journal" - CurrentJnlBatchNameSet, CurrentJnlBatchNameGet, OnOnOpenPage, & OnAfterOnOpenPage #13873

Closed ZacRyon closed 3 years ago

ZacRyon commented 3 years ago

page 254 "Purchase Journal" { // // This page has two view modes based on global variable 'IsSimplePage' as :- // // Show more coloums action (IsSimplePage = FALSE) // // - Default page layout before simple view was introduced. // // Show less coloums action (IsSimplePage = TRUE) // // Hide amount, account type coloums and set default account type to Vendor. // // Show a new column named document amount where user will enter amount for the line // // By DEFAULT this page opens up in simple page layout.

ApplicationArea = Basic, Suite;
AutoSplitKey = true;
Caption = 'Purchase Journals';
DataCaptionExpression = DataCaption;
DelayedInsert = true;
PageType = Worksheet;
PromotedActionCategories = 'New,Process,Report,Page,Post/Print,Line,Account';
SaveValues = true;
SourceTable = "Gen. Journal Line";
UsageCategory = Tasks;

layout
{
    area(content)
    {
        field(CurrentJnlBatchName; CurrentJnlBatchName)
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Batch Name';
            Lookup = true;
            ToolTip = 'Specifies the name of the journal batch, a personalized journal layout, that the journal is based on.';

            trigger OnLookup(var Text: Text): Boolean
            begin
                CurrPage.SaveRecord();
                GenJnlManagement.LookupName(CurrentJnlBatchName, Rec);
                GenJnlManagement.SetLastViewedJournalBatchName(PAGE::"Purchase Journal", CurrentJnlBatchName);
                SetControlAppearanceFromBatch();
                CurrPage.Update(false);
            end;

            trigger OnValidate()
            begin
                GenJnlManagement.CheckName(CurrentJnlBatchName, Rec);
                CurrentJnlBatchNameOnAfterVali();
                GenJnlManagement.SetLastViewedJournalBatchName(PAGE::"Purchase Journal", CurrentJnlBatchName);
            end;
        }
        repeater(Control1)
        {
            ShowCaption = false;
            field("Posting Date"; "Posting Date")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the posting date for the entry.';
            }
            field("Document Date"; "Document Date")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the date when the related document was created.';
                Visible = false;
            }
            field("Document Type"; "Document Type")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the type of document that the entry on the journal line is.';

                trigger OnValidate()
                begin
                    if xRec."Document Type" <> "Document Type" then
                        if ("Document Type" = "Document Type"::Payment) or ("Document Type" = "Document Type"::"Credit Memo") then
                            Validate(Amount, Abs(Amount))
                        else
                            if Amount > 0 then
                                Validate(Amount, -1 * Amount)
                end;
            }
            field("Document No."; "Document No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies a document number for the journal line.';
                ShowMandatory = true;
            }
            field("Incoming Document Entry No."; "Incoming Document Entry No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the number of the incoming document that this general journal line is created for.';
                Visible = false;

                trigger OnAssistEdit()
                begin
                    if "Incoming Document Entry No." > 0 then
                        HyperLink(GetIncomingDocumentURL);
                end;
            }
            field("External Document No."; "External Document No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies a document number that refers to the customer''s or vendor''s numbering system.';
            }
            field("Account Type"; "Account Type")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the type of account that the entry on the journal line will be posted to.';
                Visible = NOT IsSimplePage;

                trigger OnValidate()
                begin
                    GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);
                    EnableApplyEntriesAction();
                    CurrPage.SaveRecord();
                end;
            }
            field("Account No."; "Account No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the account number that the entry on the journal line will be posted to.';

                trigger OnValidate()
                begin
                    GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);
                    ShowShortcutDimCode(ShortcutDimCode);
                    CurrPage.SaveRecord();
                end;
            }
            field("<Vendor Name>"; AccName)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Vendor Name';
                Editable = false;
                ToolTip = 'Specifies the name of the vendor.';
            }
            field(Description; Description)
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies a description of the entry.';
            }
            field("Salespers./Purch. Code"; "Salespers./Purch. Code")
            {
                ApplicationArea = Suite;
                ToolTip = 'Specifies the salesperson or purchaser who is linked to the journal line.';
                Visible = false;
            }
            field("Campaign No."; "Campaign No.")
            {
                ApplicationArea = RelationshipMgmt;
                ToolTip = 'Specifies the number of the campaign that the journal line is linked to.';
                Visible = false;
            }
            field("Currency Code"; "Currency Code")
            {
                ApplicationArea = Suite;
                AssistEdit = true;
                ToolTip = 'Specifies the code of the currency for the amounts on the journal line.';
                Visible = false;

                trigger OnAssistEdit()
                begin
                    ChangeExchangeRate.SetParameter("Currency Code", "Currency Factor", "Posting Date");
                    if ChangeExchangeRate.RunModal = ACTION::OK then
                        Validate("Currency Factor", ChangeExchangeRate.GetParameter);

                    Clear(ChangeExchangeRate);
                end;
            }
            field("Gen. Posting Type"; "Gen. Posting Type")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the type of transaction.';
                Visible = NOT IsSimplePage;
            }
            field("Gen. Bus. Posting Group"; "Gen. Bus. Posting Group")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the vendor''s trade type to link transactions made for this vendor with the appropriate general ledger account according to the general posting setup.';
                Visible = NOT IsSimplePage;
            }
            field("Gen. Prod. Posting Group"; "Gen. Prod. Posting Group")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the item''s product type to link transactions made for this item with the appropriate general ledger account according to the general posting setup.';
                Visible = NOT IsSimplePage;
            }
            field("VAT Bus. Posting Group"; "VAT Bus. Posting Group")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the VAT specification of the involved customer or vendor to link transactions made for this record with the appropriate general ledger account according to the VAT posting setup.';
                Visible = false;
            }
            field("VAT Prod. Posting Group"; "VAT Prod. Posting Group")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the VAT specification of the involved item or resource to link transactions made for this record with the appropriate general ledger account according to the VAT posting setup.';
                Visible = false;
            }
            field(DocumentAmount; DocumentAmount)
            {
                ApplicationArea = Basic, Suite;
                AutoFormatExpression = "Currency Code";
                Caption = 'Document Amount';
                ToolTip = 'Specifies the total amount (including VAT) that the journal line consists of.';

                trigger OnValidate()
                begin
                    // Document amount can not be less than 0
                    if DocumentAmount < 0 then
                        Error(NegativeDocAmountErr);

                    if ("Document Type" = "Document Type"::Payment) or
                       ("Document Type" = "Document Type"::"Credit Memo")
                    then
                        Validate(Amount, DocumentAmount)
                    else
                        Validate(Amount, DocumentAmount * -1);
                end;
            }
            field(Amount; Amount)
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the total amount (including VAT) that the journal line consists of.';
                Visible = AmountVisible;

                trigger OnValidate()
                begin
                    DocumentAmount := Abs(Amount);
                end;
            }
            field("Amount (LCY)"; "Amount (LCY)")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the total amount in local currency (including VAT) that the journal line consists of.';
                Visible = AmountVisible;
            }
            field("Debit Amount"; "Debit Amount")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the total of the ledger entries that represent debits.';
                Visible = DebitCreditVisible;

                trigger OnValidate()
                begin
                    DocumentAmount := Abs("Debit Amount");
                end;
            }
            field("Credit Amount"; "Credit Amount")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the total of the ledger entries that represent credits.';
                Visible = DebitCreditVisible;

                trigger OnValidate()
                begin
                    DocumentAmount := Abs("Credit Amount");
                end;
            }
            field("Tax Liable"; "Tax Liable")
            {
                ApplicationArea = SalesTax;
                ToolTip = 'Specifies if the customer or vendor is liable for sales tax.';
                Visible = false;
            }
            field("Tax Area Code"; "Tax Area Code")
            {
                ApplicationArea = SalesTax;
                ToolTip = 'Specifies the tax area that is used to calculate and post sales tax.';
                Visible = false;
            }
            field("Tax Group Code"; "Tax Group Code")
            {
                ApplicationArea = SalesTax;
                ToolTip = 'Specifies the tax group that is used to calculate and post sales tax.';
                Visible = false;
            }
            field("Use Tax"; "Use Tax")
            {
                ApplicationArea = SalesTax;
                ToolTip = 'Specifies that the purchase is subject to use tax. Use tax is a sales tax that is paid on items that are purchased by a company and are used by that company instead of being sold to a customer.';
                Visible = false;
            }
            field("VAT Amount"; "VAT Amount")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the amount of VAT that is included in the total amount.';
                Visible = false;
            }
            field("VAT Difference"; "VAT Difference")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the difference between the calculated VAT amount and a VAT amount that you have entered manually.';
                Visible = false;
            }
            field("Bal. VAT Amount"; "Bal. VAT Amount")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the amount of Bal. VAT included in the total amount.';
                Visible = false;
            }
            field("Bal. VAT Difference"; "Bal. VAT Difference")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the difference between the calculate VAT amount and the VAT amount that you have entered manually.';
                Visible = false;
            }
            field("Bal. Account Type"; "Bal. Account Type")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the type of account that a balancing entry is posted to, such as BANK for a cash account.';
                Visible = NOT IsSimplePage;

                trigger OnValidate()
                begin
                    EnableApplyEntriesAction();
                end;
            }
            field("Bal. Account No."; "Bal. Account No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the number of the general ledger, customer, vendor, or bank account that the balancing entry is posted to, such as a cash account for cash purchases.';

                trigger OnValidate()
                begin
                    GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);
                    ShowShortcutDimCode(ShortcutDimCode);
                end;
            }
            field("Bal. Gen. Posting Type"; "Bal. Gen. Posting Type")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the general posting type associated with the balancing account that will be used when you post the entry on the journal line.';
                Visible = NOT IsSimplePage;
            }
            field("Bal. Gen. Bus. Posting Group"; "Bal. Gen. Bus. Posting Group")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the general business posting group code associated with the balancing account that will be used when you post the entry.';
                Visible = NOT IsSimplePage;
            }
            field("Bal. Gen. Prod. Posting Group"; "Bal. Gen. Prod. Posting Group")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the general product posting group code associated with the balancing account that will be used when you post the entry.';
                Visible = NOT IsSimplePage;
            }
            field("Bal. VAT Bus. Posting Group"; "Bal. VAT Bus. Posting Group")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the code of the VAT business posting group that will be used when you post the entry on the journal line.';
                Visible = false;
            }
            field("Bal. VAT Prod. Posting Group"; "Bal. VAT Prod. Posting Group")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the code of the VAT product posting group that will be used when you post the entry on the journal line.';
                Visible = false;
            }
            field("Bill-to/Pay-to No."; "Bill-to/Pay-to No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the number of the bill-to customer or pay-to vendor that the entry is linked to.';
                Visible = false;
            }
            field("Ship-to/Order Address Code"; "Ship-to/Order Address Code")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the address code of the ship-to customer or order-from vendor that the entry is linked to.';
                Visible = false;
            }
            field("Sales/Purch. (LCY)"; "Sales/Purch. (LCY)")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the line''s net amount (the amount excluding VAT) if you are using this journal line for an invoice.';
                Visible = false;
            }
            field("Inv. Discount (LCY)"; "Inv. Discount (LCY)")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the amount of the invoice discount if you are using this journal line for an invoice.';
                Visible = false;
            }
            field("Payment Terms Code"; "Payment Terms Code")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies a formula that calculates the payment due date, payment discount date, and payment discount amount.';
                Visible = false;
            }
            field("Due Date"; "Due Date")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the due date on the entry.';
                Visible = false;
            }
            field("Pmt. Discount Date"; "Pmt. Discount Date")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the date on which the amount in the entry must be paid for a payment discount to be granted.';
                Visible = false;
            }
            field("Payment Discount %"; "Payment Discount %")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the payment discount percent granted if payment is made on or before the date in the Pmt. Discount Date field.';
                Visible = false;
            }
            field("Applies-to Doc. Type"; "Applies-to Doc. Type")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the type of the posted document that this document or journal line will be applied to when you post, for example to register payment.';
                Visible = NOT IsSimplePage;
            }
            field("Applies-to Doc. No."; "Applies-to Doc. No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the number of the posted document that this document or journal line will be applied to when you post, for example to register payment.';
                Visible = NOT IsSimplePage;
            }
            field("Applies-to ID"; "Applies-to ID")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the ID of entries that will be applied to when you choose the Apply Entries action.';
                Visible = false;
            }
            field("On Hold"; "On Hold")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies that the related entry represents an unpaid invoice for which either a payment suggestion, a reminder, or a finance charge memo exists.';
            }
            field("Reason Code"; "Reason Code")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the reason code, a supplementary source code that enables you to trace the entry.';
                Visible = false;
            }
            field(Correction; Correction)
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the entry as a corrective entry. You can use the field if you need to post a corrective entry to an account.';
            }
            field(Comment; Comment)
            {
                ApplicationArea = Comments;
                ToolTip = 'Specifies a comment about the activity on the journal line. Note that the comment is not carried forward to posted entries.';
                Visible = false;
            }
            field("Job Queue Status"; "Job Queue Status")
            {
                ApplicationArea = All;
                Importance = Additional;
                ToolTip = 'Specifies the status of a job queue entry or task that handles the posting of general journals.';
                Visible = JobQueuesUsed;

                trigger OnDrillDown()
                var
                    JobQueueEntry: Record "Job Queue Entry";
                begin
                    if "Job Queue Status" = "Job Queue Status"::" " then
                        exit;
                    JobQueueEntry.ShowStatusMsg("Job Queue Entry ID");
                end;
            }
            field("Shortcut Dimension 1 Code"; "Shortcut Dimension 1 Code")
            {
                ApplicationArea = Dimensions;
                ToolTip = 'Specifies the code for Shortcut Dimension 1, which is one of two global dimension codes that you set up in the General Ledger Setup window.';
                Visible = DimVisible1;
            }
            field("Shortcut Dimension 2 Code"; "Shortcut Dimension 2 Code")
            {
                ApplicationArea = Dimensions;
                ToolTip = 'Specifies the code for Shortcut Dimension 2, which is one of two global dimension codes that you set up in the General Ledger Setup window.';
                Visible = DimVisible2;
            }
            field(ShortcutDimCode3; ShortcutDimCode[3])
            {
                ApplicationArea = Dimensions;
                CaptionClass = '1,2,3';
                TableRelation = "Dimension Value".Code WHERE("Global Dimension No." = CONST(3),
                                                              "Dimension Value Type" = CONST(Standard),
                                                              Blocked = CONST(false));
                Visible = DimVisible3;

                trigger OnValidate()
                begin
                    ValidateShortcutDimCode(3, ShortcutDimCode[3]);

                    OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 3);
                end;
            }
            field(ShortcutDimCode4; ShortcutDimCode[4])
            {
                ApplicationArea = Dimensions;
                CaptionClass = '1,2,4';
                TableRelation = "Dimension Value".Code WHERE("Global Dimension No." = CONST(4),
                                                              "Dimension Value Type" = CONST(Standard),
                                                              Blocked = CONST(false));
                Visible = DimVisible4;

                trigger OnValidate()
                begin
                    ValidateShortcutDimCode(4, ShortcutDimCode[4]);

                    OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 4);
                end;
            }
            field(ShortcutDimCode5; ShortcutDimCode[5])
            {
                ApplicationArea = Dimensions;
                CaptionClass = '1,2,5';
                TableRelation = "Dimension Value".Code WHERE("Global Dimension No." = CONST(5),
                                                              "Dimension Value Type" = CONST(Standard),
                                                              Blocked = CONST(false));
                Visible = DimVisible5;

                trigger OnValidate()
                begin
                    ValidateShortcutDimCode(5, ShortcutDimCode[5]);

                    OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 5);
                end;
            }
            field(ShortcutDimCode6; ShortcutDimCode[6])
            {
                ApplicationArea = Dimensions;
                CaptionClass = '1,2,6';
                TableRelation = "Dimension Value".Code WHERE("Global Dimension No." = CONST(6),
                                                              "Dimension Value Type" = CONST(Standard),
                                                              Blocked = CONST(false));
                Visible = DimVisible6;

                trigger OnValidate()
                begin
                    ValidateShortcutDimCode(6, ShortcutDimCode[6]);

                    OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 6);
                end;
            }
            field(ShortcutDimCode7; ShortcutDimCode[7])
            {
                ApplicationArea = Dimensions;
                CaptionClass = '1,2,7';
                TableRelation = "Dimension Value".Code WHERE("Global Dimension No." = CONST(7),
                                                              "Dimension Value Type" = CONST(Standard),
                                                              Blocked = CONST(false));
                Visible = DimVisible7;

                trigger OnValidate()
                begin
                    ValidateShortcutDimCode(7, ShortcutDimCode[7]);

                    OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 7);
                end;
            }
            field(ShortcutDimCode8; ShortcutDimCode[8])
            {
                ApplicationArea = Dimensions;
                CaptionClass = '1,2,8';
                TableRelation = "Dimension Value".Code WHERE("Global Dimension No." = CONST(8),
                                                              "Dimension Value Type" = CONST(Standard),
                                                              Blocked = CONST(false));
                Visible = DimVisible8;

                trigger OnValidate()
                begin
                    ValidateShortcutDimCode(8, ShortcutDimCode[8]);

                    OnAfterValidateShortcutDimCode(Rec, ShortcutDimCode, 8);
                end;
            }
        }
        group(Control28)
        {
            ShowCaption = false;
            fixed(Control1902205001)
            {
                ShowCaption = false;
                group("Number of Lines")
                {
                    Caption = 'Number of Lines';
                    field(NumberOfJournalRecords; NumberOfRecords)
                    {
                        ApplicationArea = All;
                        AutoFormatType = 1;
                        ShowCaption = false;
                        Editable = false;
                        ToolTip = 'Specifies the number of lines in the current journal batch.';
                    }
                }
                group("Account Name")
                {
                    Caption = 'Account Name';
                    Visible = false;
                    field(AccName; AccName)
                    {
                        ApplicationArea = Basic, Suite;
                        Editable = false;
                        ShowCaption = false;
                        ToolTip = 'Specifies the name of the account.';
                    }
                }
                group("Bal. Account Name")
                {
                    Caption = 'Bal. Account Name';
                    Visible = false;
                    field(BalAccName; BalAccName)
                    {
                        ApplicationArea = Basic, Suite;
                        Caption = 'Bal. Account Name';
                        Editable = false;
                        ToolTip = 'Specifies the name of the balancing account that has been entered on the journal line.';
                    }
                }
                group(Control1903866901)
                {
                    Caption = 'Balance';
                    field(Balance; Balance + "Balance (LCY)" - xRec."Balance (LCY)")
                    {
                        ApplicationArea = All;
                        AutoFormatType = 1;
                        Caption = 'Balance';
                        Editable = false;
                        ToolTip = 'Specifies the balance that has accumulated in the purchase journal on the line where the cursor is.';
                        Visible = BalanceVisible;
                    }
                }
                group("Total Balance")
                {
                    Caption = 'Total Balance';
                    field(TotalBalance; TotalBalance + "Balance (LCY)" - xRec."Balance (LCY)")
                    {
                        ApplicationArea = All;
                        AutoFormatType = 1;
                        Caption = 'Total Balance';
                        Editable = false;
                        ToolTip = 'Specifies the total balance in the purchase journal.';
                        Visible = TotalBalanceVisible;
                    }
                }
            }
        }
    }
    area(factboxes)
    {
        part(JournalErrorsFactBox; "Journal Errors FactBox")
        {
            ApplicationArea = Basic, Suite;
            Visible = BackgroundErrorCheck;
            SubPageLink = "Journal Template Name" = FIELD("Journal Template Name"),
                          "Journal Batch Name" = FIELD("Journal Batch Name"),
                          "Line No." = FIELD("Line No.");
        }
        part(JournalLineDetails; "Journal Line Details FactBox")
        {
            ApplicationArea = Basic, Suite;
            SubPageLink = "Journal Template Name" = FIELD("Journal Template Name"),
                          "Journal Batch Name" = FIELD("Journal Batch Name"),
                          "Line No." = FIELD("Line No.");
        }
        part(Control1900919607; "Dimension Set Entries FactBox")
        {
            ApplicationArea = Basic, Suite;
            SubPageLink = "Dimension Set ID" = FIELD("Dimension Set ID");
        }
        part(IncomingDocAttachFactBox; "Incoming Doc. Attach. FactBox")
        {
            ApplicationArea = Basic, Suite;
            ShowFilter = false;
        }
        systempart(Control1900383207; Links)
        {
            ApplicationArea = RecordLinks;
            Visible = false;
        }
        systempart(Control1905767507; Notes)
        {
            ApplicationArea = Notes;
            Visible = false;
        }
    }
}

actions
{
    area(navigation)
    {
        group("&Line")
        {
            Caption = '&Line';
            Image = Line;
            action(Dimensions)
            {
                AccessByPermission = TableData Dimension = R;
                ApplicationArea = Dimensions;
                Caption = 'Dimensions';
                Image = Dimensions;
                Promoted = true;
                PromotedCategory = Category6;
                ShortCutKey = 'Alt+D';
                ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';

                trigger OnAction()
                begin
                    ShowDimensions();
                    CurrPage.SaveRecord();
                end;
            }
        }
        group("A&ccount")
        {
            Caption = 'A&ccount';
            Image = ChartOfAccounts;
            action(Card)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Card';
                Image = EditLines;
                Promoted = true;
                PromotedCategory = Category7;
                RunObject = Codeunit "Gen. Jnl.-Show Card";
                ShortCutKey = 'Shift+F7';
                ToolTip = 'View or change detailed information about the record on the document or journal line.';
            }
            action("Ledger E&ntries")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Ledger E&ntries';
                Image = GLRegisters;
                Promoted = true;
                PromotedCategory = Category7;
                RunObject = Codeunit "Gen. Jnl.-Show Entries";
                ShortCutKey = 'Ctrl+F7';
                ToolTip = 'View the history of transactions that have been posted for the selected record.';
            }
        }
    }
    area(processing)
    {
        group("F&unctions")
        {
            Caption = 'F&unctions';
            Image = "Action";
            action("Renumber Document Numbers")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Renumber Document Numbers';
                Image = EditLines;
                ToolTip = 'Resort the numbers in the Document No. column to avoid posting errors because the document numbers are not in sequence. Entry applications and line groupings are preserved.';

                trigger OnAction()
                begin
                    RenumberDocumentNo();
                end;
            }
            action("Apply Entries")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Apply Entries';
                Ellipsis = true;
                Enabled = ApplyEntriesActionEnabled;
                Image = ApplyEntries;
                Promoted = true;
                PromotedCategory = Process;
                RunObject = Codeunit "Gen. Jnl.-Apply";
                ShortCutKey = 'Shift+F11';
                ToolTip = 'Apply the payment amount on a journal line to a sales or purchase document that was already posted for a customer or vendor. This updates the amount on the posted document, and the document can either be partially paid, or closed as paid or refunded.';
            }
            action("Insert Conv. LCY Rndg. Lines")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Insert Conv. LCY Rndg. Lines';
                Image = InsertCurrency;
                RunObject = Codeunit "Adjust Gen. Journal Balance";
                ToolTip = 'Insert a rounding correction line in the journal. This rounding correction line will balance in LCY when amounts in the foreign currency also balance. You can then post the journal.';
            }
            group(IncomingDocument)
            {
                Caption = 'Incoming Document';
                Image = Documents;
                action(IncomingDocCard)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'View Incoming Document';
                    Enabled = HasIncomingDocument;
                    Image = ViewOrder;
                    ToolTip = 'View any incoming document records and file attachments that exist for the entry or document.';

                    trigger OnAction()
                    var
                        IncomingDocument: Record "Incoming Document";
                    begin
                        IncomingDocument.ShowCardFromEntryNo("Incoming Document Entry No.");
                    end;
                }
                action(SelectIncomingDoc)
                {
                    AccessByPermission = TableData "Incoming Document" = R;
                    ApplicationArea = Basic, Suite;
                    Caption = 'Select Incoming Document';
                    Image = SelectLineToApply;
                    ToolTip = 'Select an incoming document record and file attachment that you want to link to the entry or document.';

                    trigger OnAction()
                    var
                        IncomingDocument: Record "Incoming Document";
                    begin
                        Validate("Incoming Document Entry No.", IncomingDocument.SelectIncomingDocument("Incoming Document Entry No.", RecordId));
                    end;
                }
                action(IncomingDocAttachFile)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Create Incoming Document from File';
                    Ellipsis = true;
                    Enabled = NOT HasIncomingDocument;
                    Image = Attach;
                    ToolTip = 'Create an incoming document record by selecting a file to attach, and then link the incoming document record to the entry or document.';

                    trigger OnAction()
                    var
                        IncomingDocumentAttachment: Record "Incoming Document Attachment";
                    begin
                        IncomingDocumentAttachment.NewAttachmentFromGenJnlLine(Rec);
                    end;
                }
                action(RemoveIncomingDoc)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Remove Incoming Document';
                    Enabled = HasIncomingDocument;
                    Image = RemoveLine;
                    ToolTip = 'Remove any incoming document records and file attachments.';

                    trigger OnAction()
                    var
                        IncomingDocument: Record "Incoming Document";
                    begin
                        if IncomingDocument.Get("Incoming Document Entry No.") then
                            IncomingDocument.RemoveLinkToRelatedRecord();
                        "Incoming Document Entry No." := 0;
                        Modify(true);
                    end;
                }
            }
        }
        group("P&osting")
        {
            Caption = 'P&osting';
            Image = Post;
            action(Reconcile)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Reconcile';
                Image = Reconcile;
                Promoted = true;
                PromotedCategory = Process;
                PromotedIsBig = true;
                ShortCutKey = 'Ctrl+F11';
                ToolTip = 'View the balances on bank accounts that are marked for reconciliation, usually liquid accounts.';

                trigger OnAction()
                begin
                    GLReconcile.SetGenJnlLine(Rec);
                    GLReconcile.Run();
                end;
            }
            action("Test Report")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Test Report';
                Ellipsis = true;
                Image = TestReport;
                ToolTip = 'View a test report so that you can find and correct any errors before you perform the actual posting of the journal or document.';

                trigger OnAction()
                begin
                    ReportPrint.PrintGenJnlLine(Rec);
                end;
            }
            action(Post)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'P&ost';
                Image = PostOrder;
                Promoted = true;
                PromotedCategory = Category5;
                PromotedIsBig = true;
                ShortCutKey = 'F9';
                ToolTip = 'Finalize the document or journal by posting the amounts and quantities to the related accounts in your company books.';

                trigger OnAction()
                begin
                    CODEUNIT.Run(CODEUNIT::"Gen. Jnl.-Post", Rec);
                    CurrentJnlBatchName := GetRangeMax("Journal Batch Name");
                    SetJobQueueVisibility();
                    //NPO begin
                    //CurrPage.Update(false);
                    //NPO end
                end;
            }
            action(Preview)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Preview Posting';
                Image = ViewPostedOrder;
                Promoted = true;
                PromotedCategory = Category5;
                ToolTip = 'Review the different types of entries that will be created when you post the document or journal.';

                trigger OnAction()
                var
                    GenJnlPost: Codeunit "Gen. Jnl.-Post";
                begin
                    GenJnlPost.Preview(Rec);
                end;
            }
            action("Post and &Print")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Post and &Print';
                Image = PostPrint;
                Promoted = true;
                PromotedCategory = Category5;
                PromotedIsBig = true;
                ShortCutKey = 'Shift+F9';
                ToolTip = 'Finalize and prepare to print the document or journal. The values and quantities are posted to the related accounts. A report request window where you can specify what to include on the print-out.';

                trigger OnAction()
                begin
                    CODEUNIT.Run(CODEUNIT::"Gen. Jnl.-Post+Print", Rec);
                    CurrentJnlBatchName := GetRangeMax("Journal Batch Name");
                    SetJobQueueVisibility();
                    //NPO begin
                    //CurrPage.Update(false);
                    //NPO end
                end;
            }
            action("Remove From Job Queue")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Remove From Job Queue';
                Image = RemoveLine;
                Promoted = true;
                PromotedCategory = Category5;
                PromotedIsBig = true;
                ToolTip = 'Remove the scheduled processing of this record from the job queue.';
                Visible = JobQueueVisible;

                trigger OnAction()
                begin
                    CancelBackgroundPosting();
                    SetJobQueueVisibility();
                    CurrPage.Update(false);
                end;
            }
        }
        group("Page")
        {
            Caption = 'Page';
            action(EditInExcel)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Edit in Excel';
                Image = Excel;
                Promoted = true;
                PromotedCategory = Category4;
                PromotedIsBig = true;
                PromotedOnly = true;
                ToolTip = 'Send the data in the journal to an Excel file for analysis or editing.';
                Visible = IsSaaSExcelAddinEnabled;
                AccessByPermission = System "Allow Action Export To Excel" = X;

                trigger OnAction()
                var
                    ODataUtility: Codeunit ODataUtility;
                begin
                    ODataUtility.EditJournalWorksheetInExcel(CurrPage.Caption, CurrPage.ObjectId(false), "Journal Batch Name", "Journal Template Name");
                end;
            }
            action(ClassicView)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Show more columns';
                Image = SetupColumns;
                Promoted = true;
                PromotedCategory = Category4;
                PromotedIsBig = true;
                PromotedOnly = true;
                ToolTip = 'Adds additional fields to the journal for a full view of the journal data.';
                Visible = IsSimplePage;

                trigger OnAction()
                begin
                    // set journal preference for this page to be NOT simple mode (classic mode)
                    CurrPage.Close();
                    GenJnlManagement.SetJournalSimplePageModePreference(false, PAGE::"Purchase Journal");
                    GenJnlManagement.SetLastViewedJournalBatchName(PAGE::"Purchase Journal", CurrentJnlBatchName);
                    PAGE.Run(PAGE::"Purchase Journal");
                end;
            }
            action(SimpleView)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Show fewer columns';
                Image = SetupList;
                Promoted = true;
                PromotedCategory = Category4;
                PromotedIsBig = true;
                PromotedOnly = true;
                ToolTip = 'Hides many of the less used fields from the journal for better productivity. The fields are still there but not shown.';
                //NPO begin
                //Visible = NOT IsSimplePage;
                //NPO end

                trigger OnAction()
                begin
                    // set journal preference for this page to be simple mode
                    CheckOnChangeToSimpleView();
                    CurrPage.Close();
                    GenJnlManagement.SetJournalSimplePageModePreference(true, PAGE::"Purchase Journal");
                    GenJnlManagement.SetLastViewedJournalBatchName(PAGE::"Purchase Journal", CurrentJnlBatchName);
                    PAGE.Run(PAGE::"Purchase Journal");
                end;
            }
            group(Errors)
            {
                Image = ErrorLog;
                Visible = BackgroundErrorCheck;
                action(ShowLinesWithErrors)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Show Lines with Issues';
                    Image = Error;
                    Promoted = true;
                    PromotedCategory = Category4;
                    Visible = BackgroundErrorCheck;
                    Enabled = not ShowAllLinesEnabled;
                    ToolTip = 'View a list of journal lines that have issues before you post the journal.';

                    trigger OnAction()
                    begin
                        SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);
                    end;
                }
                action(ShowAllLines)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Show All Lines';
                    Image = ExpandAll;
                    Promoted = true;
                    PromotedCategory = Category4;
                    Visible = BackgroundErrorCheck;
                    Enabled = ShowAllLinesEnabled;
                    ToolTip = 'View all journal lines, including lines with and without issues.';

                    trigger OnAction()
                    begin
                        SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);
                    end;
                }
            }
        }
    }
}

trigger OnAfterGetCurrRecord()
begin
    HasIncomingDocument := "Incoming Document Entry No." <> 0;
    GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);
    UpdateBalance();
    EnableApplyEntriesAction();
    CurrPage.IncomingDocAttachFactBox.PAGE.LoadDataFromRecord(Rec);
    SetJobQueueVisibility();
end;

trigger OnAfterGetRecord()
begin
    ShowShortcutDimCode(ShortcutDimCode);
    DocumentAmount := Abs(Amount);
    GenJnlManagement.GetAccounts(Rec, AccName, BalAccName);
    CurrPage.IncomingDocAttachFactBox.PAGE.SetCurrentRecordID(RecordId);
end;

trigger OnInit()
var
    ClientTypeManagement: Codeunit "Client Type Management";
begin
    TotalBalanceVisible := true;
    BalanceVisible := true;
    AmountVisible := true;

    // Get simple / classic mode for this page except when called from a webservices (SOAP or ODATA)
    //NPO begin
    IsSimplePage := false;
    //if ClientTypeManagement.GetCurrentClientType in [CLIENTTYPE::SOAP, CLIENTTYPE::OData, CLIENTTYPE::ODataV4]
    //then
    //    IsSimplePage := false
    //else
    //    IsSimplePage := GenJnlManagement.GetJournalSimplePageModePreference(PAGE::"Purchase Journal");
    //NPO end

    GeneralLedgerSetup.Get();
    SetJobQueueVisibility();
end;

trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
    CurrPage.IncomingDocAttachFactBox.PAGE.SetCurrentRecordID(RecordId);
end;

trigger OnNewRecord(BelowxRec: Boolean)
begin
    UpdateBalance();
    EnableApplyEntriesAction();
    SetUpNewLine(xRec, Balance, BelowxRec);
    Clear(DocumentAmount);
    // Setting account type to Vendor and doc type to invoice on new line when in simple page mode
    if IsSimplePage then begin
        Validate("Account Type", "Account Type"::Vendor);
        Validate("Document Type", "Document Type"::Invoice);
    end;
    Clear(ShortcutDimCode);
end;

trigger OnOpenPage()
var
    ServerSetting: Codeunit "Server Setting";
    JnlSelected: Boolean;
    LastGenJnlBatch: Code[10];
    //NPO begin
    IsHandled: Boolean;
//NPO end
begin
    IsSaaSExcelAddinEnabled := ServerSetting.GetIsSaasExcelAddinEnabled();
    if ClientTypeManagement.GetCurrentClientType = CLIENTTYPE::ODataV4 then
        exit;

    SetControlVisibility;
    SetDimensionsVisibility;
    BalAccName := '';
    if IsOpenedFromBatch then begin
        CurrentJnlBatchName := "Journal Batch Name";
        GenJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);
        SetControlAppearanceFromBatch();
        exit;
    end;
    //NPO begin
    IsHandled := false;
    OnOnOpenPage(IsHandled, CurrentJnlBatchName, GenJnlManagement);
    if IsHandled then begin
        //NPO end
        GenJnlManagement.TemplateSelection(PAGE::"Purchase Journal", "Gen. Journal Template Type"::Purchases, false, Rec, JnlSelected);
        if not JnlSelected then
            Error('');
        //NPO begin
    end;
    //NPO end

    LastGenJnlBatch := GenJnlManagement.GetLastViewedJournalBatchName(PAGE::"Purchase Journal");
    if LastGenJnlBatch <> '' then
        CurrentJnlBatchName := LastGenJnlBatch;
    GenJnlManagement.OpenJnl(CurrentJnlBatchName, Rec);
    //NPO begin
    OnAfterOnOpenPage(CurrentJnlBatchName);
    //NPO end
    SetControlAppearanceFromBatch();
end;

var
    GeneralLedgerSetup: Record "General Ledger Setup";
    GenJnlManagement: Codeunit GenJnlManagement;
    ReportPrint: Codeunit "Test Report-Print";
    ClientTypeManagement: Codeunit "Client Type Management";
    JournalErrorsMgt: Codeunit "Journal Errors Mgt.";
    ChangeExchangeRate: Page "Change Exchange Rate";
    GLReconcile: Page Reconciliation;
    CurrentJnlBatchName: Code[10];
    AccName: Text[100];
    BalAccName: Text[100];
    Balance: Decimal;
    TotalBalance: Decimal;
    NumberOfRecords: Integer;
    ShowBalance: Boolean;
    ShowTotalBalance: Boolean;
    HasIncomingDocument: Boolean;
    ApplyEntriesActionEnabled: Boolean;
    [InDataSet]
    BalanceVisible: Boolean;
    [InDataSet]
    TotalBalanceVisible: Boolean;
    AmountVisible: Boolean;
    DebitCreditVisible: Boolean;
    IsSaaSExcelAddinEnabled: Boolean;
    IsSimplePage: Boolean;
    DocumentAmount: Decimal;
    NegativeDocAmountErr: Label 'You must specify a positive amount as the document amount. If the journal line is for a document type that has a negative amount, the amount will be tracked correctly.';
    JobQueuesUsed: Boolean;
    JobQueueVisible: Boolean;
    BackgroundErrorCheck: Boolean;
    ShowAllLinesEnabled: Boolean;

protected var
    ShortcutDimCode: array[8] of Code[20];
    DimVisible1: Boolean;
    DimVisible2: Boolean;
    DimVisible3: Boolean;
    DimVisible4: Boolean;
    DimVisible5: Boolean;
    DimVisible6: Boolean;
    DimVisible7: Boolean;
    DimVisible8: Boolean;

local procedure UpdateBalance()
begin
    GenJnlManagement.CalcBalance(
      Rec, xRec, Balance, TotalBalance, ShowBalance, ShowTotalBalance);
    BalanceVisible := ShowBalance;
    TotalBalanceVisible := ShowTotalBalance;
    if ShowTotalBalance then
        NumberOfRecords := Count();
end;

local procedure EnableApplyEntriesAction()
begin
    ApplyEntriesActionEnabled :=
      ("Account Type" in ["Account Type"::Customer, "Account Type"::Vendor]) or
      ("Bal. Account Type" in ["Bal. Account Type"::Customer, "Bal. Account Type"::Vendor]);
end;

local procedure CurrentJnlBatchNameOnAfterVali()
begin
    CurrPage.SaveRecord;
    GenJnlManagement.SetName(CurrentJnlBatchName, Rec);
    SetControlAppearanceFromBatch();
    CurrPage.Update(false);
end;

local procedure SetControlVisibility()
var
    GLSetup: Record "General Ledger Setup";
begin
    GLSetup.Get();
    // Hide amount when open in simple page mode.
    if IsSimplePage then begin
        AmountVisible := false;
        DebitCreditVisible := false;
    end else begin
        AmountVisible := not (GLSetup."Show Amounts" = GLSetup."Show Amounts"::"Debit/Credit Only");
        DebitCreditVisible := not (GLSetup."Show Amounts" = GLSetup."Show Amounts"::"Amount Only");
    end;
end;

local procedure SetDimensionsVisibility()
var
    DimMgt: Codeunit DimensionManagement;
begin
    DimVisible1 := false;
    DimVisible2 := false;
    DimVisible3 := false;
    DimVisible4 := false;
    DimVisible5 := false;
    DimVisible6 := false;
    DimVisible7 := false;
    DimVisible8 := false;

    if not IsSimplePage then
        DimMgt.UseShortcutDims(
          DimVisible1, DimVisible2, DimVisible3, DimVisible4, DimVisible5, DimVisible6, DimVisible7, DimVisible8);

    Clear(DimMgt);
end;

local procedure CheckOnChangeToSimpleView()
var
    GenJournalLineCheck: Record "Gen. Journal Line";
begin
    GenJournalLineCheck.Copy(Rec);
    GenJournalLineCheck.SetFilter("Account Type", '<>%1', GenJournalLineCheck."Account Type"::Vendor);
    if GenJournalLineCheck.FindFirst() then
        GenJournalLineCheck.TestField("Account Type", GenJournalLineCheck."Account Type"::Vendor);
end;

local procedure SetControlAppearanceFromBatch()
var
    GenJournalBatch: Record "Gen. Journal Batch";
begin
    if not GenJournalBatch.Get(GetRangeMax("Journal Template Name"), CurrentJnlBatchName) then
        exit;
    BackgroundErrorCheck := GenJournalBatch."Background Error Check";
    ShowAllLinesEnabled := true;
    SwitchLinesWithErrorsFilter(ShowAllLinesEnabled);
    JournalErrorsMgt.SetFullBatchCheck(true);
end;

local procedure SetJobQueueVisibility()
begin
    JobQueueVisible := "Job Queue Status" = "Job Queue Status"::"Scheduled for Posting";
    JobQueuesUsed := GeneralLedgerSetup.JobQueueActive();
end;

[IntegrationEvent(false, false)]
local procedure OnAfterValidateShortcutDimCode(var GenJournalLine: Record "Gen. Journal Line"; var ShortcutDimCode: array[8] of Code[20]; DimIndex: Integer)
begin
end;

//NPO begin
procedure CurrentJnlBatchNameSet(var _currentJnlBatchName: code[10])
begin
    CurrentJnlBatchName := _currentJnlBatchName;
end;

procedure CurrentJnlBatchNameGet(): code[10]
begin
    exit(CurrentJnlBatchName);
end;

[IntegrationEvent(true, false)]
local procedure OnOnOpenPage(var IsHandled: Boolean; var CurrentJnlBatchName: Code[10]; GenJnlManagement: Codeunit GenJnlManagement)
begin
end;

[IntegrationEvent(true, false)]
local procedure OnAfterOnOpenPage(var CurrentJnlBatchName: Code[10])
begin
end;
//NPO end 

}

JesperSchulz commented 3 years ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.