|
@@ -22,7 +22,7 @@
|
|
(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,(isnull(tab1.purchaseQuantity,0)-tab2.jian)*tab.cost as transferCost
|
|
(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,(isnull(tab1.purchaseQuantity,0)-tab2.jian)*tab.cost as transferCost
|
|
from
|
|
from
|
|
(
|
|
(
|
|
- select oti.cInvName as goodsName,max(ot.iUnitQuantity) as dosage,sum(ot.iQuantity) as usageQuantity
|
|
|
|
|
|
+ select oti.cInvName as goodsName,max(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
,sum(pb.rmbAmount) as rmbAmount,sum(pb.usdAmount) as usdAmount,sum(pb.priceExcludingtax) as priceExcludingtax,sum(pb.iCost) as cost
|
|
,sum(pb.rmbAmount) as rmbAmount,sum(pb.usdAmount) as usdAmount,sum(pb.priceExcludingtax) as priceExcludingtax,sum(pb.iCost) as cost
|
|
from UFDATA_903_2021.dbo.om_momain om
|
|
from UFDATA_903_2021.dbo.om_momain om
|
|
join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
@@ -79,7 +79,7 @@
|
|
(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,(isnull(tab1.purchaseQuantity,0)-tab2.jian)*tab.cost as transferCost
|
|
(tab1.purchaseQuantity-tab.usageQuantity)/tab1.purchaseQuantity as loss,(isnull(tab1.purchaseQuantity,0)-tab2.jian)*tab.cost as transferCost
|
|
from
|
|
from
|
|
(
|
|
(
|
|
- select oti.cInvName as goodsName,max(ot.iUnitQuantity) as dosage,sum(ot.iQuantity) as usageQuantity
|
|
|
|
|
|
+ select oti.cInvName as goodsName,max(ot.iUnitQuantity) as dosage,sum(ot.iSendQTY) as usageQuantity
|
|
,sum(pb.rmbAmount) as rmbAmount,sum(pb.usdAmount) as usdAmount,sum(pb.priceExcludingtax) as priceExcludingtax,sum(pb.iCost) as cost
|
|
,sum(pb.rmbAmount) as rmbAmount,sum(pb.usdAmount) as usdAmount,sum(pb.priceExcludingtax) as priceExcludingtax,sum(pb.iCost) as cost
|
|
from UFDATA_901_2021.dbo.om_momain om
|
|
from UFDATA_901_2021.dbo.om_momain om
|
|
join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
@@ -90,8 +90,26 @@
|
|
SELECT p.cInvCode,p.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
|
|
SELECT p.cInvCode,p.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
|
|
,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
|
|
,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
|
|
from UFDATA_901_2021.dbo.PO_Podetails p
|
|
from UFDATA_901_2021.dbo.PO_Podetails p
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Pomain pm on p.POID = pm.POID
|
|
join UFDATA_901_2021.dbo.PurBillVouchs bi on bi.iPOsID=p.ID
|
|
join UFDATA_901_2021.dbo.PurBillVouchs bi on bi.iPOsID=p.ID
|
|
|
|
+ where pm.cVenCode != 'T010001'
|
|
GROUP BY p.cInvCode,p.iorderdid
|
|
GROUP BY p.cInvCode,p.iorderdid
|
|
|
|
+
|
|
|
|
+ union all
|
|
|
|
+
|
|
|
|
+ select
|
|
|
|
+ pod.cInvCode,pod.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
|
|
|
|
+ ,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
|
|
|
|
+ from UFDATA_902_2021.dbo.SO_SOMain so
|
|
|
|
+ join UFDATA_902_2021.dbo.SO_SODetails sd on so.id=sd.id
|
|
|
|
+ join UFDATA_902_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
|
|
|
|
+ join UFDATA_902_2021.dbo.PO_Pomain pm on pd.POID = pm.POID
|
|
|
|
+ join UFDATA_902_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.ID
|
|
|
|
+ join UFDATA_902_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Pomain pom on so.cSOCode = pom.cPOID
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
|
+ where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
|
|
|
|
+ GROUP BY pod.cInvCode,pod.iorderdid
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
|
|
WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
|
|
and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
|
|
and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
|
|
@@ -145,8 +163,26 @@
|
|
SELECT p.cInvCode,p.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
|
|
SELECT p.cInvCode,p.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
|
|
,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
|
|
,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
|
|
from UFDATA_901_2021.dbo.PO_Podetails p
|
|
from UFDATA_901_2021.dbo.PO_Podetails p
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Pomain pm on p.POID = pm.POID
|
|
join UFDATA_901_2021.dbo.PurBillVouchs bi on bi.iPOsID=p.ID
|
|
join UFDATA_901_2021.dbo.PurBillVouchs bi on bi.iPOsID=p.ID
|
|
|
|
+ where pm.cVenCode != 'T010001'
|
|
GROUP BY p.cInvCode,p.iorderdid
|
|
GROUP BY p.cInvCode,p.iorderdid
|
|
|
|
+
|
|
|
|
+ union all
|
|
|
|
+
|
|
|
|
+ select
|
|
|
|
+ pod.cInvCode,pod.iorderdid,sum(bi.iMoney) as rmbAmount,sum(bi.iOriMoney) as usdAmount
|
|
|
|
+ ,sum(bi.iMoney-bi.iTaxPrice) as priceExcludingtax,sum(bi.iCost) as iCost
|
|
|
|
+ from UFDATA_902_2021.dbo.SO_SOMain so
|
|
|
|
+ join UFDATA_902_2021.dbo.SO_SODetails sd on so.id=sd.id
|
|
|
|
+ join UFDATA_902_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
|
|
|
|
+ join UFDATA_902_2021.dbo.PO_Pomain pm on pd.POID = pm.POID
|
|
|
|
+ join UFDATA_902_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.ID
|
|
|
|
+ join UFDATA_902_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Pomain pom on so.cSOCode = pom.cPOID
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
|
+ where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
|
|
|
|
+ GROUP BY pod.cInvCode,pod.iorderdid
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
|
|
WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
|
|
and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
|
|
and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
|
|
@@ -251,7 +287,7 @@
|
|
tab.cost as unitCost,(tab.usageQuantity-isnull(tab1.purchaseQuantity,0))*tab.cost as cost
|
|
tab.cost as unitCost,(tab.usageQuantity-isnull(tab1.purchaseQuantity,0))*tab.cost as cost
|
|
from
|
|
from
|
|
(
|
|
(
|
|
- select oti.cInvName as goodsName,max(om.cCode) as ccode,sum(ot.iQuantity) as usageQuantity,sum(pb.iCost) as cost
|
|
|
|
|
|
+ select oti.cInvName as goodsName,max(om.cCode) as ccode,sum(ot.iSendQTY) as usageQuantity ,sum(pb.iCost) as cost
|
|
from UFDATA_901_2021.dbo.om_momain om
|
|
from UFDATA_901_2021.dbo.om_momain om
|
|
join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
join UFDATA_901_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
join UFDATA_901_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
|
|
join UFDATA_901_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
|
|
@@ -260,8 +296,24 @@
|
|
left join (
|
|
left join (
|
|
SELECT p.cInvCode,p.iorderdid,sum(bi.iCost) as iCost
|
|
SELECT p.cInvCode,p.iorderdid,sum(bi.iCost) as iCost
|
|
from UFDATA_901_2021.dbo.PO_Podetails p
|
|
from UFDATA_901_2021.dbo.PO_Podetails p
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Pomain pm on p.POID = pm.POID
|
|
join UFDATA_901_2021.dbo.PurBillVouchs bi on bi.iPOsID=p.ID
|
|
join UFDATA_901_2021.dbo.PurBillVouchs bi on bi.iPOsID=p.ID
|
|
|
|
+ where pm.cVenCode != 'T010001'
|
|
GROUP BY p.cInvCode,p.iorderdid
|
|
GROUP BY p.cInvCode,p.iorderdid
|
|
|
|
+
|
|
|
|
+ union all
|
|
|
|
+
|
|
|
|
+ select pod.cInvCode,pod.iorderdid,sum(bi.iCost) as iCost
|
|
|
|
+ from UFDATA_902_2021.dbo.SO_SOMain so
|
|
|
|
+ join UFDATA_902_2021.dbo.SO_SODetails sd on so.id=sd.id
|
|
|
|
+ join UFDATA_902_2021.dbo.PO_Podetails pd on pd.iorderdid=sd.isosid
|
|
|
|
+ join UFDATA_902_2021.dbo.PO_Pomain pm on pd.POID = pm.POID
|
|
|
|
+ join UFDATA_902_2021.dbo.PurBillVouchs bi on bi.iPOsID=pd.ID
|
|
|
|
+ join UFDATA_902_2021.dbo.Inventory oti on oti.cInvCode=pd.cInvCode
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Pomain pom on so.cSOCode = pom.cPOID
|
|
|
|
+ join UFDATA_901_2021.dbo.PO_Podetails pod on pod.POID = pom.POID
|
|
|
|
+ where pm.cVenCode != 'T010001' and pom.cVenCode = 'T010001'
|
|
|
|
+ GROUP BY pod.cInvCode,pod.iorderdid
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
) pb on pb.cInvCode=ot.cInvCode and pb.iorderdid=od.isosid
|
|
WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
|
|
WHERE om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and omi.cInvCcode like '19%'
|
|
and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
|
|
and om.cCode LIKE CONCAT(#{code},'%') and (oti.cInvCcode like '05%' or oti.cInvCcode like '06%'
|
|
@@ -292,7 +344,7 @@
|
|
tab.cost as unitCost,(tab.usageQuantity-isnull(tab1.purchaseQuantity,0))*tab.cost as cost
|
|
tab.cost as unitCost,(tab.usageQuantity-isnull(tab1.purchaseQuantity,0))*tab.cost as cost
|
|
from
|
|
from
|
|
(
|
|
(
|
|
- select oti.cInvName as goodsName,max(om.cCode) as ccode,sum(ot.iQuantity) as usageQuantity,sum(pb.iCost) as cost
|
|
|
|
|
|
+ select oti.cInvName as goodsName,max(om.cCode) as ccode,sum(ot.iSendQTY) as usageQuantity ,sum(pb.iCost) as cost
|
|
from UFDATA_903_2021.dbo.om_momain om
|
|
from UFDATA_903_2021.dbo.om_momain om
|
|
join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
join UFDATA_903_2021.dbo.OM_MODetails od on om.moid=od.moid
|
|
join UFDATA_903_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
|
|
join UFDATA_903_2021.dbo.OM_MOMaterials ot on ot.MoDetailsID=od.MODetailsID
|