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
}