Central management codeunit for Commission Setup configuration and feature flags. This codeunit serves as the single source of truth for all commission-related settings and feature flags. It uses SingleInstance to maintain consistent state across all calls within the same session. Key Responsibilities - Provides access to the Commission Setup record with caching for performance - Manages feature flags for Sales Network, New Sales Engine, Salesperson Integration - Controls internal state flags for table modification permissions - Handles feature flag registration and enable/disable logic Feature Flags Managed - New Salesperson Engine Controls the new salesperson management system - Sales Network Enables sales network functionality - Salesperson Integration Controls salesperson integration features Internal State Flags - SalespersonTreeModifiable Allows modifications to Salesperson Set Entry and Tree Node tables - RoleSalespersonSetsDeletable Allows deletion of Role-Salesperson Sets - DocumentBatchImportMode Enables batch import mode for documents - AutomatedTestsMode Indicates automated test execution Caching Strategy - Setup data is cached and refreshed every minute - Feature flags use tri-state (Undefined/True/False) for lazy loading - ForcedSetup flag bypasses normal cache refresh for testing Usage - Call IsNewSalesEngineEnabled(), IsSalesNetworkEnabled() to check feature status - Use SetSalespersonTreeModifiable(true) before modifying protected tables - Call GetCommissionsSetup() to retrieve cached setup record
Gathers all functions used to handle data on documents
Gathers all functions used to handle additional salespersons
Gathers all functions used to handle calculation routines
Gathers all functions used to handle general needs
Gathers all functions used to handle subscriber events
Gathers all functions used to handle journals
Gathers all functions used to handle journal post
Gathers all functions used to handle journal post
Gathers all functions used to handle journal post
Gathers all functions used to handle journal post
Gathers all functions used to handle document posting process
Gathers all published events
Gathers all functions used to handle purchase documents creation/update
Gathers all functions used to handle commission reduction
Gathers all functions used to handle commission in posting preview function
Provides functions related to extension specific subscription management.
Codeunit for managing Salesperson integration with external entities. Manages bidirectional synchronization between the EOS010 Salesperson Integration table and the Customer, Ship-to Address, and EOS Sales Network tables. This codeunit is SingleInstance to maintain the DisableNextLogging flag state across different calls during the same session.
Codeunit for managing the import of salesperson data into Business Central. This codeunit handles the complete import process including - Validating imported salesperson records - Applying salesperson assignments to various sales documents and master data - Performing data quality checks after import - Managing status updates for imported records Supports import for Customer, Ship-to Address, Sales Header, Sales Line, Sales Invoice Header/Line, Sales Credit Memo Header/Line, and archived documents.
Codeunit for advanced filtering optimization in commission calculation. This codeunit provides an optimized filtering mechanism for the EOS Commissions Calc. Setup table by using SetID fields and caching strategies to improve performance when searching for matching commission calculation setup records. Key features - SingleInstance design pattern for persistent caching across calls - Manual event subscription for table insert/modify/delete/rename events - Regex-based detection of complex filter expressions (wildcards, ranges, operators) - Multi-level caching filter values, lookup table values, regex matches, and filter match results - Automatic cache invalidation with 60-second throttling to balance freshness and performance - Integration with EOS010 Filter Value Lookup table for unique ID assignment Usage 1. Call BindCodeunit() to activate event handling 2. Use SetAdvancedFilters() to apply optimized filters to commission setup queries 3. Call UnBindCodeunit() when event handling should be disabled The caching strategy - FilterValueCache Maps field numbers to dictionaries of filter values - FieldHasComplexFilter Tracks which fields contain complex filter expressions - LookupValueCache Maps text values to their unique IDs in the lookup table - RegexMatchCache Caches regex evaluation results for filter complexity detection - FilterMatchCache Caches filter match results for value-filter combinations
Legacy Event Subscriber for Commission Management. This codeunit isolates all event subscribers related to the legacy salesperson/commission logic. Key Features - Uses Manual EventSubscriberInstance to allow dynamic binding/unbinding - Events are only active when the legacy sales engine is enabled - When the new sales engine is enabled, these subscribers are unbound to avoid performance impact Purpose This architecture allows the system to completely disable legacy event processing when the new engine is active, preventing unnecessary event handler execution and improving Business Central performance. All methods are marked as Obsolete and will be removed when the legacy engine is fully deprecated. Usage Call BindOrUnBindCodeunitIfNeeded() during setup initialization to activate/deactivate the legacy event subscribers based on commission setup configuration.
Advanced Event Subscriber for Commission Management. This codeunit isolates event subscribers that are only needed when the new salesperson engine is active. Key Features - Uses Manual EventSubscriberInstance to allow dynamic binding/unbinding - Events are only active when the new sales engine is enabled - Prevents usage of legacy tables (e.g., “EOS Add. Salesperson/Purchaser”) when the new engine is active - Can be temporarily unbound on-demand to allow special operations (e.g., table truncate) Purpose This architecture serves two main purposes 1. Protect legacy data structures from being used when the new engine is active 2. Allow temporary disabling of protections when needed for maintenance operations (truncate, bulk operations, etc.) The manual binding allows these protective events to be disabled on-demand without affecting Business Central performance or blocking legitimate administrative operations. Usage - Call BindOrUnBindCodeunitIfNeeded() during setup initialization to activate/deactivate based on engine configuration - Call ForceUnbinding() temporarily before operations that need to bypass the protections (e.g., truncate legacy tables) - Re-bind after completing the special operation
Core management codeunit for Salesperson Sets in the Commission system. This codeunit provides the central API for managing Salesperson Set structures, which represent collections of role-salesperson assignments that can be attached to various entities (Customers, Sales Documents, etc.). Key Responsibilities - Creating and retrieving Salesperson Set IDs from role-salesperson combinations - Managing Role-Salesperson Sets (the building blocks of Salesperson Sets) - Providing edit functionality for Salesperson Sets across different record types - Synchronizing Salesperson Set changes between headers and lines - Detecting and comparing changes between Salesperson Sets - Transferring salespersons between documents - Converting between different data representations (Dictionary, JSON, temporary records) Data Structures - Salesperson Set ID A unique integer identifying a specific combination of role-salesperson pairs - Role-Salesperson Set Individual role + salesperson code combination with a unique ID - Salesperson Set Entry Links Salesperson Set ID to individual role-salesperson values - Salesperson Set Tree Node Tree structure for efficient lookup and deduplication Supported Record Types - Customer, Ship-to Address - Sales Header, Sales Line - Sales Invoice Header, Sales Invoice Line - Sales Cr.Memo Header, Sales Cr.Memo Line - Sales Header Archive, Sales Line Archive - EOS Sales Network Note This codeunit uses SingleInstance for performance optimization. Protected tables are modified via CommissionSetupMgt.SetSalespersonTreeModifiable().
Event Subscribers for Salesperson management in the Commission system. This codeunit handles all table-level events for the salesperson-related tables, ensuring data integrity and enforcing business rules for the new sales engine. Key Responsibilities - Automatically creates Role-Salesperson Sets when new roles or salespersons are added - Prevents deletion/rename of roles and salespersons that are in use - Protects Salesperson Set Entry and Tree Node tables from unauthorized modifications - Blocks configuration package imports that could corrupt salesperson data structures Tables Managed - EOS Salesperson Role Synchronizes role-salesperson combinations - Salesperson/Purchaser Synchronizes salesperson-role combinations - EOS010 Salesperson Set Entry Protected from direct modifications - EOS010 Salesp. Set Tree Node Protected from direct modifications - EOS010 Role-Salesperson Sets Protected from unauthorized deletions Note This codeunit uses SingleInstance to maintain consistent state across calls. Modifications to protected tables require setting appropriate flags via CommissionSetupMgt.