From 01f9e027252b87d21c76b8dad737a761e61bb1f7 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 8 Mar 2017 21:24:25 -0800 Subject: [PATCH] End of Month invoice terms, RT#74050 --- FS/FS/Conf.pm | 12 ++++++++++-- FS/FS/Template_Mixin.pm | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 8009b6592..8d575a650 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -696,8 +696,8 @@ logo.eps '', 'Payable upon receipt', 'Net 0', 'Net 3', 'Net 5', 'Net 7', 'Net 9', 'Net 10', 'Net 14', - 'Net 15', 'Net 18', 'Net 20', 'Net 21', 'Net 25', 'Net 30', 'Net 45', - 'Net 60', 'Net 90' + 'Net 15', 'Net 18', 'Net 20', 'Net 21', 'Net 25', 'End of Month', 'Net 30', + 'Net 45', 'Net 60', 'Net 90' ); my %msg_template_options = ( @@ -6261,6 +6261,14 @@ and customer address. Include units.', { key => "vonage-password", section => "deprecated", description => "DEPRECATED", type => "text" }, { key => "vonage-fromnumber", section => "deprecated", description => "DEPRECATED", type => "text" }, + { + 'key' => 'selfservice-db_profile', + 'section' => 'development', + 'description' => 'Enable collection and logging of database profiling information for self-service servers. This has significant overhead, do not leave enabled in production beyond that necessary to collect profiling data.', + 'type' => 'checkbox', + }, + + # for internal use only; test databases should declare this option and # everyone else should pretend it doesn't exist #{ diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 229c3adc1..8734a78b4 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -10,6 +10,7 @@ use vars qw( $invoice_lines @buf ); #yuck use List::Util qw(sum); #can't import first, it conflicts with cust_main.first use Date::Format; use Date::Language; +use Time::Local qw( timelocal ); use Text::Template 1.20; use File::Temp 0.14; use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); @@ -1919,6 +1920,12 @@ sub due_date { my $duedate = ''; if ( $self->terms =~ /^\s*Net\s*(\d+)\s*$/ ) { $duedate = $self->_date() + ( $1 * 86400 ); + } elsif ( $self->terms =~ /^End of Month$/ ) { + my ($mon,$year) = (localtime($self->_date) )[4,5]; + $mon++; + until ( $mon < 12 ) { $mon -= 12; $year++; } + my $nextmonth_first = timelocal(0,0,0,1,$mon,$year); + $duedate = $nextmonth_first - 86400; } $duedate; } -- 2.11.0