mirror of
https://github.com/Karaka-Management/oms-IncomeStatement.git
synced 2026-02-14 03:28: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)
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user