bear Posted August 8 Share Posted August 8 Client has a small overpayment. It was added as a transaction and the next invoice was paid using it. The invoice is marked as paid, but the line says this in the email: Credit Applied: $0.00 USD. The ledger on the invoice shows it was applied, but strangely: Type: Client Account Debit, with "Applied Credit Note funded by Client Credit" for the description. As far as the client could see, it was paid, but no idea how. My clients don't typically log in and review, but just look for the email. This used to work back in the day, quite simply. Now it's confusing for admins, and worse, clients. Can it be made to show this (latest version WHMCS)? Not seeing any merge fields that might do it. 1 Quote Link to comment Share on other sites More sharing options...
Damo Posted August 8 Share Posted August 8 There is no way we have found. Occasionally customers double pay the same invoice. In v8 it would put the account in credit, then the credit balance would get used and shown on the invoice (not as the transaction at the bottom). v9 has changed this behaviour. And transactions are applied different ways and shown differently in the emails and PDFs Have you tried viewing the client account statement? 1 Quote Link to comment Share on other sites More sharing options...
bear Posted August 8 Author Share Posted August 8 (edited) Fun. Quote Error: Call to a member function lte() on false in /home/xxxx/public_html/clients/modules/reports/client_statement.php:194 Stack trace: #0 /home/xxxx/public_html/clients/xxxx/reports.php(0): unknown() #1 {main} Looks like it may be just the one client has the error, but don't see how this will help resolve the confusion. Edited August 8 by bear 1 Quote Link to comment Share on other sites More sharing options...
Damo Posted August 8 Share Posted August 8 Sadly it doesn't resolve the confusion. It does contribute to showing that it's broken. I had to look at the transactions list to be able to make some sense of these changes. Customising the email templates is something I did to reduce confusion. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted August 8 Author Share Posted August 8 Likely have to do the same with the templates. Something akin to "if your invoice is marked as paid while you hadn't yet submitted a new payment...." Was WHMCS made aware of this, do you know? A search reveals the error may be caused by malformed dates in either transactions or invoices. Searching this client, they have two old invoices (long before v9) that were canceled when they decided to drop a few domains. The canceled ones have date paid as "0000-00-00" (along with timestamp of zeros), which might be causing it. No way to fix it, since invoices are immutable within WHMCS now, even to the point of deleting canceled ones. Also can't add a date in that paid field, since that would indicate it's paid.... What a mess. 0 Quote Link to comment Share on other sites More sharing options...
Waqas Ahmed Waseer Posted 2 hours ago Share Posted 2 hours ago This caught me out after moving to 9 as well. The 9.0 docs page on Credit and Debit Notes explains what changed: when client credit is applied to an invoice (by hand, or automatically when the invoice is generated), WHMCS now creates a credit note for that amount and settles the invoice through the ledger. That's where your "Applied Credit Note funded by Client Credit" line comes from. The old {$invoice_credit} merge field doesn't seem to follow it, so the email shows 0.00 even though the credit did the paying. Until WHMCS maps this into the template, my workaround is to work the figure out in an EmailPreSend hook and hand it to the template as a new merge field. EmailPreSend can return extra merge fields, so something like this in /includes/hooks/invoice_credit_mergefield.php: <?php add_hook('EmailPreSend', 1, function ($vars) { if (!in_array($vars['messagename'], ['Invoice Payment Confirmation', 'Invoice Created'])) { return []; } $inv = localAPI('GetInvoice', ['invoiceid' => (int) $vars['relid']]); if (($inv['result'] ?? '') !== 'success') { return []; } $paid = 0.0; foreach ($inv['transactions']['transaction'] ?? [] as $t) { $paid += (float) $t['amountin'] - (float) $t['amountout']; } $covered = max(0, (float) $inv['total'] - $paid - (float) $inv['balance']); return ['invoice_credit_applied' => number_format($covered, 2)]; }); Then in the template: Credit Applied: {$invoice_credit_applied} One thing to check before you rely on it: run GetInvoice on one of the affected invoices and see whether the credit application shows up in the transactions array. If 9 records it there as a transaction (your "Client Account Debit" type suggests it might), the subtraction above will come out as 0. In that case, sum just those rows by their gateway/description instead. Test it on a dev copy or with a test client first, because a broken EmailPreSend hook affects every outgoing email. About the statement error: "lte() on false" means a date comparison ran on a date that failed to parse, so the 0000-00-00 datepaid on those old cancelled invoices is a very likely cause. I'd send WHMCS support that stack trace along with the two invoice IDs and report it as a bug, rather than editing the rows in the database. In 9 the ledger and the immutability checks depend on those records. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted 18 minutes ago Author Share Posted 18 minutes ago 1 hour ago, Waqas Ahmed Waseer said: my workaround Though I appreciate the response, I also could have asked AI and copy/pasted the entire thing. All all of your replies I checked appear to be 100% AI generated, please don't bother replying to my posts, if possible. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.