Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetLoadFields, SetAutoCalcFields, IsEmtpy #25084

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ codeunit 1438 "Ess. Bus. Headline Subscribers"
exit;

EssentialBusinessHeadline.SetRange("User Id", UserSecurityId());
EssentialBusinessHeadline.DeleteAll();
if not EssentialBusinessHeadline.isempty then
JesperSchulz marked this conversation as resolved.
Show resolved Hide resolved
EssentialBusinessHeadline.DeleteAll();
end;

local procedure TransferHeadlineToPage(HeadlineName: Option; var HeadlineText: Text[250]; var HeadlineVisible: Boolean)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ codeunit 1437 "Essential Bus. Headline Mgt."
exit;

BestQty := BestSoldItemQuery.SumQuantity;
Item.SetLoadFields(Description, "Base Unit of Measure");
Item.Get(BestSoldItemQuery.ProductNo);
HeadlineText := EssentialBusinessHeadline."Headline Text";

Expand All @@ -104,7 +105,8 @@ codeunit 1437 "Essential Bus. Headline Mgt."
EssentialBusinessHeadline."Headline Text" := CopyStr(HeadlineText, 1, MaxStrLen(EssentialBusinessHeadline."Headline Text"));
HeadlineDetails.SetRange(Type, HeadlineDetails.Type::Item);
HeadlineDetails.SetRange("User Id", UserSecurityId());
HeadlineDetails.DeleteAll();
if not HeadlineDetails.IsEmpty then
HeadlineDetails.DeleteAll();

InsertHeadlineDetails(BestSoldItemQuery.ProductNo, HeadlineDetails.Type::Item, Item.Description, Item."Base Unit of Measure", BestSoldItemQuery.SumQuantity, 0);

Expand Down Expand Up @@ -186,6 +188,7 @@ codeunit 1437 "Essential Bus. Headline Mgt."
if not BusiestResource.Read() then
exit;
BestQty := BusiestResource.SumQuantity;
Resource.SetLoadFields(Name, "Base Unit of Measure");
Resource.Get(BusiestResource.ProductNo);
HeadlineText := EssentialBusinessHeadline."Headline Text";

Expand All @@ -199,7 +202,8 @@ codeunit 1437 "Essential Bus. Headline Mgt."
EssentialBusinessHeadline."Headline Text" := CopyStr(HeadlineText, 1, MaxStrLen(EssentialBusinessHeadline."Headline Text"));
HeadlineDetails.SetRange(Type, HeadlineDetails.Type::Resource);
HeadlineDetails.SetRange("User Id", UserSecurityId());
HeadlineDetails.DeleteAll();
if not HeadlineDetails.IsEmpty then
HeadlineDetails.DeleteAll();

InsertHeadlineDetails(BusiestResource.ProductNo, HeadlineDetails.Type::Resource, Resource.Name, Resource."Base Unit of Measure", BusiestResource.SumQuantity, 0);

Expand Down Expand Up @@ -360,9 +364,8 @@ codeunit 1437 "Essential Bus. Headline Mgt."

// we need at least 5 sales for this headline to be valid
if (CustomerLedgerEntry.Count() > 5) then begin
CustomerLedgerEntry.SetAutoCalcFields(Amount);
if CustomerLedgerEntry.FindFirst() then begin
CustomerLedgerEntry.CalcFields(Amount);

if not Headlines.GetHeadlineText(
ChooseQualifier(QualifierWeekTxt, QualifierMonthTxt, Qualifier3MonthsTxt, DaysSearch),
StrSubstNo(LargestSalePayloadTxt,
Expand Down Expand Up @@ -506,6 +509,7 @@ codeunit 1437 "Essential Bus. Headline Mgt."
HeadlineText: Text;
begin
EssentialBusinessHeadline.GetOrCreateHeadline(EssentialBusinessHeadline."Headline Name"::RecentlyOverdueInvoices);
CustomerLedgerEntry.SetLoadFields(Open, "Due Date", "Document Type");
FindRecentlyOverdueInvoices(CustomerLedgerEntry, WorkDate());
RecentlyOverdueInvoices := CustomerLedgerEntry.Count();

Expand All @@ -516,9 +520,9 @@ codeunit 1437 "Essential Bus. Headline Mgt."
end;

TotalAmount := 0.0;
CustomerLedgerEntry.SetAutoCalcFields("Amount (LCY)");
if CustomerLedgerEntry.FindSet() then
repeat
CustomerLedgerEntry.CalcFields("Amount (LCY)");
TotalAmount := TotalAmount + CustomerLedgerEntry."Amount (LCY)";
until CustomerLedgerEntry.Next() = 0;

Expand Down Expand Up @@ -602,12 +606,10 @@ codeunit 1437 "Essential Bus. Headline Mgt."
if not TopCustomerHeadlineQuery.Read() then
exit;

Customer.Get(TopCustomerHeadlineQuery.CustomerNo);

HeadlineText := EssentialBusinessHeadline."Headline Text";
if not Headlines.GetHeadlineText(
ChooseQualifier(QualifierWeekTxt, QualifierMonthTxt, Qualifier3MonthsTxt, DaysSearch),
GetTopCustomerPayload(Customer.Name, FormatLocalCurrency(TopCustomerHeadlineQuery.SumAmountLcy)),
GetTopCustomerPayload(TopCustomerHeadlineQuery.CustomerName, FormatLocalCurrency(TopCustomerHeadlineQuery.SumAmountLcy)),
HeadlineText)
then
exit;
Expand All @@ -616,7 +618,8 @@ codeunit 1437 "Essential Bus. Headline Mgt."
EssentialBusinessHeadline."Headline Text" := CopyStr(HeadlineText, 1, MaxStrLen(EssentialBusinessHeadline."Headline Text"));
HeadlineDetails.SetRange(Type, HeadlineDetails.Type::Customer);
HeadlineDetails.SetRange("User Id", UserSecurityId());
HeadlineDetails.DeleteAll();
if not HeadlineDetails.IsEmpty then
HeadlineDetails.DeleteAll();
InsertHeadlineDetails(TopCustomerHeadlineQuery.No, HeadlineDetails.Type::Customer, TopCustomerHeadlineQuery.CustomerName, '', 0, TopCustomerHeadlineQuery.SumAmountLcy);

// if there is only one customer last month, do not set to visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ query 1440 "Best Sold Item Headline"
{
QueryType = Normal;
OrderBy = descending(SumQuantity);
DataAccessIntent = ReadOnly;

elements
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using Microsoft.Sales.History;
query 1442 "Sales Increase Headline"
{
QueryType = Normal;
DataAccessIntent = ReadOnly;

elements
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ query 1441 "Top Customer Headline"
{
QueryType = Normal;
OrderBy = descending(SumAmountLcy);
DataAccessIntent = ReadOnly;

elements
{
Expand Down