dolibarr 25.0.0-alpha
ToolReports Class Reference

Class ToolReports. More...

Inheritance diagram for ToolReports:
Collaboration diagram for ToolReports:

Public Member Functions

 __construct (DoliDB $db, $user=null, $conf=null)
 Constructor.
 
 getDefinitions ()
 Returns an array of tool definitions.
 
 getRequiredRights (string $toolName)
 Aggregated reports: the widest data reach of any tool class.
 
 getCategories ()
 Return categories this tool belongs to.
 
 execute (string $name, array $args)
 Executes the requested tool function based on its name.
 
- Public Member Functions inherited from McpTool
 __construct ($db, $user, $conf)
 Constructor.
 
 isSystem ()
 Return true if this is a system/infrastructure tool that must always remain visible and executable regardless of the admin allow-list.
 
 writeConfirmationPreview (string $toolName, array $args)
 Preview of what a call would write, or NO_WRITE for a read tool.
 

Private Member Functions

 resolveThirdparty ($args)
 Resolves a Thirdparty ID from either an ID or a name.
 
 getSalesReport (array $args)
 Generate a sales/revenue report.
 
 getThirdpartyTransactions (array $args)
 Generate a list of raw transactions (Invoices, Orders, Proposals).
 
 getPurchaseReport (array $args)
 Generate a purchase/expense report.
 
 getInventoryReport (array $args)
 Generate an inventory report.
 
 getFinancialReport (array $args)
 Generate a summary financial report (Income vs Expense).
 

Additional Inherited Members

- Public Attributes inherited from McpTool
const RIGHTS_UNDECLARED = 'undeclared'
 Default of getRequiredRights(): the class never declared anything, deny.
 
const NO_WRITE = ''
 Returned by writeConfirmationPreview() when the tool writes nothing.
 

Detailed Description

Class ToolReports.

Provides various tools related to Dolibarr reports.

Definition at line 39 of file reports.class.php.

Constructor & Destructor Documentation

◆ __construct()

ToolReports::__construct ( DoliDB $db,
$user = null,
$conf = null )

Constructor.

Aligned with McpHandler's instantiation contract: new $className($db, $user, $conf).

Parameters
DoliDB$dbDatabase handler
User | null$userService user provided by McpHandler (from AI_MCP_USER_ID)
Conf | null$confDolibarr config (optional)

Definition at line 50 of file reports.class.php.

References conf(), and user.

Member Function Documentation

◆ execute()

ToolReports::execute ( string $name,
array $args )

Executes the requested tool function based on its name.

Parameters
string$nameThe name of the tool to execute.
array<string,mixed>$args The arguments for the tool (key-value pairs).
Returns
mixed The result of the tool execution (usually an array) or an error array.

Reimplemented from McpTool.

Definition at line 198 of file reports.class.php.

References getFinancialReport(), getInventoryReport(), getPurchaseReport(), getSalesReport(), and getThirdpartyTransactions().

◆ getCategories()

ToolReports::getCategories ( )

Return categories this tool belongs to.

Used by the intent parser to filter available tools.

Returns
array<string> List of categories (e.g., ['billing', 'commercial'])

Reimplemented from McpTool.

Definition at line 186 of file reports.class.php.

◆ getDefinitions()

ToolReports::getDefinitions ( )

Returns an array of tool definitions.

Returns
list<array<string, mixed>> Array of tool definitions.

Reimplemented from McpTool.

Definition at line 64 of file reports.class.php.

◆ getFinancialReport()

ToolReports::getFinancialReport ( array $args)
private

Generate a summary financial report (Income vs Expense).

Parameters
array<string,mixed>$args Input arguments.
Returns
array<int, array<string, string>> Financial summary.

Definition at line 724 of file reports.class.php.

References dol_stringtotime(), getEntity(), and price().

Referenced by execute().

◆ getInventoryReport()

ToolReports::getInventoryReport ( array $args)
private

Generate an inventory report.

Parameters
array<string,mixed>$args Input arguments.
Returns
array<int, array<string, string>> Stock list.

Definition at line 639 of file reports.class.php.

References getEntity(), and price().

Referenced by execute().

◆ getPurchaseReport()

ToolReports::getPurchaseReport ( array $args)
private

Generate a purchase/expense report.

Parameters
array<string,mixed>$args Input arguments.
Returns
array<int, array<string, string>> List of purchases or groups.

Definition at line 533 of file reports.class.php.

References dol_print_date(), dol_stringtotime(), getEntity(), price(), and resolveThirdparty().

Referenced by execute().

◆ getRequiredRights()

ToolReports::getRequiredRights ( string $toolName)

Aggregated reports: the widest data reach of any tool class.

Parameters
string$toolNameTool being executed.
Returns
array<int,array<int,string>>|string Rights required, or a RIGHTS_* constant.

Reimplemented from McpTool.

Definition at line 167 of file reports.class.php.

References McpTool\RIGHTS_UNDECLARED.

◆ getSalesReport()

ToolReports::getSalesReport ( array $args)
private

Generate a sales/revenue report.

Parameters
array<string,mixed>$args Input arguments (date_start, date_end, limit, etc.)
Returns
array<int, array<string, string>> List of sales with localized keys and values.

Definition at line 257 of file reports.class.php.

References dol_print_date(), dol_stringtotime(), getEntity(), price(), and resolveThirdparty().

Referenced by execute().

◆ getThirdpartyTransactions()

ToolReports::getThirdpartyTransactions ( array $args)
private

Generate a list of raw transactions (Invoices, Orders, Proposals).

Parameters
array<string,mixed>$args Input arguments.
Returns
array<int, array<string, string>> Combined list of transactions.

Definition at line 394 of file reports.class.php.

References dol_print_date(), dol_stringtotime(), getEntity(), price(), and resolveThirdparty().

Referenced by execute().

◆ resolveThirdparty()

ToolReports::resolveThirdparty ( $args)
private

Resolves a Thirdparty ID from either an ID or a name.

If thirdparty_id is provided, it is returned directly. Otherwise, if thirdparty_name is provided, the function searches the Dolibarr societe table using a LIKE match and returns the first match.

Parameters
array<string,mixed>$args Input parameters (thirdparty_id, thirdparty_name)
Returns
int|null Thirdparty ID if found, otherwise null.

Definition at line 227 of file reports.class.php.

References getEntity().

Referenced by getPurchaseReport(), getSalesReport(), and getThirdpartyTransactions().


The documentation for this class was generated from the following file: