-- 完工退库单负数显红清单
IF NOT EXISTS (SELECT 1 FROM t_im_billfieldsetting WHERE FID = '924374601041975296') 
insert into t_im_billfieldsetting (FID, FBILL, FSTATUS, FENABLE, FCREATORID, FCREATETIME, FMODIFIERID, FMODIFYTIME, FNAME)
values ('924374601041975296', 'im_mdc_mftreturnbill', 'C', '1', '1', {ts'2020-06-26 18:17:00'}, '1', {ts'2020-06-26 18:17:00'}, ' ');

delete from t_im_fieldsettingentry WHERE FID = '924374601041975296'; 

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

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

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

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

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

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

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

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '924374601100809223') 
insert into t_im_fieldsettingentry (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('924374601041975296', '924374601100809223', '8', '物料明细.应收数量', 'receivalqty', 'billentry', 'billentry.receivalqty', '1');

IF NOT EXISTS (SELECT 1 FROM t_im_fieldsettingentry WHERE FENTRYID = '924374601100809224') 
insert into t_im_fieldsettingentry (FID, FENTRYID, FSEQ, FFIELDNAME, FFIELD, FENTRYENTITYID, FFULLFIELD, FISINVERSE)
values ('924374601041975296', '924374601100809224', '9', '物料明细.已收数量', 'receivedqty', 'billentry', 'billentry.receivedqty', '1');


--生产退料单红字
IF NOT EXISTS (SELECT 1 FROM t_im_billfieldsetting WHERE FID = '922447734126985216') 
insert into t_im_billfieldsetting (FID, FBILL, FSTATUS, FENABLE, FCREATORID, FCREATETIME, FMODIFIERID, FMODIFYTIME, FNAME)
values ('922447734126985216', 'im_mdc_mftreturnorder', 'C', '1', '1', {ts'2020-06-26 18:17:00'},'1', {ts'2020-06-25 18:50:00'}, ' ');

delete from t_im_fieldsettingentry WHERE FID = '922447734126985216'; 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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