Professional Documents
Culture Documents
ssi_description
as
/******************************************************************************
NAME: SSI_DESCRIPTION
PURPOSE:
REVISIONS:
Ver Date Author Description
--------- ---------- --------------- ------------------------------------
1.0 4/10/2021 lamnl 1. Created this package body.
******************************************************************************/
v_des varchar2(1000);
v_outdes varchar2(1000);
v_outmsg varchar2(1000);
v_count number;
begin
select dt.name
into v_outmsg
from c_doctype dt, c_order co
where co.c_order_id = i_order_id
and dt.c_doctype_id = co.c_doctype_id ;
return v_outdes;
end ;
v_outmsg varchar2(1000);
v_count number;
begin
v_outmsg := '( ';
v_count := 0;
for cur_order in cur_orderline(c_order_id) loop
v_count := v_count +1;
if v_count > 1 then
v_outmsg := v_outmsg || ' - ';
end if;
v_outmsg := v_outmsg || cur_order.value ||'_'||
cur_order.qtyordered||'_'
||to_char(cur_order.linenetamt,'fm999g999g999g999g999');
end loop;
v_outmsg := v_outmsg ||' )';
return v_outmsg;
end ;
v_outdes varchar2(1000);
v_outmsg varchar2(1000);
v_msg varchar2(1000);
v_count number;
v_qty number;
curinout m_inout%rowtype;
begin
select *
into curinout
from m_inout
where m_inout_id = i_inout_id;
select to_char(movementdate,'DD/MM/YYYY')
into v_msg
from m_inout
where m_inout_id = i_inout_id;
select sb.name
into v_msg
from m_inout mi, s_subaccount sb
where mi.s_subaccount_id = sb.s_subaccount_id
and mi.m_inout_id = i_inout_id;
end if;
elsif curinout.c_doctype_id = c_doctype_sellfixes then
-- Ban sua loi
v_qty := 0;
v_msg := ' ';
select cd.name
into v_outmsg
from m_inout mi, c_doctype cd
where mi.c_doctype_id = cd.c_doctype_id;
select sb.name
into v_msg
from m_inout mi, s_subaccount sb
where mi.s_subaccount_id = sb.s_subaccount_id
and mi.m_inout_id = i_inout_id;
select sb.name
into v_msg
from m_inout mi, s_subaccount sb
where mi.s_subaccount_id = sb.s_subaccount_id
and mi.m_inout_id = i_inout_id;
select *
into cur_product
from m_product
where m_product_id = curinoutline.m_product_id;
select *
into curinout
from m_inout
where curinoutline.m_inout_id = m_inout_id;
select name
into v_trading_type
from ad_ref_list_trl
where ad_ref_list_id =(select ad_ref_list_id
from ad_ref_list
where ad_reference_id = c_reference_trading_type
and value = cur_product.self_trading_type);
else
select cd.name|| ' '|| mil.qtyentered|| ' '||lower(v_trading_type)
||' '|| mp.value
|| ' '|| sb.name|| ' '|| to_char
(mi.movementdate, 'DD/MM/YYYY')
into v_outdes
from m_inout mi,
m_inoutline mil,
c_doctype cd,
m_product mp,
s_subaccount sb
where mi.m_inout_id = mil.m_inout_id
and mi.c_doctype_id = cd.c_doctype_id
and mil.m_product_id = mp.m_product_id
and mil.m_inoutline_id = i_inoutline_id
and mil.s_subaccount_id = sb.s_subaccount_id;
end if;
return v_outdes;
end;
o_des := v_outdesh||v_outdes;
end if;
return o_des;
exception
when others then
o_des := '';
return o_des;
end;
-- dien giai dieu chinh gia, phan loai lai, danh gia lai header
if cur_inventory.c_doctype_id != c_doctype_cost_adjustment
then
select name
into v_asset_type
from ad_ref_list_trl, m_inventory mi
where ad_ref_list_id =
(select ad_ref_list_id
from ad_ref_list
where ad_reference_id = i_asset_type
and value = mi.asset_type
and mi.m_inventory_id = i_inventory_id);
end if;
if cur_inventory.c_doctype_id = c_doctype_cost_adjustment
then
o_des := ' ( ';
v_count := 0;
if v_count > 1
then
o_des := o_des || ' - ';
end if;
o_des :=
o_des
|| get_inventoryline.name
|| '_'
|| get_inventoryline.qty_change
|| '_'
|| get_inventoryline.newcostprice;
end loop;
return o_des;
end;
-- dien giai dieu chinh gia, danh gia lai, phan loai lai line
function get_inventory_line_description (i_inventoryline_id in number,
i_asset_type in number)
return varchar2
is
cursor cur_get_inventoryline (i_inventoryline_id in number)
is
select mil.qty_change,
mp.name as product,
cs.name as team,
ss.name as subaccount
from m_inventory mi,
m_inventoryline mil,
m_product mp,
s_subaccount ss,
c_salesregion cs
where mil.m_product_id = mp.m_product_id
and mi.c_salesregion_id = cs.c_salesregion_id
and mi.s_subaccount_id = ss.s_subaccount_id
and mi.m_inventory_id = mil.m_inventory_id
and mil.m_inventoryline_id = i_inventoryline_id;
cur_inventory m_inventory%rowtype;
cur_inventoryline m_inventoryline%rowtype;
o_des varchar (1000);
v_asset_type varchar (100);
v_doctype_id number;
begin
select mi.c_doctype_id
into v_doctype_id
from m_inventoryline mil, m_inventory mi
where mi.m_inventory_id = mil.m_inventory_id
and mil.m_inventoryline_id = i_inventoryline_id;
if v_doctype_id != c_doctype_cost_adjustment
then
select arlt.name
into v_asset_type
from ad_ref_list_trl arlt, m_inventory mi, m_inventoryline mil
where ad_ref_list_id =
(select ad_ref_list_id
from ad_ref_list
where ad_reference_id = i_asset_type
and mil.m_inventory_id = mi.m_inventory_id
and value = mi.asset_type
and mil.m_inventoryline_id = i_inventoryline_id);
end if;
if v_doctype_id = c_doctype_cost_adjustment
then
for get_inventoryline in cur_get_inventoryline (i_inventoryline_id)
loop
o_des :=
o_des
|| get_inventoryline.qty_change
|| ' - '
|| get_inventoryline.product
|| ' - '
|| get_inventoryline.team
|| ' - '
|| get_inventoryline.subaccount;
end loop;
return o_des;
elsif v_doctype_id = c_doctype_revaluation
then
select ss.name
|| ' - '
|| v_asset_type
|| ' - '
|| mp.name
|| ' - '
|| to_char (mi.movementdate, 'dd/mm/yyyy')
into o_des
from m_inventoryline mil,
m_inventory mi,
m_product mp,
s_subaccount ss
where mil.s_subaccount_id = ss.s_subaccount_id
and mil.m_product_id = mp.m_product_id
and mil.m_inventory_id = mi.m_inventory_id
and mil.m_inventoryline_id = i_inventoryline_id;
elsif v_doctype_id = c_doctype_reclassification
then
select mp.name || ' - ' || to_char (mi.movementdate, 'dd/mm/yyyy')
into o_des
from m_inventory mi, m_inventoryline mil, m_product mp
where mil.m_inventory_id = mi.m_inventory_id
and mil.m_product_id = mp.m_product_id
and mil.m_inventoryline_id = i_inventoryline_id;
end if;
return o_des;
end;
begin
select mp.value || ' - ' ||
(case
when pr.c_productright_type = f_productstock_type then
pr.stock_ratio ||' ngày '||
to_char(prl.datetrx, 'dd/mm/yyyy')
when pr.c_productright_type = f_productbuy_type then
pr.convert_ratio ||' ngày '||
to_char(prl.datetrx,'dd/mm/yyyy')
when pr.c_productright_type = f_productmoney_type then
to_char(cs.name) ||' ngày '||
to_char(prl.datetrx,'dd/mm/yyyy')
when pr.c_productright_type = f_productmerge_type
or pr.c_productright_type = f_productsplit_type then
pr.split_ratio ||' ngày '||
to_char(prl.datetrx, 'dd/mm/yyyy')
when pr.c_productright_type = f_productswap_type then
pr.swaps_ratio || ' ' ||
sa.name ||' ngày '||
to_char(prl.datetrx, 'dd/mm/yyyy')
when pr.c_productright_type = f_productbond_type then
pr.convert_ratio ||' ngày '||
to_char(prl.datetrx, 'dd/mm/yyyy')
end)
into o_des
from c_productrightheader pr,
c_productrightline prl,
m_product mp,
s_subaccount sa,
c_salesregion cs
where ((mp.m_product_id = pr.m_product_id and pr.c_productright_type !=
'03')
or ( pr.m_product1_id = mp.m_product_id and pr.c_productright_type =
'03'))
and prl.s_subaccount_id = sa.s_subaccount_id
and prl.c_salesregion_id = cs.c_salesregion_id
and pr.c_productrightheader_id = prl.c_productrightheader_id
and prl.c_productrightline_id = i_productrightline_id;
return o_des;
exception
when others then
o_des := null;
return o_des;
end;
select cd.name
into o_des
from c_invoice ci, c_doctype cd
where ci.c_doctype_id = cd.c_doctype_id
and ci.c_invoice_id = i_invoice_id;
else
select description
into v_desinout
from m_inout
where m_inout_id = cur_invoice.m_inout_id;
o_des:= o_des ||' '||v_desinout;
end if;
else
select lower(name) into o_type
from ad_ref_list_trl where ad_ref_list_id =
(select ad_ref_list_id from ad_ref_list
where ad_reference_id = c_reference_tradingtype
and value = cur_invoice.trading_type);
return o_des;
end;
select cd.name
into o_des
from c_invoice ci, c_doctype cd
where ci.c_doctype_id = cd.c_doctype_id
and ci.c_invoice_id = cur_invoice.c_invoice_id;
if cur_invoice.trading_type is not null then
if cur_invoiceline.m_inoutline_id > 0 then
select description
into v_desinout
from m_inoutline
where m_inoutline_id = cur_invoiceline.m_inoutline_id;
o_des:= o_des ||' '||v_desinout;
else
select lower(name) into o_type
from ad_ref_list_trl where ad_ref_list_id =
(select ad_ref_list_id from ad_ref_list
where ad_reference_id = c_reference_tradingtype
and value = cur_invoice.trading_type);
select cd.name
into o_des
from c_doctype cd
where cd.c_doctype_id = cur_movement.c_doctype_id;
return o_des;
end;
return o_des;
exception
when others then
o_des := '';
return o_des;
end;
return o_des;
exception
when others then
o_des := '';
return o_des;
end;
end if;
else
o_des := 'Phạt trễ hạn hợp đồng ' ||cur_order.documentno
||' ngày '||to_char(cur_order.dateordered,'dd/mm/yyyy');
end if;
return o_des;
exception
when others then
o_des := '';
return o_des;
end;
o_des_orderline := getdesorderlineqty(cur_contract_act.c_order_id);
-- C_Payment
function get_payment_des (i_payment_id in number)
return varchar2
as
o_des varchar2(1000);
begin
select 'Xóa nợ hợp đồng '||co.documentno||' ' || cb.name
into o_des
from c_order co, c_bpartner cb, c_payment cp
where cp.c_payment_id = i_payment_id
and cp.c_order_id = co.c_order_id
and cp.c_bpartner_id = cb.c_bpartner_id;
return o_des;
exception
when others then
o_des := '';
return o_des;
end;
-- C_Payment_DTL
function get_payment_dtl_des (i_payment_dtl_id in number)
return varchar2
as
o_des varchar2(1000);
begin
select 'Xóa nợ hợp đồng '||co.documentno||' hóa đơn '||ci.documentno|| ' '
|| cb.name
into o_des
from c_payment_dtl cpl, c_invoice ci, c_order co, c_bpartner cb, c_payment
cp
where cpl.c_payment_id = cp.c_payment_id
and cpl.c_invoice_id = ci.c_invoice_id
and co.c_order_id = ci.c_order_id
and cp.c_bpartner_id = cb.c_bpartner_id
and cpl.c_payment_dtl_id = i_payment_dtl_id;
return o_des;
exception
when others then
o_des := '';
return o_des;
end;
end ssi_description;
/