1313
1414namespace Diepxuan \Simba \StoredProcedures ;
1515
16+ use Diepxuan \Simba \Helper \ParamHelper ;
1617use Diepxuan \Simba \SModel \SModel ;
1718use Illuminate \Support \Collection ;
18- use Diepxuan \Simba \Helper \ParamHelper ;
19+
20+ /**
21+ * Stored procedure asSOGetCT3.
22+ *
23+ * SP gốc từ SimbaSql:
24+ * - asSOGetCT3 (@pMa_cty, @pStt_rec, @pStruct)
25+ * - Lấy danh sách chi tiết hóa đơn bán hàng (SOCT3).
26+ */
1927
2028class AsSOGetCT3
2129{
@@ -31,28 +39,91 @@ public static function call(array $params): Collection
3139 $ connection = (new SModel ())->getConnectionName ();
3240
3341 return ProcedureCaller::call ('asSOGetCT3 ' , [
34- 'pMa_cty ' => $ paramObj ->pMa_cty ?? null ,
42+ 'pMa_cty ' => $ paramObj ->pMa_cty ?? SModel:: CTY ,
3543 'pStt_rec ' => $ paramObj ->pStt_rec ?? null ,
36- 'pStruct ' => $ paramObj ->pStruct ?? null
44+ 'pStruct ' => $ paramObj ->pStruct ?? ' 0 ' ,
3745 ], $ connection );
3846 }
3947
4048 /**
41- * Call stored procedure asSOGetCT3 with named parameters
49+ * Chuẩn hóa 1 row chi tiết SO3 về payload Portal.
4250 *
43- * @param string $Ma_cty
44- * @param string $Stt_rec
45- * @param string $Struct
46- * @return Collection
51+ * @return array<string, mixed>
4752 */
48- public static function callWithParams ( string $ Ma_cty = null , string $ Stt_rec = null , string $ Struct = null ): Collection
53+ public static function normalizeDetail ( mixed $ row ): array
4954 {
50- $ params = [
51- 'pMa_cty ' => $ Ma_cty ,
52- 'pStt_rec ' => $ Stt_rec ,
53- 'pStruct ' => $ Struct
55+ $ row = \is_array ($ row ) ? $ row : (array ) $ row ;
56+
57+ return [
58+ 'ma_cty ' => (string ) ($ row ['ma_cty ' ] ?? '' ),
59+ 'stt_rec ' => (string ) ($ row ['stt_rec ' ] ?? '' ),
60+ 'stt_rec0 ' => (string ) ($ row ['stt_rec0 ' ] ?? '' ),
61+ 'stt_rec_dh ' => (string ) ($ row ['stt_rec_dh ' ] ?? '' ),
62+ 'stt_rec0_dh ' => (string ) ($ row ['stt_rec0_dh ' ] ?? '' ),
63+ 'stt_rec_px ' => (string ) ($ row ['stt_rec_px ' ] ?? '' ),
64+ 'stt_rec0_px ' => (string ) ($ row ['stt_rec0_px ' ] ?? '' ),
65+ 'so_dh ' => (string ) ($ row ['so_dh ' ] ?? '' ),
66+ 'so_px ' => (string ) ($ row ['so_px ' ] ?? '' ),
67+ 'ma_vt ' => (string ) ($ row ['ma_vt ' ] ?? '' ),
68+ 'ten_vt ' => (string ) ($ row ['ten_vt ' ] ?? '' ),
69+ 'dvt ' => (string ) ($ row ['dvt ' ] ?? '' ),
70+ 'ton_kho ' => (float ) ($ row ['ton_kho ' ] ?? 0 ),
71+ 'ma_kho ' => (string ) ($ row ['ma_kho ' ] ?? '' ),
72+ 'ten_kho ' => (string ) ($ row ['ten_kho ' ] ?? '' ),
73+ 'so_luong ' => (float ) ($ row ['so_luong ' ] ?? 0 ),
74+ 'so_luong_qd ' => (float ) ($ row ['so_luong_qd ' ] ?? 0 ),
75+ 'gia_nt2 ' => (float ) ($ row ['gia_nt2 ' ] ?? 0 ),
76+ 'gia2 ' => (float ) ($ row ['gia2 ' ] ?? 0 ),
77+ 'tien_nt2 ' => (float ) ($ row ['tien_nt2 ' ] ?? 0 ),
78+ 'tien2 ' => (float ) ($ row ['tien2 ' ] ?? 0 ),
79+ 'tl_ck ' => (float ) ($ row ['tl_ck ' ] ?? 0 ),
80+ 'tien_ck_nt ' => (float ) ($ row ['tien_ck_nt ' ] ?? 0 ),
81+ 'tien_ck ' => (float ) ($ row ['tien_ck ' ] ?? 0 ),
82+ 'ck_ds_nt ' => (float ) ($ row ['ck_ds_nt ' ] ?? 0 ),
83+ 'ck_ds ' => (float ) ($ row ['ck_ds ' ] ?? 0 ),
84+ 'ma_thue ' => (string ) ($ row ['ma_thue ' ] ?? '' ),
85+ 'ts_gtgt ' => (float ) ($ row ['ts_gtgt ' ] ?? 0 ),
86+ 'thue_gtgt_nt ' => (float ) ($ row ['thue_gtgt_nt ' ] ?? 0 ),
87+ 'thue_gtgt ' => (float ) ($ row ['thue_gtgt ' ] ?? 0 ),
88+ 'tt_nt ' => (float ) ($ row ['tt_nt ' ] ?? 0 ),
89+ 'tt ' => (float ) ($ row ['tt ' ] ?? 0 ),
90+ 'tk_pt ' => (string ) ($ row ['tk_pt ' ] ?? '' ),
91+ 'tk_thue ' => (string ) ($ row ['tk_thue ' ] ?? '' ),
92+ 'tk_dt ' => (string ) ($ row ['tk_dt ' ] ?? '' ),
93+ 'ten_tk_dt ' => (string ) ($ row ['ten_tk_dt ' ] ?? '' ),
94+ 'tk_gv ' => (string ) ($ row ['tk_gv ' ] ?? '' ),
95+ 'ten_tk_gv ' => (string ) ($ row ['ten_tk_gv ' ] ?? '' ),
96+ 'tk_vt ' => (string ) ($ row ['tk_vt ' ] ?? '' ),
97+ 'ten_tk_vt ' => (string ) ($ row ['ten_tk_vt ' ] ?? '' ),
98+ 'tk_ck ' => (string ) ($ row ['tk_ck ' ] ?? '' ),
99+ 'ten_tk_ck ' => (string ) ($ row ['ten_tk_ck ' ] ?? '' ),
100+ 'tk_tl ' => (string ) ($ row ['tk_tl ' ] ?? '' ),
101+ 'tk_km ' => (string ) ($ row ['tk_km ' ] ?? '' ),
102+ 'gia_nt ' => (float ) ($ row ['gia_nt ' ] ?? 0 ),
103+ 'gia ' => (float ) ($ row ['gia ' ] ?? 0 ),
104+ 'tien_nt ' => (float ) ($ row ['tien_nt ' ] ?? 0 ),
105+ 'tien ' => (float ) ($ row ['tien ' ] ?? 0 ),
106+ 'khuyen_mai ' => (bool ) ($ row ['khuyen_mai ' ] ?? false ),
107+ 'tra_ck ' => (bool ) ($ row ['tra_ck ' ] ?? false ),
108+ 'sl_xuat ' => (float ) ($ row ['sl_xuat ' ] ?? 0 ),
109+ 'sl_xuat_qd ' => (float ) ($ row ['sl_xuat_qd ' ] ?? 0 ),
110+ 'ma_nvkd ' => (string ) ($ row ['ma_nvkd ' ] ?? '' ),
111+ 'ten_nvkd ' => (string ) ($ row ['ten_nvkd ' ] ?? '' ),
112+ 'ma_vitri ' => (string ) ($ row ['ma_vitri ' ] ?? '' ),
113+ 'ma_lo ' => (string ) ($ row ['ma_lo ' ] ?? '' ),
114+ 'ma_bp ' => (string ) ($ row ['ma_bp ' ] ?? '' ),
115+ 'ma_hd ' => (string ) ($ row ['ma_hd ' ] ?? '' ),
116+ 'ma_phi ' => (string ) ($ row ['ma_phi ' ] ?? '' ),
117+ 'ma_spct ' => (string ) ($ row ['ma_spct ' ] ?? '' ),
54118 ];
119+ }
55120
56- return self ::call ($ params );
121+ public static function callWithParams (?string $ maCty = null , ?string $ sttRec = null , ?string $ struct = null ): Collection
122+ {
123+ return self ::call ([
124+ 'pMa_cty ' => $ maCty ,
125+ 'pStt_rec ' => $ sttRec ,
126+ 'pStruct ' => $ struct ,
127+ ]);
57128 }
58129}
0 commit comments