Report 404 Purchase - Quote
src/Layers/W1/BaseApp/Purchases/Document/PurchaseQuote.Report.al805 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.Dimension;using Microsoft.Foundation.Address;using Microsoft.Foundation.Company;using Microsoft.Foundation.Shipping;using Microsoft.Inventory.Location;using Microsoft.Purchases.Posting;using Microsoft.Purchases.Setup;using Microsoft.Purchases.Vendor;using Microsoft.Utilities;using System.Email;using System.Globalization;using System.Utilities;report 404 "Purchase - Quote"{ Caption = 'Purchase - Quote'; PreviewMode = PrintLayout; WordMergeDataItem = "Purchase Header"; DefaultRenderingLayout = RDLCLayout; dataset { dataitem("Purchase Header"; "Purchase Header") { DataItemTableView = sorting("Document Type", "No.") where("Document Type" = const(Quote)); RequestFilterFields = "No.", "Buy-from Vendor No.", "No. Printed"; RequestFilterHeading = 'Purchase Quote'; column(DocType_PurchHead; "Document Type") { } column(PurchHeadNo; "No.") { } column(CompanyInfoPhoneNoCap; CompanyInfoPhoneNoCapLbl) { } column(CompanyInfoVATRegNoCap; CompanyInfoVATRegNoCapLbl) { } column(CompanyInfoGiroNoCap; CompanyInfoGiroNoCapLbl) { } column(CompanyInfoBankNameCap; CompanyInfoBankNameCapLbl) { } column(CompInfoBankAccNoCap; CompInfoBankAccNoCapLbl) { } column(DocumentDateCap; DocumentDateCapLbl) { } column(PageNoCaption; PageNoCaptionLbl) { } column(ShipmentMethodDescCap; ShipmentMethodDescCapLbl) { } column(PurchLineVendItemNoCap; PurchLineVendItemNoCapLbl) { } column(PurchaseLineDescCap; PurchaseLineDescCapLbl) { } column(PurchaseLineQuantityCap; PurchaseLineQuantityCapLbl) { } column(PurchaseLineUOMCaption; PurchaseLineUOMCaptionLbl) { } column(PurchaseLineNoCaption; PurchaseLineNoCaptionLbl) { } column(PurchaserTextCaption; PurchaserTextCaptionLbl) { } column(ReferenceTextCaption; ReferenceTextCaptionLbl) { } column(HomePageCaption; HomePageCaptionLbl) { } column(EMailCaption; EMailCaptionLbl) { } column(VatRegistrationNoCaption; VatRegistrationNoCaptionLbl) { } column(BuyFromContactPhoneNoLbl; BuyFromContactPhoneNoLbl) { } column(BuyFromContactMobilePhoneNoLbl; BuyFromContactMobilePhoneNoLbl) { } column(BuyFromContactEmailLbl; BuyFromContactEmailLbl) { } column(PayToContactPhoneNoLbl; PayToContactPhoneNoLbl) { } column(PayToContactMobilePhoneNoLbl; PayToContactMobilePhoneNoLbl) { } column(PayToContactEmailLbl; PayToContactEmailLbl) { } column(BuyFromContactPhoneNo; BuyFromContact."Phone No.") { } column(BuyFromContactMobilePhoneNo; BuyFromContact."Mobile Phone No.") { } column(BuyFromContactEmail; BuyFromContact."E-Mail") { } column(PayToContactPhoneNo; PayToContact."Phone No.") { } column(PayToContactMobilePhoneNo; PayToContact."Mobile Phone No.") { } column(PayToContactEmail; PayToContact."E-Mail") { } dataitem(CopyLoop; "Integer") { DataItemTableView = sorting(Number); dataitem(PageLoop; "Integer") { DataItemTableView = sorting(Number) where(Number = const(1)); column(PurchaseQuoteCopyText; StrSubstNo(Text002, CopyText)) { } column(VendAddr1; VendAddr[1]) { } column(CompanyAddr1; CompanyAddr[1]) { } column(VendAddr2; VendAddr[2]) { } column(CompanyAddr2; CompanyAddr[2]) { } column(VendAddr3; VendAddr[3]) { } column(CompanyAddr3; CompanyAddr[3]) { } column(VendAddr4; VendAddr[4]) { } column(CompanyAddr4; CompanyAddr[4]) { } column(VendAddr5; VendAddr[5]) { } column(CompanyInfoPhoneNo; CompanyInfo."Phone No.") { IncludeCaption = false; } column(VendAddr6; VendAddr[6]) { } column(CompanyInfoVatRegNo; CompanyInfo."VAT Registration No.") { IncludeCaption = false; } column(CompanyInfoGiroNo; CompanyInfo."Giro No.") { IncludeCaption = false; } column(CompanyInfoBankName; CompanyInfo."Bank Name") { IncludeCaption = false; } column(CompanyInfoBankAccNo; CompanyInfo."Bank Account No.") { IncludeCaption = false; } column(CompanyInfoHomePage; CompanyInfo."Home Page") { } column(CompanyInfoEMail; CompanyInfo."E-Mail") { } column(CompanyPicture; DummyCompanyInfo.Picture) { } column(PaytoVendNo_PurchHdr; "Purchase Header"."Pay-to Vendor No.") { } column(DocDate_PurchHdr; Format("Purchase Header"."Document Date", 0, 4)) { } column(VatNoText; VATNoText) { } column(VatTRegNo_PurchHdr; "Purchase Header"."VAT Registration No.") { } column(ExpctRecpDt_PurchHdr; Format("Purchase Header"."Expected Receipt Date")) { } column(PurchaserText; PurchaserText) { } column(SalesPurchPersonName; SalesPurchPerson.Name) { } column(No1_PurchaseHdr; "Purchase Header"."No.") { } column(ReferenceText; ReferenceText) { } column(YourRef_PurchHdr; "Purchase Header"."Your Reference") { } column(VendAddr7; VendAddr[7]) { } column(VendAddr8; VendAddr[8]) { } column(CompanyAddr5; CompanyAddr[5]) { } column(CompanyAddr6; CompanyAddr[6]) { } column(CompanyAddr7; CompanyAddr[7]) { } column(CompanyAddr8; CompanyAddr[8]) { } column(ShipMethodDesc; ShipmentMethod.Description) { } column(OutpuNo; OutputNo) { } column(BuyfromVendNo_PurchHdr; "Purchase Header"."Buy-from Vendor No.") { } column(ExpectedDateCaption; ExpectedDateCaptionLbl) { } column(QuoteNoCaption; QuoteNoCaptionLbl) { } column(PaytoVendNo_PurchHdrCaption; "Purchase Header".FieldCaption("Pay-to Vendor No.")) { } column(BuyfromVendNo_PurchHdrCaption; "Purchase Header".FieldCaption("Buy-from Vendor No.")) { } dataitem(DimensionLoop1; "Integer") { DataItemLinkReference = "Purchase Header"; DataItemTableView = sorting(Number) where(Number = filter(1 ..)); column(DimText; DimText) { } column(Number_DimensionLoop1; Number) { } column(HeaderDimensionsCaption; HeaderDimensionsCaptionLbl) { } 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 OnAfterGetRecord() begin if FirstLineHasBeenOutput then Clear(DummyCompanyInfo.Picture); FirstLineHasBeenOutput := true; end; trigger OnPreDataItem() begin FirstLineHasBeenOutput := false; DummyCompanyInfo.Picture := CompanyInfo.Picture; CurrReport.Break(); end; } dataitem(RoundLoop; "Integer") { DataItemTableView = sorting(Number); column(ShowInternalInfo; ShowInternalInfo) { } column(ArchiveDocument; ArchiveDocument) { } column(LogInteraction; LogInteraction) { } column(Type_PurchaseLine; Format("Purchase Line".Type, 0, 2)) { IncludeCaption = false; } column(LineNo_PurchaseLine; "Purchase Line"."Line No.") { IncludeCaption = false; } column(Description_PurchaseLine; "Purchase Line".Description) { IncludeCaption = false; } column(Quantity_PurchaseLine; "Purchase Line".Quantity) { IncludeCaption = false; } column(UnitOfMeasure_PurchaseLine; "Purchase Line"."Unit of Measure") { IncludeCaption = false; } column(ExpcRecpDt_PurchHdr; Format("Purchase Line"."Expected Receipt Date")) { IncludeCaption = false; } column(No_PurchaseLine; "Purchase Line"."No.") { } column(VendItemNo_PurchLine; "Purchase Line"."Vendor Item No.") { IncludeCaption = false; } column(PurchaseLineNoOurNoCap; PurchaseLineNoOurNoCapLbl) { } dataitem(DimensionLoop2; "Integer") { DataItemTableView = sorting(Number) where(Number = filter(1 ..)); column(DimText1; DimText) { } column(Number2_DimensionLoop; Number) { } column(LineDimensionsCaption; LineDimensionsCaptionLbl) { } 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(); end; } trigger OnAfterGetRecord() begin if Number = 1 then TempPurchaseLine.Find('-') else TempPurchaseLine.Next(); OnRoundLoopOnAfterGetRecordOnBeforeAssignPurchaseLine(TempPurchaseLine, "Purchase Line"); "Purchase Line" := TempPurchaseLine; if ("Purchase Line"."Item Reference No." <> '') and (not ShowInternalInfo) then "Purchase Line"."No." := CopyStr("Purchase Line"."Item Reference No.", 1, MaxStrLen("Purchase Line"."No.")); DimSetEntry2.SetRange("Dimension Set ID", "Purchase Line"."Dimension Set ID"); 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(Total3; "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.") { } trigger OnPreDataItem() begin if ("Purchase Header"."Sell-to Customer No." = '') and (ShipToAddr[1] = '') then CurrReport.Break(); end; } } trigger OnAfterGetRecord() begin FirstLineHasBeenOutput := false; Clear(TempPurchaseLine); Clear(PurchPost); TempPurchaseLine.DeleteAll(); PurchPost.GetPurchLines("Purchase Header", TempPurchaseLine, 0); if Number > 1 then begin CopyText := FormatDocument.GetCOPYText(); OutputNo += 1; end; 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 FirstLineHasBeenOutput := false; CurrReport.Language := LanguageMgt.GetLanguageIdOrDefault("Language Code"); CurrReport.FormatRegion := LanguageMgt.GetFormatRegionOrDefault("Format Region"); FormatAddr.SetLanguageCode("Language Code"); FormatAddressFields("Purchase Header"); FormatDocumentFields("Purchase Header"); if BuyFromContact.Get("Buy-from Contact No.") then; if PayToContact.Get("Pay-to Contact No.") then; DimSetEntry1.SetRange("Dimension Set ID", "Dimension Set ID"); if not IsReportInPreviewMode() then if ArchiveDocument then ArchiveManagement.StorePurchDocument("Purchase Header", LogInteraction); end; trigger OnPreDataItem() begin FirstLineHasBeenOutput := false; end; trigger OnPostDataItem() begin OnAfterPostDataItem("Purchase Header"); end; } } requestpage { SaveValues = true; layout { area(content) { group(Options) { Caption = 'Options'; field(NoOfCopies; NoOfCopies) { ApplicationArea = Suite; Caption = 'No. of Copies'; ToolTip = 'Specifies how many copies of the document to print.'; } field(ShowInternalInfo; ShowInternalInfo) { ApplicationArea = Suite; Caption = 'Show Internal Information'; ToolTip = 'Specifies if you want the printed report to show information that is only for internal use.'; } field(ArchiveDocument; ArchiveDocument) { ApplicationArea = Suite; Caption = 'Archive Document'; ToolTip = 'Specifies if the document is archived after you print it.'; trigger OnValidate() begin if not ArchiveDocument then LogInteraction := false; end; } field(LogInteraction; LogInteraction) { ApplicationArea = Suite; Caption = 'Log Interaction'; Enabled = LogInteractionEnable; ToolTip = 'Specifies if you want the program to log this interaction.'; trigger OnValidate() begin if LogInteraction then ArchiveDocument := ArchiveDocumentEnable; end; } } } } actions { } trigger OnInit() begin InitLogInteraction(); LogInteractionEnable := LogInteraction; case PurchSetup."Archive Quotes" of PurchSetup."Archive Quotes"::Never: ArchiveDocument := false; PurchSetup."Archive Quotes"::Always: ArchiveDocument := true; end; end; } rendering { layout(RDLCLayout) { Type = RDLC; LayoutFile = './Purchases/Document/PurchaseQuote.rdlc'; Summary = 'Report layout made in the legacy RDLC format. Use an RDLC editor to modify the layout.'; } } labels { } trigger OnInitReport() begin CompanyInfo.SetAutoCalcFields(Picture); CompanyInfo.Get(); PurchSetup.Get(); OnAfterInitReport(); end; trigger OnPostReport() begin if LogInteraction and not IsReportInPreviewMode() then if "Purchase Header".FindSet() then repeat "Purchase Header".CalcFields("No. of Archived Versions"); SegManagement.LogDocument( 11, "Purchase Header"."No.", "Purchase Header"."Doc. No. Occurrence", "Purchase Header"."No. of Archived Versions", DATABASE::Vendor, "Purchase Header"."Pay-to Vendor No.", "Purchase Header"."Purchaser Code", '', "Purchase Header"."Posting Description", ''); until "Purchase Header".Next() = 0; end; var#pragma warning disable AA0074 Text002: Label 'Purchase - Quote %1', Comment = '%1 = Document No.';#pragma warning restore AA0074 DummyCompanyInfo: Record "Company Information"; ShipmentMethod: Record "Shipment Method"; SalesPurchPerson: Record "Salesperson/Purchaser"; TempPurchaseLine: Record "Purchase Line" temporary; DimSetEntry1: Record "Dimension Set Entry"; DimSetEntry2: Record "Dimension Set Entry"; RespCenter: Record "Responsibility Center"; PurchSetup: Record "Purchases & Payables Setup"; BuyFromContact: Record Contact; PayToContact: Record Contact; LanguageMgt: Codeunit Language; PurchPost: Codeunit "Purch.-Post"; FormatAddr: Codeunit "Format Address"; FormatDocument: Codeunit "Format Document"; SegManagement: Codeunit SegManagement; ArchiveManagement: Codeunit ArchiveManagement; VendAddr: array[8] of Text[100]; ShipToAddr: array[8] of Text[100]; CompanyAddr: array[8] of Text[100]; PurchaserText: Text[50]; VATNoText: Text[80]; ReferenceText: Text[80]; MoreLines: Boolean; NoOfLoops: Integer; CopyText: Text[30]; DimText: Text[120]; OldDimText: Text[75]; Continue: Boolean; OutputNo: Integer; LogInteractionEnable: Boolean; ExpectedDateCaptionLbl: Label 'Expected Date'; QuoteNoCaptionLbl: Label 'Quote No.'; HeaderDimensionsCaptionLbl: Label 'Header Dimensions'; PurchaseLineNoOurNoCapLbl: Label 'Our No.'; LineDimensionsCaptionLbl: Label 'Line Dimensions'; ShiptoAddressCaptionLbl: Label 'Ship-to Address'; CompanyInfoPhoneNoCapLbl: Label 'Phone No.'; CompanyInfoVATRegNoCapLbl: Label 'VAT Reg. No.'; CompanyInfoGiroNoCapLbl: Label 'Giro No.'; CompanyInfoBankNameCapLbl: Label 'Bank'; CompInfoBankAccNoCapLbl: Label 'Account No.'; DocumentDateCapLbl: Label 'Document Date'; PageNoCaptionLbl: Label 'Page'; ShipmentMethodDescCapLbl: Label 'Shipment Method'; PurchLineVendItemNoCapLbl: Label 'Vendor Item No.'; PurchaseLineDescCapLbl: Label 'Description'; PurchaseLineQuantityCapLbl: Label 'Quantity'; PurchaseLineUOMCaptionLbl: Label 'Unit of Measure'; PurchaseLineNoCaptionLbl: Label 'Item No.'; PurchaserTextCaptionLbl: Label 'Purchaser'; ReferenceTextCaptionLbl: Label 'Your Reference'; HomePageCaptionLbl: Label 'Home Page'; EMailCaptionLbl: Label 'Email'; VatRegistrationNoCaptionLbl: Label 'VAT Registration No.'; BuyFromContactPhoneNoLbl: Label 'Buy-from Contact Phone No.'; BuyFromContactMobilePhoneNoLbl: Label 'Buy-from Contact Mobile Phone No.'; BuyFromContactEmailLbl: Label 'Buy-from Contact E-Mail'; PayToContactPhoneNoLbl: Label 'Pay-to Contact Phone No.'; PayToContactMobilePhoneNoLbl: Label 'Pay-to Contact Mobile Phone No.'; PayToContactEmailLbl: Label 'Pay-to Contact E-Mail'; protected var CompanyInfo: Record "Company Information"; ArchiveDocument: Boolean; ArchiveDocumentEnable: Boolean; LogInteraction: Boolean; NoOfCopies: Integer; ShowInternalInfo: Boolean; FirstLineHasBeenOutput: Boolean; procedure IntializeRequest(NewNoOfCopies: Integer; NewShowInternalInfo: Boolean; NewArchiveDocument: Boolean; NewLogInteraction: Boolean) begin NoOfCopies := NewNoOfCopies; ShowInternalInfo := NewShowInternalInfo; ArchiveDocument := NewArchiveDocument; LogInteraction := NewLogInteraction; end; local procedure IsReportInPreviewMode(): Boolean var MailManagement: Codeunit "Mail Management"; begin exit(CurrReport.Preview or MailManagement.IsHandlingGetEmailBody()); end; local procedure InitLogInteraction() begin LogInteraction := SegManagement.FindInteractionTemplateCode(Enum::"Interaction Log Entry Document Type"::"Purch.Qte.") <> ''; end; local procedure FormatAddressFields(PurchaseHeader: Record "Purchase Header") begin FormatAddr.GetCompanyAddr(PurchaseHeader."Responsibility Center", RespCenter, CompanyInfo, CompanyAddr); FormatAddr.PurchHeaderPayTo(VendAddr, PurchaseHeader); FormatAddr.PurchHeaderShipTo(ShipToAddr, PurchaseHeader); end; local procedure FormatDocumentFields(PurchaseHeader: Record "Purchase Header") begin FormatDocument.SetPurchaser(SalesPurchPerson, PurchaseHeader."Purchaser Code", PurchaserText); FormatDocument.SetShipmentMethod(ShipmentMethod, PurchaseHeader."Shipment Method Code", PurchaseHeader."Language Code"); 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; [IntegrationEvent(false, false)] local procedure OnRoundLoopOnAfterGetRecordOnBeforeAssignPurchaseLine(var TempPurchaseLine: Record "Purchase Line" temporary; var PurchaseLine: Record "Purchase Line") begin end;}