Oracle
Upload new projectItem
Date modified
Status
153. AI translator
04-10-2023
Done
Preview
153. AI translator
04-10-2023
Done
Preview
Block diagram
REATE OR REPLACE PACKAGE BODY pa_invoice AS
--
FUNCTION fu_next_inv_no RETURN NUMBER IS
--
CURSOR c_next_ino IS
SELECT cc_next_value, cc_increment
FROM cg_code_controls
WHERE cc_domain = 'INV_SEQ'
FOR UPDATE OF cc_next_value NOWAIT;
--
l_ino NUMBER;
l_inc NUMBER;
l_found BOOLEAN;
--
BEGIN
--
SAVEPOINT sp_next_ino;
OPEN c_next_ino;
FETCH c_next_ino INTO l_ino, l_inc;
l_found := c_next_ino%FOUND;
CLOSE c_next_ino;
--
IF l_found THEN
--
UPDATE cg_code_controls
SET cc_next_value = cc_next_value + cc_increment
WHERE cc_domain = 'INV_SEQ';
--
ELSE
--
l_ino := NULL;
--
END IF;
--
RETURN ( l_ino );
--
EXCEPTION
--
WHEN OTHERS THEN
ROLLBACK TO sp_next_ino;
RAISE;
--
END fu_next_inv_no;
--
PROCEDURE pr_new_invoice
(
p_act_id IN invoices.act_id %TYPE,
p_inv_date IN invoices.inv_date %TYPE,
p_sent_date IN invoices.sent_date %TYPE,
p_amount IN transactions.amount %TYPE,
p_descr IN transactions.descr %TYPE,
p_inv_id IN OUT invoices.id %TYPE
) IS
--
l_trn_id transactions.id %TYPE;
--
BEGIN
--
IF p_inv_id IS NULL THEN
--
p_inv_id := fu_next_inv_no;
--
END IF;
--
INSERT INTO invoices
(
id,
act_id,
inv_date,
paid_date,
sent_date
)
VALUES
(
p_inv_id,
p_act_id,
p_inv_date,
NULL,
p_sent_date
);
--
INSERT INTO transactions
(
id,
ttp_code,
trans_date,
act_id,
inv_id,
descr,
print_yn,
amount
)
VALUES
(
trn_SEQ.NEXTVAL,
'INVL',
p_inv_date,
p_act_id,
p_inv_id,
p_descr,
'N',
p_amount
)
RETURNING id INTO l_trn_id;
--
pr_upd_inv_sub_tot ( p_inv_id, l_trn_id );
pr_upd_inv_grp_tot ( p_inv_id, l_trn_id );
pr_upd_inv_vat ( p_inv_id, l_trn_id );
pr_upd_inv_tot ( p_inv_id, l_trn_id );
--
EXCEPTION
--
WHEN OTHERS THEN
ROLLBACK;
RAISE_APPLICATION_ERROR ( -20001, 'pr_new_invoice:' || sqlerrm );
--
END pr_new_invoice;
--
Procedures and Functions | Table Name | fu_next_inv_no | pr_new_invoice | pr_upd_inv_sub_tot | pr_upd_inv_grp_tot | pr_upd_inv_vat | pr_upd_inv_tot | pr_add_tsheet | pr_get_invoice | pr_merge_invoices | pr_copy_invoice |
---|---|---|---|---|---|---|---|---|---|---|
CG_CODE_CONTROLS | -RU- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | --U- | ---- |
INVOICES | ---- | C--- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
TRANSACTIONS | ---- | C--- | C-U- | C-U- | C-U- | C-U- | C--- | ---- | --UD | ---- |
TIMESHEETS | ---- | ---- | ---- | ---- | ---- | ---- | -R-- | ---- | ---- | ---- |
TRANS_LINKS | ---- | ---- | C--- | C--- | C--- | C--- | C--- | ---- | ---D | ---- |
FUNCTION pr_get_invoice ( p_inv_id IN NUMBER ) RETURN CLOB
This is a function in `pa_invoice` package called `pr_get_invoice`. It accepts an Invoice ID as an input parameter `p_inv_id`, which is a number and returns a CLOB.
The function generates a structured and formatted HTML invoice document related to the given Invoice ID.
The function executes various cursors for retrieving different information related to the invoice:
Html tags along with CSS are used for invoice formatting (like, font size, style, color etc.). Finally, the invoice `sen_date` is updated to the current date for the given invoice id.
Table | Coulmn | CRUD |
---|---|---|
INVOICES | SENT_DATE | --Y- |
INVOICES | ID | -Y-- |
INVOICES | INV_DATE | -Y-- |
ACCOUNTS | ID | -Y-- |
ACCOUNTS | NAME | -Y-- |
ACCOUNTS | ADDRESS | -Y-- |
TRANSACTIONS | TTP_CODE | -Y-- |
TRANSACTIONS | DESCR | -Y-- |
TRANSACTIONS | AMOUNT | -Y-- |
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'EXPORT_300',
job_type => 'PLSQL_BLOCK',
job_action => '
BEGIN
pa_exp_300.pr_main ( p_run_date => TRUNC (SYSDATE-1) );
COMMIT;
END;
',
start_date => TO_TIMESTAMP( 'null' ),
repeat_interval => 'FREQ=DAILY; BYHOUR=2; BYMINUTE=15;',
schedule_name => 'null',
enabled => FALSE,
comments => 'null' );
END;
/
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'LOAD_102',
job_type => 'PLSQL_BLOCK',
job_action => '
BEGIN
pa_load_102.pr_main ( p_run_date => TRUNC (SYSDATE-1) );
COMMIT;
END;
',
start_date => TO_TIMESTAMP( 'null' ),
repeat_interval => 'FREQ=DAILY; BYHOUR=6,10,14,18,20; BYMINUTE=15;',
schedule_name => 'null',
enabled => FALSE,
comments => 'null' );
END;
/
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'LOAD_105',
job_type => 'PLSQL_BLOCK',
job_action => '
BEGIN
pa_load_105.pr_main;
COMMIT;
END;
',
start_date => TO_TIMESTAMP( 'null' ),
repeat_interval => 'FREQ=DAILY; BYHOUR=6; BYMINUTE=30;',
schedule_name => 'null',
enabled => FALSE,
comments => 'null' );
END;
/
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'LOAD_120',
job_type => 'PLSQL_BLOCK',
job_action => '
BEGIN
pa_load_120.pr_main;
COMMIT;
END;
',
start_date => TO_TIMESTAMP( 'null' ),
repeat_interval => 'FREQ=WEEKLY; BYDAY=SUN,WED; BYHOUR=8; BYMINUTE=00;',
schedule_name => 'null',
enabled => FALSE,
comments => 'null' );
END;
/
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'SEND_INVOICES',
job_type => 'PLSQL_BLOCK',
job_action => '
BEGIN
pa_ivoices.send_invoices;
COMMIT;
END;
',
start_date => TO_TIMESTAMP( 'null' ),
repeat_interval => 'FREQ=WEEKLY; BYDAY=FRI; BYHOUR=2; BYMINUTE=00;',
schedule_name => 'null',
enabled => FALSE,
comments => 'null' );
END;
/
Number of Rows: | 1,823 (as at {DATE}) |
---|---|
Child Tables: | {list of tables that have this as a parent table} |
Parents Tables: | {list of tables that have this as a child table} |
Organisation: | {Partitioning details} |
Column | Type | Mandatory | Default | FK Parent | FK Child |
---|---|---|---|---|---|
ID | NUMBER(6) | Y | Y | ||
ACT_ID | NUMBER(6) | Y | Y | Y | |
INV_DATE | DATE | Y | Y | ||
PAID_DATE | DATE | Y | Y | ||
SENT_DATE | DATE | Y | Y | ||
PRINT_IMAGE | LONG | Y | Y |
Modules | INSERT (C) | SELECT (R) | UPDATE (U) | DELETE (D) |
---|---|---|---|---|
PA_INVOICE | C | R | U | D |
PA_TRANSACTIONS | R |
Job | Timing | SELECT (C) | SELECT (R) | UPDATE (U) | DELETE (D) |
---|---|---|---|---|---|
SEND_INVOICES | Every Friday at 2AM | C | R | U | - |