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