|
@@ -22,11 +22,11 @@ select t.* from (
|
|
|
case when max(sbv.cexch_name)='人民币' then max(pbv.iOriTaxCost) else round(max(pbv.iOriTaxCost)*max(pbv.cExchRate),4) end as procesUnitPricermb,
|
|
|
case when max(sbv.cexch_name)='人民币' then 0 else max(pbv.iOriTaxCost) end as procesUnitPriceusd,
|
|
|
sum(pbv.processCost) as processCost,
|
|
|
- case when max(sbv.cexch_name)='人民币' then 0 else max(pbv.iOriTaxCost) end * sum(pbv.iQuantity) as processCostUsd,
|
|
|
+ case when max(sbv.cexch_name)='人民币' then 0 else sum(pbv.iOriSum) end as processCostUsd,
|
|
|
max(v.cVenName) AS processUnit
|
|
|
|
|
|
from
|
|
|
-(select pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,sum(pbvs.iPBVQuantity) as iQuantity,ommo.ccode,max(sd.cdefine22) as cdefine22,max(sd.cdefine28) as cdefine28,max(pbvs.iOriTaxCost) as iOriTaxCost,ommo.cVenCode as cVenCode,max(pbv.cExchRate) as cExchRate,sum(pbvs.iSum) as processCost
|
|
|
+(select pbv.cDefine10,pbvs.cInvCode,pbvs.cFree1,pbvs.cFree2,pbv.cBusType,sum(pbvs.iPBVQuantity) as iQuantity,ommo.ccode,max(sd.cdefine22) as cdefine22,max(sd.cdefine28) as cdefine28,max(pbvs.iOriTaxCost) as iOriTaxCost,ommo.cVenCode as cVenCode,max(pbv.cExchRate) as cExchRate,sum(pbvs.iSum) as processCost,sum(pbvs.iOriSum) as iOriSum
|
|
|
from UFDATA_101_2021.dbo.PurBillVouchs pbvs left join UFDATA_101_2021.dbo.PurBillVouch pbv
|
|
|
on pbv.PBVID=pbvs.PBVID
|
|
|
left join UFDATA_101_2021.dbo.OM_MODetails ommos on ommos.MODetailsID=pbvs.iPOsID
|
|
@@ -60,7 +60,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
|
case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*max(so.cExchRate),4) end as procesUnitPricermb,
|
|
|
case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end as procesUnitPriceusd,
|
|
|
case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*max(so.cExchRate),4) end * sum(shs.iQuantity) as processCost,
|
|
|
- case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
|
|
|
+ case when max(so.cexch)='人民币' then 0 else sum(so.iOriSum) end as processCostUsd,
|
|
|
v.cVenName AS processUnit
|
|
|
FROM
|
|
|
UFDATA_102_2021.dbo.SaleBillVouch sh
|
|
@@ -69,7 +69,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
|
LEFT JOIN UFDATA_102_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
|
|
|
JOIN (
|
|
|
SELECT max(o.cExchRate) as cExchRate,max(supplierCode) as supplierCode,s.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
|
|
|
- max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
|
|
|
+ max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28,sum(o.iOriSum) as iOriSum
|
|
|
FROM UFDATA_103_2021.dbo.SO_SODetails a
|
|
|
inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
|
|
|
inner JOIN (
|
|
@@ -78,7 +78,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
|
max(pb.cExchRate) as cExchRate,
|
|
|
od.csoordercode as csoordercode,
|
|
|
max(om.cVenCode) AS supplierCode,max(od.cInvCode) as cInvCode,max(od.isosid) as isosid,sum(od.iQuantity) as iQuantity ,
|
|
|
- max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice
|
|
|
+ max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice,sum(bi.iOriSum) as iOriSum
|
|
|
FROM
|
|
|
UFDATA_103_2021.dbo.OM_MOMain om
|
|
|
inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
|
|
@@ -119,7 +119,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
|
case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end as procesUnitPriceusd,
|
|
|
|
|
|
case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*max(so.cExchRate),4) end * sum(shs.iQuantity) as processCost,
|
|
|
- case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
|
|
|
+ case when max(so.cexch)='人民币' then 0 else sum(so.iOriSum) end as processCostUsd,
|
|
|
v.cVenName AS processUnit
|
|
|
FROM
|
|
|
UFDATA_101_2021.dbo.SaleBillVouch sh
|
|
@@ -128,7 +128,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
|
LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
|
|
|
JOIN (
|
|
|
SELECT max(o.cExchRate) as cExchRate,max(supplierCode) as supplierCode,s.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
|
|
|
- max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
|
|
|
+ max(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28,sum(o.iOriSum) as iOriSum
|
|
|
FROM UFDATA_103_2021.dbo.SO_SODetails a
|
|
|
inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
|
|
|
inner JOIN (
|
|
@@ -137,7 +137,7 @@ GROUP BY sbv.cDefine10,sbv.iExchRate,sbv.cSOCode
|
|
|
max(pb.cExchRate) as cExchRate,
|
|
|
od.csoordercode as csoordercode,
|
|
|
max(om.cVenCode) AS supplierCode,max(od.cInvCode) as cInvCode,max(od.isosid) as isosid,sum(od.iQuantity) as iQuantity ,
|
|
|
- max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice
|
|
|
+ max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice,sum(bi.iOriSum) as iOriSum
|
|
|
FROM
|
|
|
UFDATA_103_2021.dbo.OM_MOMain om
|
|
|
inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
|
|
@@ -179,7 +179,7 @@ UNION ALL
|
|
|
case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end as procesUnitPriceusd,
|
|
|
|
|
|
case when max(so.cexch)='人民币' then max(so.iOriTaxCost) else round(max(so.iOriTaxCost)*max(so.cExchRate),4) end * sum(shs.iQuantity) as processCost,
|
|
|
- case when max(so.cexch)='人民币' then 0 else max(so.iOriTaxCost) end * sum(shs.iQuantity) as processCostUsd,
|
|
|
+ case when max(so.cexch)='人民币' then 0 else sum(so.iOriSum) end as processCostUsd,
|
|
|
v.cVenName AS processUnit
|
|
|
FROM
|
|
|
UFDATA_101_2021.dbo.SaleBillVouch sh
|
|
@@ -188,7 +188,7 @@ UNION ALL
|
|
|
LEFT JOIN UFDATA_101_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
|
|
|
JOIN (
|
|
|
SELECT max(o.cExchRate) as cExchRate,max(supplierCode) as supplierCode,s1.iSOsID,max(o.iOriTaxCost) as iOriTaxCost,max(o.cexch) as cexch,
|
|
|
- max(o.iNatUnitPrice) as iNatUnitPrice,max(s1.cdefine22) as cdefine22,max(s1.cDefine28) as cDefine28
|
|
|
+ max(o.iNatUnitPrice) as iNatUnitPrice,max(s1.cdefine22) as cdefine22,max(s1.cDefine28) as cDefine28,sum(o.iOriSum) as iOriSum
|
|
|
FROM UFDATA_103_2021.dbo.SO_SODetails a
|
|
|
inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
|
|
|
inner JOIN (
|
|
@@ -197,7 +197,7 @@ UNION ALL
|
|
|
max(pb.cExchRate) as cExchRate,
|
|
|
od.csoordercode as csoordercode,
|
|
|
max(om.cVenCode) AS supplierCode,max(od.cInvCode) as cInvCode,max(od.isosid) as isosid,sum(od.iQuantity) as iQuantity ,
|
|
|
- max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice
|
|
|
+ max(bi.iOriTaxCost) as iOriTaxCost,max(od.iNatUnitPrice) as iNatUnitPrice,sum(bi.iOriSum) as iOriSum
|
|
|
FROM
|
|
|
UFDATA_103_2021.dbo.OM_MOMain om
|
|
|
inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
|