Report 411 Vendor - Payment Receipt

Base Application, Microsoft.Purchases.Reports

src/Layers/W1/BaseApp/Purchases/Reports/VendorPaymentReceipt.Report.al422 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.Reports;using Microsoft.Finance.Currency;using Microsoft.Finance.GeneralLedger.Setup;using Microsoft.Foundation.Address;using Microsoft.Foundation.Company;using Microsoft.Purchases.Payables;using Microsoft.Purchases.Vendor;using System.Utilities;report 411 "Vendor - Payment Receipt"{    Caption = 'Vendor - Payment Receipt';    ToolTip = 'View a document showing which vendor ledger entries that a payment has been applied to.';    ApplicationArea = Suite;    UsageCategory = Documents;    WordMergeDataItem = "Vendor Ledger Entry";    DefaultRenderingLayout = RDLCLayout;    dataset    {        dataitem("Vendor Ledger Entry"; "Vendor Ledger Entry")        {            DataItemTableView = sorting("Document Type", "Vendor No.", "Posting Date", "Currency Code") where("Document Type" = filter(Payment | Refund));            RequestFilterFields = "Vendor No.", "Posting Date", "Document No.";            dataitem(PageLoop; "Integer")            {                DataItemTableView = sorting(Number) where(Number = const(1));                column(VendAddr6; VendAddr[6])                {                }                column(VendAddr7; VendAddr[7])                {                }                column(VendAddr8; VendAddr[8])                {                }                column(VendAddr4; VendAddr[4])                {                }                column(VendAddr5; VendAddr[5])                {                }                column(VendAddr3; VendAddr[3])                {                }                column(VendAddr1; VendAddr[1])                {                }                column(VendAddr2; VendAddr[2])                {                }                column(VendNo_VendLedgEntry; "Vendor Ledger Entry"."Vendor No.")                {                    IncludeCaption = true;                }                column(DocDate_VendLedgEntry; Format("Vendor Ledger Entry"."Document Date", 0, 4))                {                }                column(CompanyAddr1; CompanyAddr[1])                {                }                column(CompanyAddr2; CompanyAddr[2])                {                }                column(CompanyAddr3; CompanyAddr[3])                {                }                column(CompanyAddr4; CompanyAddr[4])                {                }                column(CompanyAddr5; CompanyAddr[5])                {                }                column(CompanyAddr6; CompanyAddr[6])                {                }                column(CompanyAddr7; CompanyAddr[7])                {                }                column(CompanyAddr8; CompanyAddr[8])                {                }                column(PhoneNo; CompanyInfo."Phone No.")                {                }                column(HomePage; CompanyInfo."Home Page")                {                }                column(Email; CompanyInfo."E-Mail")                {                }                column(VATRegistrationNo; CompanyInfo."VAT Registration No.")                {                }                column(GiroNo; CompanyInfo."Giro No.")                {                }                column(BankName; CompanyInfo."Bank Name")                {                }                column(BankAccountNo; CompanyInfo."Bank Account No.")                {                }                column(ReportTitle; ReportTitle)                {                }                column(DocNo_VendLedgEntry; "Vendor Ledger Entry"."Document No.")                {                }                column(PymtDiscTitle; PaymentDiscountTitle)                {                }                column(CompanyInfoPhoneNoCaption; CompanyInfoPhoneNoCaptionLbl)                {                }                column(CompanyInfoGiroNoCaption; CompanyInfoGiroNoCaptionLbl)                {                }                column(CompanyInfoBankNameCaption; CompanyInfoBankNameCaptionLbl)                {                }                column(CompanyInfoBankAccNoCaption; CompanyInfoBankAccNoCaptionLbl)                {                }                column(RcptNoCaption; RcptNoCaptionLbl)                {                }                column(CompanyInfoVATRegNoCaption; CompanyInfoVATRegNoCaptionLbl)                {                }                column(PostingDateCaption; PostingDateCaptionLbl)                {                }                column(AmtCaption; AmtCaptionLbl)                {                }                column(PymtAmtSpecCaption; PymtAmtSpecCaptionLbl)                {                }                column(PymtTolInvCurrCaption; PymtTolInvCurrCaptionLbl)                {                }                dataitem(DetailedVendorLedgEntry1; "Detailed Vendor Ledg. Entry")                {                    DataItemLink = "Applied Vend. Ledger Entry No." = field("Entry No.");                    DataItemLinkReference = "Vendor Ledger Entry";                    DataItemTableView = sorting("Applied Vend. Ledger Entry No.", "Entry Type") where(Unapplied = const(false));                    PrintOnlyIfDetail = true;                    column(AppliedVLENo_DtldVendLedgEntry; "Applied Vend. Ledger Entry No.")                    {                    }                    dataitem(VendLedgEntry1; "Vendor Ledger Entry")                    {                        DataItemLink = "Entry No." = field("Vendor Ledger Entry No.");                        DataItemLinkReference = DetailedVendorLedgEntry1;                        DataItemTableView = sorting("Entry No.");                        column(PostingDate_VendLedgEntry1; Format("Posting Date"))                        {                        }                        column(DocType_VendLedgEntry1; "Document Type")                        {                            IncludeCaption = true;                        }                        column(DocNo_VendLedgEntry1; "Document No.")                        {                            IncludeCaption = true;                        }                        column(Description_VendLedgEntry1; Description)                        {                            IncludeCaption = true;                        }                        column(NegShowAmountVendLedgEntry1; -NegShowAmountVendLedgEntry1)                        {                        }                        column(CurrCode_VendLedgEntry1; CurrencyCode("Currency Code"))                        {                        }                        column(NegPmtDiscInvCurrVendLedgEntry1; -NegPmtDiscInvCurrVendLedgEntry1)                        {                        }                        column(NegPmtTolInvCurrVendLedgEntry1; -NegPmtTolInvCurrVendLedgEntry1)                        {                        }                        trigger OnAfterGetRecord()                        begin                            if "Entry No." = "Vendor Ledger Entry"."Entry No." then                                CurrReport.Skip();                            NegPmtDiscInvCurrVendLedgEntry1 := 0;                            NegPmtTolInvCurrVendLedgEntry1 := 0;                            PmtDiscPmtCurr := 0;                            PmtTolPmtCurr := 0;                            NegShowAmountVendLedgEntry1 := -DetailedVendorLedgEntry1.Amount;                            if "Vendor Ledger Entry"."Currency Code" <> "Currency Code" then begin                                NegPmtDiscInvCurrVendLedgEntry1 := Round("Pmt. Disc. Rcd.(LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                                NegPmtTolInvCurrVendLedgEntry1 := Round("Pmt. Tolerance (LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                                AppliedAmount :=                                  Round(                                    -DetailedVendorLedgEntry1.Amount / "Original Currency Factor" * "Vendor Ledger Entry"."Original Currency Factor",                                    Currency."Amount Rounding Precision");                            end else begin                                NegPmtDiscInvCurrVendLedgEntry1 := Round("Pmt. Disc. Rcd.(LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                                NegPmtTolInvCurrVendLedgEntry1 := Round("Pmt. Tolerance (LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                                AppliedAmount := -DetailedVendorLedgEntry1.Amount;                            end;                            PmtDiscPmtCurr := Round("Pmt. Disc. Rcd.(LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                            PmtTolPmtCurr := Round("Pmt. Tolerance (LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                            RemainingAmount := (RemainingAmount - AppliedAmount) + PmtDiscPmtCurr + PmtTolPmtCurr;                        end;                    }                }                dataitem(DetailedVendorLedgEntry2; "Detailed Vendor Ledg. Entry")                {                    DataItemLink = "Vendor Ledger Entry No." = field("Entry No.");                    DataItemLinkReference = "Vendor Ledger Entry";                    DataItemTableView = sorting("Vendor Ledger Entry No.", "Entry Type", "Posting Date") where(Unapplied = const(false));                    column(VLENo_DtldVendLedgEntry; "Vendor Ledger Entry No.")                    {                    }                    dataitem(VendLedgEntry2; "Vendor Ledger Entry")                    {                        DataItemLink = "Entry No." = field("Applied Vend. Ledger Entry No.");                        DataItemLinkReference = DetailedVendorLedgEntry2;                        DataItemTableView = sorting("Entry No.");                        column(NegAppliedAmt; -AppliedAmount)                        {                        }                        column(Description_VendLedgEntry2; Description)                        {                        }                        column(DocNo_VendLedgEntry2; "Document No.")                        {                        }                        column(DocType_VendLedgEntry2; "Document Type")                        {                        }                        column(PostingDate_VendLedgEntry2; Format("Posting Date"))                        {                        }                        column(CurrCode_VendLedgEntry2; CurrencyCode("Currency Code"))                        {                        }                        column(NegPmtDiscInvCurrVendLedgEntry2; -NegPmtDiscInvCurrVendLedgEntry1)                        {                        }                        column(NegPmtTolInvCurr1VendLedgEntry2; -NegPmtTolInvCurrVendLedgEntry1)                        {                        }                        trigger OnAfterGetRecord()                        begin                            if "Entry No." = "Vendor Ledger Entry"."Entry No." then                                CurrReport.Skip();                            NegPmtDiscInvCurrVendLedgEntry1 := 0;                            NegPmtTolInvCurrVendLedgEntry1 := 0;                            PmtDiscPmtCurr := 0;                            PmtTolPmtCurr := 0;                            NegShowAmountVendLedgEntry1 := DetailedVendorLedgEntry2.Amount;                            if "Vendor Ledger Entry"."Currency Code" <> "Currency Code" then begin                                NegPmtDiscInvCurrVendLedgEntry1 := Round("Pmt. Disc. Rcd.(LCY)" * "Original Currency Factor");                                NegPmtTolInvCurrVendLedgEntry1 := Round("Pmt. Tolerance (LCY)" * "Original Currency Factor");                            end else begin                                NegPmtDiscInvCurrVendLedgEntry1 := Round("Pmt. Disc. Rcd.(LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                                NegPmtTolInvCurrVendLedgEntry1 := Round("Pmt. Tolerance (LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                            end;                            PmtDiscPmtCurr := Round("Pmt. Disc. Rcd.(LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                            PmtTolPmtCurr := Round("Pmt. Tolerance (LCY)" * "Vendor Ledger Entry"."Original Currency Factor");                            AppliedAmount := DetailedVendorLedgEntry2.Amount;                            RemainingAmount := (RemainingAmount - AppliedAmount) + PmtDiscPmtCurr + PmtTolPmtCurr;                        end;                    }                }                dataitem(Total; "Integer")                {                    DataItemTableView = sorting(Number) where(Number = const(1));                    column(NegRemainingAmt; -RemainingAmount)                    {                    }                    column(CurrCode_VendLedgEntry; CurrencyCode("Vendor Ledger Entry"."Currency Code"))                    {                    }                    column(NegOriginalAmt_VendLedgEntry; -"Vendor Ledger Entry"."Original Amount")                    {                    }                    column(ExtDocNo_VendLedgEntry; "Vendor Ledger Entry"."External Document No.")                    {                    }                    column(PymtAmtNotAllocatedCaption; PymtAmtNotAllocatedCaptionLbl)                    {                    }                    column(PymtAmtCaption; PymtAmtCaptionLbl)                    {                    }                    column(ExternalDocNoCaption; ExternalDocNoCaptionLbl)                    {                    }                }            }            trigger OnAfterGetRecord()            begin                Vend.Get("Vendor No.");                FormatAddr.Vendor(VendAddr, Vend);                if not Currency.Get("Currency Code") then                    Currency.InitRoundingPrecision();                if "Document Type" = "Document Type"::Payment then begin                    ReportTitle := Text004;                    PaymentDiscountTitle := Text007;                end else begin                    ReportTitle := Text003;                    PaymentDiscountTitle := Text006;                end;                CalcFields("Original Amount");                RemainingAmount := -"Original Amount";            end;            trigger OnPreDataItem()            begin                CompanyInfo.Get();                FormatAddr.Company(CompanyAddr, CompanyInfo);                GLSetup.Get();            end;        }    }    requestpage    {        layout        {        }        actions        {        }    }    rendering    {        layout(RDLCLayout)        {            Type = RDLC;            LayoutFile = './Purchases/Reports/VendorPaymentReceipt.rdlc';            Summary = 'Report layout made in the legacy RDLC format. Use an RDLC editor to modify the layout.';        }    }    labels    {        CurrencyCodeCaption = 'Currency Code';        PageCaption = 'Page';        DocDateCaption = 'Document Date';        EmailCaption = 'Email';        HomePageCaption = 'Home Page';    }    var        CompanyInfo: Record "Company Information";        GLSetup: Record "General Ledger Setup";        Vend: Record Vendor;        Currency: Record Currency;        FormatAddr: Codeunit "Format Address";        ReportTitle: Text[30];        PaymentDiscountTitle: Text[30];        CompanyAddr: array[8] of Text[100];        VendAddr: array[8] of Text[100];        RemainingAmount: Decimal;        AppliedAmount: Decimal;        NegPmtDiscInvCurrVendLedgEntry1: Decimal;        NegPmtTolInvCurrVendLedgEntry1: Decimal;        PmtDiscPmtCurr: Decimal;#pragma warning disable AA0074        Text003: Label 'Payment Receipt';        Text004: Label 'Payment Voucher';        Text006: Label 'Payment Discount Given';        Text007: Label 'Payment Discount Received';#pragma warning restore AA0074        PmtTolPmtCurr: Decimal;        NegShowAmountVendLedgEntry1: Decimal;        CompanyInfoPhoneNoCaptionLbl: Label 'Phone No.';        CompanyInfoGiroNoCaptionLbl: Label 'Giro No.';        CompanyInfoBankNameCaptionLbl: Label 'Bank';        CompanyInfoBankAccNoCaptionLbl: Label 'Account No.';        RcptNoCaptionLbl: Label 'Receipt No.';        CompanyInfoVATRegNoCaptionLbl: Label 'GST Registration No.';        PostingDateCaptionLbl: Label 'Posting Date';        AmtCaptionLbl: Label 'Amount';        PymtAmtSpecCaptionLbl: Label 'Payment Amount Specification';        PymtTolInvCurrCaptionLbl: Label 'Payment Tolerance';        PymtAmtNotAllocatedCaptionLbl: Label 'Payment Amount Not Allocated';        PymtAmtCaptionLbl: Label 'Payment Amount';        ExternalDocNoCaptionLbl: Label 'External Document No.';    local procedure CurrencyCode(SrcCurrCode: Code[10]): Code[10]    begin        if SrcCurrCode = '' then            exit(GLSetup."LCY Code");        exit(SrcCurrCode);    end;}