mirror of
https://github.com/Karaka-Management/oms-InvestmentManagement.git
synced 2026-01-10 19:28:42 +00:00
Continue implementation.
This commit is contained in:
parent
208ae3a315
commit
af101e25bc
|
|
@ -36,7 +36,7 @@
|
|||
"type": 2,
|
||||
"subtype": 1,
|
||||
"name": "PurchaseInquiries",
|
||||
"uri": "{/base}/private/investment?{?}",
|
||||
"uri": "{/prefix}/private/investment?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 10,
|
||||
|
|
|
|||
30
Admin/Install/amounttypes.json
Normal file
30
Admin/Install/amounttypes.json
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[
|
||||
{
|
||||
"name": "earnings",
|
||||
"l11n": {
|
||||
"en": "Earnings",
|
||||
"de": "Erlöse"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "costs",
|
||||
"l11n": {
|
||||
"en": "Costs",
|
||||
"de": "Kosten"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "cashflow",
|
||||
"l11n": {
|
||||
"en": "Cashflow",
|
||||
"de": "Cashflow"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "depreciation",
|
||||
"l11n": {
|
||||
"en": "Depreciation",
|
||||
"de": "Abschreibung"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_investment_title": {
|
||||
"name": "investmgmt_investment_title",
|
||||
"investmgmt_investment_name": {
|
||||
"name": "investmgmt_investment_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
|
|
@ -19,6 +19,16 @@
|
|||
"type": "TEXT",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_investment_status": {
|
||||
"name": "investmgmt_investment_status",
|
||||
"type": "TINYINT",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_investment_depreciation_type": {
|
||||
"name": "investmgmt_investment_depreciation_type",
|
||||
"type": "TINYINT",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_investment_created_by": {
|
||||
"name": "investmgmt_investment_created_by",
|
||||
"type": "INT",
|
||||
|
|
@ -33,60 +43,303 @@
|
|||
"null": true,
|
||||
"foreignTable": "unit",
|
||||
"foreignKey": "unit_id"
|
||||
},
|
||||
"investmgmt_investment_performance": {
|
||||
"name": "investmgmt_investment_performance",
|
||||
"type": "DATETIME",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_investment_created_at": {
|
||||
"name": "investmgmt_investment_created_at",
|
||||
"type": "DATETIME",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"investmgmt_investment_option": {
|
||||
"name": "investmgmt_investment_option",
|
||||
"investmgmt_investmen_media": {
|
||||
"name": "investmgmt_investmen_media",
|
||||
"fields": {
|
||||
"investmgmt_investment_option_id": {
|
||||
"name": "investmgmt_investment_option_id",
|
||||
"investmgmt_investmen_media_id": {
|
||||
"name": "investmgmt_investmen_media_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_investment_option_description": {
|
||||
"name": "investmgmt_investment_option_description",
|
||||
"investmgmt_investmen_media_investment": {
|
||||
"name": "investmgmt_investmen_media_investment",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_investmen",
|
||||
"foreignKey": "investmgmt_investmen_id"
|
||||
},
|
||||
"investmgmt_investmen_media_media": {
|
||||
"name": "investmgmt_investmen_media_media",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media",
|
||||
"foreignKey": "media_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"investmgmt_investmen_note": {
|
||||
"name": "investmgmt_investmen_note",
|
||||
"fields": {
|
||||
"investmgmt_investmen_note_id": {
|
||||
"name": "investmgmt_investmen_note_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_investmen_note_investment": {
|
||||
"name": "investmgmt_investmen_note_investment",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_investmen",
|
||||
"foreignKey": "investmgmt_investmen_id"
|
||||
},
|
||||
"investmgmt_investmen_note_doc": {
|
||||
"name": "investmgmt_investmen_note_doc",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "editor_doc",
|
||||
"foreignKey": "editor_doc_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"investmgmt_option": {
|
||||
"name": "investmgmt_option",
|
||||
"fields": {
|
||||
"investmgmt_option_id": {
|
||||
"name": "investmgmt_option_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_option_name": {
|
||||
"name": "investmgmt_option_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_option_description": {
|
||||
"name": "investmgmt_option_description",
|
||||
"type": "TEXT",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_investment_option_price": {
|
||||
"name": "investmgmt_investment_option_price",
|
||||
"type": "BIGINT",
|
||||
"investmgmt_option_link": {
|
||||
"name": "investmgmt_option_link",
|
||||
"type": "TEXT",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_investment_option_investment": {
|
||||
"name": "investmgmt_investment_option_investment",
|
||||
"investmgmt_option_approved": {
|
||||
"name": "investmgmt_option_approved",
|
||||
"type": "TINYINT",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_option_investment": {
|
||||
"name": "investmgmt_option_investment",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_investment",
|
||||
"foreignKey": "investmgmt_investment_id"
|
||||
},
|
||||
"investmgmt_investment_option_supplier": {
|
||||
"name": "investmgmt_investment_option_supplier",
|
||||
"investmgmt_option_supplier": {
|
||||
"name": "investmgmt_option_supplier",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "suppliermgmt_supplier",
|
||||
"foreignKey": "suppliermgmt_supplier_id"
|
||||
},
|
||||
"investmgmt_investment_option_supplier_alt": {
|
||||
"name": "investmgmt_investment_option_supplier_alt",
|
||||
"investmgmt_option_supplier_alt": {
|
||||
"name": "investmgmt_option_supplier_alt",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_investment_option_item": {
|
||||
"name": "investmgmt_investment_option_item",
|
||||
"investmgmt_option_item": {
|
||||
"name": "investmgmt_option_item",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "itemmgmt_item",
|
||||
"foreignKey": "itemmgmt_item_id"
|
||||
},
|
||||
"investmgmt_investment_option_item_alt": {
|
||||
"name": "investmgmt_investment_option_item_alt",
|
||||
"investmgmt_option_parent": {
|
||||
"name": "investmgmt_option_parent",
|
||||
"type": "INT",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "investmgmt_option",
|
||||
"foreignKey": "investmgmt_option_id"
|
||||
},
|
||||
}
|
||||
},
|
||||
"investmgmt_option_media": {
|
||||
"name": "investmgmt_option_media",
|
||||
"fields": {
|
||||
"investmgmt_option_media_id": {
|
||||
"name": "investmgmt_option_media_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_option_media_option": {
|
||||
"name": "investmgmt_option_media_option",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_investmen",
|
||||
"foreignKey": "investmgmt_option_id"
|
||||
},
|
||||
"investmgmt_option_media_media": {
|
||||
"name": "investmgmt_option_media_media",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media",
|
||||
"foreignKey": "media_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"investmgmt_option_note": {
|
||||
"name": "investmgmt_option_note",
|
||||
"fields": {
|
||||
"investmgmt_option_note_id": {
|
||||
"name": "investmgmt_option_note_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_option_note_option": {
|
||||
"name": "investmgmt_option_note_option",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_investmen",
|
||||
"foreignKey": "investmgmt_option_id"
|
||||
},
|
||||
"investmgmt_option_note_doc": {
|
||||
"name": "investmgmt_option_note_doc",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "editor_doc",
|
||||
"foreignKey": "editor_doc_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"investmgmt_amount_type": {
|
||||
"name": "investmgmt_amount_type",
|
||||
"fields": {
|
||||
"investmgmt_amount_type_id": {
|
||||
"name": "investmgmt_amount_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_amount_type_name": {
|
||||
"name": "investmgmt_amount_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"investmgmt_amount_type_l11n": {
|
||||
"name": "investmgmt_amount_type_l11n",
|
||||
"fields": {
|
||||
"investmgmt_amount_type_l11n_id": {
|
||||
"name": "investmgmt_amount_type_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_amount_type_l11n_title": {
|
||||
"name": "investmgmt_amount_type_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_amount_type_l11n_type": {
|
||||
"name": "investmgmt_amount_type_l11n_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_amount_type",
|
||||
"foreignKey": "investmgmt_amount_type_id"
|
||||
},
|
||||
"investmgmt_amount_type_l11n_lang": {
|
||||
"name": "investmgmt_amount_type_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"investmgmt_amount_group": {
|
||||
"name": "investmgmt_amount_group",
|
||||
"fields": {
|
||||
"investmgmt_amount_group_id": {
|
||||
"name": "investmgmt_amount_group_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_amount_group_name": {
|
||||
"name": "investmgmt_amount_group_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_amount_group_type": {
|
||||
"name": "investmgmt_amount_group_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_amount_type",
|
||||
"foreignKey": "investmgmt_amount_type_id"
|
||||
},
|
||||
"investmgmt_amount_group_option": {
|
||||
"name": "investmgmt_amount_group_option",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_option",
|
||||
"foreignKey": "investmgmt_option_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"investmgmt_amount": {
|
||||
"name": "investmgmt_amount",
|
||||
"fields": {
|
||||
"investmgmt_amount_id": {
|
||||
"name": "investmgmt_amount_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"investmgmt_amount_name": {
|
||||
"name": "investmgmt_amount_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_amount_amount": {
|
||||
"name": "investmgmt_amount_amount",
|
||||
"type": "BIGINT",
|
||||
"null": false
|
||||
},
|
||||
"investmgmt_amount_date": {
|
||||
"name": "investmgmt_amount_date",
|
||||
"type": "DATETIME",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"investmgmt_amount_group": {
|
||||
"name": "investmgmt_amount_group",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "investmgmt_amount_group",
|
||||
"foreignKey": "investmgmt_amount_group_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
|
|
@ -8,20 +8,26 @@
|
|||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\InvestmentManagement\Admin;
|
||||
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
use phpOMS\Config\SettingsInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Module\InstallerAbstract;
|
||||
use phpOMS\Module\ModuleInfo;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* Installer class.
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Admin
|
||||
* @license OMS License 2.0
|
||||
* @link https://orange-management.org
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class Installer extends InstallerAbstract
|
||||
|
|
@ -33,4 +39,83 @@ final class Installer extends InstallerAbstract
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const PATH = __DIR__;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void
|
||||
{
|
||||
parent::install($app, $info, $cfgHandler);
|
||||
|
||||
/* Fuel types */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/amounttypes.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var array $types */
|
||||
$types = \json_decode($fileContent, true);
|
||||
$amountTypes = self::createAmountTypes($app, $types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Install amount type
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $types Attribute definition
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createAmountTypes(ApplicationAbstract $app, array $types) : array
|
||||
{
|
||||
/** @var array<string, array> $amountTypes */
|
||||
$amountTypes = [];
|
||||
|
||||
/** @var \Modules\InvestmentManagement\Controller\ApiController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('InvestmentManagement', 'Api');
|
||||
|
||||
/** @var array $type */
|
||||
foreach ($types as $type) {
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('name', $type['name'] ?? '');
|
||||
$request->setData('title', \reset($type['l11n']));
|
||||
$request->setData('language', \array_keys($type['l11n'])[0] ?? 'en');
|
||||
|
||||
$module->apiFuelTypeCreate($request, $response);
|
||||
|
||||
$responseData = $response->get('');
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$amountTypes[$type['name']] = !\is_array($responseData['response'])
|
||||
? $responseData['response']->toArray()
|
||||
: $responseData['response'];
|
||||
|
||||
$isFirst = true;
|
||||
foreach ($type['l11n'] as $language => $l11n) {
|
||||
if ($isFirst) {
|
||||
$isFirst = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $l11n);
|
||||
$request->setData('language', $language);
|
||||
$request->setData('type', $amountTypes[$type['name']]['id']);
|
||||
|
||||
$module->apiFuelTypeL11nCreate($request, $response);
|
||||
}
|
||||
}
|
||||
|
||||
return $amountTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1016
Controller/ApiController.php
Normal file
1016
Controller/ApiController.php
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -25,21 +25,20 @@ use phpOMS\Stdlib\Base\FloatInt;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Money
|
||||
class Amount
|
||||
{
|
||||
public int $id = 0;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public int $depreciationType = DepreciationType::STAIGHT_LINE;
|
||||
|
||||
public int $depreciationDuration = 0;
|
||||
|
||||
public FloatInt $amount;
|
||||
|
||||
public FloatInt $residualValue;
|
||||
public int $group = 0;
|
||||
|
||||
public MoneyType $moneyType;
|
||||
public ?\DateTime $date = null;
|
||||
|
||||
public bool $recurring = false;
|
||||
public function __construct()
|
||||
{
|
||||
$this->amount = new FloatInt();
|
||||
}
|
||||
}
|
||||
|
|
@ -14,25 +14,31 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\InvestmentManagement\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Business\Finance\DepreciationType;
|
||||
use phpOMS\Stdlib\Base\FloatInt;
|
||||
|
||||
/**
|
||||
* Money type (one off cost, recurring, earnings).
|
||||
* Costs/Earnings.
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class MoneyType
|
||||
class AmountGroup
|
||||
{
|
||||
public int $id = 0;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public BaseStringL11n $content;
|
||||
public array $amounts = [];
|
||||
|
||||
public bool $cost = true;
|
||||
public BaseStringL11nType $type;
|
||||
|
||||
public bool $recurring = false;
|
||||
public int $option = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = new BaseStringL11nType();
|
||||
}
|
||||
}
|
||||
88
Models/AmountGroupMapper.php
Normal file
88
Models/AmountGroupMapper.php
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\InvestmentManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of Task
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AmountGroupMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'investmgmt_amount_group_id' => ['name' => 'investmgmt_amount_group_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'investmgmt_amount_group_name' => ['name' => 'investmgmt_amount_group_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'investmgmt_amount_group_type' => ['name' => 'investmgmt_amount_group_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'investmgmt_amount_group_option' => ['name' => 'investmgmt_amount_group_option', 'type' => 'int', 'internal' => 'option'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
'type' => [
|
||||
'mapper' => AmountTypeMapper::class,
|
||||
'external' => 'investmgmt_amount_group_type',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'amounts' => [
|
||||
'mapper' => AmountGroupMapper::class,
|
||||
'table' => 'investmgmt_amount',
|
||||
'self' => 'investmgmt_amount_group',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'investmgmt_amount_group';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'investmgmt_amount_group_id';
|
||||
}
|
||||
61
Models/AmountMapper.php
Normal file
61
Models/AmountMapper.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\InvestmentManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of Task
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AmountGroupMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'investmgmt_amount_id' => ['name' => 'investmgmt_amount_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'investmgmt_amount_name' => ['name' => 'investmgmt_amount_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'investmgmt_amount_amount' => ['name' => 'investmgmt_amount_amount', 'type' => 'Serializable', 'internal' => 'type'],
|
||||
'investmgmt_amount_date' => ['name' => 'investmgmt_amount_date', 'type' => 'DateTime', 'internal' => 'date'],
|
||||
'investmgmt_amount_group' => ['name' => 'investmgmt_amount_group', 'type' => 'int', 'internal' => 'group'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'investmgmt_amount';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'investmgmt_amount_id';
|
||||
}
|
||||
69
Models/AmountTypeL11nMapper.php
Normal file
69
Models/AmountTypeL11nMapper.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\InvestmentManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* mapper class.
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AmountTypeL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'investmgmt_amount_type_l11n_id' => ['name' => 'investmgmt_amount_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'investmgmt_amount_type_l11n_title' => ['name' => 'investmgmt_amount_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'investmgmt_amount_type_l11n_type' => ['name' => 'investmgmt_amount_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||
'investmgmt_amount_type_l11n_lang' => ['name' => 'investmgmt_amount_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'investmgmt_amount_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'investmgmt_amount_type_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
83
Models/AmountTypeMapper.php
Normal file
83
Models/AmountTypeMapper.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\InvestmentManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11nType;
|
||||
|
||||
/**
|
||||
* Item mapper class.
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11nType
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AmountTypeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'investmgmt_amount_type_id' => ['name' => 'investmgmt_amount_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'investmgmt_amount_type_name' => ['name' => 'investmgmt_amount_type_name', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => AmountTypeL11nMapper::class,
|
||||
'table' => 'investmgmt_amount_type_l11n',
|
||||
'self' => 'investmgmt_amount_type_l11n_type',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11nType::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'investmgmt_amount_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'investmgmt_amount_type_id';
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\InvestmentManagement\Models;
|
||||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use phpOMS\Business\Finance\DepreciationType;
|
||||
|
||||
/**
|
||||
|
|
@ -31,9 +32,13 @@ class Investment
|
|||
|
||||
public string $name = '';
|
||||
|
||||
public int $depreciationType = DepreciationType::STAIGHT_LINE;
|
||||
public string $description = '';
|
||||
|
||||
public array $objects = [];
|
||||
public int $depreciationType = DepreciationType::NONE;
|
||||
|
||||
public int $status = InvestmentStatus::DRAFT;
|
||||
|
||||
public array $options = [];
|
||||
|
||||
/**
|
||||
* Income
|
||||
|
|
@ -42,5 +47,27 @@ class Investment
|
|||
|
||||
public Account $createdBy;
|
||||
|
||||
public \DateTimeImmutable $createdAt;
|
||||
|
||||
public \DateTime $performanceDate;
|
||||
|
||||
public array $attributeTypes = [];
|
||||
|
||||
public ?int $unit = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public __construct()
|
||||
{
|
||||
$this->createdBy = new NullAccount();
|
||||
$this->createdAt = new \DateTimeImmutable('now');
|
||||
$this->perforamnceDate = new \DateTime('now');
|
||||
}
|
||||
|
||||
use \Modules\Media\Models\MediaListTrait;
|
||||
use \Modules\Editor\Models\EditorDocListTrait;
|
||||
use \Modules\Attribute\Models\AttributeHolderTrait;
|
||||
}
|
||||
|
|
|
|||
117
Models/InvestmentMapper.php
Normal file
117
Models/InvestmentMapper.php
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\InvestmentManagement\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Organization\Models\UnitMapper;
|
||||
use Modules\Editor\Models\EditorDocMapper;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of Task
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class InvestmentMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'investmgmt_investment_id' => ['name' => 'investmgmt_investment_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'investmgmt_investment_name' => ['name' => 'investmgmt_investment_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'investmgmt_investment_description' => ['name' => 'investmgmt_investment_description', 'type' => 'string', 'internal' => 'description'],
|
||||
'investmgmt_investment_status' => ['name' => 'investmgmt_investment_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'investmgmt_investment_depreciation_type' => ['name' => 'investmgmt_investment_depreciation_type', 'type' => 'int', 'internal' => 'depreciationType'],
|
||||
'investmgmt_investment_unit' => ['name' => 'investmgmt_investment_unit', 'type' => 'int', 'internal' => 'unit'],
|
||||
'investmgmt_investment_created_by' => ['name' => 'investmgmt_investment_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
'investmgmt_investment_performance' => ['name' => 'investmgmt_investment_performance', 'type' => 'DateTime', 'internal' => 'performanceDate'],
|
||||
'investmgmt_investment_created_at' => ['name' => 'investmgmt_investment_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'files' => [
|
||||
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||
'table' => 'investmgmt_investment_media', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'external' => 'investmgmt_investment_media_media',
|
||||
'self' => 'investmgmt_investment_media_investment',
|
||||
],
|
||||
'notes' => [
|
||||
'mapper' => EditorDocMapper::class, /* mapper of the related object */
|
||||
'table' => 'investmgmt_investment_note', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'external' => 'investmgmt_investment_note_doc',
|
||||
'self' => 'investmgmt_investment_note_investment',
|
||||
],
|
||||
'options' => [
|
||||
'mapper' => InvestmentObjectMapper::class,
|
||||
'table' => 'investmgmt_investment_option',
|
||||
'self' => 'investmgmt_investment_option_investment',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const BELONGS_TO = [
|
||||
'createdBy' => [
|
||||
'mapper' => AccountMapper::class,
|
||||
'external' => 'investmgmt_investment_created_by',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'investmgmt_investment';
|
||||
|
||||
/**
|
||||
* Created at.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const CREATED_AT = 'investmgmt_investment_created_at';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'investmgmt_investment_id';
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ class InvestmentObject
|
|||
{
|
||||
public int $id = 0;
|
||||
|
||||
public string $productName = '';
|
||||
public string $name = '';
|
||||
|
||||
public string $description = '';
|
||||
|
||||
|
|
@ -34,14 +34,23 @@ class InvestmentObject
|
|||
|
||||
public string $supplierName = '';
|
||||
|
||||
public string $productLink = '';
|
||||
public string $link = '';
|
||||
|
||||
/**
|
||||
* Costs / Revenue
|
||||
*/
|
||||
public array $money = [];
|
||||
public array $amountGroups = [];
|
||||
|
||||
public bool $approved = false;
|
||||
|
||||
public array $attributes = [];
|
||||
|
||||
public ?int $parent = null;
|
||||
|
||||
public int $investment = 0;
|
||||
|
||||
public ?int $item = null;
|
||||
|
||||
use \Modules\Media\Models\MediaListTrait;
|
||||
use \Modules\Editor\Models\EditorDocListTrait;
|
||||
}
|
||||
|
|
|
|||
114
Models/InvestmentObjectMapper.php
Normal file
114
Models/InvestmentObjectMapper.php
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\InvestmentManagement\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Editor\Models\EditorDocMapper;
|
||||
use Modules\SupplierManagement\Models\SupplierMapper;
|
||||
use Modules\ItemManagement\Models\ItemMapper;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
*
|
||||
* @package Modules\InvestmentManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of Task
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class InvestmentObjectMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'investmgmt_option_id' => ['name' => 'investmgmt_option_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'investmgmt_option_name' => ['name' => 'investmgmt_option_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'investmgmt_option_description' => ['name' => 'investmgmt_option_description', 'type' => 'string', 'internal' => 'description'],
|
||||
'investmgmt_option_link' => ['name' => 'investmgmt_option_link', 'type' => 'string', 'internal' => 'link'],
|
||||
'investmgmt_option_supplier' => ['name' => 'investmgmt_option_supplier', 'type' => 'int', 'internal' => 'supplier'],
|
||||
'investmgmt_option_supplier_alt' => ['name' => 'investmgmt_option_supplier_alt', 'type' => 'string', 'internal' => 'supplierName'],
|
||||
'investmgmt_option_item' => ['name' => 'investmgmt_option_item', 'type' => 'int', 'internal' => 'item'],
|
||||
'investmgmt_option_approved' => ['name' => 'investmgmt_option_approved', 'type' => 'bool', 'internal' => 'approved'],
|
||||
'investmgmt_option_investment' => ['name' => 'investmgmt_option_investment', 'type' => 'int', 'internal' => 'investment'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
'supplier' => [
|
||||
'mapper' => SupplierMapper::class,
|
||||
'external' => 'investmgmt_option_supplier',
|
||||
],
|
||||
'item' => [
|
||||
'mapper' => ItemMapper::class,
|
||||
'external' => 'investmgmt_option_item',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'files' => [
|
||||
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||
'table' => 'investmgmt_option_media', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'external' => 'investmgmt_option_media_media',
|
||||
'self' => 'investmgmt_option_media_option',
|
||||
],
|
||||
'notes' => [
|
||||
'mapper' => EditorDocMapper::class, /* mapper of the related object */
|
||||
'table' => 'investmgmt_option_note', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'external' => 'investmgmt_option_note_doc',
|
||||
'self' => 'investmgmt_option_note_option',
|
||||
],
|
||||
'amountGroups' => [
|
||||
'mapper' => AmountGroupMapper::class,
|
||||
'table' => 'investmgmt_amount_group',
|
||||
'self' => 'investmgmt_amount_group_option',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'investmgmt_option';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'investmgmt_option_id';
|
||||
}
|
||||
|
|
@ -27,4 +27,6 @@ use phpOMS\Stdlib\Base\Enum;
|
|||
abstract class PermissionCategory extends Enum
|
||||
{
|
||||
public const INVESTMENT = 1;
|
||||
|
||||
public const AMOUNT_TYPE = 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user