CREATE TABLE  SRETURN_AMD
(
TRAN_ID           CHAR(10) PRIMARY KEY not null,
TRAN_DATE         DATE not null,
REF_ID            CHAR(10)  not null,
REF_DATE 	  DATE not null,
SITE_CODE 	   CHAR(5) NOT NULL,
CUST_CODE	  CHAR(10) NOT NULL,
LR_NO__O          CHAR(15) ,             
LR_DATE__O        DATE ,                                                                                                                                                                                         
LR_NO              CHAR(15),
LR_DATE            DATE ,
TRANS_MODE__O     CHAR(1),                                                                                                                                                                                       
TRANS_MODE         CHAR(1) ,                                                                                                                                                                                      
LORRY_NO__O        VARCHAR2(20),                                                                                                                                                                                  
LORRY_NO           VARCHAR2(20) ,                                                                                                                                                                                 
FRT_TYPE            CHAR(1) ,                                                                                                                                                                                      
FRT_AMT            NUMBER(14,3),    
FRT_TYPE__O        CHAR(1),                                                                                                                                                                                       
FRT_AMT__O         NUMBER(14,3),                                                                                          
CHG_DATE            DATE not null,
CHG_USER            CHAR(10) not null,
CHG_TERM	 CHAR(15) not null,
CONFIRMED            CHAR(1),                                                                                                                                                                                       
CONF_DATE           DATE,   
CONSTRAINT fk_REF_ID
	  FOREIGN KEY (REF_ID)
	  REFERENCES SRETURN(TRAN_ID)
);

INSERT INTO ITM2MENU 
(
	APPLICATION,
	LEVEL_1,
	LEVEL_2,
	LEVEL_3,
	LEVEL_4,
	LEVEL_5,
	WIN_NAME,
	DESCR,
	COMMENTS,
	MENU_PATH,
	ICON_PATH,
	OBJ_TYPE,
	CHG_USER,
	CHG_TERM,
	CHG_DATE,
	OPEN_ICON,
	CLOSE_ICON
)
VALUES
(
	'DIS',
	8,8,35,0,0,
	'w_sreturn_amd',
	'Sales Return Amendment',
	null,
	'DIS.8.8.35.0.0',
	null,
	null,
	null,
	null,
	null,
	null,
	null
);



INSERT INTO TRANSETUP
(TRAN_WINDOW,SAVE_FLAG,VAL_FLAG,KEY_FLAG,KEY_STRING,REPEATE_ADD,CHG_DATE,CHG_USER,CHG_TERM,
 EDI_OPTION,SITE_ACC_COL,CONFIRM_COL,CONFIRM_VAL,LEDG_POST_CONF,CHG_DATE_ON_CONF,TRAN_ID_COL,
 CONFIRM_MODE,MAIL_OPTION,GARBAGE_OPT,REF_SER,VIEW_MODE) 
VALUES 
('w_sreturn_amd','2','2','A','site_code,tran_date,seq04','Y',sysdate,'BASE','BASE',
 '0','SITE_CODE','confirmed','Y','N','Y','TRAN_ID',
 '0','0','N','S-STK',null);	


INSERT INTO OBJ_FORMS
(
win_name,
title,
obj_brow_name,
obj_edit_name,	
form_no,
auto_accept_scan,
scan_metadata,
scan_flag,
scan_delimiter,
auto_accept_weighdata
)
values (
'w_sreturn_amd',
'header',
'd_sreturn_amd11',
'd_sreturn_amd21',
'1',
null,
null,
null,
null,
null
);	


INSERT INTO OBJ_ACTIONS 
(	
	OBJ_NAME ,
	LINE_NO ,
	RIGHTS_CHAR,
	INTERACTIVE,
	SERVICE_CODE,
	DESCRIPTION,
	TITLE,
	IMAGE,
	ACTION_TYPE,
	FORM_NO,
	SERVICE_HANDLER,
	PLACEMENT,
	TRAN_TYPE
) VALUES (
	'sreturn_amd',
	'1',
	'A',
	'a',
	'a',
	'Adding New',
	'Add',
	'add.gif',
	'S',
	'1',
	NULL,
	NULL,
	NULL
);
	
INSERT INTO OBJ_ACTIONS 
(
	OBJ_NAME ,
	LINE_NO,
	RIGHTS_CHAR,
	INTERACTIVE, 
	SERVICE_CODE, 
	DESCRIPTION, 
	TITLE, 
	IMAGE,
	ACTION_TYPE,		
	FORM_NO, 
	SERVICE_HANDLER,
	PLACEMENT,
	TRAN_TYPE
) VALUES (
	'sreturn_amd',
	'2',
	'E',
	'a',
	'a',
	'Editing Existing Record',
	'EDIT',
	'edit.gif',
	'S',
	'1',
	NULL,
	NULL,
	NULL
);

insert into obj_itemchange(
	OBJ_NAME,       
	FORM_NO,        
	FIELD_NAME
)
values
(
	'sreturn_amd',
	1,
	'site_code'
);  

