item_id
, order_id, item_index, sku_id, sub_unit_id, unit_id,pack_box,box, piece,
sys.f_remove_zero(item_qty) as item_qty, price_std, amt_std, price_sale, item_amt, price_discount, non_std_code, out_status,
sys.f_remove_zero(outing_qty) as outing_qty, outing_amt, sys.f_remove_zero(out_qty) as out_qty, out_amt,
sys.f_remove_zero(return_qty) as return_qty, return_amt, remarks, flg_valid, cp_id, wh_id,
fact_price,fact_amt,use_place,discount
t.item_id, t.order_id, t.item_index, t.sku_id, sys.f_remove_zero(t.item_qty) as item_qty, t.price_std, t.amt_std, t.price_sale, t.item_amt, t.price_discount, t.non_std_code,
t.out_status, sys.f_remove_zero(t.outing_qty) as outing_qty, t.outing_amt, sys.f_remove_zero(t.out_qty) as out_qty, t.out_amt,
sys.f_remove_zero(t.return_qty) as return_qty, t.return_amt, t.remarks, t.flg_valid, t.cp_id, t.wh_id
,t.box,t.piece,t.sub_unit_id,t.unit_id,t.pack_box,
t.fact_price,t.fact_amt,t.use_place,t.discount
AND t.order_id = #{orderId}::uuid
AND t.item_index = #{itemIndex}
AND t.sku_id = #{skuId}
AND t.item_qty = #{itemQty}
AND t.price_std = #{priceStd}
AND t.amt_std = #{amtStd}
AND t.price_sale = #{priceSale}
AND t.item_amt = #{itemAmt}
AND t.price_discount = #{priceDiscount}
AND t.non_std_code = #{nonStdCode}
AND t.out_status = #{outStatus}
AND t.outing_qty = #{outingQty}
AND t.outing_amt = #{outingAmt}
AND t.out_qty = #{outQty}
AND t.out_amt = #{outAmt}
AND t.return_qty = #{returnQty}
AND t.return_amt = #{returnAmt}
AND t.remarks = #{remarks}
AND t.flg_valid = #{flgValid}
AND t.cp_id = #{cpId}
WHERE item_id in
#{item}
insert into dkic_b.t_psi_order_item
(
order_id,
item_index,
sku_id,
item_qty,
price_std,
amt_std,
price_sale,
item_amt,
price_discount,
non_std_code,
out_status,
outing_qty,
outing_amt,
out_qty,
out_amt,
return_qty,
return_amt,
remarks,
cp_id,
wh_id,
)
values
(
#{item.orderId}::uuid,
#{item.itemIndex},
#{item.skuId}::uuid,
#{item.itemQty},
#{item.priceStd},
#{item.amtStd},
#{item.priceSale},
#{item.itemAmt},
#{item.priceDiscount},
#{item.nonStdCode},
#{item.outStatus},
#{item.outingQty},
#{item.outingAmt},
#{item.outQty},
#{item.outAmt},
#{item.returnQty},
#{item.returnAmt},
#{item.remarks},
#{item.cpId},
#{item.whId},
)
DELETE FROM dkic_b.t_psi_order_item
WHERE item_id = #{id}::UUID;
update dkic_b.t_psi_order_item
item_index = #{et.itemIndex,jdbcType=INTEGER},
sku_id = #{et.skuId,typeHandler=UuidTypeHandler},
item_qty = #{et.itemQty,jdbcType=NUMERIC},
price_std = #{et.priceStd,jdbcType=NUMERIC},
amt_std = #{et.amtStd,jdbcType=NUMERIC},
price_sale = #{et.priceSale,jdbcType=NUMERIC},
item_amt = #{et.itemAmt,jdbcType=NUMERIC},
price_discount = #{et.priceDiscount,jdbcType=NUMERIC},
non_std_code = #{et.nonStdCode,jdbcType=VARCHAR},
out_status = #{et.outStatus,jdbcType=VARCHAR},
outing_qty = outing_qty + #{et.outingQty,jdbcType=NUMERIC},
outing_amt = outing_amt + #{et.outingAmt,jdbcType=NUMERIC},
out_qty = out_qty + #{et.outQty,jdbcType=NUMERIC},
out_amt = out_amt + #{et.outAmt,jdbcType=NUMERIC},
return_qty = #{et.returnQty,jdbcType=NUMERIC},
return_amt = #{et.returnAmt,jdbcType=NUMERIC},
remarks = #{et.remarks,jdbcType=VARCHAR},
flg_valid = #{et.flgValid,jdbcType=BOOLEAN},
cp_id = #{et.cpId,jdbcType=INTEGER},
fact_price = #{et.factPrice,jdbcType=NUMERIC},
fact_amt = #{et.factAmt,jdbcType=NUMERIC},
use_place = #{et.usePlace,jdbcType=VARCHAR},
discount = #{et.discount,jdbcType=VARCHAR},
cost_price = #{et.costPrice,jdbcType=NUMERIC},
cost_amt = #{et.costAmt,jdbcType=NUMERIC},
where item_id = #{et.itemId,typeHandler=UuidTypeHandler}
and item_qty >=(
out_qty
+ #{et.outQty,jdbcType=NUMERIC}
+ outing_qty
+ #{et.outingQty,jdbcType=NUMERIC}
)
update dkic_b.t_psi_order_item
return_qty = return_qty + #{returnQty,jdbcType=NUMERIC},
return_amt = return_amt + #{returnAmt,jdbcType=NUMERIC},
where item_id = #{itemId,typeHandler=UuidTypeHandler}
and item_qty >= return_qty
AND tpo.order_no like concat('%', my_ex.likequery(#{orderNo}) , '%')
AND t.order_id = #{orderId}::uuid
AND t.item_index = #{itemIndex}
AND t.sku_id = #{skuId}
AND t.item_qty = #{itemQty}
AND t.price_std = #{priceStd}
AND t.amt_std = #{amtStd}
AND t.price_sale = #{priceSale}
AND t.item_amt = #{itemAmt}
AND t.price_discount = #{priceDiscount}
AND t.non_std_code = #{nonStdCode}
AND t.out_status = #{outStatus}
AND t.outing_qty = #{outingQty}
AND t.outing_amt = #{outingAmt}
AND t.out_qty = #{outQty}
AND t.out_amt = #{outAmt}
AND t.return_qty = #{returnQty}
AND t.return_amt = #{returnAmt}
AND t.remarks = #{remarks}
AND t.flg_valid = #{flgValid}
AND t.cp_id = #{cpId}
update dkic_b.t_psi_order_item
cost_price= #{costPrice},
cost_amt = #{costAmt},
where item_id = #{itemId}::uuid