|
|
@ -25,27 +25,48 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report |
|
|
|
{ |
|
|
|
string sqlString = "SELECT\n" + |
|
|
|
" * ,\n" + |
|
|
|
" (Price-InvoicePrice) as InvoiceDiffPrice, --单价差异 \n" + |
|
|
|
" ( Price - InvoicePrice ) AS InvoiceDiffPrice,--单价差异\n" + |
|
|
|
" ISNULL( Price * ReceiptQty - InvoiceMoney, 0 ) AS SumDiffMoney --总金额差异\n" + |
|
|
|
" \n" + |
|
|
|
"FROM\n" + |
|
|
|
" (\n" + |
|
|
|
" SELECT\n" + |
|
|
|
" c.Period as WMSDeliveryDate,--交货日期 \n" + |
|
|
|
" c.Period AS WMSDeliveryDate,--交货日期\n" + |
|
|
|
" c.WMSDeliveryNote,--交货单号\n" + |
|
|
|
" c.SpareDate as OrderDate,--订单日期 \n" + |
|
|
|
" c.SpareDate AS OrderDate,--订单日期\n" + |
|
|
|
" a.PurchaseOrderNo,--采购订单号\n" + |
|
|
|
" b.MaterialCode as SAPCode,--SAP编码,即厂内物料号 \n" + |
|
|
|
" b.MaterialCode AS SAPCode,--SAP编码,即厂内物料号\n" + |
|
|
|
" a.MaterialCode,--物料代码\n" + |
|
|
|
" b.MaterialDesc,--物料描述\n" + |
|
|
|
" a.PurchaseOrderNoText,--采购订单文本\n" + |
|
|
|
" c.ReceiptQty,-- 发货数量\n" + |
|
|
|
" a.InvoicedQty as InvoicedQty,--开票数量 \n" + |
|
|
|
" (c.ReceiptQty-d.Amt) as SettleInvoiceDiffQty,--发货与开票差异 \n" + |
|
|
|
" a.InvoicedQty AS InvoicedQty,--开票数量\n" + |
|
|
|
" ( c.ReceiptQty- d.Amt ) AS SettleInvoiceDiffQty,--发货与开票差异\n" + |
|
|
|
" d.InvoicePrice,--开票单价\n" + |
|
|
|
" 0 as InvoiceMoney --开票金额 \n" + |
|
|
|
" 0 AS InvoiceMoney --开票金额\n" + |
|
|
|
" \n" + |
|
|
|
" FROM\n" + |
|
|
|
" Set_SparePart AS a \n" + |
|
|
|
" (\n" + |
|
|
|
" SELECT\n" + |
|
|
|
" t.PurchaseOrderNoText,\n" + |
|
|
|
" t.LineNumber,\n" + |
|
|
|
" t.PurchaseOrderNo,\n" + |
|
|
|
" t.MaterialCode,\n" + |
|
|
|
" MAX ( t.SpareDate ) SpareDate,\n" + |
|
|
|
" t.DeliveryOrderNo,\n" + |
|
|
|
" SUM ( t.InvoicedQty ) AS InvoicedQty \n" + |
|
|
|
" FROM\n" + |
|
|
|
" Set_SparePart t \n" + |
|
|
|
" WHERE\n" + |
|
|
|
" t.Version= '{0}' \n" + |
|
|
|
" GROUP BY\n" + |
|
|
|
" t.PurchaseOrderNo,\n" + |
|
|
|
" t.MaterialCode,\n" + |
|
|
|
" t.SpareDate,\n" + |
|
|
|
" t.DeliveryOrderNo,\n" + |
|
|
|
" t.LineNumber,\n" + |
|
|
|
" t.PurchaseOrderNoText \n" + |
|
|
|
" ) AS a\n" + |
|
|
|
" LEFT JOIN Set_material AS b ON a.MaterialCode= b.CustomerPartCode\n" + |
|
|
|
" LEFT JOIN Set_WMSSparePart c ON a.PurchaseOrderNo= c.WMSDeliveryNote \n" + |
|
|
|
" AND a.MaterialCode= c.MaterialCode\n" + |
|
|
|