Report 408 Purchase - Receipt, source in 29
Source29
src/Layers/W1/BaseApp/Purchases/History/PurchaseReceipt.Report.al672 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.History;
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.Inventory.Location;
using Microsoft.Purchases.Vendor;
using Microsoft.Utilities;
using System.Email;
using System.Globalization;
using System.Utilities;
report 408 "Purchase - Receipt"
{
Caption = 'Purchase - Receipt';
PreviewMode = PrintLayout;
WordMergeDataItem = "Purch. Rcpt. Header";
DefaultRenderingLayout = RDLCLayout;
dataset
{
dataitem("Purch. Rcpt. Header"; "Purch. Rcpt. Header")
{
DataItemTableView = sorting("No.");
RequestFilterFields = "No.", "Buy-from Vendor No.", "No. Printed";
RequestFilterHeading = 'Posted Purchase Receipt';
column(No_PurchRcptHeader; "No.")
{
}
column(DocDateCaption; DocDateCaptionLbl)
{
}
column(PageCaption; PageCaptionLbl)
{
}
column(DescCaption; DescCaptionLbl)
{
}
column(QtyCaption; QtyCaptionLbl)
{
}
column(UOMCaption; UOMCaptionLbl)
{
}
column(PaytoVenNoCaption; PaytoVenNoCaptionLbl)
{
}
column(EmailCaption; EmailCaptionLbl)
{
}
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(PurchRcptCopyText; StrSubstNo(Text002, CopyText))
{
}
column(ShipToAddr1; ShipToAddr[1])
{
}
column(CompanyAddr1; CompanyAddr[1])
{
}
column(ShipToAddr2; ShipToAddr[2])
{
}
column(CompanyAddr2; CompanyAddr[2])
{
}
column(ShipToAddr3; ShipToAddr[3])
{
}
column(CompanyAddr3; CompanyAddr[3])
{
}
column(ShipToAddr4; ShipToAddr[4])
{
}
column(CompanyAddr4; CompanyAddr[4])
{
}
column(ShipToAddr5; ShipToAddr[5])
{
}
column(CompanyInfoPhoneNo; CompanyInfo."Phone No.")
{
}
column(ShipToAddr6; ShipToAddr[6])
{
}
column(CompanyInfoHomePage; CompanyInfo."Home Page")
{
}
column(CompanyInfoEmail; CompanyInfo."E-Mail")
{
}
column(CompanyPicture; DummyCompanyInfo.Picture)
{
}
column(CompanyInfoVATRegNo; CompanyInfo."VAT Registration No.")
{
}
column(CompanyInfoGiroNo; CompanyInfo."Giro No.")
{
}
column(CompanyInfoBankName; CompanyInfo."Bank Name")
{
}
column(CompanyInfoBankAccNo; CompanyInfo."Bank Account No.")
{
}
column(DocDate_PurchRcptHeader; Format("Purch. Rcpt. Header"."Document Date", 0, 4))
{
}
column(PurchaserText; PurchaserText)
{
}
column(SalesPurchPersonName; SalesPurchPerson.Name)
{
}
column(No1_PurchRcptHeader; "Purch. Rcpt. Header"."No.")
{
}
column(ReferenceText; ReferenceText)
{
}
column(YourRef_PurchRcptHeader; "Purch. Rcpt. Header"."Your Reference")
{
}
column(ShipToAddr7; ShipToAddr[7])
{
}
column(ShipToAddr8; ShipToAddr[8])
{
}
column(CompanyAddr5; CompanyAddr[5])
{
}
column(CompanyAddr6; CompanyAddr[6])
{
}
column(CompanyAddr7; CompanyAddr[7])
{
}
column(CompanyAddr8; CompanyAddr[8])
{
}
column(OutputNo; OutputNo)
{
}
column(PhoneNoCaption; PhoneNoCaptionLbl)
{
}
column(HomePageCaption; HomePageCaptionLbl)
{
}
column(VATRegNoCaption; VATRegNoCaptionLbl)
{
}
column(GiroNoCaption; GiroNoCaptionLbl)
{
}
column(BankNameCaption; BankNameCaptionLbl)
{
}
column(AccNoCaption; AccNoCaptionLbl)
{
}
column(ShipmentNoCaption; ShipmentNoCaptionLbl)
{
}
dataitem(DimensionLoop1; "Integer")
{
DataItemLinkReference = "Purch. Rcpt. Header";
DataItemTableView = sorting(Number) where(Number = filter(1 ..));
column(DimText; DimText)
{
}
column(HeaderDimCaption; HeaderDimCaptionLbl)
{
}
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("Purch. Rcpt. Line"; "Purch. Rcpt. Line")
{
DataItemLink = "Document No." = field("No.");
DataItemLinkReference = "Purch. Rcpt. Header";
DataItemTableView = sorting("Document No.", "Line No.");
column(ShowInternalInfo; ShowInternalInfo)
{
}
column(Type_PurchRcptLine; Format(Type, 0, 2))
{
}
column(Desc_PurchRcptLine; Description)
{
IncludeCaption = false;
}
column(Qty_PurchRcptLine; Quantity)
{
IncludeCaption = false;
}
column(UOM_PurchRcptLine; "Unit of Measure")
{
IncludeCaption = false;
}
column(No_PurchRcptLine; "No.")
{
}
column(DocNo_PurchRcptLine; "Document No.")
{
}
column(LineNo_PurchRcptLine; "Line No.")
{
IncludeCaption = false;
}
column(No_PurchRcptLineCaption; FieldCaption("No."))
{
}
dataitem(DimensionLoop2; "Integer")
{
DataItemTableView = sorting(Number) where(Number = filter(1 ..));
column(DimText1; DimText)
{
}
column(LineDimCaption; LineDimCaptionLbl)
{
}
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 (not ShowCorrectionLines) and Correction then
CurrReport.Skip();
DimSetEntry2.SetRange("Dimension Set ID", "Dimension Set ID");
if FirstLineHasBeenOutput then
Clear(DummyCompanyInfo.Picture);
FirstLineHasBeenOutput := true;
end;
trigger OnPreDataItem()
begin
MoreLines := Find('+');
while MoreLines and (Description = '') and ("No." = '') and (Quantity = 0) do
MoreLines := Next(-1) <> 0;
if not MoreLines then
CurrReport.Break();
SetFilter("Line No.", '<=%1', "Line No.");
FirstLineHasBeenOutput := false;
DummyCompanyInfo.Picture := CompanyInfo.Picture;
end;
}
dataitem(Total; "Integer")
{
DataItemTableView = sorting(Number) where(Number = const(1));
column(BuyfromVenNo_PurchRcptHeader; "Purch. Rcpt. Header"."Buy-from Vendor No.")
{
}
column(BuyfromVenNo_PurchRcptHeaderCaption; "Purch. Rcpt. Header".FieldCaption("Buy-from Vendor No."))
{
}
trigger OnPreDataItem()
begin
if "Purch. Rcpt. Header"."Buy-from Vendor No." = "Purch. Rcpt. Header"."Pay-to Vendor No." then
CurrReport.Break();
end;
}
dataitem(Total2; "Integer")
{
DataItemTableView = sorting(Number) where(Number = const(1));
column(PaytoVenNo_PurchRcptHeader; "Purch. Rcpt. Header"."Pay-to Vendor No.")
{
}
column(VendAddr1; VendAddr[1])
{
}
column(VendAddr2; VendAddr[2])
{
}
column(VendAddr3; VendAddr[3])
{
}
column(VendAddr4; VendAddr[4])
{
}
column(VendAddr5; VendAddr[5])
{
}
column(VendAddr6; VendAddr[6])
{
}
column(VendAddr7; VendAddr[7])
{
}
column(VendAddr8; VendAddr[8])
{
}
column(PaytoAddrCaption; PaytoAddrCaptionLbl)
{
}
column(PaytoVenNo_PurchRcptHeaderCaption; "Purch. Rcpt. Header".FieldCaption("Pay-to Vendor No."))
{
}
}
}
trigger OnAfterGetRecord()
begin
FirstLineHasBeenOutput := false;
if Number > 1 then begin
CopyText := FormatDocument.GetCOPYText();
OutputNo += 1;
end;
end;
trigger OnPostDataItem()
begin
if not IsReportInPreviewMode() then
CODEUNIT.Run(CODEUNIT::"Purch.Rcpt.-Printed", "Purch. Rcpt. Header");
end;
trigger OnPreDataItem()
begin
OutputNo := 1;
NoOfLoops := Abs(NoOfCopies) + 1;
CopyText := '';
SetRange(Number, 1, NoOfLoops);
end;
}
trigger OnAfterGetRecord()
begin
FirstLineHasBeenOutput := false;
CurrReport.Language := LanguageMgt.GetLanguageIdOrDefault("Language Code");
CurrReport.FormatRegion := LanguageMgt.GetFormatRegionOrDefault("Format Region");
FormatAddr.SetLanguageCode("Language Code");
FormatAddressFields("Purch. Rcpt. Header");
FormatDocumentFields("Purch. Rcpt. 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");
end;
trigger OnPreDataItem()
begin
FirstLineHasBeenOutput := false;
end;
trigger OnPostDataItem()
begin
OnAfterPostDataItem("Purch. Rcpt. Header");
end;
}
}
requestpage
{
SaveValues = true;
layout
{
area(content)
{
group(Options)
{
Caption = 'Options';
field(NoOfCopies; NoOfCopies)
{
ApplicationArea = Basic, Suite;
Caption = 'No. of Copies';
ToolTip = 'Specifies how many copies of the document to print.';
}
field(ShowInternalInfo; ShowInternalInfo)
{
ApplicationArea = Basic, Suite;
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 = Basic, Suite;
Caption = 'Log Interaction';
Enabled = LogInteractionEnable;
ToolTip = 'Specifies if you want the program to log this interaction.';
}
field(ShowCorrectionLines; ShowCorrectionLines)
{
ApplicationArea = Basic, Suite;
Caption = 'Show Correction Lines';
ToolTip = 'Specifies if the correction lines of an undoing of quantity posting will be shown on the report.';
}
}
}
}
actions
{
}
trigger OnInit()
begin
InitLogInteraction();
LogInteractionEnable := LogInteraction;
end;
}
rendering
{
layout(RDLCLayout)
{
Type = RDLC;
LayoutFile = './Purchases/History/PurchaseReceipt.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();
OnAfterInitReport();
end;
trigger OnPostReport()
begin
if LogInteraction and not IsReportInPreviewMode() then
if "Purch. Rcpt. Header".FindSet() then
repeat
SegManagement.LogDocument(
15, "Purch. Rcpt. Header"."No.", 0, 0, DATABASE::Vendor, "Purch. Rcpt. Header"."Buy-from Vendor No.",
"Purch. Rcpt. Header"."Purchaser Code",
'', "Purch. Rcpt. Header"."Posting Description", '');
until "Purch. Rcpt. Header".Next() = 0;
end;
var
#pragma warning disable AA0074
Text002: Label 'Purchase - Receipt %1', Comment = '%1 = Document No.';
#pragma warning restore AA0074
DummyCompanyInfo: Record "Company Information";
SalesPurchPerson: Record "Salesperson/Purchaser";
DimSetEntry1: Record "Dimension Set Entry";
DimSetEntry2: Record "Dimension Set Entry";
RespCenter: Record "Responsibility Center";
BuyFromContact: Record Contact;
PayToContact: Record Contact;
LanguageMgt: Codeunit Language;
FormatAddr: Codeunit "Format Address";
FormatDocument: Codeunit "Format Document";
SegManagement: Codeunit SegManagement;
VendAddr: array[8] of Text[100];
PurchaserText: Text[50];
ReferenceText: Text[80];
MoreLines: Boolean;
NoOfCopies: Integer;
NoOfLoops: Integer;
CopyText: Text[30];
DimText: Text[120];
OldDimText: Text[75];
ShowInternalInfo: Boolean;
Continue: Boolean;
LogInteraction: Boolean;
ShowCorrectionLines: Boolean;
OutputNo: Integer;
LogInteractionEnable: Boolean;
PhoneNoCaptionLbl: Label 'Phone No.';
HomePageCaptionLbl: Label 'Home Page';
VATRegNoCaptionLbl: Label 'VAT Registration No.';
GiroNoCaptionLbl: Label 'Giro No.';
BankNameCaptionLbl: Label 'Bank';
AccNoCaptionLbl: Label 'Account No.';
ShipmentNoCaptionLbl: Label 'Receipt No.';
HeaderDimCaptionLbl: Label 'Header Dimensions';
LineDimCaptionLbl: Label 'Line Dimensions';
PaytoAddrCaptionLbl: Label 'Pay-to Address';
DocDateCaptionLbl: Label 'Document Date';
PageCaptionLbl: Label 'Page';
DescCaptionLbl: Label 'Description';
QtyCaptionLbl: Label 'Quantity';
UOMCaptionLbl: Label 'Unit Of Measure';
PaytoVenNoCaptionLbl: Label 'Pay-to Vendor No.';
EmailCaptionLbl: Label 'Email';
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";
FirstLineHasBeenOutput: Boolean;
ShipToAddr: array[8] of Text[100];
CompanyAddr: array[8] of Text[100];
procedure InitializeRequest(NewNoOfCopies: Integer; NewShowInternalInfo: Boolean; NewLogInteraction: Boolean; NewShowCorrectionLines: Boolean)
begin
NoOfCopies := NewNoOfCopies;
ShowInternalInfo := NewShowInternalInfo;
LogInteraction := NewLogInteraction;
ShowCorrectionLines := NewShowCorrectionLines;
OnAfterInitializeRequest(NoOfCopies, ShowInternalInfo, LogInteraction, ShowCorrectionLines);
end;
local procedure InitLogInteraction()
begin
LogInteraction := SegManagement.FindInteractionTemplateCode(Enum::"Interaction Log Entry Document Type"::"Purch. Rcpt.") <> '';
end;
local procedure IsReportInPreviewMode(): Boolean
var
MailManagement: Codeunit "Mail Management";
begin
exit(CurrReport.Preview or MailManagement.IsHandlingGetEmailBody());
end;
local procedure FormatAddressFields(var PurchRcptHeader: Record "Purch. Rcpt. Header")
begin
FormatAddr.GetCompanyAddr(PurchRcptHeader."Responsibility Center", RespCenter, CompanyInfo, CompanyAddr);
FormatAddr.PurchRcptShipTo(ShipToAddr, PurchRcptHeader);
FormatAddr.PurchRcptPayTo(VendAddr, PurchRcptHeader);
end;
local procedure FormatDocumentFields(PurchRcptHeader: Record "Purch. Rcpt. Header")
begin
FormatDocument.SetPurchaser(SalesPurchPerson, PurchRcptHeader."Purchaser Code", PurchaserText);
ReferenceText := FormatDocument.SetText(PurchRcptHeader."Your Reference" <> '', PurchRcptHeader.FieldCaption("Your Reference"));
end;
[IntegrationEvent(true, false)]
local procedure OnAfterInitReport()
begin
end;
[IntegrationEvent(true, false)]
local procedure OnAfterPostDataItem(var PurchRcptHeader: Record "Purch. Rcpt. Header")
begin
end;
[IntegrationEvent(true, false)]
local procedure OnAfterInitializeRequest(var NoOfCopies: Integer; var ShowInternalInfo: Boolean; var LogInteraction: Boolean; var ShowCorrectionLines: Boolean)
begin
end;
}