I found that the function was applying payments to the same billing lines. For each payment row, it would start over at the first billing row again. I added logic to keep track of the billing row. I also corrected an issue with voided billing rows by sorting the query by voided.
I went ahead and put this in my working branch. I committed the original code from Jeff and Mike. Then I committed my changes.
http:// git.evergreen- ils.org/ ?p=working/ Evergreen. git;a=commit; h=b37eb844ea811 05c6ee7601b397f 86c747b321c6
I found that the function was applying payments to the same billing lines. For each payment row, it would start over at the first billing row again. I added logic to keep track of the billing row. I also corrected an issue with voided billing rows by sorting the query by voided.