|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+预支单数据合计
|
|
|
2
|
+--预支单数量 货款付款/费用付款 /非贸付款 付款类型为预付款 并且 7621-法人单位名称'山东钢铁集团国际贸易有限公司'
|
|
|
3
|
+--7623 济钢
|
|
|
4
|
+--并且 排除 费用付款 中费用大类是财务费用类 并且 审核状态 ='待审核' '发送成功' 并且 没有删除
|
|
|
5
|
+SELECT expanse_report_id ,fours AS fours,COUNT(invoice_code) AS 数量,
|
|
|
6
|
+SUM(CASE WHEN curcy ='CNY' THEN amt WHEN curcy ='CNY' THEN amt*7.85 ELSE 0 end ) AS 金额
|
|
|
7
|
+FROM (SELECT DISTINCT SUBSTR(a."expanse_report_id",0,1) AS expanse_report_id,
|
|
|
8
|
+b.fours AS fours,a.invoice_code,b.amt,b.curcy
|
|
|
9
|
+FROM SGGMINFT.inf_BCFMP1 a left join SGGMIIP.paymgrctrl b on a.invoice_code=b.fno
|
|
|
10
|
+WHERE TO_CHAR(a.create_time,'YYYY-MM-DD HH:MI:SS') >= '2026-01-01 00:00:00'
|
|
|
11
|
+ AND TO_CHAR(a.create_time, 'YYYY-MM-DD HH:MI:SS')<= '2026-01-23 12:00:00'
|
|
|
12
|
+ and b.payType like '%预付款%' --and b.fours='SGGM'
|
|
|
13
|
+ and ifnull(b.cateName,'') <> '财务费用类'
|
|
|
14
|
+ and ifnull(impBcStatus,'') in ('待审核','发送成功')
|
|
|
15
|
+ and b.del_flag<>1)
|
|
|
16
|
+GROUP BY fours ,"expanse_report_id" ;
|
|
|
17
|
+
|
|
|
18
|
+
|
|
|
19
|
+报支单数据合计
|
|
|
20
|
+SELECT expanse_report_id ,fours AS fours,COUNT(invoice_code) AS 数量,
|
|
|
21
|
+SUM(CASE WHEN curcy ='CNY' THEN amt WHEN curcy ='CNY' THEN amt*7.85 ELSE 0 end ) AS 金额
|
|
|
22
|
+FROM (SELECT DISTINCT SUBSTR(a."expanse_report_id",0,1) AS expanse_report_id,
|
|
|
23
|
+b.fours AS fours,a.invoice_code,b.totalAmt AS amt,IFNULL(b.curcy,'CNY') AS curcy
|
|
|
24
|
+FROM SGGMINFT.inf_BCFMP1 a
|
|
|
25
|
+left join SGGMIIP.purMultiSettle b on a.invoice_code=b.fno
|
|
|
26
|
+WHERE TO_CHAR(a.create_time,'YYYY-MM-DD HH:MI:SS') >= '2026-01-01 00:00:00'
|
|
|
27
|
+ AND TO_CHAR(a.create_time, 'YYYY-MM-DD HH:MI:SS')<= '2026-01-23 23:59:59'
|
|
|
28
|
+ --and b.fours='JGGM'
|
|
|
29
|
+ and ifnull(b.impBcStatus,'') in ('待审核','财务审核','财务复核','部分付款','全部付款')
|
|
|
30
|
+ and IFNULL(b.del_flag,'0')<>'1')
|
|
|
31
|
+GROUP BY fours ,"expanse_report_id" ;
|
|
|
32
|
+
|
|
|
33
|
+
|
|
|
34
|
+-- 销售发票数据
|
|
|
35
|
+select
|
|
|
36
|
+b2.serviceType ,b2.totalAmt,b2.curcy ,
|
|
|
37
|
+b2.create_by_name 制单人 ,
|
|
|
38
|
+case when ifnull(b2.fmodalid,0)=36 then '销售发票'
|
|
|
39
|
+ else '' end 模块 ,
|
|
|
40
|
+a.bill_no
|
|
|
41
|
+from
|
|
|
42
|
+(
|
|
|
43
|
+ select distinct bill_no from SGGMINFT.INF_BCFMS1
|
|
|
44
|
+ where proc_status='1'
|
|
|
45
|
+) a
|
|
|
46
|
+left join saleSettle b2 on a.bill_no=b2.fno
|
|
|
47
|
+
|
|
|
48
|
+where b2.fours='SGGM'
|
|
|
49
|
+and ifnull(b2.del_flag,0)<>1 ;
|
|
|
50
|
+
|
|
|
51
|
+---成本结转
|
|
|
52
|
+select bccode 账套代码,billType 单据类型 ,count(id) 抛帐数量,curcy,sum(amt) 原币金额 ,sum(cnyamt) 人民币金额
|
|
|
53
|
+from GwomiCtrl
|
|
|
54
|
+where impBcStatus='抛账成功' and ifnull(del_flag,0)<>1 and
|
|
|
55
|
+billType in ('C01001')
|
|
|
56
|
+group by bccode,billType,curcy
|
|
|
57
|
+order by bccode,billType,curcy
|
|
|
58
|
+
|
|
|
59
|
+--通用抛账明细表(暂估)
|
|
|
60
|
+select
|
|
|
61
|
+b.bccode ,
|
|
|
62
|
+b.billType, -- 单据类型
|
|
|
63
|
+a.curcy,
|
|
|
64
|
+count(b.id)id ,
|
|
|
65
|
+sum(case when b.table1 like '%冲销%' then 0-CAST(ROUND( ifnull(a.ntAmt,0)+ ifnull(a.tzamt1,0) ,2) AS DECIMAL(18, 2)) else CAST(ROUND( ifnull(a.ntAmt,0)+ ifnull(a.tzamt1,0) ,2) AS DECIMAL(18, 2)) end) as billSubAmt,-- 单据金额(原币)
|
|
|
66
|
+sum(case when b.table1 like '%冲销%' AND IFNULL(fcat,0)<>1 then 0-CAST(ROUND( ifnull(a.ntCnyAmt,0)+ ifnull(a.tzamt2,0) ,2)AS DECIMAL(18, 2)) else CAST(ROUND( ifnull(a.ntCnyAmt,0)+ ifnull(a.tzamt2,0) ,2)AS DECIMAL(18, 2)) end ) as billSubAmtRmb-- 单据金额(折人民币)
|
|
|
67
|
+from Gwomidtl a
|
|
|
68
|
+left join GwomiCtrl b on a.rid=b.id
|
|
|
69
|
+where nvl(a.del_flag,0)<>1
|
|
|
70
|
+and b.impBcStatus='抛账成功'
|
|
|
71
|
+and a.billType in ('I01001')
|
|
|
72
|
+and ifnull(b.del_flag,0)<>1
|
|
|
73
|
+and b.placed='2'
|
|
|
74
|
+group by b.bccode ,b.billType, a.curcy
|