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.
 
 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.
 

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).
 

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 $db, 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 179 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 167 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 705 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 620 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 514 of file reports.class.php.

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

Referenced by execute().

◆ 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 238 of file reports.class.php.

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

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 375 of file reports.class.php.

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

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 208 of file reports.class.php.

References getEntity().

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


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