ERP / Business Controls NEW

The ERP / Business tab provides enterprise-grade components for building accounting, invoicing, reporting, and business automation applications. These non-visual components handle document generation, data processing, auditing, and scheduling.

TPreprocessor CT_PREPROCESSOR = 90

Source code preprocessor engine. Processes #define, #include, #ifdef directives and custom translation rules before compilation.

PropertyTypeDefaultDescription
cSourceString""Source code to preprocess
cOutputString""Preprocessed output (read-only)
aDefinesArray{}Active #define symbols
aIncludePathsArray{}Search paths for #include files
lStrictModeLogical.F.Error on undefined symbols
EventCategoryDescription
OnProcessActionPreprocessing completed
OnErrorErrorPreprocessing error encountered
OnIncludeActionInclude file resolved

TScriptEngine CT_SCRIPTENGINE = 91

Runtime script interpreter. Executes Harbour/xBase code at runtime for dynamic business rules, formulas, and user-defined calculations.

PropertyTypeDefaultDescription
cScriptString""Script source code
xResultAnyNILLast execution result
lSandboxedLogical.T.Restrict file/network access
nTimeoutNumeric5000Maximum execution time (ms)
hVariablesHash{=>}Variables available to the script
EventCategoryDescription
OnExecuteActionScript execution completed
OnErrorErrorRuntime error in script
OnOutputActionScript produced output (e.g. ? command)

TReportDesigner CT_REPORTDESIGNER = 92

Visual report layout engine. Defines bands (header, detail, footer, group), fields, labels, and images for printable reports.

PropertyTypeDefaultDescription
cReportFileString""Path to report definition file (.hbr)
cTitleString""Report title
nPageWidthNumeric210Page width in mm (A4 default)
nPageHeightNumeric297Page height in mm
nOrientationNumeric00=Portrait, 1=Landscape
oDataSourceObjectNILData source (table, query, array)
EventCategoryDescription
OnBeforePrintActionBefore report generation starts
OnAfterPrintActionAfter report generation completes
OnNewPageActionNew page started
OnGroupChangeActionGroup break occurred

TBarcode CT_BARCODE = 93

Barcode generator supporting 1D and 2D formats. Renders barcodes as images for display, printing, or export.

PropertyTypeDefaultDescription
cDataString""Data to encode
nFormatNumeric00=Code128, 1=Code39, 2=EAN13, 3=QRCode, 4=DataMatrix, 5=PDF417
nWidthNumeric200Output width in pixels
nHeightNumeric80Output height in pixels
lShowTextLogical.T.Display human-readable text below barcode
nErrorLevelNumeric2QR error correction level (0=L, 1=M, 2=Q, 3=H)
EventCategoryDescription
OnGenerateActionBarcode image generated
OnErrorErrorInvalid data for chosen format

TPDFGenerator CT_PDFGENERATOR = 94

PDF document generator. Creates multi-page PDF files with text, images, tables, barcodes, and vector graphics.

PropertyTypeDefaultDescription
cFileNameString""Output PDF file path
cTitleString""Document title metadata
cAuthorString""Document author metadata
nPageWidthNumeric595Page width in points (A4)
nPageHeightNumeric842Page height in points (A4)
nMarginNumeric36Page margins in points
lCompressedLogical.T.Enable stream compression
EventCategoryDescription
OnNewPageActionNew page created
OnCompleteActionPDF generation completed
OnErrorErrorError during PDF generation

TExcelExport CT_EXCELEXPORT = 95

Excel spreadsheet exporter. Generates .xlsx files with formatting, formulas, and multiple sheets.

PropertyTypeDefaultDescription
cFileNameString""Output .xlsx file path
cSheetNameString"Sheet1"Active sheet name
nSheetCountNumeric1Number of sheets (read-only)
lAutoFitLogical.T.Auto-fit column widths
lHeaderBoldLogical.T.Bold header row formatting
EventCategoryDescription
OnExportActionExport completed
OnProgressActionExport progress update (nRow, nTotal)
OnErrorErrorError during export

TAuditLog CT_AUDITLOG = 96

Audit trail component. Automatically logs user actions, data changes, and system events with timestamps.

PropertyTypeDefaultDescription
cLogTableString"audit_log"Database table for storing logs
cUserFieldString"user_id"Field name for current user
lLogReadsLogical.F.Log read operations (not just writes)
lLogTimestampLogical.T.Include timestamp in log entries
aTrackedTablesArray{}Tables to monitor for changes
EventCategoryDescription
OnLogEntryActionNew audit entry recorded
OnAlertActionSuspicious activity detected

TPermissions CT_PERMISSIONS = 97

Role-based access control manager. Defines users, roles, and permissions for application features and data.

PropertyTypeDefaultDescription
cCurrentUserString""Currently authenticated user
cCurrentRoleString""Current user's role
aRolesArray{}Defined roles
hPermissionsHash{=>}Role-to-permissions mapping
cPermTableString"permissions"Permissions database table
EventCategoryDescription
OnLoginActionUser authenticated
OnDeniedActionPermission denied for action
OnRoleChangeActionUser role changed

TCurrency CT_CURRENCY = 98

Multi-currency handler. Manages exchange rates, currency conversion, and locale-aware formatting.

