Summary of the DBO.Invoice_dest_mgmt_v2 Package
The DBO.Invoice_dest_mgmt_v2 package is designed to manage the invoice destinations for businesses within an Oracle database. The package provides a set of functions that allow users to add, enable, disable, and update invoice delivery methods based on various criteria. The package also includes internal methods for specific administrative tasks and ensures that businesses always have a valid invoice destination configured. Here’s a breakdown of the main components:
AddOrEnableInvoiceDestination:
- This function allows users to add or enable an invoice delivery method (e.g., Email, FTP, Paper) for a business. It validates the provided information, such as the destination type and business ID, before updating the database. The function returns an empty string if successful or an error message if not.
DisableInvoiceDestination:
- This function disables an invoice destination for a business. If a specific format is provided, only that format is disabled; otherwise, all formats using the destination are disabled. Like the previous function, it returns an empty string if successful or an error message if not.
InternalUpdateDestination:
- This function is intended for use by specific users (e.g., system administrators) to manage the transition between mutually exclusive invoice delivery methods (FTP, EFaktura, Mail). It is not meant for general use and will block unauthorized calls.
UpdateDestinationBasedOnElma:
- This function automatically updates invoice destinations based on the ELMA register, ensuring that all businesses have a valid destination. It checks for active customers without a destination and assigns a default method where necessary. It also handles customers entering or leaving the ELMA register.
SetFallbackInvoiceDestination:
- This function sets a fallback invoice destination for a business if no active destinations are found. It prioritizes using an invoice reminder email, the primary contact's email, or the orderer from the last order, ensuring that every business has a valid destination for receiving invoices.
AreInputsValid:
- This internal function performs validation on the input parameters provided to other functions, such as checking if the delivery method is allowed and if the destination is valid for the specified method. Errors encountered during validation are logged.
HandleUpdate:
- This internal function handles the actual insertion, updating, or disabling of invoice destinations in the database, based on the validated inputs. It ensures that each business has the correct active invoice destinations and formats configured.
The package is designed with robust error handling and logging capabilities, making it suitable for managing complex business rules related to invoice delivery methods in an enterprise environment.
