Hi everybody, I have a formula that used to work in 7.2.4, but is no longer working after upgrading to 7.5.5 - I get "Error 500"
The formula is semi complex, for loans interest rate calculation, and displaying current amount owed
Here is the formula:
And this is the error that in throws in the logs:
Can anybody understand what is going on here?
Is this something I should post to Bug reports?
The formula is semi complex, for loans interest rate calculation, and displaying current amount owed
Here is the formula:
Code:
$d = interestrate/100; $u = $d/12; $k=1+$u; $i = 2; $b = $k; $e = $k; $c= creditterm; while( $i <= $c, $b = $b * $e; $i = $i + 1; ); $j = $b-1; $l = $u * $b / $j; $mon = initialsum* $l; $all = $mon * creditterm; annuitypayment = $mon; sum = $all; $totalpayment=entity\sumRelated('transactions', 'amounttransaction'); balance=(sum-$totalpayment)-balancetemp; $fix = datetime\date(datetime\today()); $fixdate = datetime\addDays(datetime\today(), (-$fix +1)); $st = string\substring($date, 8, 2); $stdate = datetime\addDays(date, -($st-1)); $date = datetime\addMonths($stdate, creditterm); $diffmon = datetime\diff($date, $fixdate, 'months'); $debt = balance - (annuitypayment * $diffmon); currentdebt = number\round($debt, 2);
And this is the error that in throws in the logs:
Code:
[2023-08-24 09:57:54] ERROR: Slim Application Error Type: TypeError Code: 0 Message: Unsupported operand types: string - int File: /var/www/html/application/Espo/Core/Formula/Functions/NumericGroup/SubtractionType.php Line: 52 Trace: #0 /var/www/html/application/Espo/Core/Formula/Processor.php(117): Espo\Core\Formula\Functions\NumericGroup\SubtractionType->process(Object(Espo\Core\Formula\ArgumentList)) #1 /var/www/html/application/Espo/Core/Formula/Functions/BaseFunction.php(97): Espo\Core\Formula\Processor->process(Object(Espo\Core\Formula\Argument)) #2 /var/www/html/application/Espo/Core/Formula/Functions/NumericGroup/SubtractionType.php(46): Espo\Core\Formula\Functions\BaseFunction->evaluate(Object(Espo\Core\Formula\Argument)) #3 /var/www/html/application/Espo/Core/Formula/Processor.php(117): Espo\Core\Formula\Functions\NumericGroup\SubtractionType->process(Object(Espo\Core\Formula\ArgumentList)) #4 /var/www/html/application/Espo/Core/Formula/Processor.php(165): Espo\Core\Formula\Processor->process(Object(Espo\Core\Formula\Argument)) #5 /var/www/html/application/Espo/Core/Formula/Processor.php(88): Espo\Core\Formula\Processor->processList(Object(Espo\Core\Formula\ArgumentList)) #6 /var/www/html/application/Espo/Core/Formula/Functions/BaseFunction.php(97): Espo\Core\Formula\Processor->process(Object(Espo\Core\Formula\ArgumentList)) #7 /var/www/html/application/Espo/Core/Formula/Functions/DatetimeGroup/AddIntervalType.php(57): Espo\Core\Formula\Functions\BaseFunction->evaluate(Object(Espo\Core\Formula\ArgumentList)) #8 /var/www/html/application/Espo/Core/Formula/Processor.php(117): Espo\Core\Formula\Functions\DatetimeGroup\AddIntervalType->process(Object(Espo\Core\Formula\ArgumentList)) #9 /var/www/html/application/Espo/Core/Formula/Functions/BaseFunction.php(97): Espo\Core\Formula\Processor->process(Object(Espo\Core\Formula\Argument)) #10 /var/www/html/application/Espo/Core/Formula/Functions/AssignType.php(51): Espo\Core\Formula\Functions\BaseFunction->evaluate(Object(Espo\Core\Formula\Argument)) #11 /var/www/html/application/Espo/Core/Formula/Processor.php(117): Espo\Core\Formula\Functions\AssignType->process(Object(Espo\Core\Formula\ArgumentList)) #12 /var/www/html/application/Espo/Core/Formula/Functions/BaseFunction.php(97): Espo\Core\Formula\Processor->process(Object(Espo\Core\Formula\Argument)) #13 /var/www/html/application/Espo/Core/Formula/Functions/BundleType.php(42): Espo\Core\Formula\Functions\BaseFunction->evaluate(Object(Espo\Core\Formula\Argument)) #14 /var/www/html/application/Espo/Core/Formula/Processor.php(117): Espo\Core\Formula\Functions\BundleType->process(Object(Espo\Core\Formula\ArgumentList)) #15 /var/www/html/application/Espo/Core/Formula/Evaluator.php(88): Espo\Core\Formula\Processor->process(Object(Espo\Core\Formula\Argument)) #16 /var/www/html/application/Espo/Core/Formula/Manager.php(60): Espo\Core\Formula\Evaluator->process('$d = interestra...', Object(Espo\Custom\Entities\Loan), Object(stdClass)) #17 /var/www/html/application/Espo/Hooks/Common/Formula.php(81): Espo\Core\Formula\Manager->run('$d = interestra...', Object(Espo\Custom\Entities\Loan), Object(stdClass)) #18 /var/www/html/application/Espo/Hooks/Common/Formula.php(75): Espo\Hooks\Common\Formula->runScript('$d = interestra...', Object(Espo\Custom\Entities\Loan), Object(stdClass)) #19 /var/www/html/application/Espo/Core/Hook/GeneralInvoker.php(81): Espo\Hooks\Common\Formula->beforeSave(Object(Espo\Custom\Entities\Loan), Object(Espo\ORM\Repository\Option\SaveOptions)) #20 /var/www/html/application/Espo/Core/HookManager.php(119): Espo\Core\Hook\GeneralInvoker->invoke(Object(Espo\Hooks\Common\Formula), 'beforeSave', Object(Espo\Custom\Entities\Loan), Array, Array) #21 /var/www/html/application/Espo/Core/Repositories/Database.php(298): Espo\Core\HookManager->process('Loan', 'beforeSave', Object(Espo\Custom\Entities\Loan), Array) #22 /var/www/html/application/Espo/ORM/Repository/RDBRepository.php(139): Espo\Core\Repositories\Database->beforeSave(Object(Espo\Custom\Entities\Loan), Array) #23 /var/www/html/application/Espo/Core/Repositories/Database.php(136): Espo\ORM\Repository\RDBRepository->save(Object(Espo\Custom\Entities\Loan), Array) #24 /var/www/html/application/Espo/ORM/EntityManager.php(247): Espo\Core\Repositories\Database->save(Object(Espo\Custom\Entities\Loan), Array) #25 /var/www/html/application/Espo/Core/MassAction/Actions/MassRecalculateFormula.php(74): Espo\ORM\EntityManager->saveEntity(Object(Espo\Custom\Entities\Loan), Array) #26 /var/www/html/application/Espo/Core/MassAction/Service.php(88): Espo\Core\MassAction\Actions\MassRecalculateFormula->process(Object(Espo\Core\MassAction\Params), Object(Espo\Core\MassAction\Data)) #27 /var/www/html/application/Espo/Core/MassAction/Api/PostProcess.php(81): Espo\Core\MassAction\Service->process('Loan', 'recalculateForm...', Object(Espo\Core\MassAction\ServiceParams), Object(stdClass)) #28 /var/www/html/application/Espo/Core/Api/ActionHandler.php(71): Espo\Core\MassAction\Api\PostProcess->process(Object(Espo\Core\Api\RequestWrapper)) #29 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Espo\Core\Api\ActionHandler->handle(Object(Slim\Psr7\Request)) #30 /var/www/html/application/Espo/Core/Api/RouteProcessor.php(177): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #31 /var/www/html/application/Espo/Core/Api/RouteProcessor.php(146): Espo\Core\Api\RouteProcessor->processAction('Espo\\Core\\MassA...', Object(Espo\Core\Api\ProcessData), Object(Slim\Psr7\Request), Object(Espo\Core\Api\ResponseWrapper)) #32 /var/www/html/application/Espo/Core/Api/RouteProcessor.php(127): Espo\Core\Api\RouteProcessor->processAfterAuth(Object(Espo\Core\Api\ProcessData), Object(Slim\Psr7\Request), Object(Espo\Core\Api\ResponseWrapper)) #33 /var/www/html/application/Espo/Core/Api/RouteProcessor.php(79): Espo\Core\Api\RouteProcessor->processInternal(Object(Espo\Core\Api\ProcessData), Object(Slim\Psr7\Request), Object(Espo\Core\Api\RequestWrapper), Object(Espo\Core\Api\ResponseWrapper)) #34 /var/www/html/application/Espo/Core/Api/Starter.php(109): Espo\Core\Api\RouteProcessor->process(Object(Espo\Core\Api\ProcessData), Object(Slim\Psr7\Request), Object(Slim\Psr7\Response)) #35 /var/www/html/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Espo\Core\Api\Starter->Espo\Core\Api\{closure}(Object(Slim\Psr7\Request), Object(Slim\Psr7\Response), Array) #36 /var/www/html/vendor/slim/slim/Slim/Routing/Route.php(358): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Psr7\Request), Object(Slim\Psr7\Response), Array) #37 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\Routing\Route->handle(Object(Slim\Psr7\Request)) #38 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #39 /var/www/html/vendor/slim/slim/Slim/Routing/Route.php(315): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #40 /var/www/html/vendor/slim/slim/Slim/Routing/RouteRunner.php(68): Slim\Routing\Route->run(Object(Slim\Psr7\Request)) #41 /var/www/html/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(45): Slim\Routing\RouteRunner->handle(Object(Slim\Psr7\Request)) #42 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(Slim\Routing\RouteRunner)) #43 /var/www/html/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(76): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Psr7\Request)) #44 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(121): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(Psr\Http\Server\RequestHandlerInterface@anonymous)) #45 /var/www/html/vendor/slim/slim/Slim/MiddlewareDispatcher.php(65): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Psr7\Request)) #46 /var/www/html/vendor/slim/slim/Slim/App.php(199): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #47 /var/www/html/vendor/slim/slim/Slim/App.php(183): Slim\App->handle(Object(Slim\Psr7\Request)) #48 /var/www/html/application/Espo/Core/Api/Starter.php(76): Slim\App->run() #49 /var/www/html/application/Espo/Core/ApplicationRunners/Api.php(45): Espo\Core\Api\Starter->start() #50 /var/www/html/application/Espo/Core/Application/RunnerRunner.php(84): Espo\Core\ApplicationRunners\Api->run() #51 /var/www/html/application/Espo/Core/Application.php(78): Espo\Core\Application\RunnerRunner->run('Espo\\Core\\Appli...', NULL) #52 /var/www/html/public/api/v1/index.php(35): Espo\Core\Application->run('Espo\\Core\\Appli...') #53 {main} Tips: To display error details in HTTP response set "displayErrorDetails" to true in the ErrorHandler constructor.
Is this something I should post to Bug reports?
Comment