====== pears.NetReportAgedDebtors ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetReportAgedDebtors"( in "pwebuserid" char(20),in "Date__D31a" char(20) )
-- RESULT( column_name column_type, ... )
begin
declare "repdate" date;
declare "divid" char(20);
set "repdate" = "iqxnetstringtodate"("Date__D31a");
set "divid" = (select first "staff"."divisionid" from "iqxnetuser" key join "staff" where "iqxnetuser"."iqxnetuserid" = "pwebuserid");
select "IQAcA"."AccountCode",
"IQAcA"."Name",
"IQAcD"."AccountingDate" as "AcDate",
"IQAcD"."DocumentID",
"IQAcD"."DocumentType" as "TranType",
"IQAcD"."OurRef",
"IQAcD"."Amount",
"IQacDocumentOutstandingAmount"("IQAcD"."documentid",:REPDATE) as "OutStanding",
"IQAcD"."XRefID" as "PlacementID",
"IQAcD"."TheirRef",
"repdate"-"AcDate" as "Age"
from "IQacDocument" as "IQAcD" key join "IQacAccount" as "IQacA"
where "IQAcD"."LedgerID" = 'Sales'
and "AcDate" <= "date"(:REPDATE)
and("fullyallocated" is null or "fullyallocated" > "date"(:REPDATE))
order by "IQAcA"."Name" asc,"AcDate" asc
end
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetReportAgedDebtors" IS
{create procedure pears."NetReportAgedDebtors"( in "pwebuserid" char(20),in "Date__D31a" char(20) )
-- RESULT( column_name column_type, ... )
begin
declare "repdate" date;
declare "divid" char(20);
set "repdate" = "iqxnetstringtodate"("Date__D31a");
set "divid" = (select first "staff"."divisionid" from "iqxnetuser" key join "staff" where "iqxnetuser"."iqxnetuserid" = "pwebuserid");
select "IQAcA"."AccountCode",
"IQAcA"."Name",
"IQAcD"."AccountingDate" as "AcDate",
"IQAcD"."DocumentID",
"IQAcD"."DocumentType" as "TranType",
"IQAcD"."OurRef",
"IQAcD"."Amount",
"IQacDocumentOutstandingAmount"("IQAcD"."documentid",:REPDATE) as "OutStanding",
"IQAcD"."XRefID" as "PlacementID",
"IQAcD"."TheirRef",
"repdate"-"AcDate" as "Age"
from "IQacDocument" as "IQAcD" key join "IQacAccount" as "IQacA"
where "IQAcD"."LedgerID" = 'Sales'
and "AcDate" <= "date"(:REPDATE)
and("fullyallocated" is null or "fullyallocated" > "date"(:REPDATE))
order by "IQAcA"."Name" asc,"AcDate" asc
end
}