diff --git a/.github/dev_bug_report.md b/.github/dev_bug_report.md deleted file mode 100644 index ef93e56..0000000 --- a/.github/dev_bug_report.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Dev Bug Report -about: Create a report to help us improve -title: '' -labels: stat_backlog, type_bug -assignees: '' - ---- - -# Bug Description -A clear and concise description of what the bug is. - -# How to Reproduce - -Steps to reproduce the behavior: - -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -## Minimal Code Example - -``` -// your code ... -``` - -# Expected Behavior -A clear and concise description of what you expected to happen. - -# Screenshots -If applicable, add screenshots to help explain your problem. - -# Additional Information -Add any other context about the problem here. diff --git a/.github/dev_feature_request.md b/.github/dev_feature_request.md deleted file mode 100644 index 9573c35..0000000 --- a/.github/dev_feature_request.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Dev Feature Request -about: Suggest an idea for this project -title: '' -labels: stat_backlog, type_feature -assignees: '' - ---- - -# What is the feature you request -* A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -* A clear and concise description of what you want to happen. - -# Alternatives -A clear and concise description of any alternative solutions or features you've considered. - -# Additional Information -Add any other context or screenshots about the feature request here. diff --git a/Admin/Install/Coa/SKR03_DE_GAAP.json b/Admin/Install/Coa/SKR03_DE_GAAP.json index 15321be..4a75008 100644 --- a/Admin/Install/Coa/SKR03_DE_GAAP.json +++ b/Admin/Install/Coa/SKR03_DE_GAAP.json @@ -8,7 +8,8 @@ "account": [], "type": "category", "formula": "", - "style": "category", + "style": "total", + "expanded": true, "children": [ { "name": "A.A", @@ -27,7 +28,7 @@ "en": "Intangible Assets", "de": "Immaterielle Vermögensgegenständ" }, - "account": [], + "account": [5], "type": "category", "formula": "", "style": "category", @@ -38,7 +39,7 @@ "en": "Self-determined trademarks and similar rights and values", "de": "Selbst geschaffene gewerbliche Schutzrechte und ähnliche Rechte und Werte" }, - "account": [], + "account": [43,44,45,46,47,48], "type": "category", "formula": "", "style": "category", @@ -50,7 +51,7 @@ "en": "Purchased licenses, trademarks and similar rights and values as well as licenses to such rights and values", "de": "entgeltlich erworbene Konzessionen, gewerbliche Schutzrechte und ähnliche Rechte und Werte sowie Lizenzen an solchen Rechten und Werten" }, - "account": [], + "account": [10,15,20,25,27,30], "type": "category", "formula": "", "style": "category", @@ -62,7 +63,7 @@ "en": "Goodwill", "de": "Geschäfts- oder Firmenwert" }, - "account": [], + "account": [35], "type": "category", "formula": "", "style": "category", @@ -74,7 +75,7 @@ "en": "Advance payments made", "de": "geleistete Anzahlungen" }, - "account": [], + "account": [38,39], "type": "category", "formula": "", "style": "category", @@ -99,7 +100,7 @@ "en": "Properties, rights equivalent to real property and buildings, including buildings on third-party land", "de": "Grundstücke, grundstücksgleiche Rechte und Bauten einschließlich der Bauten auf fremden Grundstücken" }, - "account": [], + "account": [50,59,60,65,70,75,80,85,90,100,110,111,112,113,115,140,145,146,147,148,149,160,165,170,175,176,177,178,179,190,191,192,193,194], "type": "category", "formula": "", "style": "category", @@ -111,7 +112,7 @@ "en": "Technical equipment and machinery", "de": "technische Anlagen und Maschinen" }, - "account": [], + "account": [200,210,220,240,260,280], "type": "category", "formula": "", "style": "category", @@ -123,7 +124,7 @@ "en": "Other equipment, operating and office equipment", "de": "andere Anlagen, Betriebs- und Geschäftsausstattung" }, - "account": [], + "account": [300,310,320,350,380,400,410,420,430,440,450,460,480,485,490], "type": "category", "formula": "", "style": "category", @@ -135,7 +136,7 @@ "en": "Advance payments made and construction in progress", "de": "geleistete Anzahlungen und Anlagen im Bau" }, - "account": [], + "account": [79,120,129,150,159,180,189,195,199,290,299,498,499], "type": "category", "formula": "", "style": "category", @@ -160,7 +161,7 @@ "en": "Shares in affiliated companies", "de": "Anteile an verbundenen Unternehmen" }, - "account": [], + "account": [500,501,502,503,504,509], "type": "category", "formula": "", "style": "category", @@ -172,7 +173,7 @@ "en": "Loans to affiliated companies", "de": "Ausleihungen an verbundene Unternehmen" }, - "account": [], + "account": [505,506,507,508,520,523,524], "type": "category", "formula": "", "style": "category", @@ -184,7 +185,7 @@ "en": "Other long-term equity investments", "de": "Beteiligungen" }, - "account": [], + "account": [510,513,516,517,518,519,570], "type": "category", "formula": "", "style": "category", @@ -208,7 +209,7 @@ "en": "Long-term securities", "de": "Wertpapiere des Anlagevermögens" }, - "account": [], + "account": [525,530,535,538], "type": "category", "formula": "", "style": "category", @@ -220,7 +221,7 @@ "en": "Other loans", "de": "sonstige Ausleihungen" }, - "account": [], + "account": [540,550,580,582,583,584,586,590], "type": "category", "formula": "", "style": "category", @@ -418,7 +419,7 @@ "name": "A.C", "l11n": { "en": "Accrual", - "de": "Rechnungsabgrenzungsposten" + "de": "ARAP" }, "account": [], "type": "category", @@ -461,7 +462,8 @@ "account": [], "type": "category", "formula": "", - "style": "category", + "style": "total", + "expanded": true, "children": [ { "name": "P.A", @@ -469,7 +471,7 @@ "en": "Equity", "de": "Eigenkapital" }, - "account": [], + "account": [810,811,812,813,815,819], "type": "category", "formula": "", "style": "category", @@ -480,7 +482,7 @@ "en": "Subscribed Capital", "de": "Gezeichnetes Kapital" }, - "account": [], + "account": [800,809], "type": "category", "formula": "", "style": "category", @@ -651,7 +653,7 @@ "en": "Bonds", "de": "Anleihen" }, - "account": [], + "account": [600,601,605,610,615,616,620,625], "type": "category", "formula": "", "style": "category", @@ -676,7 +678,7 @@ "en": "Liabilities to financial institutions", "de": "Verbindlichkeiten gegenüber Kreditinstituten" }, - "account": [], + "account": [630, 631, 640, 650,660,661,670,680,690,699], "type": "category", "formula": "", "style": "category", @@ -724,7 +726,7 @@ "en": "Liabilities to affiliated companies", "de": "Verbindlichkeiten gegenüber verbundenen Unternehmen" }, - "account": [], + "account": [700,701,705,710], "type": "category", "formula": "", "style": "category", @@ -736,7 +738,7 @@ "en": "Liabilities to companies invested in", "de": "Verbindlichkeiten gegenüber Unternehmen, mit denen ein Beteiligungsverhältnis besteht" }, - "account": [], + "account": [715,716,720,725], "type": "category", "formula": "", "style": "category", @@ -748,7 +750,7 @@ "en": "Other liabilities", "de": "sonstige Verbindlichkeiten" }, - "account": [], + "account": [730,731,740,750,755,760,761,764,767,770,771,774,777,780,781,784,787,790,799], "type": "category", "formula": "", "style": "category", @@ -785,7 +787,7 @@ "name": "P.D", "l11n": { "en": "Accrual", - "de": "Rechnungsabgrenzungsposten" + "de": "PRAP" }, "account": [], "type": "category", diff --git a/Admin/Install/Coa/SKR03_DE_IFRS.json b/Admin/Install/Coa/SKR03_DE_IFRS.json index 2410994..b0620a7 100644 --- a/Admin/Install/Coa/SKR03_DE_IFRS.json +++ b/Admin/Install/Coa/SKR03_DE_IFRS.json @@ -8,7 +8,8 @@ "account": [], "type": "category", "formula": "", - "style": "category", + "style": "total", + "expanded": true, "children": [ { "name": "A.A", @@ -373,7 +374,8 @@ "account": [], "type": "category", "formula": "", - "style": "category", + "style": "total", + "expanded": true, "children": [ { "name": "P.A", diff --git a/Admin/Install/db.json b/Admin/Install/db.json index b79c7d7..1839a73 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -36,11 +36,26 @@ "type": "VARCHAR(255)", "null": false }, + "balance_balance_element_formula": { + "name": "balance_balance_element_formula", + "type": "VARCHAR(255)", + "null": false + }, + "balance_balance_element_style": { + "name": "balance_balance_element_style", + "type": "VARCHAR(255)", + "null": false + }, "balance_balance_element_order": { "name": "balance_balance_element_order", "type": "INT", "null": false }, + "balance_balance_element_expanded": { + "name": "balance_balance_element_expanded", + "type": "TINYINT(1)", + "null": false + }, "balance_balance_element_parent": { "name": "balance_balance_element_parent", "type": "INT", @@ -87,5 +102,36 @@ "foreignKey": "language_639_1" } } + }, + "balance_balance_element_rel": { + "name": "balance_balance_element_rel", + "fields": { + "balance_balance_element_rel_id": { + "name": "balance_balance_element_rel_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "balance_balance_element_rel_order": { + "name": "balance_balance_element_rel_order", + "type": "INT", + "null": true + }, + "balance_balance_element_rel_account": { + "name": "balance_balance_element_rel_account", + "type": "INT", + "null": false, + "foreignTable": "accounting_account", + "foreignKey": "accounting_account_id" + }, + "balance_balance_element_rel_element": { + "name": "balance_balance_element_rel_element", + "type": "INT", + "null": false, + "foreignTable": "balance_balance_element", + "foreignKey": "balance_balance_element_id" + } + } } } \ No newline at end of file diff --git a/Admin/Installer.php b/Admin/Installer.php index 2756782..fdbf1fe 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Modules\Balance\Admin; +use Modules\Accounting\Models\AccountAbstract; +use Modules\Accounting\Models\AccountAbstractMapper; use Modules\Balance\Controller\ApiController; use phpOMS\Application\ApplicationAbstract; use phpOMS\Config\SettingsInterface; @@ -62,7 +64,7 @@ final class Installer extends InstallerAbstract private static function importStructures(ApplicationAbstract $app) : void { /** @var \Modules\Balance\Controller\ApiController $module */ - $module = $app->moduleManager->getModuleInstance('Balance', 'Api'); + $module = $app->moduleManager->get('Balance', 'Api'); $structures = \scandir(__DIR__ . '/Install/Coa'); foreach ($structures as $file) { @@ -74,8 +76,8 @@ final class Installer extends InstallerAbstract $request = new HttpRequest(); $request->header->account = 1; - $request->setData('code', \strtolower(\basename($file))); - $request->setData('name', \strtr(\basename($file), '_', ' ')); + $request->setData('code', \strtolower(\basename($file, '.json'))); + $request->setData('name', \strtr(\basename($file, '.json'), '_', ' ')); $module->apiBalanceCreate($request, $response); $responseData = $response->getData(''); @@ -102,16 +104,31 @@ final class Installer extends InstallerAbstract $request->setData('code', $element['name']); $request->setData('content', \reset($element['l11n'])); $request->setData('language', \array_keys($element['l11n'])[0] ?? 'en'); - $request->setData('accounts', \implode(',', $element['account'])); $request->setData('formula', $element['formula']); $request->setData('type', $element['type']); + $request->setData('style', $element['style']); $request->setData('balance', $structure); $request->setData('order', $order); + $request->setData('expanded', $element['expanded'] ?? false); if ($parent !== null) { $request->setData('parent', $parent); } + if (!empty($element['account'])) { + $accountObjects = AccountAbstractMapper::getAll() + ->where('code', \array_map(function($account) { + return (string) $account; + }, $element['account']), 'IN') + ->execute(); + + $request->setData('accounts', \implode(',', + \array_map(function (AccountAbstract $account) { + return $account->id; + }, $accountObjects) + )); + } + $module->apiBalanceElementCreate($request, $response); $responseData = $response->getData(''); @@ -130,7 +147,7 @@ final class Installer extends InstallerAbstract $request = new HttpRequest(); $request->header->account = 1; - $request->setData('title', $l11n); + $request->setData('content', $l11n); $request->setData('language', $language); $request->setData('ref', $balanceElement['id']); diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 8f4421e..28aa38f 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\Balance\Controller; +use Modules\Accounting\Models\NullAccountAbstract; use Modules\Balance\Models\Balance; use Modules\Balance\Models\BalanceElement; use Modules\Balance\Models\BalanceElementL11nMapper; @@ -163,10 +164,18 @@ final class ApiController extends Controller { $element = new BalanceElement(); $element->code = $request->getDataString('code') ?? ''; + $element->formula = $request->getDataString('formula') ?? ''; + $element->style = $request->getDataString('style') ?? ''; $element->balance = $request->getDataInt('balance') ?? 0; $element->order = $request->getDataInt('order') ?? 0; + $element->expanded = $request->getDataBool('expanded') ?? false; $element->parent = $request->getDataInt('parent'); + $accounts = $request->getDataList('accounts'); + foreach ($accounts as $account) { + $element->accounts[] = new NullAccountAbstract((int) $account); + } + $element->setL11n( $request->getDataString('content') ?? '', ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN diff --git a/Controller/BackendController.php b/Controller/BackendController.php index d665c3d..a48e3a9 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,7 +14,9 @@ declare(strict_types=1); namespace Modules\Balance\Controller; +use Modules\Balance\Models\BalanceElementL11nMapper; use Modules\Balance\Models\BalanceElementMapper; +use Modules\Balance\Models\BalanceMapper; use phpOMS\Contract\RenderableInterface; use phpOMS\DataStorage\Database\Query\OrderType; use phpOMS\Message\RequestAbstract; @@ -49,14 +51,29 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Balance/Theme/Backend/balance-dashboard'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006501001, $request, $response); - $elements = BalanceElementMapper::getAll() + $view->data['elements'] = BalanceElementMapper::getAll() ->with('l11n') - ->where('balance', $request->getDataInt('balance') ?? 1) - ->where('l11n/language', $response->header->l11n->language) + ->with('accounts') + ->with('accounts/l11n') + ->where('balance', $request->getDataInt('structure') ?? 1) + ->where('l11n/language', $request->getDataString('language') ?? $response->header->l11n->language) + ->where('accounts/l11n/language', $request->getDataString('language') ?? $response->header->l11n->language) ->sort('order', OrderType::ASC) ->execute(); - $view->data['elements'] = $elements; + $view->data['structures'] = BalanceMapper::getAll() + ->execute(); + + $view->data['languages'] = []; + if (!empty($view->data['elements'])) { + $tempL11ns = BalanceElementL11nMapper::getAll() + ->where('ref', \reset($view->data['elements'])->id) + ->execute(); + + foreach ($tempL11ns as $l11n) { + $view->data['languages'][] = $l11n->language; + } + } return $view; } diff --git a/Models/BalanceElement.php b/Models/BalanceElement.php index b3c049e..a6d2746 100644 --- a/Models/BalanceElement.php +++ b/Models/BalanceElement.php @@ -41,12 +41,17 @@ class BalanceElement public string $formula = ''; + public string $style = ''; + public int $order = 0; + public bool $expanded = false; public int $balance = 0; public ?int $parent = null; + public array $accounts = []; + /* * String l11n * diff --git a/Models/BalanceElementMapper.php b/Models/BalanceElementMapper.php index 1931e2d..c010ad1 100644 --- a/Models/BalanceElementMapper.php +++ b/Models/BalanceElementMapper.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\Balance\Models; +use Modules\Accounting\Models\AccountAbstractMapper; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\Localization\BaseStringL11n; @@ -39,7 +40,10 @@ final class BalanceElementMapper extends DataMapperFactory public const COLUMNS = [ 'balance_balance_element_id' => ['name' => 'balance_balance_element_id', 'type' => 'int', 'internal' => 'id'], 'balance_balance_element_code' => ['name' => 'balance_balance_element_code', 'type' => 'string', 'internal' => 'code', 'autocomplete' => true], + 'balance_balance_element_formula' => ['name' => 'balance_balance_element_formula', 'type' => 'string', 'internal' => 'formula', 'autocomplete' => true], + 'balance_balance_element_style' => ['name' => 'balance_balance_element_style', 'type' => 'string', 'internal' => 'style', 'autocomplete' => true], 'balance_balance_element_order' => ['name' => 'balance_balance_element_order', 'type' => 'int', 'internal' => 'order'], + 'balance_balance_element_expanded' => ['name' => 'balance_balance_element_expanded', 'type' => 'bool', 'internal' => 'expanded'], 'balance_balance_element_parent' => ['name' => 'balance_balance_element_parent', 'type' => 'int', 'internal' => 'parent'], 'balance_balance_element_balance' => ['name' => 'balance_balance_element_balance', 'type' => 'int', 'internal' => 'balance'], ]; @@ -58,6 +62,12 @@ final class BalanceElementMapper extends DataMapperFactory 'column' => 'content', 'external' => null, ], + 'accounts' => [ + 'mapper' => AccountAbstractMapper::class, + 'table' => 'balance_balance_element_rel', + 'self' => 'balance_balance_element_rel_element', + 'external' => 'balance_balance_element_rel_account', + ], ]; /** diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php new file mode 100644 index 0000000..21ed35f --- /dev/null +++ b/Theme/Backend/Lang/de.lang.php @@ -0,0 +1,31 @@ + [ + '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', + 'Diff' => 'Diff', + 'Diff%' => 'Diff %', +]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 7e58f5a..a9aa183 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -4,7 +4,7 @@ * * PHP Version 8.1 * - * @package Modules\Balance + * @package Modules\PL * @copyright Dennis Eichhorn * @license OMS License 2.0 * @version 1.0.0 @@ -13,4 +13,19 @@ declare(strict_types=1); return ['Balance' => [ + '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', + 'Diff' => 'Diff', + 'Diff%' => 'Diff %', ]]; diff --git a/Theme/Backend/balance-dashboard.tpl.php b/Theme/Backend/balance-dashboard.tpl.php index 14796a3..803a514 100644 --- a/Theme/Backend/balance-dashboard.tpl.php +++ b/Theme/Backend/balance-dashboard.tpl.php @@ -12,54 +12,88 @@ */ declare(strict_types=1); +use phpOMS\Localization\ISO639Enum; + +function render_accounts(array $accounts) : string +{ + $row = ''; + + foreach ($accounts as $account) { + $row .= << +
+
{$account->code} - {$account->getL11n()}
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
1,234.56 %
+
123,456.00
+ + ROW; + } + + return $row; +} + function render_elements(array $elements, ?int $parent = null) : string { $row = ''; $fn = 'render_elements'; + $acc = 'render_accounts'; foreach ($elements as $element) { if ($element->parent !== $parent) { continue; } + $expand = ''; + foreach ($elements as $child) { + if ($child->parent === $element->id + || !empty($element->accounts) + ) { + $expand = ''; + break; + } + } + + $expanded = $element->expanded ? ' checked' : ''; + $row .= << -
-
-
{$element->getL11n()}
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
-
+0.00%
+ +
+
{$expand}
+
{$element->getL11n()}
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
123,456.00
+
1,234.56 %
+
123,456.00
-
{$fn($elements, $element->id)} + {$acc($element->accounts)}
ROW; @@ -70,46 +104,305 @@ function render_elements(array $elements, ?int $parent = null) : string echo $this->data['nav']->render(); ?> + + +
+
+
+
+
+ +
+ +
+ +
-
-
data['elements'], null); ?>
+
+
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+
+ request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> +
+
+
+
+
getHtml('Category'); ?>
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
getHtml('Total'); ?>
+
getHtml('Diff%'); ?>
+
getHtml('Diff'); ?> USD
+
+
+ +
+
data['elements'], null); ?>
+
+
+ + request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> +
+
+
+
+
+ + +
+
+
+
+
+ + request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>> +
+
+
+
+
+ +
+
+
+
+
+ +
\ No newline at end of file diff --git a/info.json b/info.json index 383ea6a..5a4ebc0 100644 --- a/info.json +++ b/info.json @@ -16,6 +16,7 @@ }, "directory": "Balance", "dependencies": { + "Accounting": "*", "Controlling": "*" }, "providing": {