Skip to content

Commit b89e072

Browse files
committed
Merge pull request #181 from diepxuan/chore/update-task-069-po3-from-simba-docs
chore: update task 069 PO3 — đúng tên bảng/SP từ simba-docs, sub-tasks chi tiết
1 parent cc67a08 commit b89e072

10 files changed

Lines changed: 539 additions & 0 deletions

File tree

src/Models/PoCp3.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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-05-14 09:12:26
12+
*/
13+
14+
namespace Diepxuan\Simba\Models;
15+
16+
use Diepxuan\Simba\SModel\PoCp3Model as Model;
17+
use Illuminate\Database\Eloquent\Builder;
18+
19+
/**
20+
* Class PoCp3.
21+
*
22+
* Hóa đơn mua hàng - Chi phí (PO3).
23+
*/
24+
class PoCp3 extends Model
25+
{
26+
/** Filter theo mã chi phí */
27+
public function scopeFilterByMaCp(Builder $query, ?string $maCp): Builder
28+
{
29+
if (!empty($maCp)) {
30+
return $query->where('ma_cp', $maCp);
31+
}
32+
33+
return $query;
34+
}
35+
36+
/** Filter theo mã bộ phận */
37+
public function scopeFilterByMaBp(Builder $query, ?string $maBp): Builder
38+
{
39+
if (!empty($maBp)) {
40+
return $query->where('ma_bp', $maBp);
41+
}
42+
43+
return $query;
44+
}
45+
46+
/** Relationship với header */
47+
public function poPh3()
48+
{
49+
return $this->belongsTo(PoPh3::class, 'stt_rec', 'stt_rec');
50+
}
51+
}

src/Models/PoCt3.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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-05-14 09:12:27
12+
*/
13+
14+
namespace Diepxuan\Simba\Models;
15+
16+
use Diepxuan\Simba\SModel\PoCt3Model as Model;
17+
use Illuminate\Database\Eloquent\Builder;
18+
19+
/**
20+
* Class PoCt3.
21+
*
22+
* Hóa đơn mua hàng - Chi tiết vật tư (PO3).
23+
*/
24+
class PoCt3 extends Model
25+
{
26+
/** Filter theo mã vật tư */
27+
public function scopeFilterByMaVt(Builder $query, ?string $maVt): Builder
28+
{
29+
if (!empty($maVt)) {
30+
return $query->where('ma_vt', $maVt);
31+
}
32+
33+
return $query;
34+
}
35+
36+
/** Filter theo mã kho */
37+
public function scopeFilterByMaKho(Builder $query, ?string $maKho): Builder
38+
{
39+
if (!empty($maKho)) {
40+
return $query->where('ma_kho', $maKho);
41+
}
42+
43+
return $query;
44+
}
45+
46+
/** Relationship với header */
47+
public function poPh3()
48+
{
49+
return $this->belongsTo(PoPh3::class, 'stt_rec', 'stt_rec');
50+
}
51+
52+
/** Relationship với vật tư */
53+
public function inDmVt()
54+
{
55+
return $this->belongsTo(InDmVt::class, 'ma_vt', 'ma_vt');
56+
}
57+
58+
/** Relationship với kho */
59+
public function inDmKho()
60+
{
61+
return $this->belongsTo(InDmKho::class, 'ma_kho', 'ma_kho');
62+
}
63+
}

