Skip to main content

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

ItemTypeDescription
aInvoiceTypeCodestring, constCanonical invoice type code. Matching is case-insensitive but otherwise exact.
ResultVariantOrder 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, PurchaseOrder or numeric text is not an identity conversion and returns Null.
  • 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 VarIsNull before 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 codeOrder type codeOrder type number
CustomerInvoiceSalesOrder1
CustomerCreditSalesOrder1
SupplierInvoicePurchaseOrder2
SupplierCreditPurchaseOrder2

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

Created 2026-07-15