Page 126 Cust. Ledg. Entries Preview, source in 29
Source29
src/Layers/W1/BaseApp/Sales/Receivables/CustLedgEntriesPreview.Page.al497 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.Sales.Receivables;
using Microsoft.Finance.Dimension;
using Microsoft.Finance.GeneralLedger.Preview;
/// <summary>
/// Displays a preview of customer ledger entries that will be created when posting a transaction, using temporary records.
/// </summary>
page 126 "Cust. Ledg. Entries Preview"
{
Caption = 'Cust. Ledg. Entries Preview';
DataCaptionFields = "Customer No.";
Editable = false;
PageType = List;
SourceTable = "Cust. Ledger Entry";
SourceTableTemporary = true;
layout
{
area(content)
{
repeater(Control1)
{
ShowCaption = false;
field("Posting Date"; Rec."Posting Date")
{
ApplicationArea = Basic, Suite;
Editable = false;
}
field("Document Type"; Rec."Document Type")
{
ApplicationArea = Basic, Suite;
Editable = false;
StyleExpr = StyleTxt;
}
field("Document No."; Rec."Document No.")
{
ApplicationArea = Basic, Suite;
Editable = false;
StyleExpr = StyleTxt;
}
field("Customer No."; Rec."Customer No.")
{
ApplicationArea = Basic, Suite;
Editable = false;
}
field("Message to Recipient"; Rec."Message to Recipient")
{
ApplicationArea = Basic, Suite;
}
field(Description; Rec.Description)
{
ApplicationArea = Basic, Suite;
}
field("Global Dimension 1 Code"; Rec."Global Dimension 1 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Visible = Dim1Visible;
}
field("Global Dimension 2 Code"; Rec."Global Dimension 2 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Visible = Dim2Visible;
}
field("Customer Posting Group"; Rec."Customer Posting Group")
{
ApplicationArea = Basic, Suite;
Editable = false;
Visible = false;
}
field("IC Partner Code"; Rec."IC Partner Code")
{
ApplicationArea = Intercompany;
Editable = false;
Visible = false;
}
field("Salesperson Code"; Rec."Salesperson Code")
{
ApplicationArea = Suite;
Editable = false;
Visible = false;
}
field("Currency Code"; Rec."Currency Code")
{
ApplicationArea = Suite;
}
field(OriginalAmountFCY; OriginalAmountFCY)
{
ApplicationArea = Basic, Suite;
Caption = 'Original Amount';
Editable = false;
ToolTip = 'Specifies the amount on the customer ledger entry before you post.';
AutoFormatExpression = Rec."Currency Code";
AutoFormatType = 1;
trigger OnDrillDown()
begin
DrilldownAmounts(2);
end;
}
field(OriginalAmountLCY; OriginalAmountLCY)
{
ApplicationArea = Basic, Suite;
AutoFormatType = 1;
AutoFormatExpression = '';
Caption = 'Original Amount LCY';
Editable = false;
ToolTip = 'Specifies the original amount linked to the customer ledger entry, in local currency.';
Visible = false;
trigger OnDrillDown()
begin
DrilldownAmounts(2);
end;
}
field(AmountFCY; AmountFCY)
{
ApplicationArea = Basic, Suite;
Caption = 'Amount';
DrillDown = true;
Editable = false;
ToolTip = 'Specifies the net amount of all the lines in the customer entry.';
AutoFormatExpression = Rec."Currency Code";
AutoFormatType = 1;
trigger OnDrillDown()
begin
DrilldownAmounts(0);
end;
}
field(AmountLCY; AmountLCY)
{
ApplicationArea = Basic, Suite;
AutoFormatType = 1;
AutoFormatExpression = '';
Caption = 'Amount LCY';
DrillDown = true;
Editable = false;
ToolTip = 'Specifies the amount linked to the customer ledger entry on the line, in local currency.';
Visible = false;
trigger OnDrillDown()
begin
DrilldownAmounts(0);
end;
}
field("Debit Amount"; Rec."Debit Amount")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Debit Amount (LCY)"; Rec."Debit Amount (LCY)")
{
ApplicationArea = Basic, Suite;
AutoFormatType = 1;
AutoFormatExpression = '';
Visible = false;
}
field("Credit Amount"; Rec."Credit Amount")
{
ApplicationArea = Basic, Suite;
Visible = false;
}
field("Credit Amount (LCY)"; Rec."Credit Amount (LCY)")
{
ApplicationArea = Basic, Suite;
AutoFormatType = 1;
AutoFormatExpression = '';
Visible = false;
}
field(RemainingAmountFCY; RemainingAmountFCY)
{
ApplicationArea = Basic, Suite;
Caption = 'Remaining Amount';
Editable = false;
ToolTip = 'Specifies the remaining amount on the customer ledger entry before you post.';
AutoFormatExpression = Rec."Currency Code";
AutoFormatType = 1;
trigger OnDrillDown()
begin
DrilldownAmounts(1);
end;
}
field(RemainingAmountLCY; RemainingAmountLCY)
{
ApplicationArea = Basic, Suite;
AutoFormatType = 1;
AutoFormatExpression = '';
Caption = 'Remaining Amount LCY';
Editable = false;
ToolTip = 'Specifies the remaining amount linked to the customer ledger entry on the line, in local currency.';
Visible = false;
trigger OnDrillDown()
begin
DrilldownAmounts(1);
end;
}
field("Bal. Account Type"; Rec."Bal. Account Type")
{
ApplicationArea = Basic, Suite;
Editable = false;
Visible = false;
}
field("Bal. Account No."; Rec."Bal. Account No.")
{
ApplicationArea = Basic, Suite;
Editable = false;
Visible = false;
}
field("Due Date"; Rec."Due Date")
{
ApplicationArea = Basic, Suite;
StyleExpr = StyleTxt;
}
field("Pmt. Discount Date"; Rec."Pmt. Discount Date")
{
ApplicationArea = Basic, Suite;
}
field("Pmt. Disc. Tolerance Date"; Rec."Pmt. Disc. Tolerance Date")
{
ApplicationArea = Basic, Suite;
}
field("Original Pmt. Disc. Possible"; Rec."Original Pmt. Disc. Possible")
{
ApplicationArea = Basic, Suite;
}
field("Remaining Pmt. Disc. Possible"; Rec."Remaining Pmt. Disc. Possible")
{
ApplicationArea = Basic, Suite;
}
field("Max. Payment Tolerance"; Rec."Max. Payment Tolerance")
{
ApplicationArea = Basic, Suite;
}
field("Payment Method Code"; Rec."Payment Method Code")
{
ApplicationArea = Basic, Suite;
}
field(Open; Rec.Open)
{
ApplicationArea = Basic, Suite;
}
field("On Hold"; Rec."On Hold")
{
ApplicationArea = Basic, Suite;
}
field("Exported to Payment File"; Rec."Exported to Payment File")
{
ApplicationArea = Basic, Suite;
}
field("Source Code"; Rec."Source Code")
{
ApplicationArea = Suite;
Editable = false;
Visible = false;
}
field("Reason Code"; Rec."Reason Code")
{
ApplicationArea = Suite;
Editable = false;
Visible = false;
}
field("Dimension Set ID"; Rec."Dimension Set ID")
{
ApplicationArea = Dimensions;
Visible = false;
}
field("External Document No."; Rec."External Document No.")
{
ApplicationArea = Basic, Suite;
Editable = false;
Visible = false;
}
field("Your Reference"; Rec."Your Reference")
{
ApplicationArea = Basic, Suite;
Editable = false;
Visible = false;
}
field("Shortcut Dimension 3 Code"; Rec."Shortcut Dimension 3 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Visible = Dim3Visible;
}
field("Shortcut Dimension 4 Code"; Rec."Shortcut Dimension 4 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Visible = Dim4Visible;
}
field("Shortcut Dimension 5 Code"; Rec."Shortcut Dimension 5 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Visible = Dim5Visible;
}
field("Shortcut Dimension 6 Code"; Rec."Shortcut Dimension 6 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Visible = Dim6Visible;
}
field("Shortcut Dimension 7 Code"; Rec."Shortcut Dimension 7 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Visible = Dim7Visible;
}
field("Shortcut Dimension 8 Code"; Rec."Shortcut Dimension 8 Code")
{
ApplicationArea = Dimensions;
Editable = false;
Visible = Dim8Visible;
}
}
}
}
actions
{
area(navigation)
{
group("Ent&ry")
{
Caption = 'Ent&ry';
Image = Entry;
action(Dimensions)
{
ApplicationArea = Dimensions;
Caption = 'Dimensions';
Ellipsis = true;
Image = Dimensions;
ShortCutKey = 'Alt+D';
ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';
trigger OnAction()
var
GenJnlPostPreview: Codeunit "Gen. Jnl.-Post Preview";
begin
GenJnlPostPreview.ShowDimensions(DATABASE::"Cust. Ledger Entry", Rec."Entry No.", Rec."Dimension Set ID");
end;
}
action(SetDimensionFilter)
{
ApplicationArea = Dimensions;
Caption = 'Set Dimension Filter';
Ellipsis = true;
Image = "Filter";
ToolTip = 'Limit the entries according to the dimension filters that you specify. NOTE: If you use a high number of dimension combinations, this function may not work and can result in a message that the SQL server only supports a maximum of 2100 parameters.';
trigger OnAction()
begin
Rec.SetFilter("Dimension Set ID", DimensionSetIDFilter.LookupFilter());
end;
}
}
}
area(Promoted)
{
group(Category_Process)
{
Caption = 'Process';
actionref(Dimensions_Promoted; Dimensions)
{
}
actionref(SetDimensionFilter_Promoted; SetDimensionFilter)
{
}
}
}
}
trigger OnAfterGetRecord()
begin
StyleTxt := Rec.SetStyle();
CalcAmounts();
end;
trigger OnOpenPage()
begin
SetDimVisibility();
end;
var
TempDetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry" temporary;
DimensionSetIDFilter: Page "Dimension Set ID Filter";
StyleTxt: Text;
AmountFCY: Decimal;
AmountLCY: Decimal;
RemainingAmountFCY: Decimal;
RemainingAmountLCY: Decimal;
OriginalAmountLCY: Decimal;
OriginalAmountFCY: Decimal;
protected var
Dim1Visible: Boolean;
Dim2Visible: Boolean;
Dim3Visible: Boolean;
Dim4Visible: Boolean;
Dim5Visible: Boolean;
Dim6Visible: Boolean;
Dim7Visible: Boolean;
Dim8Visible: Boolean;
local procedure SetDimVisibility()
var
DimensionManagement: Codeunit DimensionManagement;
begin
DimensionManagement.UseShortcutDims(Dim1Visible, Dim2Visible, Dim3Visible, Dim4Visible, Dim5Visible, Dim6Visible, Dim7Visible, Dim8Visible);
end;
/// <summary>
/// Sets the preview data from temporary customer ledger entries and detailed entries.
/// </summary>
/// <param name="TempCustLedgerEntry">The temporary customer ledger entries to display.</param>
/// <param name="TempDetailedCustLedgEntry2">The temporary detailed customer ledger entries for amount calculations.</param>
procedure Set(var TempCustLedgerEntry: Record "Cust. Ledger Entry" temporary; var TempDetailedCustLedgEntry2: Record "Detailed Cust. Ledg. Entry" temporary)
begin
if TempCustLedgerEntry.FindSet() then
repeat
Rec := TempCustLedgerEntry;
Rec.Insert();
until TempCustLedgerEntry.Next() = 0;
if TempDetailedCustLedgEntry2.Find('-') then
repeat
TempDetailedCustLedgEntry := TempDetailedCustLedgEntry2;
TempDetailedCustLedgEntry.Insert();
until TempDetailedCustLedgEntry2.Next() = 0;
end;
/// <summary>
/// Calculates the amounts for the current customer ledger entry from the detailed entries.
/// </summary>
procedure CalcAmounts()
begin
AmountFCY := 0;
AmountLCY := 0;
RemainingAmountLCY := 0;
RemainingAmountFCY := 0;
OriginalAmountLCY := 0;
OriginalAmountFCY := 0;
TempDetailedCustLedgEntry.SetRange("Cust. Ledger Entry No.", Rec."Entry No.");
if TempDetailedCustLedgEntry.FindSet() then
repeat
if TempDetailedCustLedgEntry."Entry Type" = TempDetailedCustLedgEntry."Entry Type"::"Initial Entry" then begin
OriginalAmountFCY += TempDetailedCustLedgEntry.Amount;
OriginalAmountLCY += TempDetailedCustLedgEntry."Amount (LCY)";
end;
if not (TempDetailedCustLedgEntry."Entry Type" in [TempDetailedCustLedgEntry."Entry Type"::Application,
TempDetailedCustLedgEntry."Entry Type"::"Appln. Rounding"])
then begin
AmountFCY += TempDetailedCustLedgEntry.Amount;
AmountLCY += TempDetailedCustLedgEntry."Amount (LCY)";
end;
RemainingAmountFCY += TempDetailedCustLedgEntry.Amount;
RemainingAmountLCY += TempDetailedCustLedgEntry."Amount (LCY)";
until TempDetailedCustLedgEntry.Next() = 0;
OnAfterCalcAmounts(Rec, TempDetailedCustLedgEntry, AmountFCY, AmountLCY, RemainingAmountFCY, RemainingAmountLCY, OriginalAmountFCY, OriginalAmountLCY);
end;
local procedure DrilldownAmounts(AmountType: Option Amount,"Remaining Amount","Original Amount")
var
DetCustLedgEntrPreview: Page "Det. Cust. Ledg. Entr. Preview";
begin
case AmountType of
AmountType::Amount:
TempDetailedCustLedgEntry.SetFilter("Entry Type", '<>%1&<>%2',
TempDetailedCustLedgEntry."Entry Type"::Application, TempDetailedCustLedgEntry."Entry Type"::"Appln. Rounding");
AmountType::"Original Amount":
TempDetailedCustLedgEntry.SetRange("Entry Type", TempDetailedCustLedgEntry."Entry Type"::"Initial Entry");
AmountType::"Remaining Amount":
TempDetailedCustLedgEntry.SetRange("Entry Type");
end;
DetCustLedgEntrPreview.Set(TempDetailedCustLedgEntry);
DetCustLedgEntrPreview.RunModal();
Clear(DetCustLedgEntrPreview);
end;
[IntegrationEvent(false, false)]
local procedure OnAfterCalcAmounts(CustLedgerEntry: Record "Cust. Ledger Entry"; var TempDetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry" temporary; var AmountFCY: Decimal; var AmountLCY: Decimal; var RemainingAmountFCY: Decimal; var RemainingAmountLCY: Decimal; var OriginalAmountFCY: Decimal; var OriginalAmountLCY: Decimal)
begin
end;
}