From 22dd0016d0938f6acb2127d8168a4a1c5e296d3f Mon Sep 17 00:00:00 2001 From: Mitch Jackson Date: Wed, 15 Nov 2017 07:51:40 +0000 Subject: [PATCH] Fixed invoice inconsistencies with various conf flags RT#78190 Applying different invoicing conf flags manifested different variations of the same problem. Addressed by this fix: - Incorrect items listed for Previous Balance - Incorrect Items listed for applied payments and credits - Incorrect subtotals for various sections - Invoice amounts, subtotals, balances displayed did not reconcile. Because of which data was selected for display, columns could appear to have bad math. No account balances were factually incorrect. - Items disappearing from invoices used a payment receipts or "statements" giving a false impression of overpayment or credits - Applied payments or credits appearing on the wrong statements - A single applied credit appearing on up to 3 invoices - When viewing older invoices, future payments for future bills shown on, and appearing to apply to, the older invoice - Inconsistencies of line items and numbers between website, email, pdf and txt version invoices. - Invoice summary page numbers not matching the invoice - Incorrect balances shown on on aging line - Update item order on invoice_htmlsummary mason template Conf flags involved in these issues: - disable_previous_balance - previous_balance-payments_since - previous_balance-summary_only - previous_balance-show_on_statements - previous_balance-section - previous_balance-exclude_from_total - invoice_include_aging - invoice_show_prior_due_date - invoice_usesummary New invoice template stash variables made available: - aged_balance_current - aged_balance_30d - aged_balance_60d - aged_balance_90d Solved by updating, or creating, FS::cust_bill helper methods that generate data to be displayed on invoices. These helper methods are responsive to various conf flags. Updated template pipeline to use these helpers instead of inconsistent sql queries. Resolves: #78190 See Also: #75709, #76161, #74426 --- FS/FS/Template_Mixin.pm | 527 ++++++++++++----------- FS/FS/cust_bill.pm | 1042 +++++++++++++++++++++++++++++++++++++--------- conf/invoice_htmlsummary | 39 +- 3 files changed, 1111 insertions(+), 497 deletions(-) diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 7dc813993..7d92d21af 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -29,9 +29,9 @@ use FS::L10N; $DEBUG = 0; $me = '[FS::Template_Mixin]'; -FS::UID->install_callback( sub { +FS::UID->install_callback( sub { my $conf = new FS::Conf; #global - $money_char = $conf->config('money_char') || '$'; + $money_char = $conf->config('money_char') || '$'; $date_format = $conf->config('date_format') || '%x'; #/YY } ); @@ -121,7 +121,7 @@ default is now. It isn't the date of the invoice; that's the `_date' field. It is specified as a UNIX timestamp; see L. Also see L and L for conversion functions. -I