mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-05 14:46:55 +01:00
- dimension-management-wiring: SaveDefaultDim's third argument is the shortcut dimension number (1-8), not the field's AL field ID; the fixture passed FieldNo(...) = 10. GetDefaultDimID's InheritFromDimSetID must be 0 when recomputing after the linking record changes, not the document's existing Dimension Set ID (which would retain the previous customer's leftover dimensions). Verified against DimensionManagement.Codeunit.al and BankDepositHeader.Table.al in the BCApps reference clone. - check-post-line-batch-pattern: "Post Line writes exactly one line to the ledger" overclaimed - Gen. Jnl.-Post Line alone calls InsertGLEntry from a dozen call sites (balancing entry, VAT, currency rounding, deferrals) and can write several G/L Entries per journal line. Reworded to "posts exactly one journal line" and softened the "distinct, non-overlapping responsibilities" absolute. - namespace-must-be-verified-from-source.bad.al: dropped the "resolves in a local build, fails in VS Code" comment (taught an inherent compiler/language-server disagreement that isn't real); reframed as stale/cached symbols, matching the prose fix already made. - file-datatype-saas.good.al: replaced the deprecated 5-argument UploadIntoStream overload with the current 2-argument one, and actually staged through TempBlob as the article's own Best Practice instructs (the declared TempBlob variable was previously unused). - test-data-must-be-random-and-complete: no longer treats a short-but-valid value as defective merely for being "underfilled" - AL field lengths are maxima, not minimums. Scoped to missing values or a scenario with an explicit length/format requirement (e.g. a truncation test). Updated the al-testing-review.md routing cue to match. - stored-derived-fields-must-not-be-exposed-directly: stopped mandating source-field exposure as part of the core pattern: the good fixture exposed only one of the derived value's two inputs (Hours Used, not Budgeted Hours), making the claimed "so the consumer can verify it" impossible. Reframed as an optional, all-or-nothing addition and fixed the fixture to expose both inputs. Rebased onto upstream/main to resolve conflicts in al-breaking-changes-review.md, al-data-modeling-review.md, al-performance-review.md, and al-style-review.md against merged PRs #148 and #153; all sides' worklist tokens/cues retained.
87 lines
2.8 KiB
AL
87 lines
2.8 KiB
AL
// Master data: Default Dimension records, no Dimension Set ID field.
|
|
table 50100 "Course"
|
|
{
|
|
fields
|
|
{
|
|
field(1; "No."; Code[20]) { }
|
|
field(10; "Global Dimension 1 Code"; Code[20])
|
|
{
|
|
CaptionClass = '1,1,1';
|
|
TableRelation = "Dimension Value".Code where(
|
|
"Global Dimension No." = const(1), Blocked = const(false));
|
|
|
|
trigger OnValidate()
|
|
var
|
|
DimMgt: Codeunit DimensionManagement;
|
|
begin
|
|
DimMgt.ValidateDimValueCode(1, "Global Dimension 1 Code");
|
|
DimMgt.SaveDefaultDim(Database::Course, "No.", 1, "Global Dimension 1 Code");
|
|
end;
|
|
}
|
|
}
|
|
|
|
trigger OnDelete()
|
|
var
|
|
DimMgt: Codeunit DimensionManagement;
|
|
begin
|
|
DimMgt.DeleteDefaultDim(Database::Course, "No.");
|
|
end;
|
|
}
|
|
|
|
// Transactional/document data: a single Dimension Set ID, inherited from the
|
|
// related master record and overridable via shortcut dimension fields.
|
|
table 50101 "Course Registration Header"
|
|
{
|
|
fields
|
|
{
|
|
field(1; "No."; Code[20]) { }
|
|
field(2; "Customer No."; Code[20])
|
|
{
|
|
TableRelation = Customer;
|
|
|
|
trigger OnValidate()
|
|
begin
|
|
UpdateDimensionSetID();
|
|
end;
|
|
}
|
|
field(10; "Shortcut Dimension 1 Code"; Code[20])
|
|
{
|
|
CaptionClass = '1,1,1';
|
|
TableRelation = "Dimension Value".Code where(
|
|
"Global Dimension No." = const(1), Blocked = const(false));
|
|
|
|
trigger OnValidate()
|
|
var
|
|
DimMgt: Codeunit DimensionManagement;
|
|
begin
|
|
DimMgt.ValidateShortcutDimValues(1, "Shortcut Dimension 1 Code", "Dimension Set ID");
|
|
end;
|
|
}
|
|
field(480; "Dimension Set ID"; Integer)
|
|
{
|
|
Editable = false;
|
|
TableRelation = "Dimension Set Entry"."Dimension Set ID";
|
|
}
|
|
}
|
|
|
|
local procedure UpdateDimensionSetID()
|
|
var
|
|
Customer: Record Customer;
|
|
DimMgt: Codeunit DimensionManagement;
|
|
DefaultDimSource: List of [Dictionary of [Integer, Code[20]]];
|
|
GlobalDim2Code: Code[20];
|
|
begin
|
|
if not Customer.Get("Customer No.") then
|
|
exit;
|
|
|
|
// Recompute from scratch (InheritFromDimSetID = 0): passing the existing
|
|
// "Dimension Set ID" here would inherit dimensions from whichever record
|
|
// the document was previously linked to, retaining them even after the
|
|
// new customer's defaults have nothing for that dimension.
|
|
"Shortcut Dimension 1 Code" := '';
|
|
DimMgt.AddDimSource(DefaultDimSource, Database::Customer, "Customer No.");
|
|
"Dimension Set ID" :=
|
|
DimMgt.GetDefaultDimID(
|
|
DefaultDimSource, '', "Shortcut Dimension 1 Code", GlobalDim2Code, 0, 0);
|
|
end;
|
|
}
|