mirror of
https://github.com/Karaka-Management/oms-Finance.git
synced 2026-01-10 20:48:39 +00:00
too many changes
This commit is contained in:
parent
87053dc2c3
commit
7f17075951
75
Admin/Install/db.json
Normal file
75
Admin/Install/db.json
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
"tax_code": {
|
||||
"name": "tax_code",
|
||||
"fields": {
|
||||
"tax_code_id": {
|
||||
"name": "tax_code_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"tax_code_abbr": {
|
||||
"name": "tax_code_abbr",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"tax_code_invoice": {
|
||||
"name": "tax_code_invoice",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"tax_code_sales": {
|
||||
"name": "tax_code_sales",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"tax_code_input": {
|
||||
"name": "tax_code_input",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"tax_code_l11n": {
|
||||
"name": "tax_code_l11n",
|
||||
"fields": {
|
||||
"tax_code_l11n_id": {
|
||||
"name": "tax_code_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"tax_code_l11n_text_title": {
|
||||
"name": "tax_code_l11n_text_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"tax_code_l11n_text_short": {
|
||||
"name": "tax_code_l11n_text_short",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"tax_code_l11n_text_long": {
|
||||
"name": "tax_code_l11n_text_long",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"tax_code_l11n_lang": {
|
||||
"name": "tax_code_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
},
|
||||
"tax_code_l11n_code": {
|
||||
"name": "tax_code_l11n_code",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "tax_code",
|
||||
"foreignKey": "tax_code_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2716
Admin/Install/taxcodes.json
Normal file
2716
Admin/Install/taxcodes.json
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -14,7 +14,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Finance\Admin;
|
||||
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
use phpOMS\Config\SettingsInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Module\InstallerAbstract;
|
||||
use phpOMS\Module\ModuleInfo;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* Installer class.
|
||||
|
|
@ -33,4 +39,74 @@ final class Installer extends InstallerAbstract
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const PATH = __DIR__;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void
|
||||
{
|
||||
parent::install($app, $info, $cfgHandler);
|
||||
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/taxcodes.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$taxes = \json_decode($fileContent, true);
|
||||
foreach ($taxes as $type) {
|
||||
self::createCode($app, $type);
|
||||
}
|
||||
}
|
||||
|
||||
private static function createCode(ApplicationAbstract $app, array $data) : array
|
||||
{
|
||||
/** @var \Modules\Finance\Controller\ApiController $module */
|
||||
$module = $app->moduleManager->get('Finance');
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('abbr', $data['abbr'] ?? '');
|
||||
$request->setData('percentage_invoice', $data['percentage_invoice'] ?? 0);
|
||||
$request->setData('percentage_sales_tax', $data['percentage_sales_tax'] ?? 0);
|
||||
$request->setData('percentage_input_tax', $data['percentage_input_tax'] ?? 0);
|
||||
$request->setData('title', \reset($data['l11n'])['title'] ?? '');
|
||||
$request->setData('short', \reset($data['l11n'])['short'] ?? '');
|
||||
$request->setData('long', \reset($data['l11n'])['long'] ?? '');
|
||||
$request->setData('language', \array_keys($data['l11n'])[0]);
|
||||
|
||||
$module->apiTaxCodeCreate($request, $response);
|
||||
|
||||
$responseData = $response->get('');
|
||||
if (!\is_array($responseData)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/** @var \Modules\Finace\Models\TaxCode $code */
|
||||
$code = $responseData['response'];
|
||||
$id = $code->getId();
|
||||
|
||||
$isFirst = true;
|
||||
foreach ($data['l11n'] as $lang => $l11n) {
|
||||
if ($isFirst) {
|
||||
$isFirst = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $l11n['title'] ?? '');
|
||||
$request->setData('short', $l11n['short'] ?? '');
|
||||
$request->setData('long', $l11n['long'] ?? '');
|
||||
$request->setData('language', $lang);
|
||||
$request->setData('code', $id);
|
||||
|
||||
$module->apiTaxCodeL11nCreate($request, $response);
|
||||
}
|
||||
|
||||
return $code->toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
182
Controller/ApiController.php
Normal file
182
Controller/ApiController.php
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Finance
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Finance\Controller;
|
||||
|
||||
use Modules\Finance\Models\TaxCode;
|
||||
use Modules\Finance\Models\TaxCodeL11n;
|
||||
use Modules\Finance\Models\TaxCodeL11nMapper;
|
||||
use Modules\Finance\Models\TaxCodeMapper;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Message\FormValidation;
|
||||
|
||||
/**
|
||||
* Finance class.
|
||||
*
|
||||
* @package Modules\Finance
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Validate document create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTaxCodeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['abbr'] = empty($request->getData('abbr')))
|
||||
|| ($val['title'] = empty($request->getData('title')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create document
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTaxCodeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTaxCodeCreate($request))) {
|
||||
$response->set('tax_code_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$code = $this->createTaxCodeFromRequest($request);
|
||||
$this->createModel($request->header->account, $code, TaxCodeMapper::class, 'tax_code', $request->getOrigin());
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Code', 'Tax code successfully created', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create task from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TaxCode
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTaxCodeFromRequest(RequestAbstract $request) : TaxCode
|
||||
{
|
||||
$code = new TaxCode();
|
||||
$code->abbr = (string) ($request->getData('abbr') ?? '');
|
||||
$code->percentageInvoice = (int) ($request->getData('percentage_invoice') ?? 0);
|
||||
$code->percentageSales = (int) ($request->getData('percentage_sales_tax') ?? 0);
|
||||
$code->percentageInput = (int) ($request->getData('percentage_input_tax') ?? 0);
|
||||
|
||||
if (!empty($request->getData('title'))) {
|
||||
$code->l11n->title = (string) ($request->getData('title') ?? '');
|
||||
$code->l11n->short = (string) ($request->getData('short') ?? '');
|
||||
$code->l11n->long = (string) ($request->getData('long') ?? '');
|
||||
$code->l11n->setLanguage((string) ($request->getData('language') ?? 'en'));
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate l11n create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateTaxCodeL11nCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = empty($request->getData('title')))
|
||||
|| ($val['code'] = empty($request->getData('code')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create tag localization
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiTaxCodeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateTaxCodeL11nCreate($request))) {
|
||||
$response->set('tax_code_l11n_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$l11nCode = $this->createTaxCodeL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $l11nCode, TaxCodeL11nMapper::class, 'tax_code_l11n', $request->getOrigin());
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $l11nCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create tag localization from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TaxCodeL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTaxCodeL11nFromRequest(RequestAbstract $request) : TaxCodeL11n
|
||||
{
|
||||
$l11n = new TaxCodeL11n();
|
||||
$l11n->title = (string) ($request->getData('title') ?? '');
|
||||
$l11n->short = (string) ($request->getData('short') ?? '');
|
||||
$l11n->long = (string) ($request->getData('long') ?? '');
|
||||
$l11n->code = (int) ($request->getData('code') ?? 0);
|
||||
$l11n->setLanguage((string) ($request->getData('language') ?? $request->getLanguage()));
|
||||
|
||||
return $l11n;
|
||||
}
|
||||
}
|
||||
197
Models/EUVATRates.php
Normal file
197
Models/EUVATRates.php
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Finance\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\EnumArray;
|
||||
|
||||
/**
|
||||
* EU VAT rates
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class EUVATRates extends EnumArray
|
||||
{
|
||||
protected static array $constants = [
|
||||
'_AUT' => [
|
||||
[2000, 'S'],
|
||||
[1300, 'R'],
|
||||
[1000, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_BEL' => [
|
||||
[2100, 'S'],
|
||||
[1200, 'R'],
|
||||
[600, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_BGR' => [
|
||||
[2000, 'S'],
|
||||
[2100, 'R'],
|
||||
[1000, 'R'],
|
||||
[900, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_HRV' => [
|
||||
[2500, 'S'],
|
||||
[1300, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_CYP' => [
|
||||
[1900, 'S'],
|
||||
[900, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_CZE' => [
|
||||
[2100, 'S'],
|
||||
[1500, 'R'],
|
||||
[1000, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_DNK' => [
|
||||
[2500, 'S'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_EST' => [
|
||||
[2000, 'S'],
|
||||
[900, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_FIN' => [
|
||||
[2400, 'S'],
|
||||
[1400, 'R'],
|
||||
[1000, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_FRA' => [
|
||||
[2000, 'S'],
|
||||
[1000, 'R'],
|
||||
[550, 'R'],
|
||||
[210, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_DEU' => [
|
||||
[1900, 'S'],
|
||||
[700, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_GRC' => [
|
||||
[2400, 'S'],
|
||||
[1300, 'R'],
|
||||
[600, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_HUN' => [
|
||||
[2700, 'S'],
|
||||
[1800, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_IRL' => [
|
||||
[2300, 'S'],
|
||||
[1350, 'R'],
|
||||
[900, 'R'],
|
||||
[480, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_ITA' => [
|
||||
[2200, 'S'],
|
||||
[1000, 'R'],
|
||||
[500, 'R'],
|
||||
[400, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_LVA' => [
|
||||
[2100, 'S'],
|
||||
[1200, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_LTU' => [
|
||||
[2100, 'S'],
|
||||
[900, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_LUX' => [
|
||||
[1700, 'S'],
|
||||
[1400, 'R'],
|
||||
[800, 'R'],
|
||||
[300, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_MLT' => [
|
||||
[1800, 'S'],
|
||||
[700, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_NLD' => [
|
||||
[2100, 'S'],
|
||||
[900, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_POL' => [
|
||||
[2300, 'S'],
|
||||
[800, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_PRT' => [
|
||||
[2300, 'S'],
|
||||
[1300, 'R'],
|
||||
[600, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_ROU' => [
|
||||
[1900, 'S'],
|
||||
[900, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_SVK' => [
|
||||
[2000, 'S'],
|
||||
[1000, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_SVN' => [
|
||||
[2200, 'S'],
|
||||
[950, 'R'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_ESP' => [
|
||||
[2100, 'S'],
|
||||
[1000, 'R'],
|
||||
[400, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_SWE' => [
|
||||
[2500, 'S'],
|
||||
[1200, 'R'],
|
||||
[600, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
'_GBR' => [
|
||||
[2000, 'S'],
|
||||
[500, 'R'],
|
||||
[0, 'Z'],
|
||||
],
|
||||
];
|
||||
}
|
||||
46
Models/NullTaxCode.php
Normal file
46
Models/NullTaxCode.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Finance\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTaxCode extends TaxCode
|
||||
{
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
}
|
||||
46
Models/NullTaxCodeL11n.php
Normal file
46
Models/NullTaxCodeL11n.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Finance\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTaxCodeL11n extends TaxCodeL11n
|
||||
{
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
}
|
||||
83
Models/TaxCode.php
Normal file
83
Models/TaxCode.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Finance\Models;
|
||||
|
||||
/**
|
||||
* Finance class.
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TaxCode implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Article ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
public string $abbr = '';
|
||||
|
||||
public int $percentageInvoice = 0;
|
||||
public int $percentageSales = 0;
|
||||
public int $percentageInput = 0;
|
||||
|
||||
/**
|
||||
* Localization.
|
||||
*
|
||||
* @var TaxCodeL11n
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public TaxCodeL11n $l11n;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->l11n = new TaxCodeL11n();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
145
Models/TaxCodeL11n.php
Normal file
145
Models/TaxCodeL11n.php
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Finance\Models;
|
||||
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Localization of the item class.
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TaxCodeL11n implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Article ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Tax code ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $code = 0;
|
||||
|
||||
/**
|
||||
* Language.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $language = ISO639x1Enum::_EN;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $short = '';
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $long = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getLanguage() : string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param string $language Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setLanguage(string $language) : void
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'short' => $this->short,
|
||||
'long' => $this->long,
|
||||
'language' => $this->language,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
59
Models/TaxCodeL11nMapper.php
Normal file
59
Models/TaxCodeL11nMapper.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Finance\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* TaxCode mapper class.
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TaxCodeL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'tax_code_l11n_id' => ['name' => 'tax_code_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'tax_code_l11n_text_title' => ['name' => 'tax_code_l11n_text_title', 'type' => 'string', 'internal' => 'title'],
|
||||
'tax_code_l11n_text_short' => ['name' => 'tax_code_l11n_text_short', 'type' => 'string', 'internal' => 'short'],
|
||||
'tax_code_l11n_text_long' => ['name' => 'tax_code_l11n_text_long', 'type' => 'string', 'internal' => 'long'],
|
||||
'tax_code_l11n_lang' => ['name' => 'tax_code_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
'tax_code_l11n_code' => ['name' => 'tax_code_l11n_code', 'type' => 'int', 'internal' => 'code'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'tax_code_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'tax_code_l11n_id';
|
||||
}
|
||||
73
Models/TaxCodeMapper.php
Normal file
73
Models/TaxCodeMapper.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Finance\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* TaxCode mapper class.
|
||||
*
|
||||
* @package Modules\Finance\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class TaxCodeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'tax_code_id' => ['name' => 'tax_code_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'tax_code_abbr' => ['name' => 'tax_code_abbr', 'type' => 'string', 'internal' => 'abbr'],
|
||||
'tax_code_invoice' => ['name' => 'tax_code_invoice', 'type' => 'int', 'internal' => 'percentageInvoice'],
|
||||
'tax_code_sales' => ['name' => 'tax_code_sales', 'type' => 'int', 'internal' => 'percentageSales'],
|
||||
'tax_code_input' => ['name' => 'tax_code_input', 'type' => 'int', 'internal' => 'percentageInput'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'tax_code';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'tax_code_id';
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => TaxCodeL11nMapper::class,
|
||||
'table' => 'tax_code_l11n',
|
||||
'self' => 'tax_code_l11n_code',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "karaka/karaka",
|
||||
"description": "PHP Framework for Karaka.",
|
||||
"description": "PHP Framework for Jingga.",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dennis Eichhorn",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user