|
|
@@ -336,8 +336,33 @@
|
|
|
t.piece,
|
|
|
sys.f_remove_zero(t.item_qty - t.outing_qty - t.out_qty) as "canOutingQty",
|
|
|
sys.f_remove_zero(t.item_qty - t.outing_qty - t.out_qty) as outing_qty,
|
|
|
- (t.item_qty - t.outing_qty - t.out_qty)/t.pack_box as "outingBox",
|
|
|
- (t.item_qty - t.outing_qty - t.out_qty)%t.pack_box as "outingPiece",
|
|
|
+-- (t.item_qty - t.outing_qty - t.out_qty)/t.pack_box as "outingBox",
|
|
|
+-- (t.item_qty - t.outing_qty - t.out_qty)%t.pack_box as "outingPiece",
|
|
|
+
|
|
|
+ case
|
|
|
+ when t.sub_unit_id ISNULL
|
|
|
+ then 0
|
|
|
+ else
|
|
|
+ floor((T.item_qty - T.outing_qty - T.out_qty) / T.pack_box)
|
|
|
+ end AS "outingBox",
|
|
|
+
|
|
|
+ case
|
|
|
+ when t.sub_unit_id ISNULL
|
|
|
+ then floor(T.item_qty - T.outing_qty - T.out_qty)
|
|
|
+ else
|
|
|
+ floor((T.item_qty - T.outing_qty - T.out_qty) % T.pack_box)
|
|
|
+ end AS "outingPiece",
|
|
|
+
|
|
|
+ case
|
|
|
+ when t.sub_unit_id ISNULL
|
|
|
+ then dkic_b.f_box_piece(u2.unit_name, ul.unit_name, 0,
|
|
|
+ floor(T.item_qty - T.outing_qty - T.out_qty)::INT)
|
|
|
+ else
|
|
|
+ dkic_b.f_box_piece(u2.unit_name, ul.unit_name,
|
|
|
+ floor((T.item_qty - T.outing_qty - T.out_qty) / T.pack_box)::INT,
|
|
|
+ floor((T.item_qty - T.outing_qty - T.out_qty) % T.pack_box)::INT)
|
|
|
+ end AS "thisOutBoxPiece",
|
|
|
+
|
|
|
t.price_sale as "priceOut",
|
|
|
t.price_sale * (t.item_qty - t.outing_qty - t.out_qty) as outing_amt,
|
|
|
t.non_std_code,
|
|
|
@@ -349,13 +374,18 @@
|
|
|
tpi.inv_id as "invId",
|
|
|
sys.f_remove_zero(tpi.inv_qty) as "invQty",
|
|
|
sys.f_remove_zero(tpi.usable_qty) as "usableQty"
|
|
|
- ,(select ul.decimal_places from dkic_b.t_mst_unit ul where dkic_b.t_psi_order_item.unit_id = ul.unit_id) as "decimalPlaces"
|
|
|
+ ,(select ul.decimal_places from dkic_b.t_mst_unit ul where t.unit_id = ul.unit_id) as "decimalPlaces"
|
|
|
+ ,ul.unit_name as "unitName"
|
|
|
+ ,u2.unit_name as "subUnitName"
|
|
|
+ ,dkic_b.f_box_piece(u2.unit_name,ul.unit_name,t.box,t.piece) as "boxPiece"
|
|
|
FROM dkic_b.t_psi_order_item as t
|
|
|
inner join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
|
|
|
left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = t.wh_id
|
|
|
left join dkic_b.t_psi_inventory as tpi
|
|
|
on tpi.sku_id = t.sku_id and tpi.non_std_code = t.non_std_code
|
|
|
and tpi.wh_id = t.wh_id and tpi.cp_id = t.cp_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_unit AS ul ON t.unit_id = ul.unit_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_unit AS u2 ON t.sub_unit_id = u2.unit_id
|
|
|
where t.flg_valid
|
|
|
and t.item_qty > t.outing_qty
|
|
|
and t.order_id = #{orderId}::uuid
|