Sunday, August 31, 2008

How to create an invoice using autoinvoice

Insert a row in ra_interface_lines_all. A sample script with bare minimum data for the invoice is something like this:

declare
l_trx_number VARCHAR2(20);
l_no_of_lines NUMBER := &no_of_lines;
l_no_of_invoices NUMBER := &no_of_invoices;
begin
mo_global.set_policy_context('S',204);
for j in 1..l_no_of_invoices loop
select ra_customer_trx_s.nextval into l_trx_number from dual;
for i in 1..l_no_of_lines loop
insert into ra_interface_lines
(BATCH_SOURCE_NAME,
SET_OF_BOOKS_ID,
LINE_TYPE,
DESCRIPTION,
CURRENCY_CODE,
AMOUNT,
CONVERSION_TYPE ,
CONVERSION_DATE ,
CONVERSION_RATE ,
QUANTITY,
INTERFACE_LINE_CONTEXT,
INTERFACE_LINE_ATTRIBUTE1,
INTERFACE_LINE_ATTRIBUTE2,
orig_system_bill_customer_id,
orig_system_bill_address_id,
primary_salesrep_id,
inventory_item_id,
uom_code,
CUST_TRX_TYPE_ID,
CUST_TRX_TYPE_NAME,
trx_number,
TERM_ID,
TERM_NAME,
org_id
)
VALUES
('PROJECTS INVOICES',
1,
'LINE',
'Project Invoices',
'USD',
100.00*i,
'User',
trunc(sysdate),
1,
null,
'LEGACY',
l_trx_number,
i,
1007,
1039,
1008,
155,
'Ea',
2998,
'test_7347859',
l_trx_number,
4,
'30 Net',
204
) ;
end loop;
end loop;
commit;
end;


After the row is inserted successfully, run 'Autoinvoice Import Program'.

View->Requests->Submit a new request. Select 'Autoinvoice Import Program' from the LOV.



The parameter form looks like this:




You can give a range of GL dates ,transaction number,etc (from high to low).
The autoinvoice program has its own sets of validations. If the record inserted in ra_interface_lines_all violates any validation, autoinvoice program points that in the output. I will keep posting as and when I'll come accross those errors along with their solutions.