ソースを参照

订单核销去除退货金额

hu 3 年 前
コミット
40f64fc730

+ 1 - 1
src/rest/openapi/restcontroller/wechatapp/orderform/SQL/订单审核明细.sql

@@ -1,6 +1,6 @@
 declare @siteid varchar(20)
 set @siteid = $siteid$
-select t1.fsonum,t2.frownum,t5.fagentshortname fpayagentnum,t7.fagentshortname frecagentnum,pp_hr.displayname,t2.fitemname,t2.fspec,t2.fmodel,tunit.fname,t2.fqty,t2.fprice,t2.frateamount,(t2.frateamount-isnull(t2.fwriteoffamount,0)) fwriteoffamount,CONVERT(VARCHAR(10),t1.checkdate,120) checkdate,t6.fdate,t3.fmaterial,t3.fdevice,t3.fspecalnote,t3.fitemno,t3.fnotes,TPROJECT.fprojectname,t4.kaipiaodate,(t2.frateamount-isnull(t2.finvoiceamount,0)) finvoiceamount from saorder t1
+select t1.fsonum,t2.frownum,t5.fagentshortname fpayagentnum,t7.fagentshortname frecagentnum,pp_hr.displayname,t2.fitemname,t2.fspec,t2.fmodel,tunit.fname,t2.fqty,t2.fprice,t2.frateamount,(t2.frateamount-t2.frateprice*isnull(t2.freturnqty,0)-isnull(t2.fwriteoffamount,0)) fwriteoffamount,CONVERT(VARCHAR(10),t1.checkdate,120) checkdate,t6.fdate,t3.fmaterial,t3.fdevice,t3.fspecalnote,t3.fitemno,t3.fnotes,TPROJECT.fprojectname,t4.kaipiaodate,(t2.frateamount-isnull(t2.finvoiceamount,0)) finvoiceamount from saorder t1
 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid 
 inner join pp_hr on pp_hr.hrid=t1.fsaler and pp_hr.siteid=@siteid
 inner join tunit on tunit.FUNITID=t2.FUNITID

+ 6 - 6
src/rest/openapi/restcontroller/wechatapp/orderform/SQL/订单审核未收款账期统计查询.sql

@@ -2,27 +2,27 @@ declare @siteid varchar(20)
 set @siteid = $siteid$
 select t1.fagentnum,fagentname,fagentshortname,pp_hr.displayname,isnull(t2.famount1,0) famount1,isnull(t3.famount2,0) famount2,isnull(t4.famount3,0) famount3,isnull(t5.famount4,0) famount4,isnull(t6.famount5,0) famount5,isnull(t7.famount6,0) ftotalamount from tagents t1 
 inner join
-(select fsaler,t1.fagentnum,sum(t2.frateamount-isnull(t2.fwriteoffamount,0))famount6 from saorder t1
+(select fsaler,t1.fagentnum,sum(t2.frateamount-t2.frateprice*isnull(t2.freturnqty,0)-isnull(t2.fwriteoffamount,0))famount6 from saorder t1
 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
 where t1.fstatus in('审核','关闭') and t1.siteid=@siteid and CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,0,getdate()),120) group by t1.fagentnum,fsaler) t7 on t1.fagentnum=t7.fagentnum 
 left join
-(select fsaler,t1.fagentnum,sum(t2.frateamount-isnull(t2.fwriteoffamount,0))famount1 from saorder t1
+(select fsaler,t1.fagentnum,sum(t2.frateamount-t2.frateprice*isnull(t2.freturnqty,0)-isnull(t2.fwriteoffamount,0))famount1 from saorder t1
 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
 where t1.fstatus in('审核','关闭') and t1.siteid=@siteid and  CONVERT(VARCHAR(10),t1.checkdate,120)>CONVERT(VARCHAR(10),DATEADD(mm,-1,getdate()),120) and  CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,0,getdate()),120) group by t1.fagentnum,fsaler) t2 on t7.fagentnum=t2.fagentnum and t7.fsaler=t2.fsaler
 left join
-(select fsaler,t1.fagentnum,sum(t2.frateamount-isnull(t2.fwriteoffamount,0))famount2 from saorder t1
+(select fsaler,t1.fagentnum,sum(t2.frateamount-t2.frateprice*isnull(t2.freturnqty,0)-isnull(t2.fwriteoffamount,0))famount2 from saorder t1
 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
 where t1.fstatus in('审核','关闭') and t1.siteid=@siteid and  CONVERT(VARCHAR(10),t1.checkdate,120)>CONVERT(VARCHAR(10),DATEADD(mm,-3,getdate()),120) and  CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,-1,getdate()),120) group by t1.fagentnum,fsaler) t3 on t7.fagentnum=t3.fagentnum and t7.fsaler=t3.fsaler
 left join
-(select fsaler,t1.fagentnum,sum(t2.frateamount-isnull(t2.fwriteoffamount,0))famount3 from saorder t1
+(select fsaler,t1.fagentnum,sum(t2.frateamount-t2.frateprice*isnull(t2.freturnqty,0)-isnull(t2.fwriteoffamount,0))famount3 from saorder t1
 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
 where t1.fstatus in('审核','关闭') and t1.siteid=@siteid and  CONVERT(VARCHAR(10),t1.checkdate,120)>CONVERT(VARCHAR(10),DATEADD(mm,-6,getdate()),120) and  CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,-3,getdate()),120) group by t1.fagentnum,fsaler) t4 on t7.fagentnum=t4.fagentnum and t7.fsaler=t4.fsaler
 left join
-(select fsaler,t1.fagentnum,sum(t2.frateamount-isnull(t2.fwriteoffamount,0))famount4 from saorder t1
+(select fsaler,t1.fagentnum,sum(t2.frateamount-t2.frateprice*isnull(t2.freturnqty,0)-isnull(t2.fwriteoffamount,0))famount4 from saorder t1
 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
 where t1.fstatus in('审核','关闭') and t1.siteid=@siteid and  CONVERT(VARCHAR(10),t1.checkdate,120)>CONVERT(VARCHAR(10),DATEADD(mm,-12,getdate()),120) and  CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,-6,getdate()),120) group by t1.fagentnum,fsaler) t5 on t7.fagentnum=t5.fagentnum and t7.fsaler=t5.fsaler
 left join
-(select fsaler,t1.fagentnum,sum(t2.frateamount-isnull(t2.fwriteoffamount,0))famount5 from saorder t1
+(select fsaler,t1.fagentnum,sum(t2.frateamount-t2.frateprice*isnull(t2.freturnqty,0)-isnull(t2.fwriteoffamount,0))famount5 from saorder t1
 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
 where t1.fstatus in('审核','关闭') and t1.siteid=@siteid  and CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,-12,getdate()),120) group by t1.fagentnum,fsaler) t6 on t7.fagentnum=t6.fagentnum and t7.fsaler=t6.fsaler
 inner join pp_hr on pp_hr.hrid=t7.fsaler where $where$ order by  ftotalamount desc

+ 1 - 1
src/rest/openapi/restcontroller/wechatapp/orderform/SQL/订单审核未收款金额查询.sql

@@ -1,3 +1,3 @@
-select sum(t2.frateamount-isnull(t2.fwriteoffamount,0)) famount from saorder t1
+select sum(t2.frateamount-t2.frateprice*isnull(t2.freturnqty,0)-isnull(t2.fwriteoffamount,0)) famount from saorder t1
 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
 where t1.fstatus in('ÉóºË','¹Ø±Õ') and t1.siteid=$siteid$ and $where$