GetInvoiceTypeCode
Function GetInvoiceTypeCode(const aInvoiceType : Variant) : Variant;
Example
procedure ScriptEvent(var Value: variant);
begin
Value := GetInvoiceTypeCode(1); // 'CustomerInvoice'
end;
Usage
GetInvoiceTypeCode converts a Velox invoice type number to its canonical code.
Parameters and result
| Item | Type | Description |
|---|---|---|
aInvoiceType | Variant, const | Numeric invoice type value. Velox expects one of the listed integral values in a compatible Variant. |
| Result | Variant | Canonical code string in a Variant, or Null when the value is null or unrecognized. |
Mapping
| Number | Code |
|---|---|
1 | CustomerInvoice |
2 | CustomerCredit |
3 | SupplierInvoice |
4 | SupplierCredit |
Additional Technical Info
GetInvoiceTypeCode converts the numeric representation of a invoice type to the canonical code used by Velox. The mapping is hard-coded in product source, so it is deterministic and does not read customer configuration.
Implementation
The implementation first evaluates aInvoiceType = Null, then uses a case statement for the listed integral constants. A recognized value assigns the literal code; the else branch assigns Null. No database, configuration table or locale-dependent lookup is involved.
Behaviour and edge cases
- With Delphi's default loose
NullEqualityRule, aNullinput follows the explicit null branch and returnsNull. That rule is process-global; changing it to strict or error semantics can alter or break the comparison before thecasestatement. - The intended inputs are the integral values in the table. Numeric-looking strings, floating-point values, booleans and other coercible
Varianttypes should not be used as substitutes even where Delphi happens to convert them. - Unknown values return
Null; they do not raise a domain-specific "unknown invoice type" exception. - Incompatible
Variantvalues, such as arrays or interface values, can fail during comparison or ordinal conversion and propagate a Delphi conversion/operator exception. - The numeric values belong to this mapping family. A number used by another Velox type or status is not semantically interchangeable.
Side effects, errors and performance
The function is pure for normal supported values: it performs no I/O, changes no Velox state and allocates no persistent resource. It runs in constant time over a small fixed mapping. Delphi Variant comparison or conversion errors propagate; the function does not catch them.
Related entries
GetInvoiceTypeNumperforms the reverse conversion.- Embarcadero:
System.Variants.NullEqualityRule - Free Pascal:
NullEqualityRule