1111
1212namespace PayrollEngine . Client . Scripting . Function ;
1313
14- /// <summary>Build a case (default: true), optionally considering related source cases</summary>
14+ /// <summary>
15+ /// Populates case fields before the input form is displayed to the user.
16+ /// </summary>
17+ /// <remarks>
18+ /// This function executes every time the case form is opened or refreshed. It is used to
19+ /// pre-fill default values, derive field content from existing case data, apply lookups,
20+ /// compute dates, and control which fields are shown or hidden.
21+ /// <para>Typical uses:</para>
22+ /// <list type="bullet">
23+ /// <item>Set <c>Start["Field"]</c> and <c>End["Field"]</c> to default the value period.</item>
24+ /// <item>Pre-fill <c>Value["Field"]</c> from existing case values or lookups.</item>
25+ /// <item>Show or hide fields with <see cref="CaseChangeFunction.ShowCaseField"/> / <see cref="CaseChangeFunction.HideCaseField"/>.</item>
26+ /// <item>Mark the form as invalid with <see cref="BuildInvalid"/> to block submission.</item>
27+ /// </list>
28+ /// <para><strong>Return value:</strong> Return <c>null</c> to indicate a successful build.
29+ /// Return <c>false</c> to mark the case as not buildable (equivalent to <see cref="BuildInvalid"/>).</para>
30+ /// <para><strong>Low-Code / No-Code:</strong> Field population can also be expressed through
31+ /// action expressions using <c>CaseBuildAction</c> attributes — no C# scripting required.
32+ /// The <see cref="Build"/> entry point invokes all registered actions before executing
33+ /// any inline script body.</para>
34+ /// </remarks>
1535/// <example>
1636/// <code language="c#">
17- /// // Example with case value
18- /// (int)Employee["Level"] >= 2
37+ /// // Set the start date to today and derive a salary value
38+ /// Start["Salary"] = PeriodStart;
39+ /// Value["Salary"] = GetCaseValue<decimal>("BaseSalary") * 1.05m;
1940/// </code>
2041/// <code language="c#">
21- /// // Example with related case value
22- /// HasCaseValue("Wage")
23- /// </code>
24- /// <code language="c#">
25- /// // Example with optional related case value
26- /// HasCaseValue("Wage") ? (int)Employee["Level"] >= 2 : false
42+ /// // Hide a field that is not applicable
43+ /// if ((string)Employee["ContractType"] != "Management")
44+ /// HideCaseField("ManagementBonus");
2745/// </code>
2846/// </example>
47+ /// <seealso cref="CaseAvailableFunction"/>
48+ /// <seealso cref="CaseValidateFunction"/>
2949// ReSharper disable once PartialTypeWithSinglePart
3050public partial class CaseBuildFunction : CaseChangeFunction
3151{
@@ -46,32 +66,24 @@ protected CaseBuildFunction(string sourceFileName) :
4666
4767 #region Validation
4868
49- /// <summary>
50- /// Set case build to valid
51- /// </summary>
69+ /// <summary>Marks the case form as valid; submission is permitted</summary>
5270 public void BuildValid ( ) => BuildValidity ( true ) ;
5371
54- /// <summary>
55- /// Set case build to invalid
56- /// </summary>
72+ /// <summary>Marks the case form as invalid; submission is blocked</summary>
5773 public void BuildInvalid ( ) => BuildValidity ( false ) ;
5874
59- /// <summary>
60- /// Set case build validity
61- /// </summary>
62- /// <param name="valid">Build validity</param>
75+ /// <summary>Sets the validity state of the case form</summary>
76+ /// <param name="valid"><c>true</c> to permit submission; <c>false</c> to block it</param>
6377 public void BuildValidity ( bool valid ) =>
6478 SetCaseAttribute ( InputAttributes . Validity , valid ) ;
6579
6680 #endregion
6781
6882 #region Info
6983
70- /// <summary>
71- /// Add build info
72- /// </summary>
73- /// <param name="name">Info name</param>
74- /// <param name="value">Info value</param>
84+ /// <summary>Adds or updates a named entry in the case form's edit-info attribute</summary>
85+ /// <param name="name">The info entry name</param>
86+ /// <param name="value">The info entry value</param>
7587 public void AddInfo ( string name , object value )
7688 {
7789 // info values
@@ -87,10 +99,8 @@ public void AddInfo(string name, object value)
8799 SetCaseAttribute ( InputAttributes . EditInfo , JsonSerializer . Serialize ( values ) ) ;
88100 }
89101
90- /// <summary>
91- /// Remove build info
92- /// </summary>
93- /// <param name="name">Info name</param>
102+ /// <summary>Removes a named entry from the case form's edit-info attribute</summary>
103+ /// <param name="name">The info entry name to remove</param>
94104 public void RemoveInfo ( string name )
95105 {
96106 // info values
0 commit comments