|
dolibarr 24.0.0-beta
|
Class ToolProducts. More...


Public Member Functions | |
| __construct ($db, $user) | |
| Constructor. | |
| getDefinitions () | |
| Returns an array of tool definitions, including name, description, and input schema. | |
| 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 | |
| findProduct ($identifier, ?string $type=null) | |
| Find a product by various identifiers (ID, Ref, Barcode, Label). | |
| extractIdentifier (array $args) | |
| Extracts the product identifier from arguments. | |
| search (array $args) | |
| Searches for products or services based on a query, type, and pagination. | |
| getProductCategories (int $product_id) | |
| Fetch product categories. | |
| getDetails (array $args) | |
| Retrieves comprehensive details for a specific product or service. | |
| getPendingCustomerOrdersQty (int $product_id) | |
| Get pending customer orders quantity for a product. | |
| getPendingSupplierOrdersQty (int $product_id) | |
| Get pending supplier orders quantity for a product. | |
| generateReplenishmentRecommendation (float $virtual_stock, float $min_stock_alert, float $desired_stock, float $dailyBurnRate) | |
| Generate replenishment recommendation. | |
| analyze (array $args) | |
| Performs an inventory analysis for a specific product. | |
| getSupplierPrices (array $args) | |
| Retrieves a list of all defined supplier prices for a given product or service. | |
Class ToolProducts.
Provides various tools related to Dolibarr products and services.
Definition at line 39 of file products.class.php.
| ToolProducts::__construct | ( | $db, | |
| $user ) |
|
private |
Performs an inventory analysis for a specific product.
Calculates burn rate based on last 90 days of sales (Invoices) and predicts stockout dates.
| array{product_id? | int|string, product_name?: string, type?: string} $args Arguments array. |
Definition at line 749 of file products.class.php.
References $conf, $prod, dol_buildpath(), dol_include_once(), dol_now(), dol_print_date(), dol_syslog(), dol_time_plus_duree(), extractIdentifier(), findProduct(), generateReplenishmentRecommendation(), getEntity(), getPendingCustomerOrdersQty(), getPendingSupplierOrdersQty(), and user.
Referenced by execute().
| ToolProducts::execute | ( | string | $name, |
| array | $args ) |
Executes the requested tool function based on its name.
| string | $name | The name of the tool to execute. |
| array<string,mixed> | $args The arguments for the tool (key-value pairs). |
Reimplemented from McpTool.
Definition at line 189 of file products.class.php.
References analyze(), getDetails(), getSupplierPrices(), and search().
|
private |
Extracts the product identifier from arguments.
Returns the identifier string/int or null if missing.
| array{product_id? | int|string, product_name?: string, type?: string} $args Arguments array |
Definition at line 335 of file products.class.php.
References string.
Referenced by analyze(), getDetails(), and getSupplierPrices().
|
private |
Find a product by various identifiers (ID, Ref, Barcode, Label).
| string | int | $identifier | The search term (ID, ref, barcode, etc.). |
| string | null | $type | Optional filter: 'product' or 'service'. |
Definition at line 213 of file products.class.php.
References getEntity().
Referenced by analyze(), getDetails(), and getSupplierPrices().
|
private |
Generate replenishment recommendation.
Logic prioritizes Critical (Negative) -> High (Below Alert) -> Low (Below Desired).
| float | $virtual_stock | Current virtual stock (Physical + Incoming - Outgoing). |
| float | $min_stock_alert | Minimum stock alert level (Seuil alerte). |
| float | $desired_stock | Desired stock level (Stock désiré). |
| float | $dailyBurnRate | Estimated daily consumption rate. |
Definition at line 667 of file products.class.php.
Referenced by analyze().
| ToolProducts::getCategories | ( | ) |
Return categories this tool belongs to.
Used by the intent parser to filter available tools.
Reimplemented from McpTool.
Definition at line 177 of file products.class.php.
| ToolProducts::getDefinitions | ( | ) |
Returns an array of tool definitions, including name, description, and input schema.
Reimplemented from McpTool.
Definition at line 58 of file products.class.php.
|
private |
Retrieves comprehensive details for a specific product or service.
| array{product_id? | int|string, product_name?: string, type?: string} $args Arguments array. |
Definition at line 492 of file products.class.php.
References $prod, dol_buildpath(), dol_include_once(), extractIdentifier(), findProduct(), getProductCategories(), string, and user.
Referenced by execute().
|
private |
Get pending customer orders quantity for a product.
Calculates the total quantity found in Sales Orders with status Validated (1) or In Process (2).
| int | $product_id | Product ID |
Definition at line 581 of file products.class.php.
References $conf, dol_syslog(), and getEntity().
Referenced by analyze().
|
private |
Get pending supplier orders quantity for a product.
Sums quantity from Supplier Orders with status Validated(1), Approved(2), Ordered(3), or Partially Received(4).
| int | $product_id | Product ID |
Definition at line 622 of file products.class.php.
References $conf, dol_syslog(), and getEntity().
Referenced by analyze().
|
private |
Fetch product categories.
| int | $product_id | Product ID |
Definition at line 455 of file products.class.php.
References $conf, and dol_include_once().
Referenced by getDetails().
|
private |
Retrieves a list of all defined supplier prices for a given product or service.
| array<string,mixed> | $args Input parameters (product_id, product_name, type) |
Definition at line 874 of file products.class.php.
References $prod, dol_buildpath(), dol_print_date(), dol_syslog(), extractIdentifier(), findProduct(), getEntity(), and user.
Referenced by execute().
|
private |
Searches for products or services based on a query, type, and pagination.
| array{query? | string, type?: string, limit?: int, offset?: int} $args Arguments array. |
Definition at line 364 of file products.class.php.
References dol_buildpath(), dol_syslog(), getEntity(), price(), string, and user.
Referenced by execute().