
--工序委外退料单红字


IF NOT EXISTS (SELECT 1 FROM t_im_billfieldsetting WHERE FID = '990472606178114560')
insert into T_IM_BILLFIELDSETTING (FID, FBILL, FSTATUS, FENABLE, FCREATORID, FCREATETIME, FMODIFIERID, FMODIFYTIME, FNAME)
values ('990472606178114560', 'im_mdc_opmreturnorder', 'C', '1', '13466739', {ts'2020-09-28 14:08:13'}, '13466739', {ts'2020-09-28 14:13:32'}, ' ');


delete from t_im_fieldsettingentry WHERE FID = '990472606178114560'; 


IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256832') 
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256832', '1', '物料明细.数量', 'qty', 'billentry', 'billentry.qty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256833') 
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256833', '2', '物料明细.辅助数量', 'qtyunit2nd', 'billentry', 'billentry.qtyunit2nd', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256834')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256834', '3', '物料明细.基本数量', 'baseqty', 'billentry', 'billentry.baseqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256835')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256835', '4', '物料明细.金额', 'amount', 'billentry', 'billentry.amount', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256837')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256837', '6', '物料明细.累计退库基本数量', 'returnbaseqty', 'billentry', 'billentry.returnbaseqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256838')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256838', '7', '物料明细.剩余退库基本数量', 'remainreturnbaseqty', 'billentry', 'billentry.remainreturnbaseqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256839')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256839', '8', '物料明细.累计退库数量', 'returnqty', 'billentry', 'billentry.returnqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256840')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256840', '9', '物料明细.剩余退库数量', 'remainreturnqty', 'billentry', 'billentry.remainreturnqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256841')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256841', '10', '物料明细.VMI已结算数量', 'vmisettleqty', 'billentry', 'billentry.vmisettleqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256842')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256842', '11', '物料明细.VMI剩余结算数量', 'vmiremainsettleqty', 'billentry', 'billentry.vmiremainsettleqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256843')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256843', '12', '物料明细.已转固数量', 'purchasedqty', 'billentry', 'billentry.purchasedqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256844')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256844', '13', '物料明细.未转固数量', 'remainpurqty', 'billentry', 'billentry.remainpurqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256845')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256845', '14', '物料明细.已转固金额', 'purchasedamount', 'billentry', 'billentry.purchasedamount', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256846')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256846', '15', '物料明细.未转固金额', 'remainpuramount', 'billentry', 'billentry.remainpuramount', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990472606203256847')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990472606203256847', '16', '物料明细.可发数量', 'cansendqty', 'billentry', 'billentry.cansendqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990473229661380608')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990473229661380608', '17', '物料明细.VMI剩余结算数量(基本单位)', 'vmiremainsettlebaseqty', 'billentry', 'billentry.vmiremainsettlebaseqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '990473229661380609')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990472606178114560', '990473229661380609', '18', '物料明细.VMI已结算数量(基本单位)', 'vmisettlebaseqty', 'billentry', 'billentry.vmisettlebaseqty', '1');


--委外退料单红字


IF NOT EXISTS (SELECT 1 FROM T_IM_BILLFIELDSETTING WHERE FID = '990474800621166592')
insert into T_IM_BILLFIELDSETTING (FID, FBILL, FSTATUS, FENABLE, FCREATORID, FCREATETIME, FMODIFIERID, FMODIFYTIME, FNAME)
values ('990474800621166592', 'im_mdc_omreturnorder', 'C', '1', '13466739', {ts'2020-09-28 14:13:46'}, '13466739', {ts'2020-09-28 14:16:37'}, ' ');

delete from T_IM_FIELDSETTINGENTRY  where fid ='990474800621166592';


IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578752') 
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578752', '1', '物料明细.数量', 'qty', 'billentry', 'billentry.qty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578753')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578753', '2', '物料明细.辅助数量', 'qtyunit2nd', 'billentry', 'billentry.qtyunit2nd', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578754')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578754', '3', '物料明细.基本数量', 'baseqty', 'billentry', 'billentry.baseqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578755')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578755', '4', '物料明细.金额', 'amount', 'billentry', 'billentry.amount', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578757')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578757', '5', '物料明细.累计退库基本数量', 'returnbaseqty', 'billentry', 'billentry.returnbaseqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578758')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578758', '6', '物料明细.剩余退库基本数量', 'remainreturnbaseqty', 'billentry', 'billentry.remainreturnbaseqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578759')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578759', '7', '物料明细.累计退库数量', 'returnqty', 'billentry', 'billentry.returnqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578760')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578760', '8', '物料明细.剩余退库数量', 'remainreturnqty', 'billentry', 'billentry.remainreturnqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578761')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578761', '9', '物料明细.VMI已结算数量', 'vmisettleqty', 'billentry', 'billentry.vmisettleqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578762')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578762', '10', '物料明细.VMI剩余结算数量(基本单位)', 'vmiremainsettlebaseqty', 'billentry', 'billentry.vmiremainsettlebaseqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578763')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578763', '11', '物料明细.VMI剩余结算数量', 'vmiremainsettleqty', 'billentry', 'billentry.vmiremainsettleqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578764')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578764', '12', '物料明细.VMI已结算数量(基本单位)', 'vmisettlebaseqty', 'billentry', 'billentry.vmisettlebaseqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578765')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578765', '13', '物料明细.已转固数量', 'purchasedqty', 'billentry', 'billentry.purchasedqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578766')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578766', '14', '物料明细.未转固数量', 'remainpurqty', 'billentry', 'billentry.remainpurqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578767')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578767', '15', '物料明细.已转固金额', 'purchasedamount', 'billentry', 'billentry.purchasedamount', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578768')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578768', '16', '物料明细.未转固金额', 'remainpuramount', 'billentry', 'billentry.remainpuramount', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '990474800629578769')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '990474800629578769', '17', '物料明细.可发数量', 'cansendqty', 'billentry', 'billentry.cansendqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '1031791464688076800')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '1031791464688076800', '18', '物料明细.委外已核销数量', 'outverifyqty', 'billentry', 'billentry.outverifyqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '1031791464688076801')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '1031791464688076801', '19', '物料明细.委外已核销基本数量', 'outverifybaseqty', 'billentry', 'billentry.outverifybaseqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '1031791464688076802')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '1031791464688076802', '20', '物料明细.委外未核销数量', 'outunverifyqty', 'billentry', 'billentry.outunverifyqty', '1');

IF NOT EXISTS (SELECT 1 FROM T_IM_FIELDSETTINGENTRY WHERE FENTRYID = '1031791464688076803')
insert into T_IM_FIELDSETTINGENTRY (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('990474800621166592', '1031791464688076803', '21', '物料明细.委外未核销基本数量', 'outunverifybaseqty', 'billentry', 'billentry.outunverifybaseqty', '1');



