本文重点向大家讲解补充寄售业务中的关联字段和寄售退货业务的注意事项
标准的流程可参考帖子:
【文章:寄售业务流程】https://vip.kingdee.com/questions/135435217715955972/answers/135435295243471173
一、寄售直接调拨单上的关联字段
结算关联数量:
发出方向的寄售结算单自动匹配发货后保存反写(累加);
未结算关联数量:
寄售调拨类型的调拨单的调入保管类型是客户时,保存后未结算关联数量=调拨数量;
发出方向的寄售结算单保存反写(累减),下游销售退货单的退货类型是退货补货 且 退回仓库是客户仓时 在审核反写累加;
结算可退数量:
发出方向的寄售结算单生成的寄售销售出库单审核反写(累加),退回方向的寄售结算单匹配后保存反写(累减);
退货补货客户仓数量:
退回方向的寄售结算单生成的寄售销售退货 退货类型是退货补货且退回仓库是客户仓时审核反写(累加);
以上就是寄售调拨单主要的关联字段,常见出错的是结算关联数量以及未结算关联数量,文末附上通用修复脚本。
注意:
实施过程中若客户有使用寄售业务且物料是多单位,应密切关注物料单位精度设置的合理性,因为以上关联字段反写过程中会有反算(即常单位数量→基本单位数量→常单位数量),可能因精度原因在换算过程中出现误差。
二、寄售退货业务
标准流程:
1.未结算退回
流程:通过寄售调拨单→寄售调拨单(退货)
将商品从客户仓退回企业仓,若需再次结算,需重新下寄售订单;
2.已结算退回
流程:通过寄售调拨单→寄售结算单(退回)→销售退货
若退回后需再次在该客户仓结算,则退回仓库应是源调入的客户仓;若退回后需在其它客户仓结算或待结算,则退回企业仓,后续再重新下寄售订单。
注意:
场景:企业仓和客户仓都启用仓位
操作步骤:录入行退回仓库仓位→自动匹配发货→保存
退回方向的寄售结算单不录入行退回仓库及行退回仓位,匹配后默认是退回 源调出企业仓的源调出仓位;
退回方向的寄售结算单录入源调入客户仓 不录入仓位,匹配后是源调入客户仓和源调出企业仓仓位(后续补丁待修复);
退回方向的寄售结算单录入源调出企业仓 不录入仓位,匹配结果与1一致,退回 源调出企业仓的源调出仓位;
退回方向的寄售结算单录入源调入客户仓和录入非源调入仓位,匹配后是退回源调入客户仓的非源调入仓位!!!;
退回方向的寄售结算单录入源调出企业仓和录入非源调出仓位,若对应维度的调拨单有结算可退,则匹配成功到其它调拨单,否则匹配失败。
操作步骤:自动匹配发货→修改行退回仓库仓位→保存
清空行退回仓库仓位,保存后选单明细的行退回仓库仓位同步清空,下推的销售退货单需手工补录仓库仓位;
不修改行退回仓库,清空行退回仓位,保存后选单明细的行退回仓位同步清空,下推的销售退货单需手工补录仓位(7.5.1658.5之前存在异常,若仓库是客户仓,保存后会出现客户仓+企业仓位的异常)
若出现销售退货单的仓库仓位≠直接调拨单的源调出仓库仓位或源调入仓库仓位,则会出现再次结算时寄售结算单可以匹配到但无法出库提示负库存的问题,若有此问题出现,需手工做标准调拨单通过库存查询返回数据的方式调整仓库仓位。
寄售关联字段通用修复脚本,请先备份数据并在测试环境验证,谢谢!
select * into T_STK_STKTRANSFERINENTRY_T_1203 from T_STK_STKTRANSFERINENTRY_T--执行前请先备份!!!
merge into T_STK_STKTRANSFERINENTRY_T tt
using (
select h.FBILLNO,e.FENTRYID,e.FSEQ,e.FQTY,e.FBASEQTY,t.FJOINSETTLEQTY,t.FJOINBASESETTQTY,t.FJOINUNSETTLEQTY,
t.FJOINBASEUNSETTQTY,isnull(st.sumBASESETTLEQTYROW,0) as sumBASESETTLEQTYROW ,isnull(sumSalBASESETTLEQTYROW,0) as sumSalBASESETTLEQTYROW
,TSSTER.FBASEJOINQTY as FDBRetBaseQty,TSSTER.FRECEIVEQTY as FDBRetQty
from T_STK_STKTRANSFERIN h
inner join T_STK_STKTRANSFERINENTRY e on h.FID=e.FID
inner join T_STK_STKTRANSFERINENTRY_T t on t.FENTRYID=e.FENTRYID
INNER JOIN T_STK_STKTRANSFERINENTRY_R TSSTER ON TSSTER.FENTRYID=e.FENTRYID
left join (
select lk.fsid,SUM(isnull(FBASESETTLEQTYROW,0)) as sumBASESETTLEQTYROW ,sum(isnull(FSalBaseQtyRow,0)) as sumSalBASESETTLEQTYROW from T_SAL_CONSIGSETTENTRYROW_LK lk
inner join T_STK_STKTRANSFERINENTRY trans on trans.FENTRYID=lk.FSID and lk.FSBILLID=trans.FID
inner join (select fentryid from T_SAL_CONSIGSETTLE sett
inner join T_SAL_CONSIGSETTENTRYROW r on r.fid=sett.fid where sett.FCANCELSTATUS='A' and sett.FDOCUMENTSTATUS<>'Z'
) settR on settR.fEntryid=lk.FEntryId
where FRULEID='TransferDirect-ConsignmentSettle' group by lk.FSBILLID,lk.FSID ) st on e.FEntryId=st.FSID
where t.FJOINBASESETTQTY<>isnull(st.sumBASESETTLEQTYROW,0)--关联结算数量(基本)<>合计关联的结算单的数量(基本) 条件
)ut on (ut.FENTRYID=tt.FENTRYID)
when matched then update set
tt.FJOINSETTLEQTY=ut.sumBASESETTLEQTYROW*ut.FQty/ut.FBaseQty,--关联结算数量=合计关联的结算数量
tt.FJOINBASESETTQTY=ut.sumBASESETTLEQTYROW,--关联结算数量(基本)=合计关联的结算数量(基本)
tt.FJoinSaleBaseSettQty=ut.sumSalBASESETTLEQTYROW;--关联结算数量(销售基本)
merge into T_STK_STKTRANSFERINENTRY_T tt
using (
select e.FENTRYID,e.FSEQ,e.FQTY,e.FBASEQTY,t.FJOINSETTLEQTY,t.FJOINBASESETTQTY,t.FJOINUNSETTLEQTY,
t.FJOINBASEUNSETTQTY,isnull(sumAUXUNITQTY,0) as sumAUXUNITQTY
,TSSTER.FBASEJOINQTY as FDBRetBaseQty,TSSTER.FRECEIVEQTY as FDBRetQty
from T_STK_STKTRANSFERIN h
inner join T_STK_STKTRANSFERINENTRY e on h.FID=e.FID
inner join T_STK_STKTRANSFERINENTRY_T t on t.FENTRYID=e.FENTRYID
INNER JOIN T_STK_STKTRANSFERINENTRY_R TSSTER ON TSSTER.FENTRYID=e.FENTRYID
left join (
select lk.FSBILLID,lk.FSID,SUM(isnull(RW.FAUXUNITQTY,0)) as sumAUXUNITQTY from T_SAL_CONSIGSETTENTRYROW_LK lk
inner join T_SAL_CONSIGSETTENTRYROW RW on rw.fentryid=lk.fentryid
inner join T_STK_STKTRANSFERINENTRY trans on trans.FENTRYID=lk.FSID and lk.FSBILLID=trans.FID
inner join (select fentryid from T_SAL_CONSIGSETTLE sett
inner join T_SAL_CONSIGSETTENTRYROW r on r.fid=sett.fid where sett.FCANCELSTATUS='A' and sett.FDOCUMENTSTATUS<>'Z'
) settR on settR.fEntryid=lk.FEntryId
where FRULEID='TransferDirect-ConsignmentSettle' group by lk.FSBILLID,lk.FSID ) st on e.FEntryId=st.FSID
where t.FJOINSECSETTQTY<>isnull(st.sumAUXUNITQTY,0) --关联结算数量(辅助单位)
)ut on (ut.FENTRYID=tt.FENTRYID)
when matched then update set
tt.FJOINSECSETTQTY=ut.sumAUXUNITQTY;
merge into T_STK_STKTRANSFERINENTRY_T tt
using (
select h.FBILLNO,e.FENTRYID,e.FSEQ,e.FQTY,e.FBASEQTY,t.FJOINSETTLEQTY,t.FJOINBASESETTQTY,t.FJOINUNSETTLEQTY,
t.FJOINBASEUNSETTQTY,isnull(st.sumBASESETTLEQTYROW,0) as sumBASESETTLEQTYROW ,isnull(sumSalBASESETTLEQTYROW,0) as sumSalBASESETTLEQTYROW
,TSSTER.FBASEJOINQTY as FDBRetBaseQty,TSSTER.FRECEIVEQTY as FDBRetQty,FREBACKBASEQTY
from T_STK_STKTRANSFERIN h
inner join T_STK_STKTRANSFERINENTRY e on h.FID=e.FID
inner join T_STK_STKTRANSFERINENTRY_T t on t.FENTRYID=e.FENTRYID
inner join T_STK_STKTRANSFERINENTRY_E t1 on t1.FENTRYID=e.FENTRYID
INNER JOIN T_STK_STKTRANSFERINENTRY_R TSSTER ON TSSTER.FENTRYID=e.FENTRYID
left join (
select lk.fsid,SUM(isnull(FBASESETTLEQTYROW,0)) as sumBASESETTLEQTYROW ,sum(isnull(FSalBaseQtyRow,0)) as sumSalBASESETTLEQTYROW from T_SAL_CONSIGSETTENTRYROW_LK lk
inner join T_STK_STKTRANSFERINENTRY trans on trans.FENTRYID=lk.FSID and lk.FSBILLID=trans.FID
inner join (select r.fentryid from T_SAL_CONSIGSETTLE sett
inner join T_SAL_CONSIGSETTENTRYROW r on r.fid=sett.fid
where sett.FCANCELSTATUS='A' and sett.FDOCUMENTSTATUS<>'Z'
) settR on settR.fEntryid=lk.FEntryId
where FRULEID='TransferDirect-ConsignmentSettle' group by lk.FSBILLID,lk.FSID ) st on e.FEntryId=st.FSID
where e.FKEEPERTYPEID='BD_CUSTOMER' and e.FKEEPERTYPEOUTID='BD_KeeperOrg' and --寄售调拨结算是保管者:组织->客户
t.FJOINBASEUNSETTQTY<>e.FBASEQTY-TSSTER.FBASEJOINQTY-isnull(st.sumBASESETTLEQTYROW,0)+FREBACKBASEQTY --未关联结算数量(基本)<>调拨数量(基本)-调拨退货数量(基本)-合计关联结算数量(基本)+退货补货客户仓基本
)ut on (ut.FENTRYID=tt.FENTRYID)
when matched then update set
tt.FJOINUNSETTLEQTY=ut.FQTY-FDBRetQty-(ut.sumBASESETTLEQTYROW*ut.FQty/ut.FBaseQty)+(FREBACKBASEQTY*ut.FQty/ut.FBaseQty),--未关联结算数量=调拨数量-调拨退货数量-合计关联结算数量+退货补货客户仓数量
tt.FJOINBASEUNSETTQTY=ut.FBASEQTY-FDBRetBaseQty-ut.sumBASESETTLEQTYROW+FREBACKBASEQTY; --未关联结算数量(基本)=调拨数量(基本)-调拨退货数量(基本)-合计关联结算数量(基本)+退货补货客户仓基本
推荐阅读