Can't apply a simple payment to an invoice - help!

I’m sorry, I’m having trouble again doing the simplest of tasks. A customer has sent me money, I want to send a (paid) invoice as a receipt.

This time I’m documenting each step to reproduce the problem because I’m obviously doing something wrong, but I can’t for the life of me see what. (Maybe due to “brain fog”, unfortunately I’m recovering from COVID this week!)

  1. Created a new invoice for the (existing) customer. The value matches the payment the customer has sent (£50). Saved it, but no email sent or payment recorded yet, therefore the status shows as grey “Draft” (correct?), “Paid to date” shows as 0.00 and “Amount” shows as £50.00. So far so good. I don’t want the customer to see it in this state because they would end up paying twice.

  2. Imported my latest bank transactions and located the transaction in question under “Transactions”. At this stage it shows as blue “Unmatched” as expected. I click on that and a panel opens at the right with a list of invoices. I can see the draft invoice I want to match this transaction to at the top of that list. I select it.

  3. As discussed in an earlier thread, the “Link payment” button doesn’t work here as you might expect, because there’s no payment created yet, only a transaction. So I click “Create Payment”. The status of the transaction changes to green “Converted” and a payment for the correct amount shows in the right window. I want to send a receipt email but there’s no such option, again because this is a transaction not a payment. So I click “Payments”.

  4. In the payments list I can see the payment I just created at the top of the list, but its status is blue “Unapplied”. This I don’t understand, it looks like a bug. Refreshing the list or waiting a while for a cron run doesn’t help. If I go to the “Invoices” list the status of the invoice in question has now changed to “Paid” and the “Balance Due” to 0.00 as expected. However…“Paid to Date” is 0.00 (bug?), and if I click “View PDF” the Balance Due is still $50.00, which is inconsistent (bug?).

  5. Things are clearly in an inconsistent state, so I try to fix them. I go back to the “Payments” page and select the “Unapplied” payment in question. I click the “Apply Payment” button at the bottom. A popup appears offering me the chance to “Convert Currency”. I don’t need that so I leave it disabled. I click “APPLY”. The popup closes but the status doesn’t change. I also try the “Apply Payment” option in the menu at the top right of the payment. Same result.

  6. I notice there is a “Send Email” option in the menu at the top right of the payment. I click that and an email is sent, so at least the customer has an acknowledgement. Except…the prominent “View Payment” in the middle of the button links to a page that shows the payment status as “Partially Unapplied” with “Amount” £50 and “Remaining” £50. So it’s actually 100% unapplied".

  7. I go back to the “Invoices” page and select the invoice (which shows as “Paid” but with incorrect details and PDF). If I click the payment in the right-hand pane I get a list that shows the payment with a green “Paid” button, contradicting the view on the “Payments” page (which hasn’t changed) (bug?). The “Delivery Note” incorrectly shows “Balance Due” as £50 (bug?). The customer portal correctly shows the invoice as “Paid” but again the “Balance Due” is still £50 (bug?).

I’m on version 5.8.57 - W160 self-hosted on Ubuntu 22.04.4, MariaDB 10.6.18, OLS 1.7.19, LSPHP 8.2.20. Happy to allow admin access if that helps.

I’m having trouble reproducing step 4, in my tests the payment is either completed or partially unapplied depending on whether the invoices matched the transaction amount or not.

Many thanks for trying. Is there more information I can supply? Would you like a copy of the database? Or screenshots of something? Or admin access? Are there further tests I could do?

I forgot to mention that there are no errors in the logs, but it’s a production environment so full debugging is not enabled.

Would exporting everything and re-importing to a clean installation work? I’m getting fairly desperate here because it has to be sorted by the end of the month.

It may help if you can provide screenshots.

@david do you have any ideas?

Sure. Here’s the “Transactions” screen…

Here’s the “Payments” screen

Here’s “Invoices”:

Here’s the incorrect PDF:

I think I see the problem, it seems to be related to the invoice status. If you first mark the invoice as sent it should resolve the problem.

cc @david

Here’s the contradictory invoice status showing the balance due as zero:

Er, how do I do that (without actually sending it, which will be very confusing if it shows as unpaid)?

You can select ‘Mark sent’ from the invoice actions

Not seeing that here…

Or here…

You’ll only see the option for draft invoices

But there’s a hole in the bucket!.. :slight_smile:

OK, so…refund the payment first?

This should help for future invoices.

To fix this invoice it may help to mark the payment as deleted.

I’ve unlinked the transaction and deleted the payment and those two screens look as expected. The invoice is still showing as “Paid” though. I can’t see any way to fix that. The “Reverse” option just creates a credit note. Other things I tried gave various error messages.

I’ve deleted the whole invoice and recreated it by hand (fortunately a simple one) and it does seem to have solved the problem, many thanks.

Fast reponse greatly appreciated. I have a backlog of urgent stuff to catch up on now but there were several quite serious bugs along the way here, should I raise reports for them?

Yes, please let us know about any problems you run into