Report 6641 Return Order

Base Application, Microsoft.Purchases.Document

src/Layers/W1/BaseApp/Purchases/Document/ReturnOrder.Report.al966 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Purchases.Document;using Microsoft.CRM.Contact;using Microsoft.CRM.Interaction;using Microsoft.CRM.Segment;using Microsoft.CRM.Team;using Microsoft.Finance.Currency;using Microsoft.Finance.Dimension;using Microsoft.Finance.GeneralLedger.Setup;using Microsoft.Finance.VAT.Calculation;using Microsoft.Foundation.Address;using Microsoft.Foundation.Company;using Microsoft.Inventory.Location;using Microsoft.Purchases.Posting;using Microsoft.Purchases.Vendor;using Microsoft.Utilities;using System.Email;using System.Globalization;using System.Utilities;report 6641 "Return Order"{    Caption = 'Return Order';    PreviewMode = PrintLayout;    WordMergeDataItem = "Purchase Header";    DefaultRenderingLayout = RDLCLayout;    dataset    {        dataitem("Purchase Header"; "Purchase Header")        {            DataItemTableView = sorting("Document Type", "No.") where("Document Type" = const("Return Order"));            RequestFilterFields = "No.", "Buy-from Vendor No.", "No. Printed";            RequestFilterHeading = 'Purchase Return Order';            column(No_PurchHdr; "No.")            {            }            column(DiscPercentCaption; DiscPercentCaptionLbl)            {            }            column(AllowInvoiceDiscCaption; AllowInvoiceDiscCaptionLbl)            {            }            column(VATIdentifierCaption1; VATIdentifierCaption1Lbl)            {            }            column(VATPctCaption; VATPctCaptionLbl)            {            }            column(VATBaseCaption2; VATBaseCaption2Lbl)            {            }            column(VATAmountCaption; VATAmountCaptionLbl)            {            }            column(TotalCaption1; TotalCaption1Lbl)            {            }            dataitem(CopyLoop; "Integer")            {                DataItemTableView = sorting(Number);                dataitem(PageLoop; "Integer")                {                    DataItemTableView = sorting(Number) where(Number = const(1));                    column(DirectUnitCostCaption; DirectUnitCostCaptionLbl)                    {                    }                    column(AmtCaption; AmtCaptionLbl)                    {                    }                    column(PurchLineInvDiscAmtCaption; PurchLineInvDiscAmtCaptionLbl)                    {                    }                    column(SubtotalCaption; SubtotalCaptionLbl)                    {                    }                    column(VATDiscAmtCaption; VATDiscAmtCaptionLbl)                    {                    }                    column(TotalText; TotalText)                    {                    }                    column(ReturnOrderCopyText; StrSubstNo(Text004, CopyText))                    {                    }                    column(CompanyAddr1; CompanyAddr[1])                    {                    }                    column(CompanyAddr2; CompanyAddr[2])                    {                    }                    column(CompanyAddr3; CompanyAddr[3])                    {                    }                    column(CompanyAddr4; CompanyAddr[4])                    {                    }                    column(CompanyInfoPhoneNo; CompanyInfo."Phone No.")                    {                    }                    column(CompanyInfoHomePage; CompanyInfo."Home Page")                    {                    }                    column(CompanyInfoEmail; CompanyInfo."E-Mail")                    {                    }                    column(CompanyInfoVATRegNo; CompanyInfo."VAT Registration No.")                    {                    }                    column(CompanyInfoGiroNo; CompanyInfo."Giro No.")                    {                    }                    column(CompanyInfoBankName; CompanyInfo."Bank Name")                    {                    }                    column(CompanyInfoBankAccountNo; CompanyInfo."Bank Account No.")                    {                    }                    column(DocumentDate_PurchHdr; Format("Purchase Header"."Document Date", 0, 4))                    {                    }                    column(VATNoText; VATNoText)                    {                    }                    column(VATRegNo_PurchHdr; "Purchase Header"."VAT Registration No.")                    {                    }                    column(PurchaserText; PurchaserText)                    {                    }                    column(SalesPurchPersonName; SalesPurchPerson.Name)                    {                    }                    column(No1_PurchHdr; "Purchase Header"."No.")                    {                    }                    column(ReferenceText; ReferenceText)                    {                    }                    column(yourReference_PurchHdr; "Purchase Header"."Your Reference")                    {                    }                    column(CompanyAddr5; CompanyAddr[5])                    {                    }                    column(CompanyAddr6; CompanyAddr[6])                    {                    }                    column(CompanyAddr7; CompanyAddr[7])                    {                    }                    column(CompanyAddr8; CompanyAddr[8])                    {                    }                    column(BuyfromVendNo_PurchHdr; "Purchase Header"."Buy-from Vendor No.")                    {                    }                    column(BuyFromAddr1; BuyFromAddr[1])                    {                    }                    column(BuyFromAddr2; BuyFromAddr[2])                    {                    }                    column(BuyFromAddr3; BuyFromAddr[3])                    {                    }                    column(BuyFromAddr4; BuyFromAddr[4])                    {                    }                    column(BuyFromAddr5; BuyFromAddr[5])                    {                    }                    column(BuyFromAddr6; BuyFromAddr[6])                    {                    }                    column(BuyFromAddr7; BuyFromAddr[7])                    {                    }                    column(BuyFromAddr8; BuyFromAddr[8])                    {                    }                    column(PricesIncVAT_PurchHdr; "Purchase Header"."Prices Including VAT")                    {                    }                    column(PrsInclVATYesNo_PurchHdr; Format("Purchase Header"."Prices Including VAT"))                    {                    }                    column(OutputNo; OutputNo)                    {                    }                    column(PageCaption; StrSubstNo(Text005, ''))                    {                    }                    column(PhoneNoCaption; PhoneNoCaptionLbl)                    {                    }                    column(VATRegNoCaption; VATRegNoCaptionLbl)                    {                    }                    column(GiroNoCaption; GiroNoCaptionLbl)                    {                    }                    column(BankNameCaption; BankNameCaptionLbl)                    {                    }                    column(BankAccNoCaption; BankAccNoCaptionLbl)                    {                    }                    column(ReturnOrderNoCaption; ReturnOrderNoCaptionLbl)                    {                    }                    column(DocumentDateCaption; DocumentDateCaptionLbl)                    {                    }                    column(EmailCaption; EmailCaptionLbl)                    {                    }                    column(HomePageCaption; HomePageCaptionLbl)                    {                    }                    column(BuyfromVendNo_PurchHdrCaption; "Purchase Header".FieldCaption("Buy-from Vendor No."))                    {                    }                    column(PricesIncVAT_PurchHdrCaption; "Purchase Header".FieldCaption("Prices Including VAT"))                    {                    }                    dataitem(DimensionLoop1; "Integer")                    {                        DataItemLinkReference = "Purchase Header";                        DataItemTableView = sorting(Number) where(Number = filter(1 ..));                        column(DimText; DimText)                        {                        }                        column(DimensionLoop1Number; Number)                        {                        }                        column(HdrDimsCaption; HdrDimsCaptionLbl)                        {                        }                        trigger OnAfterGetRecord()                        begin                            if Number = 1 then begin                                if not DimSetEntry1.FindSet() then                                    CurrReport.Break();                            end else                                if not Continue then                                    CurrReport.Break();                            Clear(DimText);                            Continue := false;                            repeat                                OldDimText := DimText;                                if DimText = '' then                                    DimText := StrSubstNo('%1 %2', DimSetEntry1."Dimension Code", DimSetEntry1."Dimension Value Code")                                else                                    DimText :=                                      StrSubstNo(                                        '%1, %2 %3', DimText,                                        DimSetEntry1."Dimension Code", DimSetEntry1."Dimension Value Code");                                if StrLen(DimText) > MaxStrLen(OldDimText) then begin                                    DimText := OldDimText;                                    Continue := true;                                    exit;                                end;                            until DimSetEntry1.Next() = 0;                        end;                        trigger OnPreDataItem()                        begin                            if not ShowInternalInfo then                                CurrReport.Break();                        end;                    }                    dataitem("Purchase Line"; "Purchase Line")                    {                        DataItemLink = "Document Type" = field("Document Type"), "Document No." = field("No.");                        DataItemLinkReference = "Purchase Header";                        DataItemTableView = sorting("Document Type", "Document No.", "Line No.");                        trigger OnPreDataItem()                        begin                            CurrReport.Break();                        end;                    }                    dataitem(RoundLoop; "Integer")                    {                        DataItemTableView = sorting(Number);                        column(TypeInt; TypeInt)                        {                        }                        column(LineAmt_PurchLine; TempPurchaseLine."Line Amount")                        {                            AutoFormatExpression = "Purchase Line"."Currency Code";                            AutoFormatType = 1;                        }                        column(Description_PurchLine; "Purchase Line".Description)                        {                        }                        column(Description_PurchLineCaption; "Purchase Line".FieldCaption(Description))                        {                        }                        column(No_PurchLine; "Purchase Line"."No.")                        {                        }                        column(No_PurchLineCaption; "Purchase Line".FieldCaption("No."))                        {                        }                        column(Quantity_PurchLine; "Purchase Line".Quantity)                        {                        }                        column(Quantity_PurchLineCaption; "Purchase Line".FieldCaption(Quantity))                        {                        }                        column(UnitofMeasure_PurchLine; "Purchase Line"."Unit of Measure")                        {                        }                        column(UnitofMeasure_PurchLineCaption; "Purchase Line".FieldCaption("Unit of Measure"))                        {                        }                        column(DirectUnitCost_PurchLine; "Purchase Line"."Direct Unit Cost")                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 2;                        }                        column(LineDiscount_PurchLine; "Purchase Line"."Line Discount %")                        {                        }                        column(AllowInvDisc_PurchLine; "Purchase Line"."Allow Invoice Disc.")                        {                        }                        column(VATIdentifier_PurchLine; "Purchase Line"."VAT Identifier")                        {                        }                        column(VATIdentifier_PurchLineCaption; "Purchase Line".FieldCaption("VAT Identifier"))                        {                        }                        column(AllInvDiscYesNo_PurchLine; Format("Purchase Line"."Allow Invoice Disc."))                        {                        }                        column(PurchLineInvDiscountAmt; -TempPurchaseLine."Inv. Discount Amount")                        {                            AutoFormatExpression = "Purchase Line"."Currency Code";                            AutoFormatType = 1;                        }                        column(PurchLineLnAmtInvDiscAmt; TempPurchaseLine."Line Amount" - TempPurchaseLine."Inv. Discount Amount")                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(TotalInclVATText; TotalInclVATText)                        {                        }                        column(TotalSubTotal; TotalSubTotal)                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(TotalInvoiceDiscountAmount; TotalInvoiceDiscountAmount)                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(TotalAmount; TotalAmount)                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(VATAmtLineVATAmtText; TempVATAmountLine.VATAmountText())                        {                        }                        column(VATAmt; VATAmount)                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(PurchLnLnAmtInvDiscAmtVATAmt; TempPurchaseLine."Line Amount" - TempPurchaseLine."Inv. Discount Amount" + VATAmount)                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(TotalExclVATText; TotalExclVATText)                        {                        }                        column(VATDiscountAmt; -VATDiscountAmount)                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(VATBaseDisc_PurchHdr; "Purchase Header"."VAT Base Discount %")                        {                        }                        column(VATBaseAmt; VATBaseAmount)                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(TotalAmtInclVAT; TotalAmountInclVAT)                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(AllowInvDisc_PurchLineCaption; "Purchase Line".FieldCaption("Allow Invoice Disc."))                        {                        }                        dataitem(DimensionLoop2; "Integer")                        {                            DataItemTableView = sorting(Number) where(Number = filter(1 ..));                            column(DimText1; DimText)                            {                            }                            column(DimensionLoop2Number; Number)                            {                            }                            column(LineDimsCaption; LineDimsCaptionLbl)                            {                            }                            trigger OnAfterGetRecord()                            begin                                if Number = 1 then begin                                    if not DimSetEntry2.FindSet() then                                        CurrReport.Break();                                end else                                    if not Continue then                                        CurrReport.Break();                                Clear(DimText);                                Continue := false;                                repeat                                    OldDimText := DimText;                                    if DimText = '' then                                        DimText := StrSubstNo('%1 %2', DimSetEntry2."Dimension Code", DimSetEntry2."Dimension Value Code")                                    else                                        DimText :=                                          StrSubstNo(                                            '%1, %2 %3', DimText,                                            DimSetEntry2."Dimension Code", DimSetEntry2."Dimension Value Code");                                    if StrLen(DimText) > MaxStrLen(OldDimText) then begin                                        DimText := OldDimText;                                        Continue := true;                                        exit;                                    end;                                until DimSetEntry2.Next() = 0;                            end;                            trigger OnPreDataItem()                            begin                                if not ShowInternalInfo then                                    CurrReport.Break();                                DimSetEntry2.SetRange("Dimension Set ID", "Purchase Line"."Dimension Set ID");                            end;                        }                        trigger OnAfterGetRecord()                        begin                            if Number = 1 then                                TempPurchaseLine.Find('-')                            else                                TempPurchaseLine.Next();                            "Purchase Line" := TempPurchaseLine;                            if (TempPurchaseLine.Type = TempPurchaseLine.Type::"G/L Account") and (not ShowInternalInfo) then                                "Purchase Line"."No." := '';                            TypeInt := "Purchase Line".Type.AsInteger();                            TotalSubTotal += "Purchase Line"."Line Amount";                            TotalInvoiceDiscountAmount -= "Purchase Line"."Inv. Discount Amount";                            TotalAmount += "Purchase Line".Amount;                        end;                        trigger OnPostDataItem()                        begin                            TempPurchaseLine.DeleteAll();                        end;                        trigger OnPreDataItem()                        begin                            MoreLines := TempPurchaseLine.Find('+');                            while MoreLines and (TempPurchaseLine.Description = '') and (TempPurchaseLine."Description 2" = '') and                                  (TempPurchaseLine."No." = '') and (TempPurchaseLine.Quantity = 0) and                                  (TempPurchaseLine.Amount = 0)                            do                                MoreLines := TempPurchaseLine.Next(-1) <> 0;                            if not MoreLines then                                CurrReport.Break();                            TempPurchaseLine.SetRange("Line No.", 0, TempPurchaseLine."Line No.");                            SetRange(Number, 1, TempPurchaseLine.Count);                        end;                    }                    dataitem(VATCounter; "Integer")                    {                        DataItemTableView = sorting(Number);                        column(VATAmtLineVATBase; TempVATAmountLine."VAT Base")                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(VATAmtLineVATAmt; TempVATAmountLine."VAT Amount")                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(VATAmtLineLineAmt; TempVATAmountLine."Line Amount")                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(VATAmtLineInvDiscBaseAmt; TempVATAmountLine."Inv. Disc. Base Amount")                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(VATAmtLineInvDiscAmt; TempVATAmountLine."Invoice Discount Amount")                        {                            AutoFormatExpression = "Purchase Header"."Currency Code";                            AutoFormatType = 1;                        }                        column(VATAmtLineVAT; TempVATAmountLine."VAT %")                        {                            DecimalPlaces = 0 : 5;                        }                        column(VATAmtLineVATIdentifier; TempVATAmountLine."VAT Identifier")                        {                        }                        column(VATPercentCaption; VATPercentCaptionLbl)                        {                        }                        column(VATBaseCaption; VATBaseCaptionLbl)                        {                        }                        column(VATAmtCaption; VATAmtCaptionLbl)                        {                        }                        column(VATAmtSpecCaption; VATAmtSpecCaptionLbl)                        {                        }                        column(VATIdentifierCaption; VATIdentifierCaptionLbl)                        {                        }                        column(InvDiscBaseAmtCaption; InvDiscBaseAmtCaptionLbl)                        {                        }                        column(LineAmtCaption; LineAmtCaptionLbl)                        {                        }                        column(InvDisAmtCaption; InvDisAmtCaptionLbl)                        {                        }                        column(VATBaseCaption1; VATBaseCaption1Lbl)                        {                        }                        trigger OnAfterGetRecord()                        begin                            TempVATAmountLine.GetLine(Number);                        end;                        trigger OnPreDataItem()                        begin                            if VATAmount = 0 then                                CurrReport.Break();                            SetRange(Number, 1, TempVATAmountLine.Count);                        end;                    }                    dataitem(VATCounterLCY; "Integer")                    {                        DataItemTableView = sorting(Number);                        column(VALExchRate; VALExchRate)                        {                        }                        column(VALSpecLCYHdr; VALSpecLCYHeader)                        {                        }                        column(VALVATAmtLCY; VALVATAmountLCY)                        {                            AutoFormatType = 1;                        }                        column(VALVATBaseLCY; VALVATBaseLCY)                        {                            AutoFormatType = 1;                        }                        column(VATAmtLineVAT1; TempVATAmountLine."VAT %")                        {                            DecimalPlaces = 0 : 5;                        }                        column(VATAmtLineVATIdentifier1; TempVATAmountLine."VAT Identifier")                        {                        }                        trigger OnAfterGetRecord()                        begin                            TempVATAmountLine.GetLine(Number);                            VALVATBaseLCY := Round(CurrExchRate.ExchangeAmtFCYToLCY(                                  "Purchase Header"."Posting Date", "Purchase Header"."Currency Code",                                  TempVATAmountLine."VAT Base", "Purchase Header"."Currency Factor"));                            VALVATAmountLCY := Round(CurrExchRate.ExchangeAmtFCYToLCY(                                  "Purchase Header"."Posting Date", "Purchase Header"."Currency Code",                                  TempVATAmountLine."VAT Amount", "Purchase Header"."Currency Factor"));                        end;                        trigger OnPreDataItem()                        begin                            if (not GLSetup."Print VAT specification in LCY") or                               ("Purchase Header"."Currency Code" = '') or                               (TempVATAmountLine.GetTotalVATAmount() = 0)                            then                                CurrReport.Break();                            SetRange(Number, 1, TempVATAmountLine.Count);                            Clear(VALVATBaseLCY);                            Clear(VALVATAmountLCY);                            if GLSetup."LCY Code" = '' then                                VALSpecLCYHeader := Text007 + Text008                            else                                VALSpecLCYHeader := Text007 + Format(GLSetup."LCY Code");                            CurrExchRate.FindCurrency("Purchase Header"."Posting Date", "Purchase Header"."Currency Code", 1);                            VALExchRate := StrSubstNo(Text009, CurrExchRate."Relational Exch. Rate Amount", CurrExchRate."Exchange Rate Amount");                        end;                    }                    dataitem(Total; "Integer")                    {                        DataItemTableView = sorting(Number) where(Number = const(1));                        trigger OnPreDataItem()                        begin                            if "Purchase Header"."Buy-from Vendor No." = "Purchase Header"."Pay-to Vendor No." then                                CurrReport.Break();                        end;                    }                    dataitem(Total2; "Integer")                    {                        DataItemTableView = sorting(Number) where(Number = const(1));                        column(SelltoCustNo_PurchHdr; "Purchase Header"."Sell-to Customer No.")                        {                        }                        column(ShipToAddr1; ShipToAddr[1])                        {                        }                        column(ShipToAddr2; ShipToAddr[2])                        {                        }                        column(ShipToAddr3; ShipToAddr[3])                        {                        }                        column(ShipToAddr4; ShipToAddr[4])                        {                        }                        column(ShipToAddr5; ShipToAddr[5])                        {                        }                        column(ShipToAddr6; ShipToAddr[6])                        {                        }                        column(ShipToAddr7; ShipToAddr[7])                        {                        }                        column(ShipToAddr8; ShipToAddr[8])                        {                        }                        column(ShiptoAddressCaption; ShiptoAddressCaptionLbl)                        {                        }                        column(ShipToPhoneNo; "Purchase Header"."Ship-to Phone No.")                        {                        }                        column(SelltoCustNo_PurchHdrCaption; "Purchase Header".FieldCaption("Sell-to Customer No."))                        {                        }                        trigger OnPreDataItem()                        begin                            if ("Purchase Header"."Sell-to Customer No." = '') and (ShipToAddr[1] = '') then                                CurrReport.Break();                        end;                    }                }                trigger OnAfterGetRecord()                begin                    Clear(TempPurchaseLine);                    Clear(PurchPost);                    TempPurchaseLine.DeleteAll();                    TempVATAmountLine.DeleteAll();                    PurchPost.GetPurchLines("Purchase Header", TempPurchaseLine, 0);                    TempPurchaseLine.CalcVATAmountLines(0, "Purchase Header", TempPurchaseLine, TempVATAmountLine);                    TempPurchaseLine.UpdateVATOnLines(0, "Purchase Header", TempPurchaseLine, TempVATAmountLine);                    VATAmount := TempVATAmountLine.GetTotalVATAmount();                    VATBaseAmount := TempVATAmountLine.GetTotalVATBase();                    VATDiscountAmount :=                      TempVATAmountLine.GetTotalVATDiscount("Purchase Header"."Currency Code", "Purchase Header"."Prices Including VAT");                    TotalAmountInclVAT := TempVATAmountLine.GetTotalAmountInclVAT();                    if Number > 1 then begin                        CopyText := FormatDocument.GetCOPYText();                        OutputNo += 1;                    end;                    TotalSubTotal := 0;                    TotalInvoiceDiscountAmount := 0;                    TotalAmount := 0;                end;                trigger OnPostDataItem()                begin                    if not IsReportInPreviewMode() then                        CODEUNIT.Run(CODEUNIT::"Purch.Header-Printed", "Purchase Header");                end;                trigger OnPreDataItem()                begin                    NoOfLoops := Abs(NoOfCopies) + 1;                    CopyText := '';                    SetRange(Number, 1, NoOfLoops);                    OutputNo := 1;                end;            }            trigger OnAfterGetRecord()            begin                CurrReport.Language := LanguageMgt.GetLanguageIdOrDefault("Language Code");                CurrReport.FormatRegion := LanguageMgt.GetFormatRegionOrDefault("Format Region");                FormatAddr.SetLanguageCode("Language Code");                FormatAddressFields("Purchase Header");                FormatDocumentFields("Purchase Header");                DimSetEntry1.SetRange("Dimension Set ID", "Dimension Set ID");            end;            trigger OnPostDataItem()            begin                OnAfterPostDataItem("Purchase Header");            end;        }    }    requestpage    {        SaveValues = true;        layout        {            area(content)            {                group(Options)                {                    Caption = 'Options';                    field(NoOfCopies; NoOfCopies)                    {                        ApplicationArea = PurchReturnOrder;                        Caption = 'No. of Copies';                        ToolTip = 'Specifies how many copies of the document to print.';                    }                    field(ShowInternalInfo; ShowInternalInfo)                    {                        ApplicationArea = PurchReturnOrder;                        Caption = 'Show Internal Information';                        ToolTip = 'Specifies if you want the printed report to show information that is only for internal use.';                    }                    field(LogInteraction; LogInteraction)                    {                        ApplicationArea = PurchReturnOrder;                        Caption = 'Log Interaction';                        Enabled = LogInteractionEnable;                        ToolTip = 'Specifies if you want to record the reports that you print as interactions.';                    }                }            }        }        actions        {        }        trigger OnInit()        begin            InitLogInteraction();            LogInteractionEnable := LogInteraction;        end;    }    rendering    {        layout(RDLCLayout)        {            Type = RDLC;            LayoutFile = './Purchases/Document/ReturnOrder.rdlc';            Summary = 'Report layout made in the legacy RDLC format. Use an RDLC editor to modify the layout.';        }    }    labels    {    }    trigger OnInitReport()    begin        GLSetup.Get();        CompanyInfo.Get();        OnAfterInitReport();    end;    trigger OnPostReport()    begin        if LogInteraction and not IsReportInPreviewMode() then            if "Purchase Header".FindSet() then                repeat                    if "Purchase Header"."Buy-from Contact No." <> '' then                        SegManagement.LogDocument(22, "Purchase Header"."No.", 0, 0, Database::Contact,                          "Purchase Header"."Buy-from Contact No.", "Purchase Header"."Purchaser Code", '',                          "Purchase Header"."Posting Description", '')                    else                        SegManagement.LogDocument(22, "Purchase Header"."No.", 0, 0, Database::Vendor,                          "Purchase Header"."Buy-from Vendor No.", "Purchase Header"."Purchaser Code", '',                          "Purchase Header"."Posting Description", '')                until "Purchase Header".Next() = 0;    end;    var        GLSetup: Record "General Ledger Setup";        SalesPurchPerson: Record "Salesperson/Purchaser";        TempVATAmountLine: Record "VAT Amount Line" temporary;        TempPurchaseLine: Record "Purchase Line" temporary;        DimSetEntry1: Record "Dimension Set Entry";        DimSetEntry2: Record "Dimension Set Entry";        RespCenter: Record "Responsibility Center";        CurrExchRate: Record "Currency Exchange Rate";        LanguageMgt: Codeunit Language;        FormatAddr: Codeunit "Format Address";        FormatDocument: Codeunit "Format Document";        PurchPost: Codeunit "Purch.-Post";        SegManagement: Codeunit SegManagement;        VendAddr: array[8] of Text[100];        ShipToAddr: array[8] of Text[100];        CompanyAddr: array[8] of Text[100];        BuyFromAddr: array[8] of Text[100];        PurchaserText: Text[50];        VATNoText: Text[80];        ReferenceText: Text[80];        TotalText: Text[50];        TotalInclVATText: Text[50];        TotalExclVATText: Text[50];        MoreLines: Boolean;        NoOfCopies: Integer;        NoOfLoops: Integer;        CopyText: Text[30];        DimText: Text[120];        OldDimText: Text[75];        ShowInternalInfo: Boolean;        Continue: Boolean;        VATAmount: Decimal;        VATBaseAmount: Decimal;        VATDiscountAmount: Decimal;        TotalAmountInclVAT: Decimal;        VALVATBaseLCY: Decimal;        VALVATAmountLCY: Decimal;        VALSpecLCYHeader: Text[80];        VALExchRate: Text[50];        OutputNo: Integer;        TypeInt: Integer;        LogInteractionEnable: Boolean;#pragma warning disable AA0074        Text004: Label 'Return Order %1', Comment = '%1 = Document No.';#pragma warning disable AA0470        Text005: Label 'Page %1';#pragma warning restore AA0470        Text007: Label 'VAT Amount Specification in ';        Text008: Label 'Local Currency';#pragma warning disable AA0470        Text009: Label 'Exchange rate: %1/%2';#pragma warning restore AA0470#pragma warning restore AA0074        DirectUnitCostCaptionLbl: Label 'Direct Unit Cost';        AmtCaptionLbl: Label 'Amount';        PurchLineInvDiscAmtCaptionLbl: Label 'Invoice Discount Amount';        SubtotalCaptionLbl: Label 'Subtotal';        VATDiscAmtCaptionLbl: Label 'Payment Discount on VAT';        PhoneNoCaptionLbl: Label 'Phone No.';        VATRegNoCaptionLbl: Label 'VAT Reg. No.';        GiroNoCaptionLbl: Label 'Giro No.';        BankNameCaptionLbl: Label 'Bank';        BankAccNoCaptionLbl: Label 'Account No.';        ReturnOrderNoCaptionLbl: Label 'Return Order No.';        DocumentDateCaptionLbl: Label 'Document Date';        EmailCaptionLbl: Label 'Email';        HomePageCaptionLbl: Label 'Home Page';        HdrDimsCaptionLbl: Label 'Header Dimensions';        LineDimsCaptionLbl: Label 'Line Dimensions';        VATPercentCaptionLbl: Label 'VAT %';        VATBaseCaptionLbl: Label 'VAT Base';        VATAmtCaptionLbl: Label 'VAT Amount';        VATAmtSpecCaptionLbl: Label 'VAT Amount Specification';        VATIdentifierCaptionLbl: Label 'VAT Identifier';        InvDiscBaseAmtCaptionLbl: Label 'Invoice Discount Base Amount';        LineAmtCaptionLbl: Label 'Line Amount';        InvDisAmtCaptionLbl: Label 'Invoice Discount Amount';        VATBaseCaption1Lbl: Label 'Total';        ShiptoAddressCaptionLbl: Label 'Ship-to Address';        TotalSubTotal: Decimal;        TotalAmount: Decimal;        TotalInvoiceDiscountAmount: Decimal;        DiscPercentCaptionLbl: Label 'Discount %';        AllowInvoiceDiscCaptionLbl: Label 'Allow Invoice Discount';        VATIdentifierCaption1Lbl: Label 'VAT Identifier';        VATPctCaptionLbl: Label 'VAT %';        VATBaseCaption2Lbl: Label 'VAT Base';        VATAmountCaptionLbl: Label 'VAT Amount';        TotalCaption1Lbl: Label 'Total';    protected var        CompanyInfo: Record "Company Information";        LogInteraction: Boolean;    local procedure InitLogInteraction()    begin        LogInteraction := SegManagement.FindInteractionTemplateCode(Enum::"Interaction Log Entry Document Type"::"Purch. Return Ord. Cnfrmn.") <> '';    end;    local procedure IsReportInPreviewMode(): Boolean    var        MailManagement: Codeunit "Mail Management";    begin        exit(CurrReport.Preview or MailManagement.IsHandlingGetEmailBody());    end;    local procedure FormatAddressFields(PurchaseHeader: Record "Purchase Header")    begin        FormatAddr.GetCompanyAddr(PurchaseHeader."Responsibility Center", RespCenter, CompanyInfo, CompanyAddr);        FormatAddr.PurchHeaderBuyFrom(BuyFromAddr, PurchaseHeader);        if PurchaseHeader."Buy-from Vendor No." <> PurchaseHeader."Pay-to Vendor No." then            FormatAddr.PurchHeaderPayTo(VendAddr, PurchaseHeader);        FormatAddr.PurchHeaderShipTo(ShipToAddr, PurchaseHeader);    end;    local procedure FormatDocumentFields(PurchaseHeader: Record "Purchase Header")    begin        FormatDocument.SetTotalLabels(PurchaseHeader."Currency Code", TotalText, TotalInclVATText, TotalExclVATText);        FormatDocument.SetPurchaser(SalesPurchPerson, PurchaseHeader."Purchaser Code", PurchaserText);        ReferenceText := FormatDocument.SetText(PurchaseHeader."Your Reference" <> '', PurchaseHeader.FieldCaption("Your Reference"));        VATNoText := FormatDocument.SetText(PurchaseHeader."VAT Registration No." <> '', PurchaseHeader.FieldCaption("VAT Registration No."));    end;    [IntegrationEvent(true, false)]    local procedure OnAfterInitReport()    begin    end;    [IntegrationEvent(true, false)]    local procedure OnAfterPostDataItem(var PurchaseHeader: Record "Purchase Header")    begin    end;}