reportextension 70XXX "XXX_Ext" extends "Warehouse Register - Quantity"
{
RDLCLayout = 'Reports/Layout/XXXWarehouseRegisterQuantity.rdlc';
dataset
{
modify("Warehouse Entry")
{
addafter("EntryType_WarehouseEntry")
{
column(AccountValue_WarehouseEntry; CalcAccountValue)
{
Caption = 'Valor Contábil';
ToolTip = 'Valor contábil calculado com base nos movimentos do item.';
DataType = Decimal;
SourceExpr = CalcAccountValue;
}
}
}
}
var
CalcAccountValue: Decimal;
trigger OnAfterGetRecord()
var
ItemLedgerEntry: Record "Item Ledger Entry";
WarehouseEntry: Record "Warehouse Entry";
begin
CalcAccountValue := 0;
// Filtra os registros da tabela 7312 - Mov. Armazém
WarehouseEntry.SetRange("Item No.", "Item No.");
WarehouseEntry.SetRange("Posting Date", "Posting Date");
WarehouseEntry.SetRange(Quantity, Quantity);
WarehouseEntry.SetRange("Lot No.", "Lot No.");
if WarehouseEntry.FindSet() then
begin
repeat
// Filtra os registros da tabela 32 - Mov. Item com base nos filtros da tabela 7312
ItemLedgerEntry.Reset();
ItemLedgerEntry.SetRange("Item No.", WarehouseEntry."Item No.");
ItemLedgerEntry.SetRange("Posting Date", WarehouseEntry."Posting Date");
ItemLedgerEntry.SetRange(Quantity, WarehouseEntry.Quantity);
ItemLedgerEntry.SetRange("Lot No.", WarehouseEntry."Lot No.");
if ItemLedgerEntry.FindFirst() then
CalcAccountValue += ItemLedgerEntry."Actual Cost Amount (ACY)";
until WarehouseEntry.Next() = 0;
end;
end;
}