mirror of
https://github.com/Karaka-Management/oms-Accounting.git
synced 2026-01-11 13:28:40 +00:00
new datamapper mostly implemented
This commit is contained in:
parent
00abd33bb6
commit
c08deecc87
|
|
@ -325,18 +325,15 @@ final class BackendController extends Controller
|
|||
|
||||
if ($request->getData('ptype') === 'p') {
|
||||
$view->setData('costcenter',
|
||||
CostCenterMapper::with('language', $response->getLanguage())
|
||||
::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25)
|
||||
CostCenterMapper::getAll()->where('id', (int) ($request->getData('id') ?? 0), '<')->limit(25)->execute()
|
||||
);
|
||||
} elseif ($request->getData('ptype') === 'n') {
|
||||
$view->setData('costcenter',
|
||||
CostCenterMapper::with('language', $response->getLanguage())
|
||||
::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25)
|
||||
CostCenterMapper::getAll()->where('id', (int) ($request->getData('id') ?? 0), '>')->limit(25)->execute()
|
||||
);
|
||||
} else {
|
||||
$view->setData('costcenter',
|
||||
CostCenterMapper::with('language', $response->getLanguage())
|
||||
::getAfterPivot(0, null, 25)
|
||||
CostCenterMapper::getAll()->where('id', 0, '>')->limit(25)->execute()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -363,18 +360,15 @@ final class BackendController extends Controller
|
|||
|
||||
if ($request->getData('ptype') === 'p') {
|
||||
$view->setData('costobject',
|
||||
CostObjectMapper::with('language', $response->getLanguage())
|
||||
::getBeforePivot((int) ($request->getData('id') ?? 0), null, 25)
|
||||
CostObjectMapper::getAll()->where('id', (int) ($request->getData('id') ?? 0), '<')->limit(25)->execute()
|
||||
);
|
||||
} elseif ($request->getData('ptype') === 'n') {
|
||||
$view->setData('costobject',
|
||||
CostObjectMapper::with('language', $response->getLanguage())
|
||||
::getAfterPivot((int) ($request->getData('id') ?? 0), null, 25)
|
||||
CostObjectMapper::getAll()->where('id', (int) ($request->getData('id') ?? 0), '>')->limit(25)->execute()
|
||||
);
|
||||
} else {
|
||||
$view->setData('costobject',
|
||||
CostObjectMapper::with('language', $response->getLanguage())
|
||||
::getAfterPivot(0, null, 25)
|
||||
CostObjectMapper::getAll()->where('id', 0, '>')->limit(25)->execute()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Accounting\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* CostCenter mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class CostCenterL11nMapper extends DataMapperAbstract
|
||||
final class CostCenterL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class CostCenterL11nMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
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' => 'name', 'autocomplete' => true],
|
||||
'accounting_costcenter_l11n_description' => ['name' => 'accounting_costcenter_l11n_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true],
|
||||
|
|
@ -46,7 +46,7 @@ final class CostCenterL11nMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'accounting_costcenter_l11n';
|
||||
public const TABLE = 'accounting_costcenter_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -54,5 +54,5 @@ final class CostCenterL11nMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'accounting_costcenter_l11n_id';
|
||||
public const PRIMARYFIELD ='accounting_costcenter_l11n_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Accounting\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Accounting mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class CostCenterMapper extends DataMapperAbstract
|
||||
final class CostCenterMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class CostCenterMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'accounting_costcenter_id' => ['name' => 'accounting_costcenter_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'accounting_costcenter_code' => ['name' => 'accounting_costcenter_code', 'type' => 'string', 'internal' => 'code'],
|
||||
];
|
||||
|
|
@ -43,12 +43,11 @@ final class CostCenterMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $hasMany = [
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => CostCenterL11nMapper::class,
|
||||
'table' => 'accounting_costcenter_l11n',
|
||||
'self' => 'accounting_costcenter_l11n_costcenter',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
|
@ -59,7 +58,7 @@ final class CostCenterMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $model = CostCenter::class;
|
||||
public const MODEL = CostCenter::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
|
|
@ -67,7 +66,7 @@ final class CostCenterMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'accounting_costcenter';
|
||||
public const TABLE = 'accounting_costcenter';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -75,5 +74,5 @@ final class CostCenterMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'accounting_costcenter_id';
|
||||
public const PRIMARYFIELD ='accounting_costcenter_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Accounting\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* CostObject mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class CostObjectL11nMapper extends DataMapperAbstract
|
||||
final class CostObjectL11nMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class CostObjectL11nMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
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' => 'name', 'autocomplete' => true],
|
||||
'accounting_costobject_l11n_description' => ['name' => 'accounting_costobject_l11n_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true],
|
||||
|
|
@ -46,7 +46,7 @@ final class CostObjectL11nMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'accounting_costobject_l11n';
|
||||
public const TABLE = 'accounting_costobject_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -54,5 +54,5 @@ final class CostObjectL11nMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'accounting_costobject_l11n_id';
|
||||
public const PRIMARYFIELD ='accounting_costobject_l11n_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Accounting\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Accounting mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class CostObjectMapper extends DataMapperAbstract
|
||||
final class CostObjectMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class CostObjectMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'accounting_costobject_id' => ['name' => 'accounting_costobject_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'accounting_costobject_code' => ['name' => 'accounting_costobject_code', 'type' => 'string', 'internal' => 'code'],
|
||||
];
|
||||
|
|
@ -43,7 +43,7 @@ final class CostObjectMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $hasMany = [
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => CostObjectL11nMapper::class,
|
||||
'table' => 'accounting_costobject_l11n',
|
||||
|
|
@ -59,7 +59,7 @@ final class CostObjectMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $model = CostObject::class;
|
||||
public const MODEL = CostObject::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
|
|
@ -67,7 +67,7 @@ final class CostObjectMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'accounting_costobject';
|
||||
public const TABLE = 'accounting_costobject';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -75,5 +75,5 @@ final class CostObjectMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'accounting_costobject_id';
|
||||
public const PRIMARYFIELD ='accounting_costobject_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ require_once __DIR__ . '/../vendor/autoload.php';
|
|||
require_once __DIR__ . '/Autoloader.php';
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\DataStorage\Session\HttpSession;
|
||||
|
||||
$CONFIG = [
|
||||
|
|
@ -329,7 +329,7 @@ $GLOBALS['dbpool']->create('delete', $CONFIG['db']['core']['masters']['delete'])
|
|||
$GLOBALS['dbpool']->create('insert', $CONFIG['db']['core']['masters']['insert']);
|
||||
$GLOBALS['dbpool']->create('schema', $CONFIG['db']['core']['masters']['schema']);
|
||||
|
||||
DataMapperAbstract::setConnection($GLOBALS['dbpool']->get());
|
||||
DataMapperFactory::db($GLOBALS['dbpool']->get());
|
||||
|
||||
$GLOBALS['frameworkpath'] = '/phpOMS/';
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ final class CostCenterMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$costcenter->l11n->name = 'Test CostCenter';
|
||||
$costcenter->l11n->description = 'Test description';
|
||||
|
||||
$id = CostCenterMapper::create($costcenter);
|
||||
$id = CostCenterMapper::create()->execute($costcenter);
|
||||
self::assertGreaterThan(0, $costcenter->getId());
|
||||
self::assertEquals($id, $costcenter->getId());
|
||||
|
||||
$costcenterR = CostCenterMapper::with('language', ISO639x1Enum::_EN)::get($costcenter->getId());
|
||||
$costcenterR = CostCenterMapper::get()->with('l11n')->where('l11n/language', ISO639x1Enum::_EN)->where('id', $costcenter->getId())->execute();
|
||||
self::assertEquals($costcenter->code, $costcenterR->code);
|
||||
self::assertEquals($costcenter->l11n->name, $costcenterR->l11n->name);
|
||||
self::assertEquals($costcenter->l11n->description, $costcenterR->l11n->description);
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ final class CostObjectMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$costobject->l11n->name = 'Test CostObject';
|
||||
$costobject->l11n->description = 'Test description';
|
||||
|
||||
$id = CostObjectMapper::create($costobject);
|
||||
$id = CostObjectMapper::create()->execute($costobject);
|
||||
self::assertGreaterThan(0, $costobject->getId());
|
||||
self::assertEquals($id, $costobject->getId());
|
||||
|
||||
$costobjectR = CostObjectMapper::with('language', ISO639x1Enum::_EN)::get($costobject->getId());
|
||||
$costobjectR = CostObjectMapper::get()->with('l11n')->where('l11n/language', ISO639x1Enum::_EN)->where('id', $costobject->getId())->execute();
|
||||
self::assertEquals($costobject->code, $costobjectR->code);
|
||||
self::assertEquals($costobject->l11n->name, $costobjectR->l11n->name);
|
||||
self::assertEquals($costobject->l11n->description, $costobjectR->l11n->description);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user