====== pears.iqacPostJournalLine ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."iqacPostJournalLine"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "pdocid" char(8),in "pnominalcode" char(12),in "pdescription" long varchar,in "pVATCode" char(3),in "pTimesheetLineID" char(20),in "pAccountCode" char(12),in "punitamount" double,
in "pVatRate" double,in "pquantity" double,in "pDocDate" date,in "pUnitDesc" char(20),in "pXRef" char(1),in "pclass" char(20),in "Ledger" char(8) default 'Sales' )
begin
declare "gamount" double;
declare "Vamount" double;
set "gamount" = "round"(-"pquantity"*"punitamount",2);
set "Vamount" = "round"("gamount"*"pVATrate"/100.0,2);
insert into "IQacJournal"( "DocumentID","LineNumber","NominalCode","AccountingDate",
"LedgerID","AccountCode","XRefID","XRef","Description","Amount","JournalClass","GoodsAmount",
"VATAmount","VATRate","VATCode","PriceEach","Quantity","ProductCode",
"UnitDescription","XRefDocumentID","XRefLineNumber","CashVATCode","CashVATAmount" ) values( "pdocid",
1+"isnull"((select "max"("LineNumber") from "iqacjournal" where "documentid" = "pdocid"),0),"pnominalcode","pdocdate",
if "pclass" = 'InvoiceControl' then "Ledger" endif,
"pAccountCode","pTimesheetLineID","pXRef",
"pdescription","GAmount","pclass",
if("pclass" = 'InvoiceControl') or("pclass" = 'InvoiceVAT') then 0 else "GAmount" endif,
"VAmount","pVatRate","pVATCode",
if("pclass" = 'InvoiceControl') or("pclass" = 'InvoiceVAT') then 0 else if "Ledger" = 'Purchase' then-"punitamount" else "punitamount" endif endif,
if("pclass" = 'InvoiceControl') or("pclass" = 'InvoiceVAT') then 0 else "pQuantity" endif,
"pTimesheetLineID","pUnitDesc",'',0,"pVATCode",0 )
exception
when others then
resignal
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."iqacPostJournalLine" IS
{create procedure iqacPostJournalLine
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(in pdocid char(8),in pnominalcode char(12),in pdescription long varchar,in pVATCode char(3),in pTimesheetLineID char(20),in pAccountCode char(12),in punitamount double,
in pVatRate double,in pquantity double,in pDocDate date,in pUnitDesc char(20),in pXRef char(1),in pclass char(20), in Ledger char(8) default 'Sales')
begin
declare gamount double;
declare Vamount double;
set gamount=round(-pquantity*punitamount,2);
set Vamount=round(gamount*pVATrate/100.0,2);
insert into IQacJournal( DocumentID,LineNumber,NominalCode,AccountingDate,
LedgerID,AccountCode,XRefID,XRef,Description,Amount,JournalClass,GoodsAmount,
VATAmount,VATRate,VATCode,PriceEach,Quantity,ProductCode,
UnitDescription,XRefDocumentID,XRefLineNumber,CashVATCode,CashVATAmount) values( pdocid,
1+isnull((select max(LineNumber) from iqacjournal where documentid = pdocid),0),pnominalcode,pdocdate,
if pclass = 'InvoiceControl' then Ledger
endif,pAccountCode,pTimesheetLineID,pXRef,
pdescription,GAmount,pclass,
if(pclass = 'InvoiceControl') or(pclass = 'InvoiceVAT') then 0 else GAmount endif,
VAmount,pVatRate,pVATCode,
if(pclass = 'InvoiceControl') or(pclass = 'InvoiceVAT') then 0 else if Ledger = 'Purchase' then -punitamount else punitamount endif endif,
if(pclass = 'InvoiceControl') or(pclass = 'InvoiceVAT') then 0 else pQuantity endif,
pTimesheetLineID,pUnitDesc,'',0,pVATCode,0)
exception
when others then
resignal
end
}