src/Models/PoPh3.php

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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-05-14 09:12:27
12+
*/
13+
14+
namespace Diepxuan\Simba\Models;
15+
16+
use Diepxuan\Simba\SModel\PoPh3Model as Model;
17+
use Illuminate\Database\Eloquent\Builder;
18+
19+
/**
20+
* Class PoPh3.
21+
*
22+
* Hóa đơn mua hàng - Header (PO3).
23+
*/
24+
class PoPh3 extends Model
25+
{
26+
/** Filter theo tìm kiếm (số hóa đơn, số chứng từ, diễn giải) */
27+
public function scopeFilterBySearch(Builder $query, ?string $search): Builder
28+
{
29+
if (!empty($search)) {
30+
return $query->where(static function ($q) use ($search): void {
31+
$q->where('so_hd', 'like', "%{$search}%")
32+
->orWhere('so_ct', 'like', "%{$search}%")
33+
->orWhere('dien_giai', 'like', "%{$search}%")
34+
;
35+
});
36+
}
37+
38+
return $query;
39+
}
40+
41+
/** Filter theo mã khách hàng/NCC */
42+
public function scopeFilterByMaKh(Builder $query, ?string $maKh): Builder
43+
{
44+
if (!empty($maKh)) {
45+
return $query->where('ma_kh', $maKh);
46+
}
47+
48+
return $query;
49+
}
50+
51+
/** Filter theo ngày chứng từ */
52+
public function scopeFilterByNgayCt(Builder $query, ?string $fromDate, ?string $toDate): Builder
53+
{
54+
if (!empty($fromDate)) {
55+
$query->whereDate('ngay_ct', '>=', $fromDate);
56+
}
57+
if (!empty($toDate)) {
58+
$query->whereDate('ngay_ct', '<=', $toDate);
59+
}
60+
61+
return $query;
62+
}
63+
64+
/** Relationship với chi tiết vật tư */
65+
public function chiTiets()
66+
{
67+
return $this->hasMany(PoCt3::class, 'stt_rec', 'stt_rec');
68+
}
69+
70+
/** Relationship với chi phí */
71+
public function chiPhis()
72+
{
73+
return $this->hasMany(PoCp3::class, 'stt_rec', 'stt_rec');
74+
}
75+
76+
/** Relationship với nhà cung cấp */
77+
public function nhaCungCap()
78+
{
79+
return $this->belongsTo(ArDmKh::class, 'ma_kh', 'ma_kh');
80+
}
81+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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-05-14 09:12:28
12+
*/
13+
14+
namespace Diepxuan\Simba\StoredProcedures;
15+
16+
use Diepxuan\Simba\Helper\ParamHelper;
17+
use Diepxuan\Simba\SModel\SModel;
18+
use Illuminate\Support\Collection;
19+
20+
/**
21+
* Class AsPODeletePO3.
22+
*
23+
* Stored procedure: asPODeletePO3
24+
* Mục đích: Xóa hóa đơn mua hàng (PO3).
25+
*/
26+
class AsPODeletePO3
27+
{
28+
public static function call(array $params): Collection
29+
{
30+
$paramObj = ParamHelper::fromArray($params);
31+
$connection = (new SModel())->getConnectionName();
32+
33+
return ProcedureCaller::call('asPODeletePO3', [
34+
'pMa_cty' => $paramObj->pMa_cty ?? SModel::CTY,
35+
'pStt_rec' => $paramObj->pStt_rec ?? null,
36+
'pRet' => ['type' => 'INT', 'output' => true],
37+
], $connection);
38+
}
39+
40+
public static function callWithParams(?string $maCty = null, ?string $sttRec = null): Collection
41+
{
42+
return self::call([
43+
'pMa_cty' => $maCty,
44+
'pStt_rec' => $sttRec,
45+
]);
46+
}
47+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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-05-14 09:12:29
12+
*/
13+
14+
namespace Diepxuan\Simba\StoredProcedures;
15+
16+
use Diepxuan\Simba\Helper\ParamHelper;
17+
use Diepxuan\Simba\SModel\SModel;
18+
use Illuminate\Support\Collection;
19+
20+
/**
21+
* Class AsPOGetChiPhi.
22+
*
23+
* Stored procedure: asPOGetChiPhi
24+
* Mục đích: Lấy danh mục chi phí cho PO3.
25+
*/
26+
class AsPOGetChiPhi
27+
{
28+
public static function call(array $params): Collection
29+
{
30+
$paramObj = ParamHelper::fromArray($params);
31+
$connection = (new SModel())->getConnectionName();
32+
33+
return ProcedureCaller::call('asPOGetChiPhi', [
34+
'pMa_cty' => $paramObj->pMa_cty ?? SModel::CTY,
35+
], $connection);
36+
}
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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-05-14 09:12:30
12+
*/
13+
14+
namespace Diepxuan\Simba\StoredProcedures;
15+
16+
use Diepxuan\Simba\Helper\ParamHelper;
17+
use Diepxuan\Simba\SModel\SModel;
18+
use Illuminate\Support\Collection;
19+
20+
/**
21+
* Class AsPOGetDmKho.
22+
*
23+
* Stored procedure: asPOGetDmKho
24+
* Mục đích: Lấy danh mục kho cho PO3.
25+
*/
26+
class AsPOGetDmKho
27+
{
28+
public static function call(array $params): Collection
29+
{
30+
$paramObj = ParamHelper::fromArray($params);
31+
$connection = (new SModel())->getConnectionName();
32+
33+
return ProcedureCaller::call('asPOGetDmKho', [
34+
'pMa_cty' => $paramObj->pMa_cty ?? SModel::CTY,
35+
], $connection);
36+
}
37+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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-05-14 09:12:30
12+
*/
13+
14+
namespace Diepxuan\Simba\StoredProcedures;
15+
16+
use Diepxuan\Simba\Helper\ParamHelper;
17+
use Diepxuan\Simba\SModel\SModel;
18+
use Illuminate\Support\Collection;
19+
20+
/**
21+
* Class AsPOGetDmVt.
22+
*
23+
* Stored procedure: asPOGetDmVt
24+
* Mục đích: Lấy danh mục vật tư cho PO3.
25+
*/
26+
class AsPOGetDmVt
27+
{
28+
public static function call(array $params): Collection
29+
{
30+
$paramObj = ParamHelper::fromArray($params);
31+
$connection = (new SModel())->getConnectionName();
32+
33+
return ProcedureCaller::call('asPOGetDmVt', [
34+
'pMa_cty' => $paramObj->pMa_cty ?? SModel::CTY,
35+
'pSearch' => $paramObj->pSearch ?? null,
36+
], $connection);
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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-05-14 09:12:31
12+
*/
13+
14+
namespace Diepxuan\Simba\StoredProcedures;
15+
16+
use Diepxuan\Simba\Helper\ParamHelper;
17+
use Diepxuan\Simba\SModel\SModel;
18+
use Illuminate\Support\Collection;
19+
20+
/**
21+
* Class AsPOGetHachToan.
22+
*
23+
* Stored procedure: asPOGetHachToan
24+
* Mục đích: Lấy hạch toán cho PO3.
25+
*/
26+
class AsPOGetHachToan
27+
{
28+
public static function call(array $params): Collection
29+
{
30+
$paramObj = ParamHelper::fromArray($params);
31+
$connection = (new SModel())->getConnectionName();
32+
33+
return ProcedureCaller::call('asPOGetHachToan', [
34+
'pMa_cty' => $paramObj->pMa_cty ?? SModel::CTY,
35+
'pStt_rec' => $paramObj->pStt_rec ?? null,
36+
], $connection);
37+
}
38+
}

0 commit comments

Comments
 (0)