GetOrderTypeForInvoiceType
Function GetOrderTypeForInvoiceType(const aInvoiceTypeCode : string) : Variant;
Example
procedure ScriptEvent(var Value: variant);
begin
Value := GetOrderTypeForInvoiceType('CustomerInvoice'); // 'SalesOrder'
end;
Usage
GetOrderTypeForInvoiceType maps a Velox invoice type code to its corresponding order type code.
Parameters and result
| Item | Type | Description |
|---|---|---|
aInvoiceTypeCode | string, const | Canonical invoice type code. Matching is case-insensitive but otherwise exact. |
| Result | Variant | Order type code string for a recognized input, otherwise Null. |
Behaviour and edge cases
- Invoice direction, not debit/credit polarity, selects the order type. Customer invoice and credit both become SalesOrder; supplier invoice and credit both become PurchaseOrder.
- Matching ignores ASCII letter case but does not trim. Whitespace, punctuation differences, empty text and unknown/custom type codes return
Null. - The function recognizes source-family codes only. Passing
SalesOrder,PurchaseOrderor numeric text is not an identity conversion and returnsNull. - The result describes type/direction only; it does not copy, create, validate or change an order.
- The mapping is not extensible through customer configuration.
- Test
VarIsNullbefore treating the result as a valid order type.
Additional Technical Info
GetOrderTypeForInvoiceType converts a invoice type code into the canonical order type code that represents the same customer/supplier direction. It is a compiled business mapping; it does not inspect a document, order record, trading party or database configuration.
Complete transformation
| Input invoice type code | Order type code | Order type number |
|---|---|---|
CustomerInvoice | SalesOrder | 1 |
CustomerCredit | SalesOrder | 1 |
SupplierInvoice | PurchaseOrder | 2 |
SupplierCredit | PurchaseOrder | 2 |
Implementation
The function tests each supported input with installed Delphi SameText. It returns the literal Type_SalesOrder_String or Type_PurchaseOrder_String value. The final branch returns Null. There is no intermediate call to another public conversion function.
Side effects, errors and performance
The function is pure, performs no I/O and runs over a small fixed comparison chain. Ordinary unmatched string input returns Null.
Related entries
GetOrderTypeNumForInvoiceTypereturns the same directional mapping as a number.GetInvoiceTypeCodedocuments the reciprocal invoice type number/code domain accepted here.GetOrderTypeCodeandGetOrderTypeNumconvert within the output order-type domain.- Embarcadero:
System.SysUtils.SameText - Free Pascal:
SameText