Chance Posted December 26, 2024 Report Posted December 26, 2024 The Transactions Model has two methods named add() and apply() which both accept a date parameter. Blesta does store that provided date in the transactions and transaction_applied tables as desired. But when Blesta uses the apply() method to apply a transaction, line #802 of the Transactions Model invokes the setClosed() method of the Invoices Model. The setClosed() method of the Invoices Model does NOT honor the specified date. Instead, it uses current date/time EVERY time. Whatever transaction causes the invoice to be paid in full is the date Blesta should record in the date_closed field for the invoice(s). The date used in date_closed field should be one of: 1) The date specified by admin (or gateway callback), or 2) Default to current date/time (ONLY if #1 is missing (or invalid)). To make this possible, the Invoices Model should accept an optional date parameter/variable in its setClosed() method. When the Transactions Model is used to apply a transaction to an invoice, it should pass the same date parameter to the Invoices Model. In turn, the Invoices Model should set the date_closed field using the provided date, or default date if a date is not passed. Example: $this->Invoices->setClosed($invoice_id, $the_date_transaction_applied) // date is provided so this date used $this->Invoices->setClosed($invoice_id) // no date given so will default to current date/time This issue was discovered after running a WHMCS import. You can replicate this easily: 1) Create an invoice for 10.00, 2) Record a manual payment of 10.00, and set the date received to any date other than the current. Make sure the payment amount matches invoice amount so the invoice will be considered paid in full when saving the payment, 3) Visit the list of invoices. Notice the Date Closed column on this invoice does NOT match the date you entered when recording the payment transaction that closed the invoice. While this is not a runtime type error, it is a general accounting error in that clients viewing their invoices will NEVER see their invoices as being closed on the same day they were paid in full. Not a big deal when we are talking just a day or two between the dates....but after importing over 10,000 invoices over a 15 year period, it looks really strange to see an invoice closed on 12/26/2024 when it was paid in full on 4/16/2016 (8.5 years ago). Just as weird to see years and years of invoices dating back 13 years all being closed on the same day 12/23/2024. This is an easy fix in the setClosed() method of Invoices Model on our developer test install but it should be incorporated as an official Blesta fix. Please consider. Quote
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.