diff options
author | Ivan Kohler <ivan@freeside.biz> | 2017-03-08 21:24:23 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2017-03-08 21:24:23 -0800 |
commit | 5eb48cca81177ae5336fd014808eefe5cc75c8f4 (patch) | |
tree | e60cc6c02b3e6305b1bb7ead0b004608457e5c18 /FS/FS/Template_Mixin.pm | |
parent | 1c0d446903667479a85385015cc5fa1dda60a280 (diff) |
End of Month invoice terms, RT#74050
Diffstat (limited to 'FS/FS/Template_Mixin.pm')
-rw-r--r-- | FS/FS/Template_Mixin.pm | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 5d7fe32..3e027d3 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 ); @@ -1924,6 +1925,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; } |