Created attachment 2370 [details] should be $0 due I hope I'm wrong on this - but see the attached screenshots for 2 different patrons on HEAD. Their fines are not adding up.
Created attachment 2371 [details] should be $293
Investigating this and it seems more of a problem with manual credits than a problem with the fines calculation. The second example (balance 93) could well be correct. Where the amount outstanding is 0.00 indicates that that fine has been paid in full. The last 4 lines can be paired up so you have two invoice lines and two corresponding credit lines, each with amount outstanding now zero so the credit lines have been used to pay the invoice lines. On an old but still recent version of koha when you enter a manual credit the outstanding column also displays the negative value and the total makes sense. Testing on latest head though and it's easy to add a manual credit which gets entered as having no amount outstanding but without actually subtracting from any invoices with an amount outstanding. This leads to discrepancy in the total and I think the first example illustrates that situation. To my mind, when a manual credit is entered and it is to pay off outstanding invoices or part of, there should be a selection process to select which items are to be paid off and in which order. The interface for this and use cases need to be thought through. Potentially the old implementation for manual credits should be re-instated as current implementation appears buggy. I will continue to investigate this issue and try and track down the exact cause.
I thought I had been able to reproduce this originally but don't seem to be able to now I'm looking at it again. Can you note down the steps taken? Note that the second attachment does look like it adds up correctly given writeoff and payment received lines but the first one definitely seems off.
I'm closing this bug because I'm not sure now that it was a bug - it might have just been my math skills ;) If someone else can reproduce feel free to reopen.