====== pears.iqacSelfBillOneTimesheet ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."iqacSelfBillOneTimesheet"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "ptsid" char(20),in "pDocDate" date,in "pdocid" char(8),in "paccountcode" char(12) )
begin
declare "vrate" double;
-- loop over lines
for "timesheetlines" as "tslcursor" no scroll cursor for
select "l"."linenumber",-"l"."payrate" as "payrate","l"."unitspaid",
("l"."unitspaid"*-"l"."payrate") as "pay",
"selfbillnominalfortimesheetline"("l"."temptimesheetlineid","paccountcode") as "nominal",
"selfbilldescriptionfortimesheetline"("l"."temptimesheetlineid","paccountcode") as "descrip",
"selfbillvatcodefortimesheetline"("l"."temptimesheetlineid","paccountcode") as "vcode",
"l"."temptimesheetlineid",
"b"."unit"
from "temptimesheetline" as "l" key join "temppayband" as "b"
where "l"."temptimesheetid" = "ptsid"
and "pay" <> 0.0
order by "l"."linenumber" asc for read only
do -- invoice a line (pdocid)
select "vatrate" into "vrate" from "iqacvatrate" where "vatcode" = "vcode";
call "iqacCreateNominal"("nominal",'P','SelfBill Expenditure '+"nominal",'Purchase','NoAccount',null,null,"res");
call "iqacPostJournalLine"("pdocid","nominal","descrip","vcode","temptimesheetlineid",'',"payrate","vrate","unitspaid","pdocdate","unit",'T','InvoiceGoods','Purchase')
end for
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."iqacSelfBillOneTimesheet" IS
{create procedure iqacSelfBillOneTimesheet
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(
in ptsid char(20),in pDocDate date,in pdocid char(8), in paccountcode char(12) )
begin
declare vrate double;
-- loop over lines
for timesheetlines as tslcursor no scroll cursor for
select l.linenumber,-l.payrate as payrate,l.unitspaid,
(l.unitspaid*-l.payrate) as pay,
selfbillnominalfortimesheetline(l.temptimesheetlineid,paccountcode) as nominal,
selfbilldescriptionfortimesheetline(l.temptimesheetlineid,paccountcode) as descrip,
selfbillvatcodefortimesheetline(l.temptimesheetlineid,paccountcode) as vcode,
l.temptimesheetlineid,
b.unit
from temptimesheetline as l key join temppayband as b
where l.temptimesheetid = ptsid
and pay <> 0.0
order by l.linenumber asc for read only
do -- invoice a line (pdocid)
select vatrate into vrate from iqacvatrate where vatcode = vcode;
call iqacCreateNominal(nominal,'P','SelfBill Expenditure '+nominal,'Purchase','NoAccount',null,null,res);
call iqacPostJournalLine(pdocid,nominal,descrip,vcode,temptimesheetlineid,'',payrate,vrate,unitspaid,pdocdate,unit,'T','InvoiceGoods','Purchase')
end for
end
}