Detailed Description

The routine takes the values in the Debtors account (parameter 2) and Sales account (parameter 3) for the current period and compares them. If either are zero or negative, the calculation stops. For each successive period where the debtors value exceeds that of the cumulative sales (working backwards from the current period), the routine adds the number of days for that period as specified in the days in the Period account (parameter 4) to a running total.

When all the Debtors values has been "exhausted" in this way, the final period’s days are calculated as a proportion of the unexpired debtors against the periodic sales value.

Finally, the routine posts the running total to the destination account (parameter 1).