diff --git a/Admin/Hooks/Manual.php b/Admin/Hooks/Manual.php new file mode 100644 index 0000000..599b568 --- /dev/null +++ b/Admin/Hooks/Manual.php @@ -0,0 +1,19 @@ + [ + 'callback' => ['\Modules\Accounting\Controller\ApiController:eventBillArchive'], + ], +]; diff --git a/Admin/Install/Coa/SKR03_DE_GAAP.csv b/Admin/Install/Coa/SKR03_DE_GAAP.csv index 2db6646..09d12e0 100644 --- a/Admin/Install/Coa/SKR03_DE_GAAP.csv +++ b/Admin/Install/Coa/SKR03_DE_GAAP.csv @@ -1257,7 +1257,6 @@ Account,Type (B/PL),C/D,S,Sammelkonto,IFRS,HB,SB,EUR,G,U,K,Tax ID,PL Tax1,B Tax1 8403,,,,,,,,,,,,,,,,,,,Erlöse 19% USt,"Revenue, 19 % VAT" 8404,,,,,,,,,,,,,,,,,,,Erlöse 19% USt,"Revenue, 19 % VAT" 8405,,,,,,,,,,,,,,,,,,,Erlöse 19% USt,"Revenue, 19 % VAT" -8405,,,,,,,,,,,,,,,,,,,Erlöse 19% USt,"Revenue, 19 % VAT" 8406,,,,,,,,,,,,,,,,,,,Erlöse 19% USt,"Revenue, 19 % VAT" 8407,,,,,,,,,,,,,,,,,,,Erlöse 19% USt,"Revenue, 19 % VAT" 8408,,,,,,,,,,,,,,,,,,,Erlöse 19% USt,"Revenue, 19 % VAT" diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 9ddb2ff..aceaa83 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -246,29 +246,168 @@ "primary": true, "autoincrement": true }, + "accounting_posting_status": { + "name": "accounting_posting_status", + "type": "TINYINT", + "null": false + }, + "accounting_posting_number": { + "name": "accounting_posting_number", + "type": "VARCHAR(255)", + "null": false + }, + "accounting_posting_account": { + "name": "accounting_posting_account", + "type": "INT", + "null": true, + "default": null, + "foreignTable": "accounting_account", + "foreignKey": "accounting_account_id" + }, + "accounting_posting_paymentterms": { + "@todo": "only install in providing case + then use foreignTable/Key", + "name": "accounting_posting_paymentterms", + "type": "INT", + "null": true, + "default": null + }, + "accounting_posting_payment": { + "description": "should this handle the dues?", + "name": "accounting_posting_payment", + "type": "INT", + "null": true, + "default": null + }, + "accounting_posting_dun_level": { + "name": "accounting_posting_dun_level", + "type": "TINYINT", + "null": false + }, + "accounting_posting_dun_stop": { + "name": "accounting_posting_dun_stop", + "type": "TINYINT(1)", + "null": false + }, + "accounting_posting_bill": { + "@todo": "only install in providing case + then use foreignTable/Key", + "name": "accounting_posting_bill", + "type": "INT", + "null": true + }, "accounting_posting_batch": { "name": "accounting_posting_batch", "type": "INT", - "null": false, + "null": true, "foreignTable": "accounting_batch", "foreignKey": "accounting_batch_id" }, - "accounting_posting_receipt": { - "name": "accounting_posting_receipt", - "type": "INT", - "default": null, - "null": true - }, - "accounting_posting_receipt_ext": { - "name": "accounting_posting_receipt_ext", - "type": "INT", - "default": null, - "null": true - }, - "accounting_posting_price": { - "name": "accounting_posting_price", + "accounting_posting_value": { + "name": "accounting_posting_value", "type": "BIGINT", "null": false + }, + "accounting_posting_createdat": { + "name": "accounting_posting_createdat", + "type": "DATETIME", + "null": false + }, + "accounting_posting_createdby": { + "name": "accounting_posting_createdby", + "type": "INT", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + }, + "accounting_posting_performance": { + "name": "accounting_posting_performance", + "type": "DATETIME", + "null": false + }, + "accounting_posting_unit": { + "name": "accounting_posting_unit", + "type": "INT", + "null": false, + "foreignTable": "unit", + "foreignKey": "unit_id" + } + } + }, + "accounting_posting_note": { + "name": "accounting_posting_note", + "fields": { + "accounting_posting_note_id": { + "name": "accounting_posting_note_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "accounting_posting_note_dst": { + "name": "accounting_posting_note_dst", + "type": "INT", + "null": false, + "foreignTable": "editor_doc", + "foreignKey": "editor_doc_id" + }, + "accounting_posting_note_src": { + "name": "accounting_posting_note_src", + "type": "INT", + "null": false, + "foreignTable": "accounting_posting", + "foreignKey": "accounting_posting_id" + } + } + }, + "accounting_posting_media": { + "name": "accounting_posting_media", + "fields": { + "accounting_posting_media_id": { + "name": "accounting_posting_media_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "accounting_posting_media_dst": { + "name": "accounting_posting_media_dst", + "type": "INT", + "null": false, + "foreignTable": "media", + "foreignKey": "media_id" + }, + "accounting_posting_media_src": { + "name": "accounting_posting_media_src", + "type": "INT", + "null": false, + "foreignTable": "accounting_posting", + "foreignKey": "accounting_posting_id" + } + } + }, + "accounting_posting_eq": { + "name": "accounting_posting_eq", + "description": "Marks posts as equalized credit/debit", + "fields": { + "accounting_posting_eq_id": { + "name": "accounting_posting_eq_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "accounting_posting_eq_1": { + "name": "accounting_posting_eq_1", + "type": "INT", + "null": true, + "foreignTable": "accounting_posting", + "foreignKey": "accounting_posting_id" + }, + "accounting_posting_eq_2": { + "name": "accounting_posting_eq_2", + "type": "INT", + "null": true, + "foreignTable": "accounting_posting", + "foreignKey": "accounting_posting_id" } } }, @@ -282,7 +421,20 @@ "primary": true, "autoincrement": true }, + "accounting_posting_ele_status": { + "description": "debit/credit", + "name": "accounting_posting_ele_status", + "type": "TINYINT", + "null": false + }, + "accounting_posting_ele_text": { + "description": "debit/credit", + "name": "accounting_posting_ele_text", + "type": "VARCHAR(255)", + "null": false + }, "accounting_posting_ele_type": { + "description": "debit/credit", "name": "accounting_posting_ele_type", "type": "TINYINT", "null": false @@ -294,6 +446,22 @@ "foreignTable": "accounting_account", "foreignKey": "accounting_account_id" }, + "accounting_posting_ele_cc": { + "name": "accounting_posting_ele_cc", + "type": "INT", + "null": true, + "default": null, + "foreignTable": "accounting_costcenter", + "foreignKey": "accounting_costcenter_id" + }, + "accounting_posting_ele_co": { + "name": "accounting_posting_ele_co", + "type": "INT", + "null": true, + "default": null, + "foreignTable": "accounting_costobject", + "foreignKey": "accounting_costobject_id" + }, "accounting_posting_ele_value": { "name": "accounting_posting_ele_value", "type": "BIGINT", @@ -303,6 +471,45 @@ "name": "accounting_posting_ele_tax", "type": "INT", "null": false + }, + "accounting_posting_ele_createdat": { + "name": "accounting_posting_ele_createdat", + "type": "DATETIME", + "null": false + }, + "accounting_posting_ele_createdby": { + "name": "accounting_posting_ele_createdby", + "type": "INT", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + }, + "accounting_posting_ele_performance": { + "name": "accounting_posting_ele_performance", + "type": "DATETIME", + "null": false + }, + "accounting_posting_ele_opposite": { + "description": "Often you have a 1:1 match between credit/debit posting, this speeds it up. Alternatively you have to find the opposite postings through the posting", + "name": "accounting_posting_ele_opposite", + "type": "INT", + "null": false, + "foreignTable": "accounting_posting_ele", + "foreignKey": "accounting_posting_ele_id" + }, + "accounting_posting_ele_posting": { + "name": "accounting_posting_ele_posting", + "type": "INT", + "null": false, + "foreignTable": "accounting_posting", + "foreignKey": "accounting_posting_id" + }, + "accounting_posting_ele_unit": { + "name": "accounting_posting_ele_unit", + "type": "INT", + "null": false, + "foreignTable": "unit", + "foreignKey": "unit_id" } } } diff --git a/Admin/Installer.php b/Admin/Installer.php index be392cc..66c4834 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -22,7 +22,6 @@ use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Module\InstallerAbstract; use phpOMS\Module\ModuleInfo; -use phpOMS\Uri\HttpUri; /** * Installer class. @@ -88,7 +87,7 @@ final class Installer extends InstallerAbstract } $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('code', $line[0]); @@ -109,7 +108,7 @@ final class Installer extends InstallerAbstract for ($i = 1; $i < $languages; ++$i) { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('ref', $accountId); @@ -147,7 +146,7 @@ final class Installer extends InstallerAbstract foreach ($mapper::yield()->execute() as $person) { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); // @todo define default account number format for clients, if number -> consider number as starting value // @todo define default account number format for suppliers, if number -> consider number as starting value diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index dbae7ab..95ba8eb 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ - '^.*/accounting/entries.*$' => [ + '^.*/accounting/entries(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewEntries', 'verb' => RouteVerb::GET, @@ -29,7 +29,7 @@ return [ ], ], ], - '^.*/accounting/stack/list.*$' => [ + '^.*/accounting/stack/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewStackList', 'verb' => RouteVerb::GET, @@ -40,7 +40,7 @@ return [ ], ], ], - '^.*/accounting/stack/entries.*$' => [ + '^.*/accounting/stack/entries(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewStackEntries', 'verb' => RouteVerb::GET, @@ -51,7 +51,7 @@ return [ ], ], ], - '^.*/accounting/stack/archive/list.*$' => [ + '^.*/accounting/stack/archive/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewStackArchiveList', 'verb' => RouteVerb::GET, @@ -62,7 +62,7 @@ return [ ], ], ], - '^.*/accounting/stack/create.*$' => [ + '^.*/accounting/stack/create(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewStackCreate', 'verb' => RouteVerb::GET, @@ -73,7 +73,7 @@ return [ ], ], ], - '^.*/accounting/stack/predefined/list.*$' => [ + '^.*/accounting/stack/predefined/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewStackPredefinedList', 'verb' => RouteVerb::GET, @@ -84,9 +84,9 @@ return [ ], ], ], - '^.*/accounting/coa/profile.*$' => [ + '^.*/accounting/coa/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewAccountProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewAccountView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -95,7 +95,7 @@ return [ ], ], ], - '^.*/accounting/coa/list.*$' => [ + '^.*/accounting/coa/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewCOAList', 'verb' => RouteVerb::GET, @@ -106,7 +106,7 @@ return [ ], ], ], - '^.*/accounting/coa/create.*$' => [ + '^.*/accounting/coa/create(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewCOACreate', 'verb' => RouteVerb::GET, @@ -117,9 +117,9 @@ return [ ], ], ], - '^.*/accounting/dun/print.*$' => [ + '^.*/accounting/dun/print(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -128,9 +128,9 @@ return [ ], ], ], - '^.*/accounting/statement/print.*$' => [ + '^.*/accounting/statement/print(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -139,9 +139,9 @@ return [ ], ], ], - '^.*/accounting/balances/print.*$' => [ + '^.*/accounting/balances/print(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -150,9 +150,9 @@ return [ ], ], ], - '^.*/accounting/accountform/print.*$' => [ + '^.*/accounting/accountform/print(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -162,7 +162,7 @@ return [ ], ], - '^.*/accounting/costcenter/list.*$' => [ + '^.*/accounting/costcenter/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterList', 'verb' => RouteVerb::GET, @@ -173,7 +173,7 @@ return [ ], ], ], - '^.*/accounting/costobject/list.*$' => [ + '^.*/accounting/costobject/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostObjectList', 'verb' => RouteVerb::GET, @@ -184,9 +184,9 @@ return [ ], ], ], - '^.*/accounting/costcenter/profile.*$' => [ + '^.*/accounting/costcenter/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostCenterView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -195,9 +195,9 @@ return [ ], ], ], - '^.*/accounting/costobject/profile.*$' => [ + '^.*/accounting/costobject/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostObjectProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewCostObjectView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -207,7 +207,7 @@ return [ ], ], - '^.*/accounting/supplier/list.*$' => [ + '^.*/accounting/supplier/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewSupplierList', 'verb' => RouteVerb::GET, @@ -218,7 +218,7 @@ return [ ], ], ], - '^.*/accounting/client/list.*$' => [ + '^.*/accounting/client/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewClientList', 'verb' => RouteVerb::GET, @@ -229,9 +229,9 @@ return [ ], ], ], - '^.*/accounting/supplier/profile.*$' => [ + '^.*/accounting/supplier/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewSupplierProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewSupplierView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -240,9 +240,9 @@ return [ ], ], ], - '^.*/accounting/client/profile.*$' => [ + '^.*/accounting/client/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewClientProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewClientView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -251,9 +251,9 @@ return [ ], ], ], - '^.*/accounting/supplier/entries.*$' => [ + '^.*/accounting/supplier/entries(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewSupplierProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewSupplierView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -262,9 +262,9 @@ return [ ], ], ], - '^.*/accounting/client/entries.*$' => [ + '^.*/accounting/client/entries(\?.*$|$)' => [ [ - 'dest' => '\Modules\Accounting\Controller\BackendController:viewClientProfile', + 'dest' => '\Modules\Accounting\Controller\BackendController:viewClientView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 6b5163d..e29df4a 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -22,8 +22,18 @@ use Modules\Accounting\Models\CostCenter; use Modules\Accounting\Models\CostCenterMapper; use Modules\Accounting\Models\CostObject; use Modules\Accounting\Models\CostObjectMapper; +use Modules\Accounting\Models\Posting; +use Modules\Accounting\Models\PostingElement; +use Modules\Accounting\Models\PostingMapper; +use Modules\Accounting\Models\PostingSide; +use Modules\Admin\Models\AccountMapper; +use Modules\Admin\Models\NullAccount; +use Modules\ItemManagement\Models\Attribute\ItemAttributeTypeMapper; +use Modules\ItemManagement\Models\Attribute\ItemAttributeValueMapper; use phpOMS\Localization\BaseStringL11n; use phpOMS\Localization\ISO639x1Enum; +use phpOMS\Message\Http\HttpRequest; +use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; @@ -41,9 +51,148 @@ use phpOMS\Model\Message\FormValidation; */ final class ApiController extends Controller { - public function hookPersonalAccountCreate(...$data) + use \Modules\Attribute\Controller\ApiAttributeTraitController; + + /** + * Event after creating a stock + * + * @param int $account Account + * @param mixed $old Old stock model + * @param mixed $new New / created stock model + * @param null|int $type Event type (usually mapper hash) + * @param string $trigger Trigger name + * @param null|string $module Module name who triggers the event + * @param null|string $ref Reference (e.g. reference to a different model) + * @param null|string $content Content for the event (e.g. comment, values, ...) + * @param null|string $ip Ip of the account + * + * @return void + * + * @since 1.0.0 + */ + public function eventBillArchive( + int $account, + mixed $old, + mixed $new, + ?int $type = null, + string $trigger = '', + ?string $module = null, + ?string $ref = null, + ?string $content = null, + ?string $ip = null + ) : void { - \var_dump($data); + if (!$new->type->isAccounting) { + return; + } + + $type = ''; + $person = null; + + /** @var \Modules\Billing\Models\Bill $new */ + if ($new->client !== null) { + $new->client = \Modules\ClientManagement\Models\ClientMapper::get() + ->where('id', $new->client->id) + ->execute(); + + $person = $new->client; + $type = 'client'; + } else { + $new->supplier = \Modules\SupplierManagement\Models\SupplierMapper::get() + ->where('id', $new->supplier->id) + ->execute(); + + $person = $new->supplier; + $type = 'supplier'; + } + + $finAcc = AccountAbstractMapper::get() + ->where('code', $person->number) + ->execute(); + + $posting = new Posting(); + $posting->createdBy = new NullAccount($account); + $posting->unit = $new->unit; + $posting->account = AccountAbstractMapper::get() + ->where('code', $person->number) + ->execute(); + + // First side + $firstElement = new PostingElement(); + $firstElement->createdBy = new NullAccount($account); + $firstElement->unit = $posting->unit; + $firstElement->account = $finAcc; + $firstElement->value = $new->grossSales->getInt(); + + if ($type === 'client') { + $firstElement->type = $new->grossSales->getInt() > 0 + ? PostingSide::DEBIT + : PostingSide::CREDIT; + } else { + $firstElement->type = $new->grossSales->getInt() > 0 + ? PostingSide::CREDIT + : PostingSide::DEBIT; + } + + $posting->elements[] = $firstElement; + + // Second side + foreach ($new->elements as $element) { + // @todo handle pl account from bill + // @todo handle taxes + $postingElement = new PostingElement(); + $postingElement->createdBy = new NullAccount($account); + $postingElement->unit = $posting->unit; + $postingElement->account = $finAcc; + $postingElement->value = $element->totalSalesPriceGross->getInt(); + $postingElement->type = $firstElement->type === PostingSide::DEBIT + ? PostingSide::CREDIT + : PostingSide::DEBIT; + + $posting->elements[] = $postingElement; + } + + // @todo check debit === credit + // @todo check bill tax = sum(element.tax) + // @todo check bill net = sum(element.net) + // @todo check bill gross = sum(element.gross) + + $this->createModel($account, $posting, PostingMapper::class, 'posting-bill', $ip); + } + + public function hookPersonalAccountCreate( + int $account, + mixed $old, + mixed $new, + ?int $type = null, + string $trigger = '', + ?string $module = null, + ?string $ref = null, + ?string $content = null, + ?string $ip = null + ) : void + { + $accountType = $new instanceof \Modules\ClientManagement\Models\Client + ? AccountType::DEBITOR + : AccountType::CREDITOR; + + $new->account = AccountMapper::get() + ->where('id', $new->account->id) + ->execute(); + + $response = new HttpResponse(); + $request = new HttpRequest(); + + // @todo define default account number format for clients, if number -> consider number as starting value + // @todo define default account number format for suppliers, if number -> consider number as starting value + + $request->header->account = $account; + $request->setData('code', $new->number); + $request->setData('content', \rtrim($new->account->name1 . ' ' . $new->account->name2)); + $request->setData('language', ISO639x1Enum::_EN); + $request->setData('type', $accountType); + $request->setData('account', $new->account->id); + $this->apiAccountCreate($request, $response); } /** @@ -105,14 +254,17 @@ final class ApiController extends Controller private function createAccountFromRequest(RequestAbstract $request) : AccountAbstract { $account = new AccountAbstract(); - $account->code = $request->getDataString('code') ?? ''; + $account->code = $request->getDataString('code') ?? ''; $account->account = $request->getDataInt('account'); if ($request->hasData('content')) { - $account->setL11n($request->getDataString('content') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $account->setL11n( + $request->getDataString('content') ?? '', + ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN + ); } - $account->type = $request->getDataInt('type') ?? AccountType::IMPERSONAL; + $account->type = AccountType::tryFromValue($request->getDataInt('type')) ?? AccountType::IMPERSONAL; return $account; } @@ -155,12 +307,10 @@ final class ApiController extends Controller */ private function createAccountL11nFromRequest(RequestAbstract $request) : BaseStringL11n { - $accountL11n = new BaseStringL11n(); - $accountL11n->ref = $request->getDataInt('ref') ?? 0; - $accountL11n->setLanguage( - $request->getDataString('language') ?? $request->header->l11n->language - ); - $accountL11n->content = $request->getDataString('content') ?? ''; + $accountL11n = new BaseStringL11n(); + $accountL11n->ref = $request->getDataInt('ref') ?? 0; + $accountL11n->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $request->header->l11n->language; + $accountL11n->content = $request->getDataString('content') ?? ''; return $accountL11n; } @@ -253,6 +403,31 @@ final class ApiController extends Controller $costcenter = $this->createCostCenterFromRequest($request); $this->createModel($request->header->account, $costcenter, CostCenterMapper::class, 'costcenter', $request->getOrigin()); + + // Create item attribute value + $type = ItemAttributeTypeMapper::get() + ->with('defaults') + ->where('name', 'costcenter') + ->execute(); + + $internalRequest = new HttpRequest($request->uri); + $internalRequest->header->account = $request->header->account; + $internalRequest->setData('default', true); + $internalRequest->setData('value', $costcenter->code); + $internalRequest->setData('title', $costcenter->getL11n()); + $internalRequest->setData('language', $costcenter->l11n->language); + $internalRequest->setData('unit', $request->getDataInt('unit') ?? $this->app->unitId); + + $attrValue = $this->createAttributeValueFromRequest($internalRequest, $type); + $this->createModel($request->header->account, $attrValue, ItemAttributeValueMapper::class, 'attr_value', $request->getOrigin()); + + $this->createModelRelation( + $request->header->account, + $type->id, + $attrValue->id, + ItemAttributeTypeMapper::class, 'defaults', '', $request->getOrigin() + ); + $this->createStandardCreateResponse($request, $response, $costcenter); } @@ -277,7 +452,7 @@ final class ApiController extends Controller } /** - * Method to create costcenter from request. + * Method to create cost center from request. * * @param RequestAbstract $request Request * @@ -287,9 +462,12 @@ final class ApiController extends Controller */ private function createCostCenterFromRequest(RequestAbstract $request) : CostCenter { - $costcenter = new CostCenter(); + $costcenter = new CostCenter(); $costcenter->code = $request->getDataString('code') ?? ''; - $costcenter->setL11n($request->getDataString('content') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $costcenter->setL11n( + $request->getDataString('content') ?? '', + ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN + ); $costcenter->unit = $request->getDataInt('unit') ?? 1; return $costcenter; @@ -362,11 +540,36 @@ final class ApiController extends Controller $costobject = $this->createCostObjectFromRequest($request); $this->createModel($request->header->account, $costobject, CostObjectMapper::class, 'costobject', $request->getOrigin()); + + // Create item attribute value + $type = ItemAttributeTypeMapper::get() + ->with('defaults') + ->where('name', 'costobject') + ->execute(); + + $internalRequest = new HttpRequest($request->uri); + $internalRequest->header->account = $request->header->account; + $internalRequest->setData('default', true); + $internalRequest->setData('value', $costobject->code); + $internalRequest->setData('title', $costobject->getL11n()); + $internalRequest->setData('language', $costobject->l11n->language); + $internalRequest->setData('unit', $request->getDataInt('unit') ?? $this->app->unitId); + + $attrValue = $this->createAttributeValueFromRequest($internalRequest, $type); + $this->createModel($request->header->account, $attrValue, ItemAttributeValueMapper::class, 'attr_value', $request->getOrigin()); + + $this->createModelRelation( + $request->header->account, + $type->id, + $attrValue->id, + ItemAttributeTypeMapper::class, 'defaults', '', $request->getOrigin() + ); + $this->createStandardCreateResponse($request, $response, $costobject); } /** - * Method to create costobject from request. + * Method to create cost object from request. * * @param RequestAbstract $request Request * @@ -376,9 +579,12 @@ final class ApiController extends Controller */ private function createCostObjectFromRequest(RequestAbstract $request) : CostObject { - $costobject = new CostObject(); + $costobject = new CostObject(); $costobject->code = $request->getDataString('code') ?? ''; - $costobject->setL11n($request->getDataString('content') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $costobject->setL11n( + $request->getDataString('content') ?? '', + ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN + ); $costobject->unit = $request->getDataInt('unit') ?? 1; return $costobject; diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 4e4d480..98397a5 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -17,8 +17,6 @@ namespace Modules\Accounting\Controller; use Modules\Accounting\Models\AccountAbstractMapper; use Modules\Accounting\Models\CostCenterMapper; use Modules\Accounting\Models\CostObjectMapper; -use Modules\Admin\Models\LocalizationMapper; -use Modules\Admin\Models\SettingsEnum; use Modules\Auditor\Models\AuditMapper; use Modules\ClientManagement\Models\Attribute\ClientAttributeTypeMapper; use Modules\ClientManagement\Models\ClientMapper; @@ -252,10 +250,10 @@ final class BackendController extends Controller * @since 1.0.0 * @codeCoverageIgnore */ - public function viewCostCenterProfile(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + public function viewCostCenterView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/Accounting/Theme/Backend/costcenter-profile'); + $view->setTemplate('/Modules/Accounting/Theme/Backend/costcenter-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002604001, $request, $response); return $view; @@ -273,10 +271,10 @@ final class BackendController extends Controller * @since 1.0.0 * @codeCoverageIgnore */ - public function viewCostObjectProfile(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + public function viewCostObjectView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/Accounting/Theme/Backend/costobject-profile'); + $view->setTemplate('/Modules/Accounting/Theme/Backend/costobject-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002604001, $request, $response); return $view; @@ -426,7 +424,7 @@ final class BackendController extends Controller * @since 1.0.0 * @codeCoverageIgnore */ - public function viewSupplierProfile(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + public function viewSupplierView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); @@ -437,7 +435,7 @@ final class BackendController extends Controller $head->addAsset(AssetType::JSLATE, 'Modules/Accounting/Controller.js', ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/Accounting/Theme/Backend/personal-profile'); + $view->setTemplate('/Modules/Accounting/Theme/Backend/personal-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002604001, $request, $response); $account = SupplierMapper::get() @@ -459,11 +457,8 @@ final class BackendController extends Controller $view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing'); - /** @var \Model\Setting $settings */ - $settings = $this->app->appSettings->get(null, SettingsEnum::DEFAULT_LOCALIZATION); - - $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); - $view->data['attributeView']->data['default_localization'] = LocalizationMapper::get()->where('id', (int) $settings->id)->execute(); + $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); + $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; /** @var \Modules\Media\Models\Media[] $files */ $files = MediaMapper::getAll() @@ -474,8 +469,10 @@ final class BackendController extends Controller $view->data['files'] = $files; - $view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response); - $view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response); + $view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response); + $view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response); + $view->data['address-component'] = new \Modules\Admin\Theme\Backend\Components\AddressEditor\AddressView($this->app->l11nManager, $request, $response); + $view->data['contact-component'] = new \Modules\Admin\Theme\Backend\Components\ContactEditor\ContactView($this->app->l11nManager, $request, $response); return $view; } @@ -492,7 +489,7 @@ final class BackendController extends Controller * @since 1.0.0 * @codeCoverageIgnore */ - public function viewClientProfile(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + public function viewClientView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $head = $response->data['Content']->head; $nonce = $this->app->appSettings->getOption('script-nonce'); @@ -503,12 +500,13 @@ final class BackendController extends Controller $head->addAsset(AssetType::JSLATE, 'Modules/Accounting/Controller.js', ['nonce' => $nonce, 'type' => 'module']); $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/Accounting/Theme/Backend/personal-profile'); + $view->setTemplate('/Modules/Accounting/Theme/Backend/personal-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002604001, $request, $response); $account = ClientMapper::get() ->with('account') - ->with('contactElements') + ->with('account/addresses') + ->with('account/contacts') ->with('mainAddress') ->with('files')->limit(5, 'files')->sort('files/id', OrderType::DESC) ->with('notes')->limit(5, 'notes')->sort('notes/id', OrderType::DESC) @@ -517,11 +515,8 @@ final class BackendController extends Controller $view->data['account'] = $account; - /** @var \Model\Setting $settings */ - $settings = $this->app->appSettings->get(null, SettingsEnum::DEFAULT_LOCALIZATION); - - $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); - $view->data['attributeView']->data['default_localization'] = LocalizationMapper::get()->where('id', (int) $settings->id)->execute(); + $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); + $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; /** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */ $attributeTypes = ClientAttributeTypeMapper::getAll() @@ -585,8 +580,10 @@ final class BackendController extends Controller $view->data['files'] = $files; - $view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response); - $view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response); + $view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response); + $view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response); + $view->data['address-component'] = new \Modules\Admin\Theme\Backend\Components\AddressEditor\AddressView($this->app->l11nManager, $request, $response); + $view->data['contact-component'] = new \Modules\Admin\Theme\Backend\Components\ContactEditor\ContactView($this->app->l11nManager, $request, $response); $view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing'); diff --git a/Models/AccountAbstract.php b/Models/AccountAbstract.php index fe72d5e..3e1acc7 100755 --- a/Models/AccountAbstract.php +++ b/Models/AccountAbstract.php @@ -73,18 +73,6 @@ class AccountAbstract */ public array $entries = []; - /** - * Get account id. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * Get entry. * @@ -114,12 +102,12 @@ class AccountAbstract if ($l11n instanceof BaseStringL11n) { $this->l11n = $l11n; } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } else { - $this->l11n = new BaseStringL11n(); - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } } @@ -148,7 +136,7 @@ class AccountAbstract * * @since 1.0.0 */ - public function getEntriesByDate(\DateTime $start, \DateTime $end = null, int $dateType = TimeRangeType::RECEIPT_DATE) : array + public function getEntriesByDate(\DateTime $start, ?\DateTime $end = null, int $dateType = TimeRangeType::RECEIPT_DATE) : array { return []; } @@ -159,7 +147,7 @@ class AccountAbstract public function toArray() : array { return [ - 'id' => $this->id, + 'id' => $this->id, ]; } diff --git a/Models/AccountAbstractMapper.php b/Models/AccountAbstractMapper.php index 7924ed4..0a1a66f 100644 --- a/Models/AccountAbstractMapper.php +++ b/Models/AccountAbstractMapper.php @@ -36,11 +36,11 @@ class AccountAbstractMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'accounting_account_id' => ['name' => 'accounting_account_id', 'type' => 'int', 'internal' => 'id'], - 'accounting_account_code' => ['name' => 'accounting_account_code', 'type' => 'string', 'internal' => 'code', 'autocomplete' => true], - 'accounting_account_type' => ['name' => 'accounting_account_type', 'type' => 'int', 'internal' => 'type'], - 'accounting_account_parent' => ['name' => 'accounting_account_parent', 'type' => 'int', 'internal' => 'parent'], - 'accounting_account_account' => ['name' => 'accounting_account_account', 'type' => 'int', 'internal' => 'account'], + 'accounting_account_id' => ['name' => 'accounting_account_id', 'type' => 'int', 'internal' => 'id'], + 'accounting_account_code' => ['name' => 'accounting_account_code', 'type' => 'string', 'internal' => 'code', 'autocomplete' => true], + 'accounting_account_type' => ['name' => 'accounting_account_type', 'type' => 'int', 'internal' => 'type'], + 'accounting_account_parent' => ['name' => 'accounting_account_parent', 'type' => 'int', 'internal' => 'parent'], + 'accounting_account_account' => ['name' => 'accounting_account_account', 'type' => 'int', 'internal' => 'account'], ]; /** diff --git a/Models/AccountL11nMapper.php b/Models/AccountL11nMapper.php index 9a225d6..f9bd15d 100644 --- a/Models/AccountL11nMapper.php +++ b/Models/AccountL11nMapper.php @@ -37,10 +37,10 @@ final class AccountL11nMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'accounting_account_l11n_id' => ['name' => 'accounting_account_l11n_id', 'type' => 'int', 'internal' => 'id'], - 'accounting_account_l11n_title' => ['name' => 'accounting_account_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], - 'accounting_account_l11n_account' => ['name' => 'accounting_account_l11n_account', 'type' => 'int', 'internal' => 'ref'], - 'accounting_account_l11n_lang' => ['name' => 'accounting_account_l11n_lang', 'type' => 'string', 'internal' => 'language'], + 'accounting_account_l11n_id' => ['name' => 'accounting_account_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'accounting_account_l11n_title' => ['name' => 'accounting_account_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'accounting_account_l11n_account' => ['name' => 'accounting_account_l11n_account', 'type' => 'int', 'internal' => 'ref'], + 'accounting_account_l11n_lang' => ['name' => 'accounting_account_l11n_lang', 'type' => 'string', 'internal' => 'language'], ]; /** diff --git a/Models/BatchPosting.php b/Models/BatchPosting.php index 9d527e5..a01b09d 100755 --- a/Models/BatchPosting.php +++ b/Models/BatchPosting.php @@ -74,32 +74,6 @@ class BatchPosting implements \Countable $this->created = new \DateTimeImmutable('now'); } - /** - * Get id. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - - /** - * Get posting. - * - * @param int $id Posting ID - * - * @return null|PostingInterface - * - * @since 1.0.0 - */ - public function getPosting(int $id) : ?PostingInterface - { - return $this->postings[$id] ?? null; - } - /** * Remove posting. * @@ -120,20 +94,6 @@ class BatchPosting implements \Countable return true; } - /** - * Add posting. - * - * @param PostingInterface $posting Posting - * - * @return void - * - * @since 1.0.0 - */ - public function addPosting(PostingInterface $posting) : void - { - $this->postings[] = $posting; - } - /** * {@inheritdoc} */ diff --git a/Models/CostCenter.php b/Models/CostCenter.php index c96bb5b..31702aa 100755 --- a/Models/CostCenter.php +++ b/Models/CostCenter.php @@ -61,18 +61,6 @@ class CostCenter public int $unit = 0; - /** - * Get balance id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * Set l11n * @@ -88,12 +76,12 @@ class CostCenter if ($l11n instanceof BaseStringL11n) { $this->l11n = $l11n; } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } else { - $this->l11n = new BaseStringL11n(); - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } } @@ -117,9 +105,9 @@ class CostCenter public function toArray() : array { return [ - 'id' => $this->id, - 'code' => $this->code, - 'parent' => $this->parent, + 'id' => $this->id, + 'code' => $this->code, + 'parent' => $this->parent, ]; } diff --git a/Models/CostCenterL11nMapper.php b/Models/CostCenterL11nMapper.php index 635bc21..51ae137 100755 --- a/Models/CostCenterL11nMapper.php +++ b/Models/CostCenterL11nMapper.php @@ -37,10 +37,10 @@ final class CostCenterL11nMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'accounting_costcenter_l11n_id' => ['name' => 'accounting_costcenter_l11n_id', 'type' => 'int', 'internal' => 'id'], - 'accounting_costcenter_l11n_name' => ['name' => 'accounting_costcenter_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], - 'accounting_costcenter_l11n_costcenter' => ['name' => 'accounting_costcenter_l11n_costcenter', 'type' => 'int', 'internal' => 'ref'], - 'accounting_costcenter_l11n_language' => ['name' => 'accounting_costcenter_l11n_language', 'type' => 'string', 'internal' => 'language'], + 'accounting_costcenter_l11n_id' => ['name' => 'accounting_costcenter_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'accounting_costcenter_l11n_name' => ['name' => 'accounting_costcenter_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'accounting_costcenter_l11n_costcenter' => ['name' => 'accounting_costcenter_l11n_costcenter', 'type' => 'int', 'internal' => 'ref'], + 'accounting_costcenter_l11n_language' => ['name' => 'accounting_costcenter_l11n_language', 'type' => 'string', 'internal' => 'language'], ]; /** diff --git a/Models/CostCenterMapper.php b/Models/CostCenterMapper.php index 7e42f7c..83255ea 100755 --- a/Models/CostCenterMapper.php +++ b/Models/CostCenterMapper.php @@ -49,11 +49,11 @@ final class CostCenterMapper extends DataMapperFactory */ public const HAS_MANY = [ 'l11n' => [ - 'mapper' => CostCenterL11nMapper::class, - 'table' => 'accounting_costcenter_l11n', - 'self' => 'accounting_costcenter_l11n_costcenter', + 'mapper' => CostCenterL11nMapper::class, + 'table' => 'accounting_costcenter_l11n', + 'self' => 'accounting_costcenter_l11n_costcenter', 'column' => 'content', - 'external' => null, + 'external' => null, ], ]; diff --git a/Models/CostObject.php b/Models/CostObject.php index ec6a884..1f3636d 100755 --- a/Models/CostObject.php +++ b/Models/CostObject.php @@ -61,18 +61,6 @@ class CostObject public int $unit = 0; - /** - * Get balance id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * Set l11n * @@ -88,12 +76,12 @@ class CostObject if ($l11n instanceof BaseStringL11n) { $this->l11n = $l11n; } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } else { - $this->l11n = new BaseStringL11n(); - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } } @@ -117,9 +105,9 @@ class CostObject public function toArray() : array { return [ - 'id' => $this->id, - 'code' => $this->code, - 'parent' => $this->parent, + 'id' => $this->id, + 'code' => $this->code, + 'parent' => $this->parent, ]; } diff --git a/Models/CostObjectL11nMapper.php b/Models/CostObjectL11nMapper.php index 5857290..81d6fce 100755 --- a/Models/CostObjectL11nMapper.php +++ b/Models/CostObjectL11nMapper.php @@ -37,10 +37,10 @@ final class CostObjectL11nMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'accounting_costobject_l11n_id' => ['name' => 'accounting_costobject_l11n_id', 'type' => 'int', 'internal' => 'id'], - 'accounting_costobject_l11n_name' => ['name' => 'accounting_costobject_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], - 'accounting_costobject_l11n_costobject' => ['name' => 'accounting_costobject_l11n_costobject', 'type' => 'int', 'internal' => 'ref'], - 'accounting_costobject_l11n_language' => ['name' => 'accounting_costobject_l11n_language', 'type' => 'string', 'internal' => 'language'], + 'accounting_costobject_l11n_id' => ['name' => 'accounting_costobject_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'accounting_costobject_l11n_name' => ['name' => 'accounting_costobject_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'accounting_costobject_l11n_costobject' => ['name' => 'accounting_costobject_l11n_costobject', 'type' => 'int', 'internal' => 'ref'], + 'accounting_costobject_l11n_language' => ['name' => 'accounting_costobject_l11n_language', 'type' => 'string', 'internal' => 'language'], ]; /** diff --git a/Models/CostObjectMapper.php b/Models/CostObjectMapper.php index 4e99eab..548bc5a 100755 --- a/Models/CostObjectMapper.php +++ b/Models/CostObjectMapper.php @@ -49,11 +49,11 @@ final class CostObjectMapper extends DataMapperFactory */ public const HAS_MANY = [ 'l11n' => [ - 'mapper' => CostObjectL11nMapper::class, - 'table' => 'accounting_costobject_l11n', - 'self' => 'accounting_costobject_l11n_costobject', + 'mapper' => CostObjectL11nMapper::class, + 'table' => 'accounting_costobject_l11n', + 'self' => 'accounting_costobject_l11n_costobject', 'column' => 'content', - 'external' => null, + 'external' => null, ], ]; diff --git a/Models/Creditor.php b/Models/Creditor.php index 609367e..a5819e2 100755 --- a/Models/Creditor.php +++ b/Models/Creditor.php @@ -42,26 +42,14 @@ class Creditor */ public $account = null; - /** - * Get id. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * {@inheritdoc} */ public function toArray() : array { return [ - 'id' => $this->id, - 'account' => $this->account, + 'id' => $this->id, + 'account' => $this->account, ]; } diff --git a/Models/Debitor.php b/Models/Debitor.php index 35d3438..eb28132 100755 --- a/Models/Debitor.php +++ b/Models/Debitor.php @@ -42,26 +42,14 @@ class Debitor */ public $account = null; - /** - * Get id. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * {@inheritdoc} */ public function toArray() : array { return [ - 'id' => $this->id, - 'account' => $this->account, + 'id' => $this->id, + 'account' => $this->account, ]; } diff --git a/Models/PostingInterface.php b/Models/NullAccountAbstract.php old mode 100755 new mode 100644 similarity index 50% rename from Models/PostingInterface.php rename to Models/NullAccountAbstract.php index 2b466b3..af73150 --- a/Models/PostingInterface.php +++ b/Models/NullAccountAbstract.php @@ -15,13 +15,32 @@ declare(strict_types=1); namespace Modules\Accounting\Models; /** - * Posting interface. + * Null model * * @package Modules\Accounting\Models * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 */ -interface PostingInterface +final class NullAccountAbstract extends AccountAbstract { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() : mixed + { + return ['id' => $this->id]; + } } diff --git a/Models/Posting.php b/Models/Posting.php index be9d779..939e58f 100755 --- a/Models/Posting.php +++ b/Models/Posting.php @@ -14,6 +14,9 @@ declare(strict_types=1); namespace Modules\Accounting\Models; +use Modules\Admin\Models\Account; +use Modules\Admin\Models\NullAccount; + /** * Posting class. * @@ -22,6 +25,45 @@ namespace Modules\Accounting\Models; * @link https://jingga.app * @since 1.0.0 */ -abstract class Posting extends PostingAbstract +class Posting { + public int $id = 0; + + public int $status = 0; + + public string $number = ''; + + public ?AccountAbstract $account = null; + + public ?int $paymentTerms = null; + + public ?int $payment = null; + + public int $dunLevel = 0; + + public bool $dunStop = false; + + public ?int $bill = null; + + public ?int $batch = null; + + public int $value = 0; + + public \DateTimeImmutable $createdAt; + + public \DateTimeImmutable $performanceDate; + + public Account $createdBy; + + public int $unit = 0; + + public array $elements = []; + + public function __construct() + { + $this->createdAt = new \DateTimeImmutable('now'); + $this->performanceDate = new \DateTimeImmutable('now'); + + $this->createdBy = new NullAccount(); + } } diff --git a/Models/PostingElement.php b/Models/PostingElement.php new file mode 100644 index 0000000..b1f8627 --- /dev/null +++ b/Models/PostingElement.php @@ -0,0 +1,68 @@ +createdAt = new \DateTimeImmutable('now'); + $this->performanceDate = new \DateTimeImmutable('now'); + + $this->createdBy = new NullAccount(); + $this->account = new NullAccountAbstract(); + } +} diff --git a/Models/PostingElementMapper.php b/Models/PostingElementMapper.php new file mode 100644 index 0000000..c2b0f17 --- /dev/null +++ b/Models/PostingElementMapper.php @@ -0,0 +1,115 @@ + + */ +class PostingElementMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'accounting_posting_ele_id' => ['name' => 'accounting_posting_ele_id', 'type' => 'int', 'internal' => 'id'], + 'accounting_posting_ele_status' => ['name' => 'accounting_posting_ele_status', 'type' => 'int', 'internal' => 'status'], + 'accounting_posting_ele_text' => ['name' => 'accounting_posting_ele_text', 'type' => 'string', 'internal' => 'text'], + 'accounting_posting_ele_type' => ['name' => 'accounting_posting_ele_type', 'type' => 'int', 'internal' => 'type'], + 'accounting_posting_ele_account' => ['name' => 'accounting_posting_ele_account', 'type' => 'int', 'internal' => 'account'], + 'accounting_posting_ele_cc' => ['name' => 'accounting_posting_ele_cc', 'type' => 'int', 'internal' => 'costcenter'], + 'accounting_posting_ele_co' => ['name' => 'accounting_posting_ele_co', 'type' => 'int', 'internal' => 'costobject'], + 'accounting_posting_ele_value' => ['name' => 'accounting_posting_ele_value', 'type' => 'int', 'internal' => 'value'], + 'accounting_posting_ele_tax' => ['name' => 'accounting_posting_ele_tax', 'type' => 'int', 'internal' => 'tax'], + 'accounting_posting_ele_createdat' => ['name' => 'accounting_posting_ele_createdat', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], + 'accounting_posting_ele_createdby' => ['name' => 'accounting_posting_ele_createdby', 'type' => 'int', 'internal' => 'createdBy'], + 'accounting_posting_ele_performance' => ['name' => 'accounting_posting_ele_performance', 'type' => 'DateTimeImmutable', 'internal' => 'performanceDate'], + 'accounting_posting_ele_opposite' => ['name' => 'accounting_posting_ele_opposite', 'type' => 'int', 'internal' => 'opposite'], + 'accounting_posting_ele_posting' => ['name' => 'accounting_posting_ele_posting', 'type' => 'int', 'internal' => 'posting'], + 'accounting_posting_ele_unit' => ['name' => 'accounting_posting_ele_unit', 'type' => 'int', 'internal' => 'unit'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + public const OWNS_ONE = [ + 'account' => [ + 'mapper' => AccountAbstractMapper::class, + 'external' => 'accounting_posting_ele_account', + ], + 'createdBy' => [ + 'mapper' => AccountMapper::class, + 'external' => 'accounting_posting_ele_createdby', + ], + 'costcenter' => [ + 'mapper' => CostCenterMapper::class, + 'external' => 'accounting_posting_ele_cc', + ], + 'costobject' => [ + 'mapper' => CostObjectMapper::class, + 'external' => 'accounting_posting_ele_co', + ], + /* + 'opposite' => [ + 'mapper' => PostingElementMapper::class, + 'external' => 'accounting_posting_ele_opposite', + ], + 'posting' => [ + 'mapper' => PostingMapper::class, + 'external' => 'accounting_posting_ele_posting', + ], + */ + ]; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = PostingElement::class; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'accounting_posting_ele'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'accounting_posting_ele_id'; +} diff --git a/Models/PostingMapper.php b/Models/PostingMapper.php new file mode 100644 index 0000000..35676a2 --- /dev/null +++ b/Models/PostingMapper.php @@ -0,0 +1,112 @@ + + */ +class PostingMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'accounting_posting_id' => ['name' => 'accounting_posting_id', 'type' => 'int', 'internal' => 'id'], + 'accounting_posting_status' => ['name' => 'accounting_posting_status', 'type' => 'int', 'internal' => 'status'], + 'accounting_posting_number' => ['name' => 'accounting_posting_number', 'type' => 'string', 'internal' => 'number'], + 'accounting_posting_account' => ['name' => 'accounting_posting_account', 'type' => 'int', 'internal' => 'account'], + 'accounting_posting_paymentterms' => ['name' => 'accounting_posting_paymentterms', 'type' => 'int', 'internal' => 'paymentTerms'], + 'accounting_posting_payment' => ['name' => 'accounting_posting_payment', 'type' => 'int', 'internal' => 'payment'], + 'accounting_posting_dun_level' => ['name' => 'accounting_posting_dun_level', 'type' => 'int', 'internal' => 'dunLevel'], + 'accounting_posting_dun_stop' => ['name' => 'accounting_posting_dun_stop', 'type' => 'bool', 'internal' => 'dunStop'], + 'accounting_posting_bill' => ['name' => 'accounting_posting_bill', 'type' => 'int', 'internal' => 'bill'], + 'accounting_posting_batch' => ['name' => 'accounting_posting_batch', 'type' => 'int', 'internal' => 'batch'], + 'accounting_posting_value' => ['name' => 'accounting_posting_value', 'type' => 'int', 'internal' => 'value'], + 'accounting_posting_createdat' => ['name' => 'accounting_posting_createdat', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], + 'accounting_posting_createdby' => ['name' => 'accounting_posting_createdby', 'type' => 'int', 'internal' => 'createdBy'], + 'accounting_posting_performance' => ['name' => 'accounting_posting_performance', 'type' => 'DateTimeImmutable', 'internal' => 'performanceDate'], + 'accounting_posting_unit' => ['name' => 'accounting_posting_unit', 'type' => 'int', 'internal' => 'unit'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + public const OWNS_ONE = [ + 'account' => [ + 'mapper' => AccountAbstractMapper::class, + 'external' => 'accounting_posting_account', + ], + 'createdBy' => [ + 'mapper' => AccountMapper::class, + 'external' => 'accounting_posting_createdby', + ], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'elements' => [ + 'mapper' => PostingElementMapper::class, + 'table' => 'accounting_posting_ele', + 'self' => 'accounting_posting_ele_posting', + 'external' => null, + ], + ]; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = Posting::class; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'accounting_posting'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'accounting_posting_id'; +} diff --git a/Models/PostingAbstract.php b/Models/PostingSide.php old mode 100755 new mode 100644 similarity index 69% rename from Models/PostingAbstract.php rename to Models/PostingSide.php index 511e0ad..7bdb5cf --- a/Models/PostingAbstract.php +++ b/Models/PostingSide.php @@ -14,14 +14,19 @@ declare(strict_types=1); namespace Modules\Accounting\Models; +use phpOMS\Stdlib\Base\Enum; + /** - * Posting abstract class. + * Posting side enum. * * @package Modules\Accounting\Models * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 */ -abstract class PostingAbstract implements PostingInterface +abstract class PostingSide extends Enum { + public const DEBIT = 1; /* Soll */ + + public const CREDIT = 2; /* Haben */ } diff --git a/Models/TimeRangeType.php b/Models/TimeRangeType.php index 7f6479a..664c969 100755 --- a/Models/TimeRangeType.php +++ b/Models/TimeRangeType.php @@ -34,7 +34,7 @@ abstract class TimeRangeType extends Enum public const ASSOCIATED_DATE = 4; /* Date of the association (e.g. when did the articles arrive) */ - public const PERIOD_DATE = 5; /* Date of the period this booking is assoziated with */ + public const PERIOD_DATE = 5; /* Date of the period this booking is associated with */ public const SQUARED_DATE = 6; /* Date of when the entry got squared/balanced */ } diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php index db88006..58b32b1 100755 --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -17,7 +17,7 @@ return ['Accounting' => [ 'Accounts' => 'Konten', 'BatchPostings' => 'Chargenbuchungen', 'Charts' => 'Charts', - 'COA' => 'Chart of Accounts (COA)', + 'COA' => 'Chart of Accounts (COA)', 'Code' => 'Code', 'ContraAccount' => 'Gegenkonto', 'CostCenter' => 'Kostenstelle', @@ -50,38 +50,38 @@ return ['Accounting' => [ 'Total' => 'Gesamt', 'Type' => 'Typ', 'City' => 'Stadt', - 'Zip' => 'Postleitzahl', - 'Address' => 'Adresse', - 'Country' => 'Land', + 'Zip' => 'Postleitzahl', + 'Address' => 'Adresse', + 'Country' => 'Land', 'Info' => 'Info', 'Date' => 'Datum', - 'Number' => 'Nummer', - 'Payment' => 'Zahlung', + 'Number' => 'Nummer', + 'Payment' => 'Zahlung', 'Open' => 'Offen', - 'Balanced' => 'Ausgeglichen', - 'Balance' => 'Ausgleich', - 'YTDSales' => 'Ytd Sales', - 'MTDSales' => 'Mtd Sales', - 'CLV' => 'CLV', - 'LastContact' => 'Letzter Kontakt', - 'LastOrder' => 'Letzte Bestellung', - 'DSO' => 'DSO', - 'Name1' => 'Name 1', - 'Name2' => 'Name 2', - 'Name3' => 'Name 3', - 'Contact' => 'Kontakt', - 'Phone' => 'Telefon', - 'Email' => 'Email', - 'Website' => 'Webseite', - 'Postal' => 'Postleitzahl', - 'Map' => 'Karte', - 'RecentInvoices' => 'Neuste Rechnungen', - 'Notes' => 'Notizen', - 'Documents' => 'Dokumente', - 'CreatedAt' => 'Erstellt', - 'Finance' => 'Finanzen', - 'Files' => 'Dateien', - 'Title' => 'Titel', - 'Net' => 'Netto', - 'BalanceSheet' => 'Balance Sheet', + 'Balanced' => 'Ausgeglichen', + 'Balance' => 'Ausgleich', + 'YTDSales' => 'Ytd Sales', + 'MTDSales' => 'Mtd Sales', + 'CLV' => 'CLV', + 'LastContact' => 'Letzter Kontakt', + 'LastOrder' => 'Letzte Bestellung', + 'DSO' => 'DSO', + 'Name1' => 'Name 1', + 'Name2' => 'Name 2', + 'Name3' => 'Name 3', + 'Contact' => 'Kontakt', + 'Phone' => 'Telefon', + 'Email' => 'Email', + 'Website' => 'Webseite', + 'Postal' => 'Postleitzahl', + 'Map' => 'Karte', + 'RecentInvoices' => 'Neuste Rechnungen', + 'Notes' => 'Notizen', + 'Documents' => 'Dokumente', + 'CreatedAt' => 'Erstellt', + 'Finance' => 'Finanzen', + 'Files' => 'Dateien', + 'Title' => 'Titel', + 'Net' => 'Netto', + 'BalanceSheet' => 'Balance Sheet', ]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index bac86e9..c680c52 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -17,7 +17,7 @@ return ['Accounting' => [ 'Accounts' => 'Accounts', 'BatchPostings' => 'Batch Postings', 'Charts' => 'Charts', - 'COA' => 'Chart of Accounts (COA)', + 'COA' => 'Chart of Accounts (COA)', 'Code' => 'Code', 'ContraAccount' => 'Contra Account', 'CostCenter' => 'Cost Center', @@ -50,38 +50,38 @@ return ['Accounting' => [ 'Total' => 'Total', 'Type' => 'Type', 'City' => 'City', - 'Zip' => 'Zip', - 'Address' => 'Address', - 'Country' => 'Country', + 'Zip' => 'Zip', + 'Address' => 'Address', + 'Country' => 'Country', 'Info' => 'Info', 'Date' => 'Date', - 'Number' => 'Number', - 'Payment' => 'Payment', + 'Number' => 'Number', + 'Payment' => 'Payment', 'Open' => 'Open', - 'Balanced' => 'Balanced', - 'Balance' => 'Balance', - 'YTDSales' => 'YTD Sales', - 'MTDSales' => 'MTD Sales', - 'CLV' => 'CLV', - 'LastContact' => 'Last Contact', - 'LastOrder' => 'Last Order', - 'DSO' => 'DSO', - 'Name1' => 'Name 1', - 'Name2' => 'Name 2', - 'Name3' => 'Name 3', - 'Contact' => 'Contact', - 'Phone' => 'Phone', - 'Email' => 'Email', - 'Website' => 'Website', - 'Postal' => 'Postal', - 'Map' => 'Map', - 'RecentInvoices' => 'Recent Invoices', - 'Notes' => 'Notes', - 'Documents' => 'Documents', - 'CreatedAt' => 'Created At', - 'Finance' => 'Finance', - 'Files' => 'Files', - 'Title' => 'Title', - 'Net' => 'Net', - 'BalanceSheet' => 'Balance Sheet', + 'Balanced' => 'Balanced', + 'Balance' => 'Balance', + 'YTDSales' => 'YTD Sales', + 'MTDSales' => 'MTD Sales', + 'CLV' => 'CLV', + 'LastContact' => 'Last Contact', + 'LastOrder' => 'Last Order', + 'DSO' => 'DSO', + 'Name1' => 'Name 1', + 'Name2' => 'Name 2', + 'Name3' => 'Name 3', + 'Contact' => 'Contact', + 'Phone' => 'Phone', + 'Email' => 'Email', + 'Website' => 'Website', + 'Postal' => 'Postal', + 'Map' => 'Map', + 'RecentInvoices' => 'Recent Invoices', + 'Notes' => 'Notes', + 'Documents' => 'Documents', + 'CreatedAt' => 'Created At', + 'Finance' => 'Finance', + 'Files' => 'Files', + 'Title' => 'Title', + 'Net' => 'Net', + 'BalanceSheet' => 'Balance Sheet', ]]; diff --git a/Theme/Backend/coa-list.tpl.php b/Theme/Backend/coa-list.tpl.php index bb76e71..f68610c 100644 --- a/Theme/Backend/coa-list.tpl.php +++ b/Theme/Backend/coa-list.tpl.php @@ -34,7 +34,7 @@ echo $this->data['nav']->render(); ?> $value) : ++$c; - $url = UriFactory::build('{/base}/accounting/coa/profile?{?}&id=' . $value->id); ?> + $url = UriFactory::build('{/base}/accounting/coa/view?{?}&id=' . $value->id); ?> printHtml($value->code); ?> printHtml($value->getL11n()); ?> diff --git a/Theme/Backend/costcenter-list.tpl.php b/Theme/Backend/costcenter-list.tpl.php index 8ac68b2..73e3884 100755 --- a/Theme/Backend/costcenter-list.tpl.php +++ b/Theme/Backend/costcenter-list.tpl.php @@ -35,7 +35,7 @@ echo $this->data['nav']->render(); ?> getHtml('Name'); ?> $value) : ++$count; - $url = UriFactory::build('{/base}/tag/single?{?}&id=' . $value->id); ?> + $url = UriFactory::build('{/base}/tag/view?{?}&id=' . $value->id); ?> printHtml($value->code); ?> diff --git a/Theme/Backend/costobject-list.tpl.php b/Theme/Backend/costobject-list.tpl.php index d21918e..2be90e5 100755 --- a/Theme/Backend/costobject-list.tpl.php +++ b/Theme/Backend/costobject-list.tpl.php @@ -35,7 +35,7 @@ echo $this->data['nav']->render(); ?> getHtml('Name'); ?> $value) : ++$count; - $url = UriFactory::build('{/base}/tag/single?{?}&id=' . $value->id); ?> + $url = UriFactory::build('{/base}/tag/view?{?}&id=' . $value->id); ?> printHtml($value->code); ?> diff --git a/Theme/Backend/gl-profile.tpl.php b/Theme/Backend/gl-view.tpl.php old mode 100755 new mode 100644 similarity index 100% rename from Theme/Backend/gl-profile.tpl.php rename to Theme/Backend/gl-view.tpl.php diff --git a/Theme/Backend/personal-list.tpl.php b/Theme/Backend/personal-list.tpl.php index c373c71..cc21dfb 100644 --- a/Theme/Backend/personal-list.tpl.php +++ b/Theme/Backend/personal-list.tpl.php @@ -27,76 +27,76 @@ echo $this->data['nav']->render(); ?>
getHtml('Accounts'); ?>download
- +
$value) : ++$count; - $url = UriFactory::build('{/base}/accounting/' . $type . '/profile?{?}&id=' . $value->id); + $url = UriFactory::build('{/base}/accounting/' . $type . '/view?{?}&id=' . $value->id); ?> - id); + notes as $note) : + $url = UriFactory::build('{/base}/editor/view?{?}&id=' . $note->id); ?> - id); + files as $file) : + $url = UriFactory::build('{/base}/media/view?{?}&id=' . $file->id); ?>
getHtml('ID', '0', '0'); ?> - getHtml('Name'); ?> - getHtml('City'); ?> - getHtml('Zip'); ?> - getHtml('Address'); ?> - getHtml('Country'); ?> -
printHtml($value->number); ?> @@ -113,7 +113,7 @@ echo $this->data['nav']->render(); ?> printHtml($value->mainAddress->city); ?> printHtml($value->mainAddress->postal); ?> printHtml($value->mainAddress->address); ?> - printHtml($value->mainAddress->getCountry()); ?> + printHtml($value->mainAddress->country); ?>
getHtml('Empty', '0', '0'); ?> diff --git a/Theme/Backend/personal-profile.tpl.php b/Theme/Backend/personal-profile.tpl.php index cc6d862..50fcaab 100644 --- a/Theme/Backend/personal-profile.tpl.php +++ b/Theme/Backend/personal-profile.tpl.php @@ -22,16 +22,14 @@ use phpOMS\Uri\UriFactory; /** @var \phpOMS\Views\View $this */ $account = $this->data['account'] ?? null; -$notes = $account->notes; -$files = $account->files; $accountImage = $this->getData('accountImage') ?? new NullMedia(); -$attributeView = $this->data['attributeView']; +$attributeView = $this->data['attributeView']; $countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants(); $countries = \phpOMS\Localization\ISO3166NameEnum::getConstants(); -$languages = ISO639Enum::getConstants(); +$languages = ISO639Enum::getConstants(); echo $this->data['nav']->render(); ?>
@@ -97,17 +95,17 @@ echo $this->data['nav']->render(); ?>
- +
- +
- +
@@ -170,7 +168,7 @@ echo $this->data['nav']->render(); ?>
@@ -198,7 +196,7 @@ echo $this->data['nav']->render(); ?>
- getEditorDocByTypeName('account_backend_warning'))->id !== 0) : ?> + notes) && ($warning = $account->getEditorDocByTypeName('account_backend_warning'))->id !== 0) : ?>
@@ -269,8 +267,8 @@ echo $this->data['nav']->render(); ?>
getHtml('Title'); ?> getHtml('CreatedAt'); ?>
title; ?> @@ -292,8 +290,8 @@ echo $this->data['nav']->render(); ?> getHtml('CreatedAt'); ?>
name; ?> @@ -464,15 +462,17 @@ echo $this->data['nav']->render(); ?> request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
+ data['contact-component']->render('account-contact', 'contacts', $account->account->contacts); ?> + data['address-component']->render('account-address', 'addresses', $account->account->addresses); ?>
request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>> -
+
data['media-upload']->render('account-file', 'files', '', $account->files); ?>
request->uri->fragment === 'c-tab-6' ? ' checked' : ''; ?>> -
+
data['note']->render('account-note', 'notes', $account->notes); ?>
diff --git a/Theme/Backend/personal-view.tpl.php b/Theme/Backend/personal-view.tpl.php new file mode 100644 index 0000000..50fcaab --- /dev/null +++ b/Theme/Backend/personal-view.tpl.php @@ -0,0 +1,479 @@ +data['account'] ?? null; + +$accountImage = $this->getData('accountImage') ?? new NullMedia(); + +$attributeView = $this->data['attributeView']; + +$countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants(); +$countries = \phpOMS\Localization\ISO3166NameEnum::getConstants(); +$languages = ISO639Enum::getConstants(); + +echo $this->data['nav']->render(); ?> +
+
+ +
+
+ request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> +
+
+
+ + +
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ +
+
+
+ +
+
+ getHtml('Contact'); ?> + mail +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ +
+
+ getHtml('Address'); ?> + + + + + +
+
+ mainAddress->fao)) : ?> +
+ + +
+ + +
+ + +
+ + mainAddress->addressAddition)) : ?> +
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+
+ +
+
+ <?= $this->printHtml($accountImage->name); ?> +
+
+ +
+
+ +
+
+
+
+ notes) && ($warning = $account->getEditorDocByTypeName('account_backend_warning'))->id !== 0) : ?> + +
+
+
+
printHtml($warning->plain); ?>
+
+
+
+ + + data['hasBilling']) : ?> +
+
+
+
+ +
getHtml('YTDSales'); ?>: + getCurrency(SalesBillMapper::getClientNetSales($account->id, SmartDateTime::startOfYear($this->data['business_start']), new \DateTime('now')), format: 'medium'); ?> +
getHtml('MTDSales'); ?>: + getCurrency(SalesBillMapper::getClientNetSales($account->id, SmartDateTime::startOfMonth(), new \DateTime('now')), format: 'medium'); ?> +
getHtml('CLV'); ?>: + getCurrency(SalesBillMapper::getCLVHistoric($account->id), format: 'medium'); ?> +
+
+
+
+ +
+
+
+ +
getHtml('LastContact'); ?>: + id)?->format('Y-m-d'); ?> +
getHtml('LastOrder'); ?>: + id)?->format('Y-m-d'); ?> +
getHtml('Created'); ?>: + createdAt->format('Y-m-d H:i'); ?> +
+
+
+
+ +
+
+
+ +
getHtml('DSO'); ?>: + TBD +
getHtml('Due'); ?>: + TBD +
getHtml('Balance'); ?>: + TBD +
+
+
+
+
+ + +
+
+
+
getHtml('Notes'); ?>
+
+ + + + + notes as $note) : + $url = UriFactory::build('{/base}/editor/view?{?}&id=' . $note->id); + ?> + +
getHtml('Title'); ?> + getHtml('CreatedAt'); ?> +
title; ?> + createdAt->format('Y-m-d'); ?> + +
+
+
+
+ +
+
+
getHtml('Documents'); ?>
+
+ + + + + files as $file) : + $url = UriFactory::build('{/base}/media/view?{?}&id=' . $file->id); + ?> + +
getHtml('Title'); ?> + + getHtml('CreatedAt'); ?> +
name; ?> + extension; ?> + createdAt->format('Y-m-d'); ?> + +
+
+
+
+
+ + data['hasBilling']) : ?> +
+
+
+
getHtml('RecentInvoices'); ?>
+ + + + + with('type') + ->with('type/l11n') + ->with('account') + ->where('account', $account->id) + ->where('type/l11n/language', $this->response->header->l11n->language) + ->sort('id', OrderType::DESC) + ->limit(5) + ->execute(); + + /** @var \Modules\Billing\Models\Bill $invoice */ + foreach ($newestInvoices as $invoice) : + $url = UriFactory::build('{/base}/sales/bill?{?}&id=' . $invoice->id); + ?> + +
getHtml('Number'); ?> + getHtml('Type'); ?> + getHtml('Name'); ?> + getHtml('Net'); ?> + getHtml('Date'); ?> +
getNumber(); ?> + type->getL11n(); ?> + billTo; ?> + getCurrency($invoice->netSales); ?> + createdAt->format('Y-m-d'); ?> + +
+
+
+
+ +
+
+
+ + request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> +
+
+
+
+
getHtml('Account'); ?>
+
+
+ + +
+
+
+
+ +
+
+
getHtml('Accounts'); ?>
+
+ + + + + +
+
+
+
+
+
+
+
+ + request->uri->fragment === 'c-tab-7' ? ' checked' : ''; ?>> +
+
+ +
+
+ + request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>> +
+
+
+
+
getHtml('QuickAction'); ?>
+
+ +
+
+
+ +
+
+
+
+
getHtml('Open'); ?>
+ + + + + +
+ getHtml('Info'); ?> + getHtml('Date'); ?> + getHtml('Credit'); ?> + getHtml('Debit'); ?> + getHtml('Number'); ?> + getHtml('Text'); ?> + getHtml('Due'); ?> + getHtml('Payment'); ?> +
getHtml('Empty', '0', '0'); ?> +
+
+
+ getHtml('Total'); ?>: 0.00 + getHtml('Due'); ?>: 0.00 +
+
+
+
+ +
+
+
+
getHtml('Total'); ?>
+ + + + + +
getHtml('Info'); ?> + getHtml('Date'); ?> + getHtml('Credit'); ?> + getHtml('Debit'); ?> + getHtml('Number'); ?> + getHtml('Text'); ?> + getHtml('Due'); ?> + getHtml('Payment'); ?> + getHtml('Balanced'); ?> + getHtml('Balance'); ?> +
getHtml('Empty', '0', '0'); ?> +
+
+
+
+
+
+
+
+ + request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>> +
+ data['contact-component']->render('account-contact', 'contacts', $account->account->contacts); ?> + data['address-component']->render('account-address', 'addresses', $account->account->addresses); ?> +
+ + request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>> +
+ data['media-upload']->render('account-file', 'files', '', $account->files); ?> +
+ + request->uri->fragment === 'c-tab-6' ? ' checked' : ''; ?>> +
+ data['note']->render('account-note', 'notes', $account->notes); ?> +
+
+
diff --git a/tests/Autoloader.php b/tests/Autoloader.php index 66e62da..c85670f 100755 --- a/tests/Autoloader.php +++ b/tests/Autoloader.php @@ -75,8 +75,8 @@ final class Autoloader */ public static function defaultAutoloader(string $class) : void { - $class = \ltrim($class, '\\'); - $class = \strtr($class, '_\\', '//'); + $class = \ltrim($class, '\\'); + $class = \strtr($class, '_\\', '//'); if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) { $class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class); diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index ddc049d..e559f7f 100755 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -1,4 +1,15 @@ [ + 'db' => [ 'core' => [ 'masters' => [ - 'admin' => [ + 'admin' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -80,7 +91,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -90,7 +101,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -100,7 +111,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -110,7 +121,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -120,7 +131,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -132,7 +143,7 @@ $CONFIG = [ ], ], 'postgresql' => [ - 'admin' => [ + 'admin' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -142,7 +153,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -152,7 +163,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -162,7 +173,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -172,7 +183,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -182,7 +193,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -194,37 +205,37 @@ $CONFIG = [ ], ], 'sqlite' => [ - 'admin' => [ + 'admin' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ @@ -232,7 +243,7 @@ $CONFIG = [ ], ], 'mssql' => [ - 'admin' => [ + 'admin' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -242,7 +253,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -252,7 +263,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -262,7 +273,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -272,7 +283,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -282,7 +293,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -322,16 +333,16 @@ $CONFIG = [ 'password' => '123456', ], ], - 'log' => [ + 'log' => [ 'file' => [ 'path' => __DIR__ . '/Logs', ], ], - 'page' => [ + 'page' => [ 'root' => '/', 'https' => false, ], - 'app' => [ + 'app' => [ 'path' => __DIR__, 'default' => [ 'app' => 'Backend', @@ -350,7 +361,7 @@ $CONFIG = [ ], ], ], - 'socket' => [ + 'socket' => [ 'master' => [ 'host' => '127.0.0.1', 'limit' => 300, @@ -360,7 +371,7 @@ $CONFIG = [ 'language' => [ 'en', ], - 'apis' => [ + 'apis' => [ ], ]; diff --git a/tests/Controller/Api/ApiControllerAccountTrait.php b/tests/Controller/Api/ApiControllerAccountTrait.php index 6b4e638..b6cd76d 100755 --- a/tests/Controller/Api/ApiControllerAccountTrait.php +++ b/tests/Controller/Api/ApiControllerAccountTrait.php @@ -17,7 +17,6 @@ namespace Modules\Accounting\tests\Controller\Api; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; -use phpOMS\Uri\HttpUri; trait ApiControllerAccountTrait { @@ -28,7 +27,7 @@ trait ApiControllerAccountTrait public function testApiAccountCreate() : void { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', '1'); @@ -46,7 +45,7 @@ trait ApiControllerAccountTrait public function testApiAccountCreateInvalid() : void { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); @@ -62,7 +61,7 @@ trait ApiControllerAccountTrait public function testApiAccountUpdate() : void { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('id', '1'); @@ -80,7 +79,7 @@ trait ApiControllerAccountTrait public function testApiAccountUpdateInvalid() : void { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); diff --git a/tests/Controller/Api/ApiControllerBatchEntryTrait.php b/tests/Controller/Api/ApiControllerBatchEntryTrait.php index 01982aa..10f3a2a 100755 --- a/tests/Controller/Api/ApiControllerBatchEntryTrait.php +++ b/tests/Controller/Api/ApiControllerBatchEntryTrait.php @@ -17,7 +17,6 @@ namespace Modules\Accounting\tests\Controller\Api; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; -use phpOMS\Uri\HttpUri; trait ApiControllerBatchEntryTrait { @@ -27,8 +26,8 @@ trait ApiControllerBatchEntryTrait */ public function testApiBatchEntryCreate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', '1'); @@ -45,8 +44,8 @@ trait ApiControllerBatchEntryTrait */ public function testApiBatchEntryCreateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); @@ -61,8 +60,8 @@ trait ApiControllerBatchEntryTrait */ public function testApiBatchEntryUpdate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('id', '1'); @@ -79,8 +78,8 @@ trait ApiControllerBatchEntryTrait */ public function testApiBatchEntryUpdateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); @@ -95,8 +94,8 @@ trait ApiControllerBatchEntryTrait */ public function testApiRecurringEntryCreate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', '1'); @@ -113,8 +112,8 @@ trait ApiControllerBatchEntryTrait */ public function testApiRecurringEntryCreateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); @@ -129,8 +128,8 @@ trait ApiControllerBatchEntryTrait */ public function testApiRecurringEntryUpdate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('id', '1'); @@ -147,8 +146,8 @@ trait ApiControllerBatchEntryTrait */ public function testApiRecurringEntryUpdateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); diff --git a/tests/Controller/Api/ApiControllerCostCenterTrait.php b/tests/Controller/Api/ApiControllerCostCenterTrait.php index 69ee454..2ea760c 100755 --- a/tests/Controller/Api/ApiControllerCostCenterTrait.php +++ b/tests/Controller/Api/ApiControllerCostCenterTrait.php @@ -17,7 +17,6 @@ namespace Modules\Accounting\tests\Controller\Api; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; -use phpOMS\Uri\HttpUri; trait ApiControllerCostCenterTrait { @@ -27,8 +26,8 @@ trait ApiControllerCostCenterTrait */ public function testApiCostCenterCreate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', '1'); @@ -45,8 +44,8 @@ trait ApiControllerCostCenterTrait */ public function testApiCostCenterCreateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); @@ -61,8 +60,8 @@ trait ApiControllerCostCenterTrait */ public function testApiCostCenterUpdate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('id', '1'); @@ -79,8 +78,8 @@ trait ApiControllerCostCenterTrait */ public function testApiCostCenterUpdateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); diff --git a/tests/Controller/Api/ApiControllerCostObjectTrait.php b/tests/Controller/Api/ApiControllerCostObjectTrait.php index 4dabf61..49f0301 100755 --- a/tests/Controller/Api/ApiControllerCostObjectTrait.php +++ b/tests/Controller/Api/ApiControllerCostObjectTrait.php @@ -17,7 +17,6 @@ namespace Modules\Accounting\tests\Controller\Api; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; -use phpOMS\Uri\HttpUri; trait ApiControllerCostObjectTrait { @@ -27,8 +26,8 @@ trait ApiControllerCostObjectTrait */ public function testApiCostObjectCreate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', '1'); @@ -45,8 +44,8 @@ trait ApiControllerCostObjectTrait */ public function testApiCostObjectCreateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); @@ -61,8 +60,8 @@ trait ApiControllerCostObjectTrait */ public function testApiCostObjectUpdate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('id', '1'); @@ -79,8 +78,8 @@ trait ApiControllerCostObjectTrait */ public function testApiCostObjectUpdateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); diff --git a/tests/Controller/Api/ApiControllerEntryTrait.php b/tests/Controller/Api/ApiControllerEntryTrait.php index f544514..71273fb 100755 --- a/tests/Controller/Api/ApiControllerEntryTrait.php +++ b/tests/Controller/Api/ApiControllerEntryTrait.php @@ -17,7 +17,6 @@ namespace Modules\Accounting\tests\Controller\Api; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; -use phpOMS\Uri\HttpUri; trait ApiControllerEntryTrait { @@ -28,7 +27,7 @@ trait ApiControllerEntryTrait public function testApiEntryCreate() : void { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', '1'); @@ -46,7 +45,7 @@ trait ApiControllerEntryTrait public function testApiEntryCreateInvalidData() : void { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); @@ -62,7 +61,7 @@ trait ApiControllerEntryTrait public function testApiEntryUpdate() : void { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('id', '1'); @@ -80,7 +79,7 @@ trait ApiControllerEntryTrait public function testApiEntryUpdateInvalidData() : void { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); diff --git a/tests/Controller/Api/ApiControllerTaxKeyTrait.php b/tests/Controller/Api/ApiControllerTaxKeyTrait.php index 10941bd..1193e7b 100755 --- a/tests/Controller/Api/ApiControllerTaxKeyTrait.php +++ b/tests/Controller/Api/ApiControllerTaxKeyTrait.php @@ -17,7 +17,6 @@ namespace Modules\Accounting\tests\Controller\Api; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; -use phpOMS\Uri\HttpUri; trait ApiControllerTaxKeyTrait { @@ -27,8 +26,8 @@ trait ApiControllerTaxKeyTrait */ public function testApiTaxKeyCreate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', '1'); @@ -45,8 +44,8 @@ trait ApiControllerTaxKeyTrait */ public function testApiTaxKeyCreateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); @@ -61,8 +60,8 @@ trait ApiControllerTaxKeyTrait */ public function testApiTaxKeyUpdate() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('id', '1'); @@ -79,8 +78,8 @@ trait ApiControllerTaxKeyTrait */ public function testApiTaxKeyUpdateInvalid() : void { - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $response = new HttpResponse(); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('invalid', '1'); diff --git a/tests/Models/BalanceL11nTest.php b/tests/Models/BalanceL11nTest.php index 1bfc6e2..af3151f 100755 --- a/tests/Models/BalanceL11nTest.php +++ b/tests/Models/BalanceL11nTest.php @@ -65,16 +65,6 @@ final class BalanceL11nTest extends \PHPUnit\Framework\TestCase self::assertEquals('TestDescription', $this->l11n->description); } - /** - * @covers Modules\Accounting\Models\BalanceL11n - * @group module - */ - public function testLanguageInputOutput() : void - { - $this->l11n->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $this->l11n->language); - } - /** * @covers Modules\Accounting\Models\BalanceL11n * @group module @@ -84,15 +74,15 @@ final class BalanceL11nTest extends \PHPUnit\Framework\TestCase $this->l11n->name = 'Title'; $this->l11n->description = 'Description'; $this->l11n->balance = 2; - $this->l11n->setLanguage(ISO639x1Enum::_DE); + $this->l11n->language = ISO639x1Enum::_DE; self::assertEquals( [ - 'id' => 0, - 'name' => 'Title', - 'description' => 'Description', - 'balance' => 2, - 'language' => ISO639x1Enum::_DE, + 'id' => 0, + 'name' => 'Title', + 'description' => 'Description', + 'balance' => 2, + 'language' => ISO639x1Enum::_DE, ], $this->l11n->jsonSerialize() ); diff --git a/tests/Models/BalanceTest.php b/tests/Models/BalanceTest.php index 2756d8c..7169d1d 100755 --- a/tests/Models/BalanceTest.php +++ b/tests/Models/BalanceTest.php @@ -48,7 +48,7 @@ final class BalanceTest extends \PHPUnit\Framework\TestCase { self::assertEquals( [ - 'id' => 0, + 'id' => 0, ], $this->balance->jsonSerialize() ); diff --git a/tests/Models/CostCenterL11nTest.php b/tests/Models/CostCenterL11nTest.php index 6ad5584..7aef16e 100755 --- a/tests/Models/CostCenterL11nTest.php +++ b/tests/Models/CostCenterL11nTest.php @@ -65,34 +65,24 @@ final class CostCenterL11nTest extends \PHPUnit\Framework\TestCase self::assertEquals('TestDescription', $this->l11n->description); } - /** - * @covers Modules\Accounting\Models\CostCenterL11n - * @group module - */ - public function testLanguageInputOutput() : void - { - $this->l11n->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $this->l11n->language); - } - /** * @covers Modules\Accounting\Models\CostCenterL11n * @group module */ public function testSerialize() : void { - $this->l11n->name = 'Title'; - $this->l11n->description = 'Description'; - $this->l11n->costcenter = 2; - $this->l11n->setLanguage(ISO639x1Enum::_DE); + $this->l11n->name = 'Title'; + $this->l11n->description = 'Description'; + $this->l11n->costcenter = 2; + $this->l11n->language = ISO639x1Enum::_DE; self::assertEquals( [ - 'id' => 0, - 'name' => 'Title', - 'description' => 'Description', - 'costcenter' => 2, - 'language' => ISO639x1Enum::_DE, + 'id' => 0, + 'name' => 'Title', + 'description' => 'Description', + 'costcenter' => 2, + 'language' => ISO639x1Enum::_DE, ], $this->l11n->jsonSerialize() ); diff --git a/tests/Models/CostCenterTest.php b/tests/Models/CostCenterTest.php index f2ccde7..ccb8458 100755 --- a/tests/Models/CostCenterTest.php +++ b/tests/Models/CostCenterTest.php @@ -72,9 +72,9 @@ final class CostCenterTest extends \PHPUnit\Framework\TestCase self::assertEquals( [ - 'id' => 0, - 'code' => '123', - 'parent' => null, + 'id' => 0, + 'code' => '123', + 'parent' => null, ], $this->cc->jsonSerialize() ); diff --git a/tests/Models/CostObjectL11nTest.php b/tests/Models/CostObjectL11nTest.php index 77984a4..baf52c4 100755 --- a/tests/Models/CostObjectL11nTest.php +++ b/tests/Models/CostObjectL11nTest.php @@ -65,34 +65,24 @@ final class CostObjectL11nTest extends \PHPUnit\Framework\TestCase self::assertEquals('TestDescription', $this->l11n->description); } - /** - * @covers Modules\Accounting\Models\CostObjectL11n - * @group module - */ - public function testLanguageInputOutput() : void - { - $this->l11n->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $this->l11n->language); - } - /** * @covers Modules\Accounting\Models\CostObjectL11n * @group module */ public function testSerialize() : void { - $this->l11n->name = 'Title'; - $this->l11n->description = 'Description'; - $this->l11n->costobject = 2; - $this->l11n->setLanguage(ISO639x1Enum::_DE); + $this->l11n->name = 'Title'; + $this->l11n->description = 'Description'; + $this->l11n->costobject = 2; + $this->l11n->language = ISO639x1Enum::_DE; self::assertEquals( [ - 'id' => 0, - 'name' => 'Title', - 'description' => 'Description', - 'costobject' => 2, - 'language' => ISO639x1Enum::_DE, + 'id' => 0, + 'name' => 'Title', + 'description' => 'Description', + 'costobject' => 2, + 'language' => ISO639x1Enum::_DE, ], $this->l11n->jsonSerialize() ); diff --git a/tests/Models/CostObjectTest.php b/tests/Models/CostObjectTest.php index 6d34d0e..1f71740 100755 --- a/tests/Models/CostObjectTest.php +++ b/tests/Models/CostObjectTest.php @@ -72,9 +72,9 @@ final class CostObjectTest extends \PHPUnit\Framework\TestCase self::assertEquals( [ - 'id' => 0, - 'code' => '123', - 'parent' => null, + 'id' => 0, + 'code' => '123', + 'parent' => null, ], $this->co->jsonSerialize() ); diff --git a/tests/Models/CreditorTest.php b/tests/Models/CreditorTest.php index d4d1ee9..b33d022 100755 --- a/tests/Models/CreditorTest.php +++ b/tests/Models/CreditorTest.php @@ -48,8 +48,8 @@ final class CreditorTest extends \PHPUnit\Framework\TestCase { self::assertEquals( [ - 'id' => 0, - 'account' => null, + 'id' => 0, + 'account' => null, ], $this->creditor->jsonSerialize() ); diff --git a/tests/Models/DebitorTest.php b/tests/Models/DebitorTest.php index 09e68fb..da4aaa0 100755 --- a/tests/Models/DebitorTest.php +++ b/tests/Models/DebitorTest.php @@ -48,8 +48,8 @@ final class DebitorTest extends \PHPUnit\Framework\TestCase { self::assertEquals( [ - 'id' => 0, - 'account' => null, + 'id' => 0, + 'account' => null, ], $this->debitor->jsonSerialize() );