仅脚本记录,参考谨慎操作
//应收应付往来重分类
let CTX_E_CODE = ctx.E.number;
let CTX_E_ISBASE = ctx.E.isBase();
if (CTX_E_ISBASE && ctx.BP.number == "ERAdj" && ctx.S.number== "MRpt"){
let tAllNoneReClassAuto=",CT@EndingBalance,AT@ReClassAuto";
let AccSc=scope(
CT.in("EndingBalance"),IC["ICTotal"].base(),BP.in("EIRpt"),
AT.in("EntityInput"),
A.in("R100602", //应收账款
"R110802" //应付账款
));
let Cs=getCellSet(AccSc);
let mapping = {};
Cs.forEach(function(dc){
AData=dc.value;
if(AData<0){
Acc=dc.Account;
RsIc=dc.InternalCompany;
JL.clear(ctx);
if (mapping[Acc] == undefined) {
mapping[Acc] = [];
}
let obj = {};
switch(Acc){
case "R100602" :
obj = {'ic': RsIc, 'acc': 'R1047', 'val': AData, 'txt': "应收账款负数重分类到预收账款"};
mapping[Acc].push(obj);
break;
case "R110802":
obj = {'ic': RsIc, 'acc': 'R1007', 'val': AData, 'txt': "应付账款负数重分类到预付账款"};
mapping[Acc].push(obj);
break;
}
}
});
for (let key in mapping) {
let JL = new Journal(ctx);
JL.open(key, mapping[key][0]['txt'], "ReClassAuto","root","");
mapping[key].forEach(function(item){
JL.insert(item['val'],"A@"+ key + "" + tAllNoneReClassAuto+ ",IC@"+item['ic']+"" ,-1, "明细表");
JL.insert(item['val'],"A@"+ item['acc'] + "" + tAllNoneReClassAuto+ ",IC@"+item['ic']+"" ,-1,"明细表");
JL.insert(item['val'],"A@"+ item['acc'] + "" + tAllNoneReClassAuto+",IC@ICNone",-1,"主表");
JL.insert(item['val'],"A@"+ key + "" + tAllNoneReClassAuto+",IC@ICNone",-1,"主表");
});
JL.submit();
}
}
推荐阅读