PropertyTypeDefaultDescription
cBaseCurrencyString"USD"Base currency code (ISO 4217)
nAmountNumeric0.00Current amount in base currency
hRatesHash{=>}Exchange rates hash (code => rate)
nDecimalsNumeric2Decimal precision
lAutoUpdateLogical.F.Auto-fetch rates from online API
EventCategoryDescription
OnConvertActionCurrency conversion performed
OnRatesUpdatedActionExchange rates refreshed

TTaxEngine CT_TAXENGINE = 99

Tax calculation engine. Handles VAT, sales tax, withholding, and multi-jurisdiction tax rules.

PropertyTypeDefaultDescription
nBaseAmountNumeric0.00Amount before tax
nTaxRateNumeric0.00Tax rate (percentage)
nTaxAmountNumeric0.00Calculated tax (read-only)
nTotalAmountNumeric0.00Amount + tax (read-only)
cJurisdictionString""Tax jurisdiction code
lInclusiveLogical.F.Tax-inclusive pricing
aTaxRulesArray{}Custom tax rules per category
EventCategoryDescription
OnCalculateActionTax calculation completed
OnRuleAppliedActionSpecific tax rule matched and applied

TDashboard CT_DASHBOARD = 100

Business dashboard container. Hosts widgets (charts, KPIs, gauges, tables) in a configurable grid layout for executive overviews.

PropertyTypeDefaultDescription
nColumnsNumeric3Grid column count
nRowsNumeric2Grid row count
nRefreshIntervalNumeric60000Auto-refresh interval (ms)
lAutoRefreshLogical.T.Enable automatic data refresh
cThemeString"dark"Visual theme (dark, light, corporate)
aWidgetsArray{}Dashboard widget definitions
EventCategoryDescription
OnRefreshActionDashboard data refreshed
OnWidgetClickActionUser clicked a dashboard widget
OnDrillDownActionUser drilled into widget detail

TScheduler CT_SCHEDULER = 101

Task scheduler for background job management. Supports cron-like scheduling, one-time tasks, and recurring jobs.

PropertyTypeDefaultDescription
aJobsArray{}Registered scheduled jobs
lRunningLogical.F.Scheduler is active (read-only)
nMaxConcurrentNumeric4Maximum concurrent jobs
cLogFileString""Job execution log file
lPersistentLogical.T.Persist schedule across restarts
EventCategoryDescription
OnJobStartActionScheduled job started
OnJobCompleteActionJob completed successfully
OnJobErrorErrorJob failed with error
OnScheduleChangeActionSchedule modified

Code Example: Barcode + PDF Export

This example demonstrates generating product barcodes and exporting them to a PDF catalog.

// Generate barcode and export to PDF
FUNCTION ExportProductCatalog()
   LOCAL oBarcode, oPdf, cFile, nRow

   // Create barcode generator
   oBarcode := TBarcode():New()
   oBarcode:nFormat := 0  // Code128
   oBarcode:nWidth  := 250
   oBarcode:nHeight := 60
   oBarcode:lShowText := .T.

   // Create PDF document
   oPdf := TPDFGenerator():New()
   oPdf:cFileName := "catalog.pdf"
   oPdf:cTitle    := "Product Catalog"
   oPdf:cAuthor   := "HarbourBuilder ERP"
   oPdf:NewPage()

   // Header
   oPdf:SetFont( "Helvetica", 18, .T. )
   oPdf:DrawText( 36, 780, "Product Barcode Catalog" )
   oPdf:DrawLine( 36, 775, 559, 775 )

   // Generate barcodes for each product
   nRow := 720
   Products->GoTop()
   DO WHILE ! Products->Eof()
      // Generate barcode image
      oBarcode:cData := Products->SKU
      cFile := oBarcode:Generate()

      // Draw product info + barcode on PDF
      oPdf:SetFont( "Helvetica", 12, .F. )
      oPdf:DrawText( 36, nRow, Products->Name )
      oPdf:DrawText( 36, nRow - 15, "SKU: " + Products->SKU )
      oPdf:DrawImage( 300, nRow - 50, 250, 60, cFile )

      nRow -= 90
      IF nRow < 100
         oPdf:NewPage()
         nRow := 780
      ENDIF

      Products->Skip()
   ENDDO

   oPdf:Save()
   MsgInfo( "Catalog exported to catalog.pdf" )
RETURN NIL
12 ERP / Business Controls

These enterprise components accelerate business application development. From barcode generation and PDF export to audit logging and role-based permissions, they provide the building blocks for full-featured ERP, accounting, and business management systems.

On This Page

TPreprocessor CT_PREPROCESSOR = 90 TScriptEngine CT_SCRIPTENGINE = 91 TReportDesigner CT_REPORTDESIGNER = 92 TBarcode CT_BARCODE = 93 TPDFGenerator CT_PDFGENERATOR = 94 TExcelExport CT_EXCELEXPORT = 95 TAuditLog CT_AUDITLOG = 96 TPermissions CT_PERMISSIONS = 97 TCurrency CT_CURRENCY = 98 TTaxEngine CT_TAXENGINE = 99 TDashboard CT_DASHBOARD = 100 TScheduler CT_SCHEDULER = 101 Code Example: Barcode + PDF Export