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.
 
 writePrecheck (string $toolName, array $args)
 Reason why a write cannot run at all, checked before any confirmation.
 

Private Member Functions

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

Additional Inherited Members

- Static Public Member Functions inherited from McpTool
static normalizeInputSchema (array $schema)
 Normalize a tool input schema to ensure broad compatibility with LLM function-calling APIs (e.g.
 
- 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 207 of file reports.class.php.

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

◆ 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 195 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 768 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 683 of file reports.class.php.

References getEntity(), and price().

Referenced by execute().

◆ getPurchaseReport()

ToolReports::getPurchaseReport ( 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. Generate a purchase/expense report.
Parameters
array<string,mixed>$args Input arguments.
Returns
array<int, array<string, string>>|array{rows:array<int,array<string,string>>,chart:array<string,mixed>} List of rows, or {rows, chart} when grouped.

Definition at line 561 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 176 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>>|array{rows:array<int,array<string,string>>,chart:array<string,mixed>} List of rows, or {rows, chart} when grouped.

Definition at line 266 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 236 of file reports.class.php.

References getEntity().

Referenced by getPurchaseReport(), and getSalesReport().


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