mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-05 06:36:55 +01:00
Move canonical knowledge for Microsoft-owned review domains into the Microsoft layer and document the skill/knowledge co-location policy. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com> Copilot-Session: 2a6ea875-d38e-4f30-aadb-0d606f9be231
31 lines
1.4 KiB
AL
31 lines
1.4 KiB
AL
codeunit 50541 "Perf Sample NoShortCircuit Bad"
|
|
{
|
|
procedure ExceedsThreshold(var Thresholds: array[10] of Decimal; Index: Integer; Amount: Decimal): Boolean
|
|
begin
|
|
// Thresholds[Index] is evaluated even when Index is 0, so the leading range
|
|
// check does not prevent the subscript from being read out of range.
|
|
exit((Index >= 1) and (Index <= ArrayLen(Thresholds)) and (Amount > Thresholds[Index]));
|
|
end;
|
|
|
|
procedure IsBlockedCustomer(CustomerNo: Code[20]): Boolean
|
|
var
|
|
Customer: Record Customer;
|
|
begin
|
|
// The Get runs even for an empty CustomerNo, and Blocked is read even when the
|
|
// Get failed, so the result is taken from a record that was never loaded.
|
|
exit((CustomerNo <> '') and Customer.Get(CustomerNo) and (Customer.Blocked <> Customer.Blocked::" "));
|
|
end;
|
|
|
|
procedure IsEligibleForFreeShipping(SalesHeader: Record "Sales Header"): Boolean
|
|
begin
|
|
// HasActiveLoyaltyBenefit runs even when the amount alone already qualifies,
|
|
// paying for the costly check on every evaluation instead of only the path
|
|
// where it can still change the outcome.
|
|
exit((SalesHeader."Amount Including VAT" >= 1000) or HasActiveLoyaltyBenefit(SalesHeader."Sell-to Customer No."));
|
|
end;
|
|
|
|
local procedure HasActiveLoyaltyBenefit(CustomerNo: Code[20]): Boolean
|
|
begin
|
|
exit(CustomerNo <> '');
|
|
end;
|
|
}
|