|
|
@@ -1,24 +1,24 @@
|
|
|
-select *,t2.freceivedamount,tp.fprojectname,sdate.closedate1 from saorderdetail t1
|
|
|
-left join saorder_receivedview t2 on t1.siteid=t2.siteid and t1.saorderdetailid=t2.saorderdetailid
|
|
|
-left join saorder sa on t1.fparentid = sa.saorderid
|
|
|
-left join tproject tp on sa.fprojectnum = tp.fprojectnum
|
|
|
-left join sainvoice_closedate sdate on sdate.fsourceid = t1.saorderdetailid
|
|
|
-where
|
|
|
-t1.siteid=$siteid$ and
|
|
|
-exists(
|
|
|
- select *from saorder_receivedview
|
|
|
- where siteid=t1.siteid and saorderid=t1.fparentid and saorderdetailid=t1.saorderdetailid
|
|
|
- and isnull(freceivedamount,0)>isnull(t1.finvoiceamount,0)
|
|
|
-)
|
|
|
-and exists(select * from sainvoice_closedate sdate left join saorderdetail t1 on sdate.fsourceid = t1.saorderdetailid
|
|
|
- where sdate.closedate1 is not null and $where$)
|
|
|
-and exists(select * from tproject tp left join saorder sa on sa.fprojectnum = tp.fprojectnum
|
|
|
- left join saorderdetail t1 on t1.fparentid = sa.saorderid where $where$)
|
|
|
-and exists(
|
|
|
- select * from saorder
|
|
|
- where fstatus in('ÉóºË','¹Ø±Õ') and siteid=t1.siteid
|
|
|
- and saorderid=t1.fparentid and fpayagentnum=$fagentnum$ --and finvoicetaxnumber=$finvoicetaxnumber$
|
|
|
-)
|
|
|
-and not exists(
|
|
|
- select *from tinvoiceapplyorder where siteid=$siteid$ and tinvoiceapplyid=$tinvoiceapplyid$ and saorderdetailid=t1.saorderdetailid
|
|
|
+select *,t2.freceivedamount,tp.fprojectname,sdate.closedate1 from saorderdetail t1
|
|
|
+left join saorder_receivedview t2 on t1.siteid=t2.siteid and t1.saorderdetailid=t2.saorderdetailid
|
|
|
+left join saorder sa on t1.fparentid = sa.saorderid
|
|
|
+left join tproject tp on sa.fprojectnum = tp.fprojectnum
|
|
|
+left join sainvoice_closedate sdate on sdate.fsourceid = t1.saorderdetailid
|
|
|
+where
|
|
|
+t1.siteid=$siteid$ and
|
|
|
+exists(
|
|
|
+ select *from saorder_receivedview
|
|
|
+ where siteid=t1.siteid and saorderid=t1.fparentid and saorderdetailid=t1.saorderdetailid
|
|
|
+ and isnull(freceivedamount,0)>isnull(t1.finvoiceamount,0)
|
|
|
+)
|
|
|
+and exists(select tp.fprojectname,sa.*,t1.* from tproject tp where sa.fprojectnum = tp.fprojectnum
|
|
|
+ and t1.fparentid = sa.saorderid and $where2$)
|
|
|
+and exists(select sdate.closedate1,t1.* from sainvoice_closedate sdate where sdate.fsourceid = t1.saorderdetailid
|
|
|
+ and sdate.closedate1 is not null and $where1$)
|
|
|
+and exists(
|
|
|
+ select * from saorder
|
|
|
+ where fstatus in('ÉóºË','¹Ø±Õ') and siteid=t1.siteid
|
|
|
+ and saorderid=t1.fparentid and fpayagentnum=$fagentnum$ --and finvoicetaxnumber=$finvoicetaxnumber$
|
|
|
+)
|
|
|
+and not exists(
|
|
|
+ select *from tinvoiceapplyorder where siteid=$siteid$ and tinvoiceapplyid=$tinvoiceapplyid$ and saorderdetailid=t1.saorderdetailid
|
|
|
)
|