|
dolibarr 25.0.0-alpha
|
Class ToolProducts. More...


Public Member Functions | |
| __construct ($db, $user) | |
| Constructor. | |
| getDefinitions () | |
| Returns an array of tool definitions, including name, description, and input schema. | |
| getRequiredRights (string $toolName) | |
| Catalog reads, supplier prices and stock forecast. | |
| writeConfirmationPreview (string $toolName, array $args) | |
| Preview of the catalog record this call would write. | |
| 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 | |
| create (array $args) | |
| Create a new product or service in the catalog. | |
| 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. | |
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. | |
Class ToolProducts.
Provides various tools related to Dolibarr products and services.
Definition at line 42 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 877 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().
|
private |
Create a new product or service in the catalog.
| array{label?:string,ref?:string,type?:string,price?:float|int|string,price_base_type?:string,vat_rate?:float|int|string,cost_price?:float|int|string,barcode?:string,description?:string} | $args Tool arguments. |
Definition at line 274 of file products.class.php.
References Product\TYPE_PRODUCT, Product\TYPE_SERVICE, 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 250 of file products.class.php.
References analyze(), create(), 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 461 of file products.class.php.
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 339 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. |
| float | $dailyBurnRate | Estimated daily consumption rate. |
Definition at line 795 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 238 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 61 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 618 of file products.class.php.
References $prod, aiStripPersonalExtrafields(), dol_buildpath(), dol_include_once(), extractIdentifier(), findProduct(), getProductCategories(), 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 709 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 750 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 581 of file products.class.php.
References $conf, and dol_include_once().
Referenced by getDetails().
| ToolProducts::getRequiredRights | ( | string | $toolName | ) |
Catalog reads, supplier prices and stock forecast.
| string | $toolName | Tool being executed. |
Reimplemented from McpTool.
Definition at line 199 of file products.class.php.
References McpTool\RIGHTS_UNDECLARED.
|
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 1002 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 490 of file products.class.php.
References dol_buildpath(), dol_syslog(), getEntity(), price(), and user.
Referenced by execute().
| ToolProducts::writeConfirmationPreview | ( | string | $toolName, |
| array | $args ) |
Preview of the catalog record this call would write.
| string | $toolName | Tool that would run. |
| array<string,mixed> | $args Arguments it would run with. |
Reimplemented from McpTool.
Definition at line 219 of file products.class.php.
References McpTool\NO_WRITE.