insert into obj_itemchange(
	OBJ_NAME,       
	FORM_NO,        
	FIELD_NAME
)
values
(
	'sreturn_amd',
	1,
	'ref_id'
);

INSERT INTO SYSTEM_EVENTS
(
	OBJ_NAME,
	EVENT_CODE,
	EVENT_CONTEXT,
	SERVICE_CODE,
	METHOD_RULE,
	CHG_DATE,
	CHG_USER,
	CHG_TERM,
	RESULT_HANDLE,
	OVERWRITE_CORE,
	COMP_TYPE,
	COMP_NAME,
	COMM_FORMAT
) VALUES (
	'sreturn_amd',
	'pre_validate',
	'1',
	'prv_default_ejb',
	null,
	sysdate,
	'BASE',
	'BASE',
	'2',
	'0',
	'EJB',
	'SReturnAmd',
	NULL
);

INSERT INTO SYSTEM_EVENTS
(	
	OBJ_NAME,
	EVENT_CODE,
	EVENT_CONTEXT,
	SERVICE_CODE,
	METHOD_RULE,
	CHG_DATE,
	CHG_USER,
	CHG_TERM,
	RESULT_HANDLE,
	OVERWRITE_CORE,
	COMP_TYPE,
	COMP_NAME,
	COMM_FORMAT
) VALUES (
	'sreturn_amd',
	'post_item_change',
	'1',
	'poic_default_ejb',
	null,
	sysdate,
	'BASE',
	'BASE',
	'2',
	'0',
	'EJB',
	'SReturnAmd',
	NULL
);




INSERT INTO SYSTEM_EVENTS (
	obj_name ,
	event_code ,
	event_context ,
	service_code ,
	method_rule ,
	chg_date ,
	chg_user ,
	chg_term ,
	result_handle ,
	overwrite_core ,
	comp_type ,
	comp_name ,
	comm_format )
  VALUES (
	'sreturn_amd',
	'pre_confirm',
	'1',
	'prv_confirm',
	NULL,
	sysdate,
	'Kunal',
	'base',
	'2',
	'0',
	'EJB',
	'SReturnAmdConf',
	NULL);


insert into obj_actions (
	obj_name ,
	line_no ,
	rights_char ,
	interactive ,
	service_code ,
	description ,
	title ,
	image ,
	action_type ,
	form_no ,
	service_handler ,
	placement,
	tran_type ,
	chg_date ,
	chg_term ,
	chg_user )
 VALUES (
	'sreturn_amd',
	3,
	'F',
	'a',
	'pre_confirm',
	'Confirm',
	'Confirm',
	'confirm.gif',
	'U',
	'1',
	'2',
	NULL,
	NULL,
	sysdate,
	'BASE',
	'KUNAL');



insert into messages(
MSG_NO,         
MSG_STR ,       
MSG_DESCR,      
MSG_TYPE,
MSG_OPT,
chg_date,
chg_user,
chg_term
)
values(
'VMSRETAMDC',
'SReturnAmd Confirmed',
'SReturn Amendment confirmed successfully',
'P',
'N',
sysdate,
'Kunal',
'base'
);

insert into  POPHELP
(
field_name,
mod_name,
sql_str,
msg_title,
chg_date,
chg_user,
chg_term,
dist_opt
)
values
(
'REF_ID',
'W_SRETURN_AMD',
'SELECT TRAN_ID,tran_date FROM sreturn where confirmed = ''Y'' and status <> ''X'' and ret_opt = ''R''',
'Ref Id',
sysdate,
'BASE',
'BASE',
'1'
);

insert into messages(
MSG_NO,         
MSG_STR ,       
MSG_DESCR,      
MSG_TYPE,
MSG_OPT,
chg_date,
chg_user,
chg_term
)
values(
'VMREFIDBK',
'Invalid Ref Tran Id',
'Ref Tran Id can not be blank',
'E',
'Y',
sysdate,
'base',
'base'
);


insert into messages(
MSG_NO,         
MSG_STR ,       
MSG_DESCR,      
MSG_TYPE,
MSG_OPT,
chg_date,
chg_user,
chg_term
)
values(
'VMREFIDCN',
'Invalid Ref Id',
'Invalid Ref Id not in master Or it Cancel Transaction ',
'E',
'Y',
sysdate,
'base',
'base'
);

insert into messages(
MSG_NO,         
MSG_STR ,       
MSG_DESCR,      
MSG_TYPE,
MSG_OPT,
chg_date,
chg_user,
chg_term
)
values(
'VMREFIDCON',
'Invalid Ref Id',
'Transaction should be confirmed',
'E',
'Y',
sysdate,
'base',
'base'
);

insert into messages(
MSG_NO,         
MSG_STR ,       
MSG_DESCR,      
MSG_TYPE,
MSG_OPT,
chg_date,
chg_user,
chg_term
)
values(
'VMREFIDREP',
'Invalid Ref Id',
'Return option should be Replacement',
'E',
'Y',
sysdate,
'base',
'base'
);