Skip to content

Commit 96427c4

Browse files
committed
feat(simba): add metadata models (#191)
* feat(simba): add metadata models * feat(simba): add metadata models * fix(simba): map voucher open form flag
1 parent 3b5ae1e commit 96427c4

2 files changed

Lines changed: 224 additions & 0 deletions

File tree

src/Models/SiDmCt.php

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* @copyright © 2019 Dxvn, Inc.
7+
*
8+
* @author Tran Ngoc Duc <ductn@diepxuan.com>
9+
* @author Tran Ngoc Duc <caothu91@gmail.com>
10+
*
11+
* @lastupdate 2026-06-05 20:58:00
12+
*/
13+
14+
namespace Diepxuan\Simba\Models;
15+
16+
use Diepxuan\Simba\SModel\SModel;
17+
18+
/**
19+
* Model SiDmCt - Khai báo màn hình nhập chứng từ.
20+
*
21+
* Source: simba-docs/tables/SiDmCt.md.
22+
*/
23+
class SiDmCt extends SModel
24+
{
25+
public $incrementing = false;
26+
public $timestamps = false;
27+
protected $table = 'SiDmCt';
28+
protected $primaryKey = 'ma_ct';
29+
protected $keyType = 'string';
30+
31+
protected $fillable = [
32+
'ma_cty',
33+
'ma_ct',
34+
'phan_he',
35+
'ma_ct_me',
36+
'ten_ct',
37+
'tk_no',
38+
'tk_co',
39+
'ma_nt',
40+
'so_lien',
41+
'stt_nkc',
42+
'stt_ntxt',
43+
'ct_dc',
44+
'loc_nsd',
45+
'vv',
46+
'spct',
47+
'phi',
48+
'bp',
49+
'lo',
50+
'sp_post',
51+
'sp_process',
52+
'ph',
53+
'ct',
54+
'sd',
55+
'nxt',
56+
'menuid',
57+
'vn_prefix',
58+
'vn_postfix',
59+
'vn_sequence',
60+
'vn_pattern',
61+
'vn_width',
62+
'PhFieldlist2IN',
63+
'CtFieldlist2IN',
64+
'kieu_trung_so_ct',
65+
'VoucherGetWhenOpenForm',
66+
];
67+
68+
protected $casts = [
69+
'so_lien' => 'integer',
70+
'stt_nkc' => 'integer',
71+
'stt_ntxt' => 'integer',
72+
'ct_dc' => 'boolean',
73+
'loc_nsd' => 'boolean',
74+
'vv' => 'boolean',
75+
'spct' => 'boolean',
76+
'phi' => 'boolean',
77+
'bp' => 'boolean',
78+
'lo' => 'boolean',
79+
'sd' => 'boolean',
80+
'vn_sequence' => 'integer',
81+
'vn_width' => 'integer',
82+
'kieu_trung_so_ct' => 'integer',
83+
'VoucherGetWhenOpenForm' => 'boolean',
84+
];
85+
86+
/**
87+
* Scope: find voucher metadata by company and voucher code.
88+
*
89+
* @param mixed $query
90+
*/
91+
public function scopeVoucher($query, string $maCt, string $maCty = SModel::CTY)
92+
{
93+
return $query->where('ma_cty', $maCty)->where('ma_ct', $maCt);
94+
}
95+
96+
/**
97+
* Scope: find voucher metadata by Simba menuid.
98+
*
99+
* @param mixed $query
100+
*/
101+
public function scopeMenuId($query, string $menuId)
102+
{
103+
return $query->where('menuid', $menuId);
104+
}
105+
106+
/**
107+
* @return list<string>
108+
*/
109+
public function headerFieldsForInventory(): array
110+
{
111+
return array_values(array_filter(array_map('trim', explode(',', (string) $this->PhFieldlist2IN))));
112+
}
113+
114+
/**
115+
* @return list<string>
116+
*/
117+
public function detailFieldsForInventory(): array
118+
{
119+
return array_values(array_filter(array_map('trim', explode(',', (string) $this->CtFieldlist2IN))));
120+
}
121+
}

src/Models/SysDictionaryInfo.php

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* @copyright © 2019 Dxvn, Inc.
7+
*
8+
* @author Tran Ngoc Duc <ductn@diepxuan.com>
9+
* @author Tran Ngoc Duc <caothu91@gmail.com>
10+
*
11+
* @lastupdate 2026-06-05 20:58:00
12+
*/
13+
14+
namespace Diepxuan\Simba\Models;
15+
16+
use Illuminate\Database\Eloquent\Model;
17+
18+
/**
19+
* SimbaERP sysDictionaryInfo table model.
20+
*
21+
* Source: simba-docs/tables/sysDictionaryInfo.md.
22+
*/
23+
class SysDictionaryInfo extends Model
24+
{
25+
public $incrementing = false;
26+
public $timestamps = false;
27+
protected $connection = 'sqlsrv';
28+
protected $table = 'sysDictionaryInfo';
29+
protected $primaryKey = 'code_name';
30+
protected $keyType = 'string';
31+
32+
protected $fillable = [
33+
'code_name',
34+
'PK',
35+
'code_fname',
36+
'code_length',
37+
'name_fname',
38+
'table_name',
39+
'menuid',
40+
'lookup_when_invalid',
41+
'allow_merge_code',
42+
'dllname',
43+
'view_class_name',
44+
'edit_class_name',
45+
'carry_field_list',
46+
'default_sort',
47+
'copy_vaora',
48+
'par0',
49+
'par1',
50+
'par2',
51+
'par3',
52+
'par4',
53+
'par5',
54+
'par6',
55+
'par7',
56+
'par8',
57+
'par9',
58+
'description',
59+
];
60+
61+
protected $casts = [
62+
'code_length' => 'integer',
63+
'lookup_when_invalid' => 'boolean',
64+
'allow_merge_code' => 'boolean',
65+
'copy_vaora' => 'boolean',
66+
];
67+
68+
/**
69+
* @return list<string>
70+
*/
71+
public function primaryKeyFields(): array
72+
{
73+
return array_values(array_filter(array_map('trim', explode(',', (string) $this->PK))));
74+
}
75+
76+
/**
77+
* @return list<string>
78+
*/
79+
public function carryFields(): array
80+
{
81+
return array_values(array_filter(array_map('trim', explode(',', (string) $this->carry_field_list))));
82+
}
83+
84+
/**
85+
* Scope: find dictionary metadata by Simba code_name.
86+
*
87+
* @param mixed $query
88+
*/
89+
public function scopeCodeName($query, string $codeName)
90+
{
91+
return $query->where('code_name', $codeName);
92+
}
93+
94+
/**
95+
* Scope: find dictionary metadata by Simba menuid.
96+
*
97+
* @param mixed $query
98+
*/
99+
public function scopeMenuId($query, string $menuId)
100+
{
101+
return $query->where('menuid', $menuId);
102+
}
103+
}

0 commit comments

Comments
 (0)