Show pageOld revisionsBacklinksExport to PDFFold/unfold allBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== pears.NetDebtorsDaySalesOutstanding ====== <WRAP center round info> Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. </WRAP> ===== Original SQL ===== <code sql> 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 } </code> database/procedures/pears_netdebtorsdaysalesoutstanding.txt Last modified: 2026/08/07 19:24by 127.0.0.1