<?php
namespace App\AI\Contexts\Utils; class Configurations extends \App\AI\Contexts\ContextAbstract { protected function checkPermission_configured_services_list() : bool { return \App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToSection('Modules/Admin/Config/Services/Basic'); } protected function checkPermission_configured_calculations_vats() : bool { return \App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToSection('Modules/Admin/Config/Services/Advanced'); } protected function checkPermission_configured_offer_vat_percents() : bool { return \App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToSection('Modules/Admin/Config/Services/Advanced'); } protected function checkPermission_configured_invoice_vat_percents() : bool { return \App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToSection('Modules/Admin/Config/Services/Advanced'); } protected function generateFunctionObject_configured_services_list(\App\AI\Api\ChatGpt\Responses\ToolFunction $funcObj) : \App\AI\Api\ChatGpt\Responses\ToolFunction { return $funcObj; } protected function generateFunctionObject_configured_calculations_vats(\App\AI\Api\ChatGpt\Responses\ToolFunction $funcObj) : \App\AI\Api\ChatGpt\Responses\ToolFunction { return $funcObj; } protected function generateFunctionObject_configured_offer_vat_percents(\App\AI\Api\ChatGpt\Responses\ToolFunction $funcObj) : \App\AI\Api\ChatGpt\Responses\ToolFunction { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $servCodeObj = new \App\AI\Api\ChatGpt\Responses\Property(); $servCodeObj->type = "string"; $servCodeObj->description = "The service code."; $servCodeObj->enum = array_keys(\App\Config\Services_Basic::getInstance()->getListLinearSimple()); $funcObj->parameters->addProperty("serviceCode", $servCodeObj); $locCodeObj = new \App\AI\Api\ChatGpt\Responses\Property(); $locCodeObj->type = "string"; $locCodeObj->description = "The location code for the service."; $locCodeObj->enum = array_values($CFG['countriesCriteria']); $funcObj->parameters->addProperty("locationCode", $locCodeObj); $calcCodeObj = new \App\AI\Api\ChatGpt\Responses\Property(); $calcCodeObj->type = "string"; $calcCodeObj->description = "The calculation code for the service and location."; $funcObj->parameters->addProperty("calculationCode", $calcCodeObj); $funcObj->parameters->required = ['serviceCode', 'locationCode', 'calculationCode']; return $funcObj; } protected function generateFunctionObject_configured_invoice_vat_percents(\App\AI\Api\ChatGpt\Responses\ToolFunction $funcObj) : \App\AI\Api\ChatGpt\Responses\ToolFunction { return $this->generateFunctionObject_configured_offer_vat_percents($funcObj); } protected function executeFunction_configured_services_list(string $arguments) : array { $args = json_decode($arguments, 1); $results = \App\Config\Services_Basic::getInstance()->getListLinear(); return $results; } protected function executeFunction_configured_calculations_vats(string $arguments) : array { $args = json_decode($arguments, 1); $results = \App\Config\Services_Calculations::getInstance()->getAllSimpleList(); return $results; } protected function executeFunction_configured_offer_vat_percents(string $arguments) : array { $args = json_decode($arguments, 1); $results = \App\Config\Services_Calculations_OfferVat::getAdmin()->getCalculationDetails($args['serviceCode'], $args['locationCode'], $args['calculationCode']); return $results; } protected function executeFunction_configured_invoice_vat_percents(string $arguments) : array { $args = json_decode($arguments, 1); $results = \App\Config\Services_Calculations_InvoiceVat::getAdmin()->getCalculationDetails($args['serviceCode'], $args['locationCode'], $args['calculationCode']); return $results; } protected function developerMessage_configured_services_list(string $arguments, array $response): string { return "Allow the user to see the `Services setup` section by giving him a clickable link to the section: " . \Engine\Mvc\Dispatcher::getInstance()->getAppUrl('Modules/Admin/Config/Services/Basic', 'index'); } protected function developerMessage_configured_calculations_vats(string $arguments): string { $developerMessage = "The function `configured_calculations_vats` retrieves a list of the configured VAT quotas for all the services in the format serviceCode=>locationCode=>calculationCode=>calculationName. Don't display the calculationCode to the user."; $developerMessage .= "\n\nIt does not return the exact VAT percents, for that you need to access one of the other functions `configured_offer_vat_percents` or `configured_invoice_vat_percents` using serviceCode, locationCode and calculationCode as parameters."; $developerMessage .= "\n\nAllow the user to see the `Configure services - calculations and VATs` section by giving him a clickable link to the section: " . \Engine\Mvc\Dispatcher::getInstance()->getAppUrl('Modules/Admin/Config/Services/Advanced', 'index'); return $developerMessage; } } 