|
@@ -68,9 +68,9 @@
|
|
avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
|
|
avg(shs.iTaxUnitPrice) AS exportUnitPrice ,
|
|
sum(shs.iSum) as exportPrice,
|
|
sum(shs.iSum) as exportPrice,
|
|
sum(iNatSum) as rmbAmount,
|
|
sum(iNatSum) as rmbAmount,
|
|
- max(so.iTax) as procesUnitPriceusd,
|
|
|
|
- max(so.iTax)*sh.iExchRate as procesUnitPricermb,
|
|
|
|
- max(so.iNatTax) * sum(shs.iQuantity) as processCost,
|
|
|
|
|
|
+ avg(so.iOriTaxCost) as procesUnitPriceusd,
|
|
|
|
+ avg(so.iOriTaxCost)*sh.iExchRate as procesUnitPricermb,
|
|
|
|
+ avg(so.iNatUnitPrice) * sum(shs.iQuantity) as processCost,
|
|
v.cVenName AS processUnit
|
|
v.cVenName AS processUnit
|
|
FROM
|
|
FROM
|
|
UFDATA_102_2021.dbo.SaleBillVouch sh
|
|
UFDATA_102_2021.dbo.SaleBillVouch sh
|
|
@@ -78,19 +78,22 @@
|
|
LEFT JOIN UFDATA_102_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode
|
|
LEFT JOIN UFDATA_102_2021.dbo.Inventory c ON c.cInvCode= shs.cInvCode
|
|
LEFT JOIN UFDATA_102_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
|
|
LEFT JOIN UFDATA_102_2021.dbo.rdrecords32 rd ON rd.AutoID = shs.isaleoutid
|
|
JOIN (
|
|
JOIN (
|
|
- SELECT supplierCode,s.iSOsID,s.id ,o.iTax,o.iNatTax,s.cdefine22,s.cDefine28
|
|
|
|
|
|
+ SELECT max(supplierCode) as supplierCode,s.iSOsID,avg(o.iOriTaxCost) as iOriTaxCost,
|
|
|
|
+ avg(o.iNatUnitPrice) as iNatUnitPrice,max(s.cdefine22) as cdefine22,max(s.cDefine28) as cDefine28
|
|
FROM UFDATA_103_2021.dbo.SO_SODetails a
|
|
FROM UFDATA_103_2021.dbo.SO_SODetails a
|
|
inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
|
|
inner JOIN UFDATA_103_2021.dbo.SO_SOMain b on b.ID= a.ID
|
|
inner JOIN (
|
|
inner JOIN (
|
|
SELECT
|
|
SELECT
|
|
- om.cCode AS omCode, od.csoordercode,
|
|
|
|
- om.MOID AS ompoId,od.MODetailsID AS ompoIdItem,
|
|
|
|
- om.cVenCode AS supplierCode,od.cInvCode,od.isosid,od.iQuantity ,od.iTax,od.iNatTax
|
|
|
|
|
|
+ max(od.csoordercode) as csoordercode,
|
|
|
|
+ max(om.cVenCode) AS supplierCode,od.cInvCode,od.isosid,sum(od.iQuantity) as iQuantity ,
|
|
|
|
+ avg(bi.iOriTaxCost) as iOriTaxCost,avg(od.iNatUnitPrice) as iNatUnitPrice
|
|
FROM
|
|
FROM
|
|
UFDATA_103_2021.dbo.OM_MOMain om
|
|
UFDATA_103_2021.dbo.OM_MOMain om
|
|
inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
|
|
inner JOIN UFDATA_103_2021.dbo.OM_MODetails od ON om.MOID = od.MOID
|
|
|
|
+ left join UFDATA_103_2021.dbo.PurBillVouchs bi on bi.iPOsID=od.MODetailsID
|
|
WHERE
|
|
WHERE
|
|
om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and om.cCode like CONCAT(#{code},'%')
|
|
om.iVerifyStateNew = 2 and (om.cCloser is null or om.cCloser='asuser') and om.cCode like CONCAT(#{code},'%')
|
|
|
|
+ GROUP BY od.cInvCode,od.isosid
|
|
) o ON a.isosid = o.isosid AND a.cInvCode = o.cInvCode
|
|
) o ON a.isosid = o.isosid AND a.cInvCode = o.cInvCode
|
|
inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
|
|
inner JOIN UFDATA_103_2021.dbo.Vendor v ON o.supplierCode= v.cVenCode
|
|
inner JOIN UFDATA_103_2021.dbo.Inventory c on c.cInvCode=a.cInvCode
|
|
inner JOIN UFDATA_103_2021.dbo.Inventory c on c.cInvCode=a.cInvCode
|
|
@@ -100,6 +103,7 @@
|
|
inner join UFDATA_102_2021.dbo.SO_SODetails s on s.iSOsID=g.iorderdid
|
|
inner join UFDATA_102_2021.dbo.SO_SODetails s on s.iSOsID=g.iorderdid
|
|
inner join UFDATA_102_2021.dbo.so_somain ss on ss.id=s.id
|
|
inner join UFDATA_102_2021.dbo.so_somain ss on ss.id=s.id
|
|
WHERE b.cCusCode in ('T020001','0001') and ss.cCusCode not in ('T020001','0001') and c.cInvCcode like '19%'
|
|
WHERE b.cCusCode in ('T020001','0001') and ss.cCusCode not in ('T020001','0001') and c.cInvCcode like '19%'
|
|
|
|
+ GROUP BY s.iSOsID
|
|
) so ON so.iSOsID = rd.iorderdid
|
|
) so ON so.iSOsID = rd.iorderdid
|
|
LEFT JOIN UFDATA_102_2021.dbo.Vendor v ON so.supplierCode= v.cVenCode
|
|
LEFT JOIN UFDATA_102_2021.dbo.Vendor v ON so.supplierCode= v.cVenCode
|
|
group by sh.cDefine10,sh.iExchRate,sh.cSOCode,c.cInvName, v.cVenName
|
|
group by sh.cDefine10,sh.iExchRate,sh.cSOCode,c.cInvName, v.cVenName
|