Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- GOODS TRANSFER OUT
- -- Added by Adrian, Jan 31, 2017
- EXECUTE 'INSERT INTO tt_r_stock_amount_card(
- session_id, product_code, product_name, transaction_date, transaction_no,
- doc_type_id, transaction_type, qty_in, amount_in, qty_out, amount_out, qty_balance, amount_balance,
- qty_original, amount_original
- )
- SELECT $1, X.product_code, X.product_name, A.doc_date AS note_date, A.doc_no AS note_no,
- A.doc_type_id, $2, $3 AS qty_in,
- $3 AS amount_in,
- (D.qty_out - D.qty_in) AS qty_out,
- $3,
- $3, $3,
- $3, $3
- FROM in_inventory A
- JOIN in_inventory_item B ON A.inventory_id = B.inventory_id
- JOIN m_product X ON X.product_id = B.product_id
- join m_ou_structure Z ON A.ou_from_id = Z.ou_id
- INNER JOIN in_inventory_item C ON C.ref_item_id = B.inventory_item_id
- INNER JOIN in_balance_transfer_in_item D ON D.inventory_item_id = C.inventory_item_id
- WHERE SUBSTRING(A.doc_date, 1, 6) BETWEEN $4 AND $5
- AND (Z.ou_bu_id = $6 OR Z.ou_id = $6)
- AND A.tenant_id = $7 '
- || vFilterProductCode || vFilterProductName ||
- ' AND A.status_doc = $8
- AND A.doc_type_id = $9
- AND D.flg_receipt = $10
- 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'
- USING pSessionId, vGoodsTransferOutDoc, vZero, pPeriodStart, pPeriodEnd, pOuId, pTenantId, vReleased, vGoodsTransferOutDocTypeId, vNo;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement