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.
| Property | Type | Default | Description |
cSource | String | "" | Source code to preprocess |
cOutput | String | "" | Preprocessed output (read-only) |
aDefines | Array | {} | Active #define symbols |
aIncludePaths | Array | {} | Search paths for #include files |
lStrictMode | Logical | .F. | Error on undefined symbols |
| Event | Category | Description |
OnProcess | Action | Preprocessing completed |
OnError | Error | Preprocessing error encountered |
OnInclude | Action | Include file resolved |
TScriptEngine CT_SCRIPTENGINE = 91
Runtime script interpreter. Executes Harbour/xBase code at runtime for dynamic business rules, formulas, and user-defined calculations.
| Property | Type | Default | Description |
cScript | String | "" | Script source code |
xResult | Any | NIL | Last execution result |
lSandboxed | Logical | .T. | Restrict file/network access |
nTimeout | Numeric | 5000 | Maximum execution time (ms) |
hVariables | Hash | {=>} | Variables available to the script |
| Event | Category | Description |
OnExecute | Action | Script execution completed |
OnError | Error | Runtime error in script |
OnOutput | Action | Script 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.
| Property | Type | Default | Description |
cReportFile | String | "" | Path to report definition file (.hbr) |
cTitle | String | "" | Report title |
nPageWidth | Numeric | 210 | Page width in mm (A4 default) |
nPageHeight | Numeric | 297 | Page height in mm |
nOrientation | Numeric | 0 | 0=Portrait, 1=Landscape |
oDataSource | Object | NIL | Data source (table, query, array) |
| Event | Category | Description |
OnBeforePrint | Action | Before report generation starts |
OnAfterPrint | Action | After report generation completes |
OnNewPage | Action | New page started |
OnGroupChange | Action | Group break occurred |
TBarcode CT_BARCODE = 93
Barcode generator supporting 1D and 2D formats. Renders barcodes as images for display, printing, or export.
| Property | Type | Default | Description |
cData | String | "" | Data to encode |
nFormat | Numeric | 0 | 0=Code128, 1=Code39, 2=EAN13, 3=QRCode, 4=DataMatrix, 5=PDF417 |
nWidth | Numeric | 200 | Output width in pixels |
nHeight | Numeric | 80 | Output height in pixels |
lShowText | Logical | .T. | Display human-readable text below barcode |
nErrorLevel | Numeric | 2 | QR error correction level (0=L, 1=M, 2=Q, 3=H) |
| Event | Category | Description |
OnGenerate | Action | Barcode image generated |
OnError | Error | Invalid data for chosen format |
TPDFGenerator CT_PDFGENERATOR = 94
PDF document generator. Creates multi-page PDF files with text, images, tables, barcodes, and vector graphics.
| Property | Type | Default | Description |
cFileName | String | "" | Output PDF file path |
cTitle | String | "" | Document title metadata |
cAuthor | String | "" | Document author metadata |
nPageWidth | Numeric | 595 | Page width in points (A4) |
nPageHeight | Numeric | 842 | Page height in points (A4) |
nMargin | Numeric | 36 | Page margins in points |
lCompressed | Logical | .T. | Enable stream compression |
| Event | Category | Description |
OnNewPage | Action | New page created |
OnComplete | Action | PDF generation completed |
OnError | Error | Error during PDF generation |
TExcelExport CT_EXCELEXPORT = 95
Excel spreadsheet exporter. Generates .xlsx files with formatting, formulas, and multiple sheets.
| Property | Type | Default | Description |
cFileName | String | "" | Output .xlsx file path |
cSheetName | String | "Sheet1" | Active sheet name |
nSheetCount | Numeric | 1 | Number of sheets (read-only) |
lAutoFit | Logical | .T. | Auto-fit column widths |
lHeaderBold | Logical | .T. | Bold header row formatting |
| Event | Category | Description |
OnExport | Action | Export completed |
OnProgress | Action | Export progress update (nRow, nTotal) |
OnError | Error | Error during export |
TAuditLog CT_AUDITLOG = 96
Audit trail component. Automatically logs user actions, data changes, and system events with timestamps.
| Property | Type | Default | Description |
cLogTable | String | "audit_log" | Database table for storing logs |
cUserField | String | "user_id" | Field name for current user |
lLogReads | Logical | .F. | Log read operations (not just writes) |
lLogTimestamp | Logical | .T. | Include timestamp in log entries |
aTrackedTables | Array | {} | Tables to monitor for changes |
| Event | Category | Description |
OnLogEntry | Action | New audit entry recorded |
OnAlert | Action | Suspicious activity detected |
TPermissions CT_PERMISSIONS = 97
Role-based access control manager. Defines users, roles, and permissions for application features and data.
| Property | Type | Default | Description |
cCurrentUser | String | "" | Currently authenticated user |
cCurrentRole | String | "" | Current user's role |
aRoles | Array | {} | Defined roles |
hPermissions | Hash | {=>} | Role-to-permissions mapping |
cPermTable | String | "permissions" | Permissions database table |
| Event | Category | Description |
OnLogin | Action | User authenticated |
OnDenied | Action | Permission denied for action |
OnRoleChange | Action | User role changed |
TCurrency CT_CURRENCY = 98
Multi-currency handler. Manages exchange rates, currency conversion, and locale-aware formatting.
| Property | Type | Default | Description |
cBaseCurrency | String | "USD" | Base currency code (ISO 4217) |
nAmount | Numeric | 0.00 | Current amount in base currency |
hRates | Hash | {=>} | Exchange rates hash (code => rate) |
nDecimals | Numeric | 2 | Decimal precision |
lAutoUpdate | Logical | .F. | Auto-fetch rates from online API |
| Event | Category | Description |
OnConvert | Action | Currency conversion performed |
OnRatesUpdated | Action | Exchange rates refreshed |
TTaxEngine CT_TAXENGINE = 99
Tax calculation engine. Handles VAT, sales tax, withholding, and multi-jurisdiction tax rules.
| Property | Type | Default | Description |
nBaseAmount | Numeric | 0.00 | Amount before tax |
nTaxRate | Numeric | 0.00 | Tax rate (percentage) |
nTaxAmount | Numeric | 0.00 | Calculated tax (read-only) |
nTotalAmount | Numeric | 0.00 | Amount + tax (read-only) |
cJurisdiction | String | "" | Tax jurisdiction code |
lInclusive | Logical | .F. | Tax-inclusive pricing |
aTaxRules | Array | {} | Custom tax rules per category |
| Event | Category | Description |
OnCalculate | Action | Tax calculation completed |
OnRuleApplied | Action | Specific 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.
| Property | Type | Default | Description |
nColumns | Numeric | 3 | Grid column count |
nRows | Numeric | 2 | Grid row count |
nRefreshInterval | Numeric | 60000 | Auto-refresh interval (ms) |
lAutoRefresh | Logical | .T. | Enable automatic data refresh |
cTheme | String | "dark" | Visual theme (dark, light, corporate) |
aWidgets | Array | {} | Dashboard widget definitions |
| Event | Category | Description |
OnRefresh | Action | Dashboard data refreshed |
OnWidgetClick | Action | User clicked a dashboard widget |
OnDrillDown | Action | User drilled into widget detail |
TScheduler CT_SCHEDULER = 101
Task scheduler for background job management. Supports cron-like scheduling, one-time tasks, and recurring jobs.
| Property | Type | Default | Description |
aJobs | Array | {} | Registered scheduled jobs |
lRunning | Logical | .F. | Scheduler is active (read-only) |
nMaxConcurrent | Numeric | 4 | Maximum concurrent jobs |
cLogFile | String | "" | Job execution log file |
lPersistent | Logical | .T. | Persist schedule across restarts |
| Event | Category | Description |
OnJobStart | Action | Scheduled job started |
OnJobComplete | Action | Job completed successfully |
OnJobError | Error | Job failed with error |
OnScheduleChange | Action | Schedule 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.