Advertisement
aadddrr

Untitled

Jan 31st, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- GOODS TRANSFER OUT
  2.     -- Added by Adrian, Jan 31, 2017
  3.     EXECUTE 'INSERT INTO tt_r_stock_amount_card(
  4.        session_id, product_code, product_name, transaction_date, transaction_no,
  5.        doc_type_id, transaction_type, qty_in, amount_in, qty_out, amount_out, qty_balance, amount_balance,
  6.        qty_original, amount_original
  7.     )
  8.     SELECT $1, X.product_code, X.product_name, A.doc_date AS note_date, A.doc_no AS note_no,
  9.         A.doc_type_id, $2, $3 AS qty_in,
  10.         $3 AS amount_in,
  11.         (D.qty_out - D.qty_in) AS qty_out,
  12.         $3,
  13.         $3, $3,
  14.         $3, $3
  15.     FROM in_inventory A
  16.     JOIN in_inventory_item B ON A.inventory_id = B.inventory_id
  17.     JOIN m_product X ON X.product_id = B.product_id
  18.     join m_ou_structure Z ON A.ou_from_id = Z.ou_id
  19.     INNER JOIN in_inventory_item C ON C.ref_item_id = B.inventory_item_id
  20.     INNER JOIN in_balance_transfer_in_item D ON D.inventory_item_id = C.inventory_item_id
  21.     WHERE SUBSTRING(A.doc_date, 1, 6) BETWEEN $4 AND $5
  22.     AND (Z.ou_bu_id = $6 OR Z.ou_id = $6)
  23.     AND A.tenant_id = $7 '
  24.     || vFilterProductCode || vFilterProductName ||
  25.     ' AND A.status_doc = $8
  26.     AND A.doc_type_id = $9
  27.     AND D.flg_receipt = $10
  28.     GROUP BY X.product_code, X.product_name, A.doc_date, A.doc_no, A.doc_type_id, B.qty_realization, B.qty_request, D.qty_out, D.qty_in'
  29.     USING pSessionId, vGoodsTransferOutDoc, vZero, pPeriodStart, pPeriodEnd, pOuId, pTenantId, vReleased, vGoodsTransferOutDocTypeId, vNo;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement