1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
FOR unites_operationnelles in ( SELECT distinct org_id
FROM xxbp_prov_factures_annulees
WHERE code_annulation in ('AT')
)
LOOP
XXBP_AP_PROVISIONS_PKG.connection_oa_p(unites_operationnelles.org_id);
FOR factures in ( SELECT set_of_books_id,
invoice_id,
period_name,
check_id
FROM xxbp_prov_factures_annulees
WHERE org_id = unites_operationnelles.org_id
AND code_annulation in ('AT')
)
LOOP
BEGIN
v_result_annulation := AP_CANCEL_PKG.ap_cancel_single_invoice
( P_invoice_id => factures.invoice_id,
P_last_updated_by => 0,
P_last_update_login => 0,
P_set_of_books_id => factures.set_of_books_id,
P_accounting_date => TRUNC(sysdate),
P_period_name => factures.period_name,
P_message_name => v_message_name,
P_invoice_amount => v_invoice_amount,
P_base_amount => v_base_amount,
P_tax_amount => v_tax_amount,
P_temp_cancelled_amount => v_temp_cancelled_amount,
P_cancelled_by => v_cancelled_by,
P_cancelled_amount => v_cancelled_amount,
P_cancelled_date => v_cancelled_date,
P_last_update_date => v_last_update_date,
P_original_prepayment_amount => v_original_prepayment_amount,
P_check_id => factures.check_id,
P_pay_curr_invoice_amount => v_pay_curr_invoice_amount,
P_calling_sequence => 'APXINWKB'
);
EXCEPTION
WHEN OTHERS THEN
v_message_name := SQLCODE||' '||SQLERRM;
END;
UPDATE xxbp_prov_factures_annulees
SET code_annulation = decode(v_message_name, null, 'OK', 'KO'),
message_annulation = v_message_name
WHERE invoice_id = factures.invoice_id;
UPDATE ap_invoice_distributions_all aida
SET global_attribute2 = 'Y'
WHERE cancellation_flag = 'Y'
AND last_updated_by = 0
AND invoice_id = factures.invoice_id;
COMMIT;
END LOOP;
END LOOP; |
Partager