58: SELECT NVL(fsp.purch_encumbrance_flag,'N'),
59: ai.org_id
60: INTO l_purch_encumbrance_flag,
61: l_org_id
62: FROM ap_invoices_all ai,
63: financials_system_params_all fsp
64: WHERE ai.invoice_id = p_invoice_id
65: AND ai.org_id = fsp.org_id;
66:
190: SELECT nvl(sob.sla_ledger_cash_basis_flag, 'N'),
191: asp.org_id
192: INTO l_cash_basis_flag,
193: l_org_id
194: FROM ap_invoices_all ai,
195: ap_system_parameters_all asp,
196: gl_sets_of_books sob
197: WHERE ai.invoice_id = p_invoice_id
198: AND ai.org_id = asp.org_id
291: BEGIN
292:
293: ---------------------------------------------------------------------
294: -- Get the encumbrance flag
295: -- MOAC. Included select from ap_invoices_all to get the org_id from
296: -- the invoice_id since it is unique
297:
298: SELECT NVL(fsp.purch_encumbrance_flag,'N'), ai.org_id
299: INTO encumbrance_flag, l_org_id
296: -- the invoice_id since it is unique
297:
298: SELECT NVL(fsp.purch_encumbrance_flag,'N'), ai.org_id
299: INTO encumbrance_flag, l_org_id
300: FROM ap_invoices_all ai,
301: financials_system_params_all fsp
302: WHERE ai.invoice_id = p_invoice_id
303: AND ai.org_id = fsp.org_id;
304:
512:
513: l_prepay_amount_applied NUMBER := 0;
514: l_enc_enabled VARCHAR2(1); --bug6009101
515: l_po_not_approved VARCHAR2(1); --bug6009101
516: l_org_id ap_invoices_all.org_id%type; -- for bug 5936290
517: CURSOR dist_gl_date_Cur IS
518: SELECT accounting_date
519: FROM ap_invoice_distributions AID
520: WHERE AID.invoice_id = p_line_rec.invoice_id
573: -- So now we are passing the org_id also in these two calls.
574:
575: SELECT org_id
576: INTO l_org_id
577: FROM ap_invoices_all
578: WHERE invoice_id = p_line_rec.invoice_id;
579:
580: FOR i in NVL(l_gl_date_list.FIRST,0)..NVL(l_gl_date_list.LAST,-1)
581: LOOP
624:
625: SELECT NVL(purch_encumbrance_flag,'N')
626: INTO l_enc_enabled
627: FROM financials_system_params_all FSP,
628: ap_invoices_all AI
629: WHERE AI.invoice_id = p_line_rec.invoice_id
630: AND FSP.org_id = AI.org_id;
631:
632: if l_enc_enabled = 'Y' then
660: l_debug_info := 'Check if this invoice is a quick credit';
661:
662: SELECT count(*)
663: INTO l_quick_credit_count
664: FROM ap_invoices AI
665: WHERE AI.invoice_id = p_line_rec.invoice_id
666: AND NVL(AI.quick_credit, 'N') = 'Y';
667:
668: IF ( l_quick_credit_count > 0 ) THEN
704: if (p_line_rec.invoice_id is not NULL
705: AND p_line_rec.line_type_lookup_code <> 'PREPAY') then
706: SELECT 1
707: INTO l_quick_credit_ref_count
708: FROM ap_invoices AI
709: WHERE AI.credited_invoice_id = p_line_rec.invoice_id
710: AND NVL(AI.quick_credit, 'N') = 'Y'
711: AND AI.cancelled_date is null
712: AND Rownum = 1;
741: SELECT count(*)
742: INTO l_po_dist_count
743: FROM po_distributions_all POD,
744: ap_invoice_distributions AID,
745: ap_invoices ai,
746: po_line_locations PLL,
747: po_lines PL
748: WHERE POD.po_distribution_id = AID.po_distribution_id
749: AND POD.line_location_id = PLL.line_location_id
965:
966: SELECT count(*)
967: INTO l_count
968: FROM ap_invoice_lines AIL,
969: ap_invoices AI
970: WHERE AIL.invoice_id = P_line_rec.invoice_id
971: AND AIL.line_number = P_line_rec.line_number
972: AND AIL.line_type_lookup_code = 'AWT'
973: /*bug12865213, commented exists clause
1009: | is applied. If so, return FALSE (Bug #5114854) |
1010: +-----------------------------------------------------------------*/
1011: SELECT count(*)
1012: INTO l_count
1013: FROM ap_invoices_all ai
1014: WHERE invoice_id = p_line_rec.invoice_id
1015: AND invoice_type_lookup_code = 'PREPAYMENT';
1016:
1017: IF ( l_count > 0 ) THEN
1016:
1017: IF ( l_count > 0 ) THEN
1018:
1019: l_prepay_amount_applied :=
1020: ap_invoices_pkg.get_prepay_amount_applied(p_line_rec.invoice_id);
1021:
1022: if (l_prepay_amount_applied <> 0) then
1023: p_error_code := 'AP_INV_DEL_APPLIED_PREPAY';
1024: RETURN FALSE;
1156: --bug 5475668 Added the if condition
1157: if (p_invoice_id is not null) then
1158: Select 1
1159: Into dummy
1160: From ap_invoices_all AI
1161: Where AI.credited_invoice_id = p_Invoice_Id
1162: AND NVL(AI.quick_credit, 'N') = 'Y'
1163: AND AI.cancelled_date is null
1164: AND Rownum = 1;
1792: nvl( AID.quantity_invoiced,0 ) ) < 0
1793: OR
1794: NVL(POD.amount_billed, 0) - NVL(AID.amount, 0) < 0 );
1795:
1796: l_invoice_id ap_invoices_all.invoice_id%TYPE;
1797: current_calling_sequence VARCHAR2(4000);
1798: debug_info VARCHAR2(240);
1799: l_po_dist_count NUMBER := 0;
1800: l_return_var BOOLEAN := FALSE;
2191: ) IS
2192:
2193: l_inv_amt_remaining ap_payment_schedules.amount_remaining%TYPE := 0;
2194: l_gross_amount ap_payment_schedules.gross_amount%TYPE := 0;
2195: l_payment_cross_rate ap_invoices_all.payment_cross_rate%TYPE :=0;
2196: l_payment_currency_code ap_invoices_all.payment_currency_code%TYPE;
2197:
2198: -- Debug variables
2199: l_debug_loc VARCHAR2(30) := 'Manual_Withhold_Tax';
2192:
2193: l_inv_amt_remaining ap_payment_schedules.amount_remaining%TYPE := 0;
2194: l_gross_amount ap_payment_schedules.gross_amount%TYPE := 0;
2195: l_payment_cross_rate ap_invoices_all.payment_cross_rate%TYPE :=0;
2196: l_payment_currency_code ap_invoices_all.payment_currency_code%TYPE;
2197:
2198: -- Debug variables
2199: l_debug_loc VARCHAR2(30) := 'Manual_Withhold_Tax';
2200: l_curr_calling_sequence VARCHAR2(2000);
2206: l_curr_calling_sequence := 'AP_INVOICE_LINES_UTILITY_PKG.'||l_debug_loc;
2207:
2208: SELECT nvl(payment_cross_rate,0), payment_currency_code
2209: INTO l_payment_cross_rate, l_payment_currency_code
2210: FROM ap_invoices_all
2211: WHERE invoice_id = p_invoice_id;
2212:
2213: SELECT sum(nvl(amount_remaining,0)), sum(nvl(gross_amount,0))
2214: INTO l_inv_amt_remaining, l_gross_amount
2235: * l_payment_cross_rate), l_payment_currency_code)),
2236: payment_status_flag = DECODE(payment_status_flag,'Y','P',payment_status_flag)
2237: where invoice_id = p_invoice_id;
2238:
2239: update ap_invoices
2240: set payment_status_flag = DECODE(payment_status_flag,'Y','P',payment_status_flag)
2241: where invoice_id = p_invoice_id ;
2242:
2243: END IF;