autofixes

This commit is contained in:
Dennis Eichhorn 2023-08-30 12:08:10 +00:00
parent f9aaadf3f6
commit c873e2bcaa
11 changed files with 62 additions and 68 deletions

View File

@ -54,7 +54,7 @@ final class Installer extends InstallerAbstract
}
/** @var array $types */
$types = \json_decode($fileContent, true);
$types = \json_decode($fileContent, true);
$amountTypes = self::createAmountTypes($app, $types);
}

View File

@ -20,9 +20,9 @@ use Modules\InvestmentManagement\Models\AmountGroup;
use Modules\InvestmentManagement\Models\AmountTypeL11nMapper;
use Modules\InvestmentManagement\Models\AmountTypeMapper;
use Modules\InvestmentManagement\Models\Investment;
use Modules\InvestmentManagement\Models\InvestmentMapper;
use Modules\InvestmentManagement\Models\InvestmentObject;
use Modules\InvestmentManagement\Models\InvestmentObjectMapper;
use Modules\InvestmentManagement\Models\InvestmentMapper;
use Modules\InvestmentManagement\Models\InvestmentStatus;
use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\MediaMapper;
@ -95,14 +95,14 @@ final class ApiController extends Controller
*/
public function createInvestmentFromRequest(RequestAbstract $request) : Investment
{
$investment = new Investment();
$investment->name = $request->getDataString('name') ?? '';
$investment = new Investment();
$investment->name = $request->getDataString('name') ?? '';
$investment->description = $request->getDataString('description') ?? '';
$investment->status = $request->getDataInt('status') ?? InvestmentStatus::DRAFT;
$investment->status = $request->getDataInt('status') ?? InvestmentStatus::DRAFT;
//$investment->type = new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0));
$investment->description = $request->getDataString('description') ?? '';
$investment->unit = $request->getDataInt('unit') ?? $this->app->unitId;
$investment->createdBy = new NullAccount($request->header->account);
$investment->unit = $request->getDataInt('unit') ?? $this->app->unitId;
$investment->createdBy = new NullAccount($request->header->account);
$investment->performanceDate = $request->getDataDateTime('performance') ?? new \DateTime($investment->createdAt->format('Y-m-d H:i:s'));
return $investment;
@ -111,8 +111,8 @@ final class ApiController extends Controller
/**
* Create media files for investment
*
* @param Investment $investment Investment
* @param RequestAbstract $request Request incl. media do upload
* @param Investment $investment Investment
* @param RequestAbstract $request Request incl. media do upload
*
* @return void
*
@ -245,7 +245,7 @@ final class ApiController extends Controller
/** @var \Modules\InvestmentManagement\Models\Investment $investment */
$investment = InvestmentMapper::get()->where('id', (int) $request->getData('investment'))->execute();
$path = $this->createInvestmentDir($investment);
$path = $this->createInvestmentDir($investment);
$uploaded = [];
if (!empty($uploadedFiles = $request->files)) {
@ -470,15 +470,15 @@ final class ApiController extends Controller
*/
public function createInvestmentOptionFromRequest(RequestAbstract $request) : InvestmentObject
{
$investment = new InvestmentObject();
$investment->name = $request->getDataString('name') ?? '';
$investment->description = $request->getDataString('description') ?? '';
$investment->link = $request->getDataString('link') ?? '';
$investment->investment = (int) $request->getData('investment');
$investment->parent = $request->getDataInt('parent');
$investment->supplier = $request->getDataInt('supplier');
$investment = new InvestmentObject();
$investment->name = $request->getDataString('name') ?? '';
$investment->description = $request->getDataString('description') ?? '';
$investment->link = $request->getDataString('link') ?? '';
$investment->investment = (int) $request->getData('investment');
$investment->parent = $request->getDataInt('parent');
$investment->supplier = $request->getDataInt('supplier');
$investment->supplierName = $request->getDataString('supplierName') ?? '';
$investment->item = $request->getDataInt('item');
$investment->item = $request->getDataInt('item');
// @todo: reconsider the following lines. This seems rather complicated.
if ($request->hasData('amount')) {
@ -486,35 +486,35 @@ final class ApiController extends Controller
foreach ($types as $type) {
if ($type->title = 'costs') {
$defaultGroup = new AmountGroup();
$defaultGroup = new AmountGroup();
$defaultGroup->name = 'Purchase Price'; // @todo: replace with api l11n
$defaultGroup->type = $type->id;
$amount = new Amount();
$amount = new Amount();
$amount->amount = new FloatInt((int) $request->getDataInt('amount'));
$defaultGroup->amounts[] = $amount;
$investment->amountGroups[] = $defaultGroup;
} elseif ($type->title === 'cashflow') {
$defaultGroup = new AmountGroup();
$defaultGroup = new AmountGroup();
$defaultGroup->name = 'Cashflow'; // @todo: replace with api l11n
$defaultGroup->type = $type->id;
// @todo: calculate date based on performance date + offer conditions / 30 days
$amount = new Amount();
$amount = new Amount();
$amount->amount = new FloatInt((int) $request->getDataInt('amount'));
$defaultGroup->amounts[] = $amount;
$investment->amountGroups[] = $defaultGroup;
} elseif ($type->title === 'depreciation') {
$defaultGroup = new AmountGroup();
$defaultGroup = new AmountGroup();
$defaultGroup->name = 'Depreciation'; // @todo: replace with api l11n
$defaultGroup->type = $type->id;
// @todo: calculate automatic depreciation;
$amount = new Amount();
$amount = new Amount();
$amount->amount = new FloatInt((int) $request->getDataInt('amount'));
$defaultGroup->amounts[] = $amount;
@ -559,8 +559,8 @@ final class ApiController extends Controller
/**
* Create media files for investment
*
* @param InvestmentObject $investment Investment
* @param RequestAbstract $request Request incl. media do upload
* @param InvestmentObject $investment Investment
* @param RequestAbstract $request Request incl. media do upload
*
* @return void
*
@ -693,7 +693,7 @@ final class ApiController extends Controller
/** @var \Modules\InvestmentManagement\Models\InvestmentObject $investment */
$investment = InvestmentObjectMapper::get()->where('id', (int) $request->getData('option'))->execute();
$path = $this->createInvestmentObjectDir($investment);
$path = $this->createInvestmentObjectDir($investment);
$uploaded = [];
if (!empty($uploadedFiles = $request->files)) {

View File

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Modules\InvestmentManagement\Models;
use phpOMS\Business\Finance\DepreciationType;
use phpOMS\Stdlib\Base\FloatInt;
/**

View File

@ -14,9 +14,6 @@ declare(strict_types=1);
namespace Modules\InvestmentManagement\Models;
use phpOMS\Business\Finance\DepreciationType;
use phpOMS\Stdlib\Base\FloatInt;
/**
* Costs/Earnings.
*

View File

@ -36,9 +36,9 @@ final class AmountGroupMapper extends DataMapperFactory
* @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_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'],
];
@ -63,7 +63,7 @@ final class AmountGroupMapper extends DataMapperFactory
*/
public const HAS_MANY = [
'amounts' => [
'mapper' => AmountGroupMapper::class,
'mapper' => self::class,
'table' => 'investmgmt_amount',
'self' => 'investmgmt_amount_group',
'external' => null,

View File

@ -36,11 +36,11 @@ final class AmountGroupMapper extends DataMapperFactory
* @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_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'],
'investmgmt_amount_date' => ['name' => 'investmgmt_amount_date', 'type' => 'DateTime', 'internal' => 'date'],
'investmgmt_amount_group' => ['name' => 'investmgmt_amount_group', 'type' => 'int', 'internal' => 'group'],
];
/**

View File

@ -65,8 +65,8 @@ class Investment
*/
public function __construct()
{
$this->createdBy = new NullAccount();
$this->createdAt = new \DateTimeImmutable('now');
$this->createdBy = new NullAccount();
$this->createdAt = new \DateTimeImmutable('now');
$this->performanceDate = new \DateTime('now');
}

View File

@ -15,9 +15,8 @@ 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 Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
@ -40,15 +39,15 @@ final class InvestmentMapper extends DataMapperFactory
* @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_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],
'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],
];
/**

View File

@ -14,11 +14,10 @@ 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 Modules\Media\Models\MediaMapper;
use Modules\SupplierManagement\Models\SupplierMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
@ -41,15 +40,15 @@ final class InvestmentObjectMapper extends DataMapperFactory
* @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_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'],
'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'],
];
/**

View File

@ -14,5 +14,5 @@ declare(strict_types=1);
return ['Navigation' => [
'InvestmentInquiries' => 'Investment Inquiries',
'Investments' => 'Investments',
'Investments' => 'Investments',
]];

View File

@ -13,10 +13,10 @@
declare(strict_types=1);
return ['InvestmentManagement' => [
'Investment' => 'Investment',
'Investment' => 'Investment',
'Investments' => 'Investments',
':status1' => 'Draft',
':status2' => 'Open',
':status3' => 'Approved',
':status4' => 'Denied',
':status1' => 'Draft',
':status2' => 'Open',
':status3' => 'Approved',
':status4' => 'Denied',
]];