pears.NetDebtorsDaySalesOutstanding

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetDebtorsDaySalesOutstanding" IS 
{CREATE FUNCTION pears."NetDebtorsDaySalesOutstanding"( IN "pAccountCode" CHAR(12),IN "DaysInPeriod" INTEGER,IN "CutoffDate" DATE ) 
RETURNS DECIMAL(10,2)
BEGIN
  DECLARE "Outst" DECIMAL(10,2);
  DECLARE "Sales" DECIMAL(10,2);
  DECLARE "dStart" DATE;
  SET "dStart" = "dateadd"("dd",-1*("daysinperiod"-1),"CutoffDate");
  SET "Outst" = (SELECT "sum"("IQacDocumentOutstandingAmount"("DocumentID","CutOffDate")) FROM "iqacdocument" WHERE "AccountCode" = "pAccountCode" AND "ledgerid" = 'Sales' AND("fullyallocated" IS NULL OR "fullyallocated" > "CutOffDate"));
  SET "Sales" = (SELECT "sum"("amount") FROM "iqacdocument" WHERE "ledgerid" = 'Sales' AND "accountcode" = "pAccountCode" AND "accountingdate" BETWEEN "dstart" AND "cutoffdate" AND "documentclass" = 'Invoice');
  IF "isnull"("Sales",0) = 0 THEN
    RETURN NULL
  ELSE
    RETURN("Outst"/"sales")*"DaysInPeriod"
  END IF
END
}
  • database/procedures/pears_netdebtorsdaysalesoutstanding.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1