|
|
@@ -1,44 +1,18 @@
|
|
|
-SELECT
|
|
|
- t1.sa_u8prodpriceid,
|
|
|
- CONCAT(
|
|
|
- 'UPDATE rdrecords01 b ',
|
|
|
- 'INNER JOIN rdrecord01 h ON b.ID = h.ID ',
|
|
|
- 'SET ',
|
|
|
- 'b.iOriTaxCost = ', t2.costprice * (100 + IFNULL(t2.taxrate, 0)) / 100,
|
|
|
- ', ',
|
|
|
- 'b.iTaxRate = ', IFNULL(t2.taxrate, 0),
|
|
|
- ', ',
|
|
|
- 'b.iUnitCost = ', t2.costprice,
|
|
|
- ', ',
|
|
|
- 'b.iOriCost = ', t2.costprice,
|
|
|
- ', ',
|
|
|
- 'b.fACost = ', t2.costprice,
|
|
|
- ', ',
|
|
|
- 'b.iPrice = ', t2.costprice, ' * b.iQuantity',
|
|
|
- ', ',
|
|
|
- 'b.iAPrice = ', t2.costprice, ' * b.iQuantity',
|
|
|
- ', ',
|
|
|
- 'b.iOriMoney = ', t2.costprice, ' * b.iQuantity',
|
|
|
- ', ',
|
|
|
- 'b.iTaxPrice = ', t2.costprice * IFNULL(t2.taxrate, 0) / 100, ' * b.iQuantity',
|
|
|
- ', ',
|
|
|
- 'b.iOriTaxPrice = ', t2.costprice * IFNULL(t2.taxrate, 0) / 100, ' * b.iQuantity',
|
|
|
- ', ',
|
|
|
- 'b.ioriSum = ', t2.costprice, ' * b.iQuantity + ', t2.costprice * IFNULL(t2.taxrate, 0) / 100, ' * b.iQuantity',
|
|
|
- ', ',
|
|
|
- 'b.iSum = ', t2.costprice, ' * b.iQuantity + ', t2.costprice * IFNULL(t2.taxrate, 0) / 100, ' * b.iQuantity',
|
|
|
- ' ',
|
|
|
- 'WHERE h.cBusType = ''委外加工'' ',
|
|
|
- 'AND h.dDate >= ''', DATE_FORMAT(t1.begindate, '%Y-%m-%d'), ''' ',
|
|
|
- 'AND h.dDate <= ''', DATE_FORMAT(t1.enddate, '%Y-%m-%d'), ''' ',
|
|
|
- 'AND h.cWhCode = ''', IFNULL(t2.stockno, ''), ''' ',
|
|
|
- 'AND b.cinvcode = ''', t2.itemno, ''''
|
|
|
- ) AS sqlstr
|
|
|
-FROM
|
|
|
- sa_u8prodprice AS t1
|
|
|
- INNER JOIN
|
|
|
- sa_u8prodprice_datail AS t2
|
|
|
- ON t1.sa_u8prodpriceid = t2.sa_u8prodpriceid
|
|
|
-WHERE
|
|
|
- t1.status = '审核'
|
|
|
- AND t1.type = '委外入库';
|
|
|
+SELECT sa_u8prodpriceid, sqlstr
|
|
|
+FROM (SELECT t1.sa_u8prodpriceid, CONCAT_WS('','update rdrecords01 set
|
|
|
+iOriTaxCost=' , t2.costprice * (100 + IFNULL(t2.taxrate, 0)) / 100 , ',
|
|
|
+iTaxRate=' , IfNULL(t2.taxrate, 0) , ',
|
|
|
+iUnitCost=' , t2.costprice , ',
|
|
|
+iOriCost=' , t2.costprice , ',
|
|
|
+fACost=' , t2.costprice
|
|
|
+ , ',
|
|
|
+iPrice=' , t2.costprice , '*iQuantity,
|
|
|
+iAPrice=' , t2.costprice , '*iQuantity,
|
|
|
+iOriMoney=' , t2.costprice , '*iQuantity,
|
|
|
+iTaxPrice=' , t2.costprice * IFNULL(t2.taxrate, 0), '*iQuantity/100,
|
|
|
+iOriTaxPrice=' , t2.costprice * IFNULL(t2.taxrate, 0) , '*iQuantity/100,
|
|
|
+ioriSum=' , t2.costprice , '*iQuantity,' , t2.costprice * IFNULL(t2.taxrate, 0) , '*iQuantity/100,
|
|
|
+iSum=' ,t2.costprice , '*iQuantity,' , t2.costprice * IFNULL(t2.taxrate, 0), '*iQuantity/100 from rdrecords01 b left join rdrecord01 h on b.ID=h.ID where h.cBusType=''委外加工'' and h.dDate>=''' , DATE_FORMAT(t1.begindate, '%Y-%m-%d') , ''' and h.dDate<=''' , DATE_FORMAT(t1.enddate, '%Y-%m-%d'), ''' and h.cWhCode =''' , IfNULL(t2.stockno, '') , ''' and cinvcode=''' , t2.itemno , '''') AS sqlstr
|
|
|
+ FROM sa_u8prodprice AS t1 INNER JOIN
|
|
|
+ sa_u8prodprice_datail AS t2 ON t1.sa_u8prodpriceid = t2.sa_u8prodpriceid
|
|
|
+ WHERE (t1.status = '审核') AND (t1.type = '委外入库') and ifnull(t1.uploaddate,'')='') AS t
|