mirror of
https://github.com/Karaka-Management/oms-IncomeStatement.git
synced 2026-01-11 11:48:41 +00:00
code fixes
This commit is contained in:
parent
6fba758816
commit
86ae899f4a
|
|
@ -67,6 +67,10 @@ final class Installer extends InstallerAbstract
|
||||||
$module = $app->moduleManager->get('IncomeStatement', 'Api');
|
$module = $app->moduleManager->get('IncomeStatement', 'Api');
|
||||||
|
|
||||||
$structures = \scandir(__DIR__ . '/Install/Coa');
|
$structures = \scandir(__DIR__ . '/Install/Coa');
|
||||||
|
if ($structures === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($structures as $file) {
|
foreach ($structures as $file) {
|
||||||
if ($file === '..' || $file === '.') {
|
if ($file === '..' || $file === '.') {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -80,17 +84,35 @@ final class Installer extends InstallerAbstract
|
||||||
$request->setData('name', \strtr(\basename($file, '.json'), '_', ' '));
|
$request->setData('name', \strtr(\basename($file, '.json'), '_', ' '));
|
||||||
|
|
||||||
$module->apiIncomeStatementCreate($request, $response);
|
$module->apiIncomeStatementCreate($request, $response);
|
||||||
$responseData = $response->getData('');
|
$responseData = $response->getDataArray('');
|
||||||
|
|
||||||
$incomeStatement = \is_array($responseData['response'])
|
$incomeStatement = \is_array($responseData['response'])
|
||||||
? $responseData['response']
|
? $responseData['response']
|
||||||
: $responseData['response']->toArray();
|
: $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);
|
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
|
private static function createElement(ApiController $module, array $elements, int $structure, ?int $parent = null) : void
|
||||||
{
|
{
|
||||||
$order = 0;
|
$order = 0;
|
||||||
|
|
@ -116,6 +138,7 @@ final class Installer extends InstallerAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($element['account'])) {
|
if (!empty($element['account'])) {
|
||||||
|
/** @var AccountAbstract[] $accountObjects */
|
||||||
$accountObjects = AccountAbstractMapper::getAll()
|
$accountObjects = AccountAbstractMapper::getAll()
|
||||||
->where('code', \array_map(function($account) {
|
->where('code', \array_map(function($account) {
|
||||||
return (string) $account;
|
return (string) $account;
|
||||||
|
|
@ -123,7 +146,7 @@ final class Installer extends InstallerAbstract
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$request->setData('accounts', \implode(',',
|
$request->setData('accounts', \implode(',',
|
||||||
\array_map(function (AccountAbstract $account) {
|
\array_map(function (AccountAbstract $account) : int {
|
||||||
return $account->id;
|
return $account->id;
|
||||||
}, $accountObjects)
|
}, $accountObjects)
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -164,11 +164,11 @@ final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
$element = new IncomeStatementElement();
|
$element = new IncomeStatementElement();
|
||||||
$element->code = $request->getDataString('code') ?? '';
|
$element->code = $request->getDataString('code') ?? '';
|
||||||
$element->formula = $request->getDataString('formula') ?? '';
|
$element->formula = $request->getDataString('formula') ?? '';
|
||||||
$element->style = $request->getDataString('style') ?? '';
|
$element->style = $request->getDataString('style') ?? '';
|
||||||
$element->incomeStatement = $request->getDataInt('pl') ?? 0;
|
$element->incomeStatement = $request->getDataInt('pl') ?? 0;
|
||||||
$element->order = $request->getDataInt('order') ?? 0;
|
$element->order = $request->getDataInt('order') ?? 0;
|
||||||
$element->expanded = $request->getDataBool('expanded') ?? false;
|
$element->expanded = $request->getDataBool('expanded') ?? false;
|
||||||
$element->parent = $request->getDataInt('parent');
|
$element->parent = $request->getDataInt('parent');
|
||||||
|
|
||||||
$accounts = $request->getDataList('accounts');
|
$accounts = $request->getDataList('accounts');
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ final class BackendController extends Controller
|
||||||
|
|
||||||
$view->data['languages'] = [];
|
$view->data['languages'] = [];
|
||||||
if (!empty($view->data['elements'])) {
|
if (!empty($view->data['elements'])) {
|
||||||
|
/** @var \phpOMS\Localization\BaseStringL11n[] $tempL11ns */
|
||||||
$tempL11ns = IncomeStatementElementL11nMapper::getAll()
|
$tempL11ns = IncomeStatementElementL11nMapper::getAll()
|
||||||
->where('ref', \reset($view->data['elements'])->id)
|
->where('ref', \reset($view->data['elements'])->id)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ class IncomeStatementElement
|
||||||
public string $style = '';
|
public string $style = '';
|
||||||
|
|
||||||
public int $order = 0;
|
public int $order = 0;
|
||||||
|
|
||||||
public bool $expanded = false;
|
public bool $expanded = false;
|
||||||
|
|
||||||
public int $incomeStatement = 0;
|
public int $incomeStatement = 0;
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,14 @@ final class IncomeStatementElementMapper extends DataMapperFactory
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const COLUMNS = [
|
public const COLUMNS = [
|
||||||
'incomestmt_pl_element_id' => ['name' => 'incomestmt_pl_element_id', 'type' => 'int', 'internal' => 'id'],
|
'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_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_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_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_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_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_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_pl' => ['name' => 'incomestmt_pl_element_pl', 'type' => 'int', 'internal' => 'incomeStatement'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,11 @@ final class IncomeStatementMapper extends DataMapperFactory
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const COLUMNS = [
|
public const COLUMNS = [
|
||||||
'incomestmt_pl_id' => ['name' => 'incomestmt_pl_id', 'type' => 'int', 'internal' => 'id'],
|
'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_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_name' => ['name' => 'incomestmt_pl_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||||
'incomestmt_pl_default' => ['name' => 'incomestmt_pl_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
'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'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,21 +13,21 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
return ['IncomeStatement' => [
|
return ['IncomeStatement' => [
|
||||||
'Start' => 'Start',
|
'Start' => 'Start',
|
||||||
'End' => 'Ende',
|
'End' => 'Ende',
|
||||||
'Overview' => 'Übersicht',
|
'Overview' => 'Übersicht',
|
||||||
'Metrics' => 'Metriken',
|
'Metrics' => 'Metriken',
|
||||||
'Charts' => 'Charts',
|
'Charts' => 'Charts',
|
||||||
'Interval' => 'Intervall',
|
'Interval' => 'Intervall',
|
||||||
'Environment' => 'Environment',
|
'Environment' => 'Environment',
|
||||||
'Monthly' => 'Monatlich',
|
'Monthly' => 'Monatlich',
|
||||||
'Quarterly' => 'Quartalsweise',
|
'Quarterly' => 'Quartalsweise',
|
||||||
'Annually' => 'Jährlich',
|
'Annually' => 'Jährlich',
|
||||||
'Category' => 'Kategorie',
|
'Category' => 'Kategorie',
|
||||||
'Subtotal' => 'Zwischensumme',
|
'Subtotal' => 'Zwischensumme',
|
||||||
'Total' => 'Summe',
|
'Total' => 'Summe',
|
||||||
'HR' => 'Personal',
|
'HR' => 'Personal',
|
||||||
'Sales' => 'Umsatz',
|
'Sales' => 'Umsatz',
|
||||||
'Diff' => 'Diff',
|
'Diff' => 'Diff',
|
||||||
'Diff%' => 'Diff %',
|
'Diff%' => 'Diff %',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
|
|
@ -13,21 +13,21 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
return ['IncomeStatement' => [
|
return ['IncomeStatement' => [
|
||||||
'Start' => 'Start',
|
'Start' => 'Start',
|
||||||
'End' => 'End',
|
'End' => 'End',
|
||||||
'Overview' => 'Overview',
|
'Overview' => 'Overview',
|
||||||
'Metrics' => 'Metrics',
|
'Metrics' => 'Metrics',
|
||||||
'Charts' => 'Charts',
|
'Charts' => 'Charts',
|
||||||
'Interval' => 'Interval',
|
'Interval' => 'Interval',
|
||||||
'Environment' => 'Environment',
|
'Environment' => 'Environment',
|
||||||
'Monthly' => 'Monthly',
|
'Monthly' => 'Monthly',
|
||||||
'Quarterly' => 'Quarterly',
|
'Quarterly' => 'Quarterly',
|
||||||
'Annually' => 'Annually',
|
'Annually' => 'Annually',
|
||||||
'Category' => 'Category',
|
'Category' => 'Category',
|
||||||
'Subtotal' => 'Subtotal',
|
'Subtotal' => 'Subtotal',
|
||||||
'Total' => 'Total',
|
'Total' => 'Total',
|
||||||
'HR' => 'HR',
|
'HR' => 'HR',
|
||||||
'Diff' => 'Diff',
|
'Diff' => 'Diff',
|
||||||
'Sales' => 'Sales',
|
'Sales' => 'Sales',
|
||||||
'Diff%' => 'Diff %',
|
'Diff%' => 'Diff %',
|
||||||
]];
|
]];
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ function render_elements(array $elements, ?int $parent = null) : string
|
||||||
{
|
{
|
||||||
$row = '';
|
$row = '';
|
||||||
$fn = 'render_elements';
|
$fn = 'render_elements';
|
||||||
$acc = 'render_accounts';
|
$acc = 'render_accounts';
|
||||||
|
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if ($element->parent !== $parent) {
|
if ($element->parent !== $parent) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user