code fixes

This commit is contained in:
Dennis Eichhorn 2024-03-15 20:24:38 +00:00
parent 6fba758816
commit 86ae899f4a
9 changed files with 76 additions and 51 deletions

View File

@ -67,6 +67,10 @@ final class Installer extends InstallerAbstract
$module = $app->moduleManager->get('IncomeStatement', 'Api');
$structures = \scandir(__DIR__ . '/Install/Coa');
if ($structures === false) {
return;
}
foreach ($structures as $file) {
if ($file === '..' || $file === '.') {
continue;
@ -80,17 +84,35 @@ final class Installer extends InstallerAbstract
$request->setData('name', \strtr(\basename($file, '.json'), '_', ' '));
$module->apiIncomeStatementCreate($request, $response);
$responseData = $response->getData('');
$responseData = $response->getDataArray('');
$incomeStatement = \is_array($responseData['response'])
? $responseData['response']
: $responseData['response']->toArray();
$json = \json_decode(\file_get_contents(__DIR__ . '/Install/Coa/' . $file), true);
$fileContent = \file_get_contents(__DIR__ . '/Install/Coa/' . $file);
if ($fileContent === false) {
return;
}
/** @var array $json */
$json = \json_decode($fileContent, true);
self::createElement($module, $json, (int) $incomeStatement['id'], null);
}
}
/**
* Create income statement element
*
* @param ApiController $module Module
* @param array $elements Elements to create
* @param int $structure Structure the elements belong to
* @param null|int $parent Parent element (null = none)
*
* @return void
*
* @since 1.0.0
*/
private static function createElement(ApiController $module, array $elements, int $structure, ?int $parent = null) : void
{
$order = 0;
@ -116,6 +138,7 @@ final class Installer extends InstallerAbstract
}
if (!empty($element['account'])) {
/** @var AccountAbstract[] $accountObjects */
$accountObjects = AccountAbstractMapper::getAll()
->where('code', \array_map(function($account) {
return (string) $account;
@ -123,7 +146,7 @@ final class Installer extends InstallerAbstract
->execute();
$request->setData('accounts', \implode(',',
\array_map(function (AccountAbstract $account) {
\array_map(function (AccountAbstract $account) : int {
return $account->id;
}, $accountObjects)
));

View File

@ -164,11 +164,11 @@ final class ApiController extends Controller
{
$element = new IncomeStatementElement();
$element->code = $request->getDataString('code') ?? '';
$element->formula = $request->getDataString('formula') ?? '';
$element->style = $request->getDataString('style') ?? '';
$element->formula = $request->getDataString('formula') ?? '';
$element->style = $request->getDataString('style') ?? '';
$element->incomeStatement = $request->getDataInt('pl') ?? 0;
$element->order = $request->getDataInt('order') ?? 0;
$element->expanded = $request->getDataBool('expanded') ?? false;
$element->expanded = $request->getDataBool('expanded') ?? false;
$element->parent = $request->getDataInt('parent');
$accounts = $request->getDataList('accounts');

View File

@ -66,6 +66,7 @@ final class BackendController extends Controller
$view->data['languages'] = [];
if (!empty($view->data['elements'])) {
/** @var \phpOMS\Localization\BaseStringL11n[] $tempL11ns */
$tempL11ns = IncomeStatementElementL11nMapper::getAll()
->where('ref', \reset($view->data['elements'])->id)
->execute();

View File

@ -44,6 +44,7 @@ class IncomeStatementElement
public string $style = '';
public int $order = 0;
public bool $expanded = false;
public int $incomeStatement = 0;

View File

@ -38,14 +38,14 @@ final class IncomeStatementElementMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'incomestmt_pl_element_id' => ['name' => 'incomestmt_pl_element_id', 'type' => 'int', 'internal' => 'id'],
'incomestmt_pl_element_code' => ['name' => 'incomestmt_pl_element_code', 'type' => 'string', 'internal' => 'code', 'autocomplete' => true],
'incomestmt_pl_element_formula' => ['name' => 'incomestmt_pl_element_formula', 'type' => 'string', 'internal' => 'formula', 'autocomplete' => true],
'incomestmt_pl_element_style' => ['name' => 'incomestmt_pl_element_style', 'type' => 'string', 'internal' => 'style', 'autocomplete' => true],
'incomestmt_pl_element_order' => ['name' => 'incomestmt_pl_element_order', 'type' => 'int', 'internal' => 'order'],
'incomestmt_pl_element_expanded' => ['name' => 'incomestmt_pl_element_expanded', 'type' => 'bool', 'internal' => 'expanded'],
'incomestmt_pl_element_parent' => ['name' => 'incomestmt_pl_element_parent', 'type' => 'int', 'internal' => 'parent'],
'incomestmt_pl_element_pl' => ['name' => 'incomestmt_pl_element_pl', 'type' => 'int', 'internal' => 'incomeStatement'],
'incomestmt_pl_element_id' => ['name' => 'incomestmt_pl_element_id', 'type' => 'int', 'internal' => 'id'],
'incomestmt_pl_element_code' => ['name' => 'incomestmt_pl_element_code', 'type' => 'string', 'internal' => 'code', 'autocomplete' => true],
'incomestmt_pl_element_formula' => ['name' => 'incomestmt_pl_element_formula', 'type' => 'string', 'internal' => 'formula', 'autocomplete' => true],
'incomestmt_pl_element_style' => ['name' => 'incomestmt_pl_element_style', 'type' => 'string', 'internal' => 'style', 'autocomplete' => true],
'incomestmt_pl_element_order' => ['name' => 'incomestmt_pl_element_order', 'type' => 'int', 'internal' => 'order'],
'incomestmt_pl_element_expanded' => ['name' => 'incomestmt_pl_element_expanded', 'type' => 'bool', 'internal' => 'expanded'],
'incomestmt_pl_element_parent' => ['name' => 'incomestmt_pl_element_parent', 'type' => 'int', 'internal' => 'parent'],
'incomestmt_pl_element_pl' => ['name' => 'incomestmt_pl_element_pl', 'type' => 'int', 'internal' => 'incomeStatement'],
];
/**

View File

@ -37,11 +37,11 @@ final class IncomeStatementMapper extends DataMapperFactory
* @since 1.0.0
*/
public const COLUMNS = [
'incomestmt_pl_id' => ['name' => 'incomestmt_pl_id', 'type' => 'int', 'internal' => 'id'],
'incomestmt_pl_code' => ['name' => 'incomestmt_pl_code', 'type' => 'string', 'internal' => 'code', 'autocomplete' => true],
'incomestmt_pl_name' => ['name' => 'incomestmt_pl_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'incomestmt_pl_id' => ['name' => 'incomestmt_pl_id', 'type' => 'int', 'internal' => 'id'],
'incomestmt_pl_code' => ['name' => 'incomestmt_pl_code', 'type' => 'string', 'internal' => 'code', 'autocomplete' => true],
'incomestmt_pl_name' => ['name' => 'incomestmt_pl_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'incomestmt_pl_default' => ['name' => 'incomestmt_pl_default', 'type' => 'bool', 'internal' => 'isDefault'],
'incomestmt_pl_unit' => ['name' => 'incomestmt_pl_unit', 'type' => 'int', 'internal' => 'unit'],
'incomestmt_pl_unit' => ['name' => 'incomestmt_pl_unit', 'type' => 'int', 'internal' => 'unit'],
];
/**

View File

@ -13,21 +13,21 @@
declare(strict_types=1);
return ['IncomeStatement' => [
'Start' => 'Start',
'End' => 'Ende',
'Overview' => 'Übersicht',
'Metrics' => 'Metriken',
'Charts' => 'Charts',
'Interval' => 'Intervall',
'Start' => 'Start',
'End' => 'Ende',
'Overview' => 'Übersicht',
'Metrics' => 'Metriken',
'Charts' => 'Charts',
'Interval' => 'Intervall',
'Environment' => 'Environment',
'Monthly' => 'Monatlich',
'Quarterly' => 'Quartalsweise',
'Annually' => 'Jährlich',
'Category' => 'Kategorie',
'Subtotal' => 'Zwischensumme',
'Total' => 'Summe',
'HR' => 'Personal',
'Sales' => 'Umsatz',
'Diff' => 'Diff',
'Diff%' => 'Diff %',
'Monthly' => 'Monatlich',
'Quarterly' => 'Quartalsweise',
'Annually' => 'Jährlich',
'Category' => 'Kategorie',
'Subtotal' => 'Zwischensumme',
'Total' => 'Summe',
'HR' => 'Personal',
'Sales' => 'Umsatz',
'Diff' => 'Diff',
'Diff%' => 'Diff %',
]];

View File

@ -13,21 +13,21 @@
declare(strict_types=1);
return ['IncomeStatement' => [
'Start' => 'Start',
'End' => 'End',
'Overview' => 'Overview',
'Metrics' => 'Metrics',
'Charts' => 'Charts',
'Interval' => 'Interval',
'Start' => 'Start',
'End' => 'End',
'Overview' => 'Overview',
'Metrics' => 'Metrics',
'Charts' => 'Charts',
'Interval' => 'Interval',
'Environment' => 'Environment',
'Monthly' => 'Monthly',
'Quarterly' => 'Quarterly',
'Annually' => 'Annually',
'Category' => 'Category',
'Subtotal' => 'Subtotal',
'Total' => 'Total',
'HR' => 'HR',
'Diff' => 'Diff',
'Sales' => 'Sales',
'Diff%' => 'Diff %',
'Monthly' => 'Monthly',
'Quarterly' => 'Quarterly',
'Annually' => 'Annually',
'Category' => 'Category',
'Subtotal' => 'Subtotal',
'Total' => 'Total',
'HR' => 'HR',
'Diff' => 'Diff',
'Sales' => 'Sales',
'Diff%' => 'Diff %',
]];

View File

@ -49,7 +49,7 @@ function render_elements(array $elements, ?int $parent = null) : string
{
$row = '';
$fn = 'render_elements';
$acc = 'render_accounts';
$acc = 'render_accounts';
foreach ($elements as $element) {
if ($element->parent !== $parent) {