projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2317823
)
per-customer option to force anniversary packages to prorate, #38191
author
Mark Wells
<mark@freeside.biz>
Thu, 13 Oct 2016 22:35:26 +0000
(15:35 -0700)
committer
Mark Wells
<mark@freeside.biz>
Fri, 14 Oct 2016 22:06:19 +0000
(15:06 -0700)
FS/FS/Schema.pm
patch
|
blob
|
history
FS/FS/cust_main.pm
patch
|
blob
|
history
FS/FS/part_pkg/flat.pm
patch
|
blob
|
history
FS/FS/part_pkg/prorate_calendar.pm
patch
|
blob
|
history
FS/FS/part_pkg/recur_Common.pm
patch
|
blob
|
history
FS/FS/part_pkg/subscription.pm
patch
|
blob
|
history
httemplate/edit/cust_main/billing.html
patch
|
blob
|
history
diff --git
a/FS/FS/Schema.pm
b/FS/FS/Schema.pm
index
2acbe3d
..
26fa08d
100644
(file)
--- a/
FS/FS/Schema.pm
+++ b/
FS/FS/Schema.pm
@@
-1210,6
+1210,7
@@
sub tables_hashref {
'accountcode_cdr', 'char', 'NULL', 1, '', '',
'billday', 'int', 'NULL', '', '', '',
'prorate_day', 'int', 'NULL', '', '', '',
'accountcode_cdr', 'char', 'NULL', 1, '', '',
'billday', 'int', 'NULL', '', '', '',
'prorate_day', 'int', 'NULL', '', '', '',
+ 'force_prorate_day', 'char', 'NULL', 1, '', '',
'edit_subject', 'char', 'NULL', 1, '', '',
'locale', 'varchar', 'NULL', 16, '', '',
'calling_list_exempt', 'char', 'NULL', 1, '', '',
'edit_subject', 'char', 'NULL', 1, '', '',
'locale', 'varchar', 'NULL', 16, '', '',
'calling_list_exempt', 'char', 'NULL', 1, '', '',
diff --git
a/FS/FS/cust_main.pm
b/FS/FS/cust_main.pm
index
90b93f2
..
7e1a25d
100644
(file)
--- a/
FS/FS/cust_main.pm
+++ b/
FS/FS/cust_main.pm
@@
-1853,6
+1853,7
@@
sub check {
|| $self->ut_floatn('credit_limit')
|| $self->ut_numbern('billday')
|| $self->ut_numbern('prorate_day')
|| $self->ut_floatn('credit_limit')
|| $self->ut_numbern('billday')
|| $self->ut_numbern('prorate_day')
+ || $self->ut_flag('force_prorate_day')
|| $self->ut_flag('edit_subject')
|| $self->ut_flag('calling_list_exempt')
|| $self->ut_flag('invoice_noemail')
|| $self->ut_flag('edit_subject')
|| $self->ut_flag('calling_list_exempt')
|| $self->ut_flag('invoice_noemail')
diff --git
a/FS/FS/part_pkg/flat.pm
b/FS/FS/part_pkg/flat.pm
index
e10094e
..
8c24882
100644
(file)
--- a/
FS/FS/part_pkg/flat.pm
+++ b/
FS/FS/part_pkg/flat.pm
@@
-177,6
+177,12
@@
sub calc_recur {
sub cutoff_day {
my $self = shift;
my $cust_pkg = shift;
sub cutoff_day {
my $self = shift;
my $cust_pkg = shift;
+ my $cust_main = $cust_pkg->cust_main;
+ # force it to act like a prorate package, is what this means
+ # because we made a distinction once between prorate and flat packages
+ if ( $cust_main->force_prorate_day and $cust_main->prorate_day ) {
+ return ( $cust_main->prorate_day );
+ }
if ( $self->option('sync_bill_date',1) ) {
my $next_bill = $cust_pkg->cust_main->next_bill_date;
if ( defined($next_bill) ) {
if ( $self->option('sync_bill_date',1) ) {
my $next_bill = $cust_pkg->cust_main->next_bill_date;
if ( defined($next_bill) ) {
diff --git
a/FS/FS/part_pkg/prorate_calendar.pm
b/FS/FS/part_pkg/prorate_calendar.pm
index
c50cae0
..
a8ed8f9
100644
(file)
--- a/
FS/FS/part_pkg/prorate_calendar.pm
+++ b/
FS/FS/part_pkg/prorate_calendar.pm
@@
-72,7
+72,11
@@
sub check {
sub cutoff_day {
my( $self, $cust_pkg ) = @_;
my @periods = @{ $freq_cutoff_days{$self->freq} };
sub cutoff_day {
my( $self, $cust_pkg ) = @_;
my @periods = @{ $freq_cutoff_days{$self->freq} };
- my @cutoffs = ($self->option('cutoff_day') || 1); # Jan 1 = 1
+ my $prorate_day = $cust_pkg->cust_main->prorate_day
+ || $self->option('cutoff_day')
+ || 1;
+
+ my @cutoffs = ($prorate_day);
pop @periods; # we don't care about the last one
foreach (@periods) {
push @cutoffs, $cutoffs[-1] + $_;
pop @periods; # we don't care about the last one
foreach (@periods) {
push @cutoffs, $cutoffs[-1] + $_;
diff --git
a/FS/FS/part_pkg/recur_Common.pm
b/FS/FS/part_pkg/recur_Common.pm
index
3573cf1
..
07355f6
100644
(file)
--- a/
FS/FS/part_pkg/recur_Common.pm
+++ b/
FS/FS/part_pkg/recur_Common.pm
@@
-41,13
+41,14
@@
sub cutoff_day {
# prorate/subscription only; we don't support sync_bill_date here
my( $self, $cust_pkg ) = @_;
my $recur_method = $self->option('recur_method',1) || 'anniversary';
# prorate/subscription only; we don't support sync_bill_date here
my( $self, $cust_pkg ) = @_;
my $recur_method = $self->option('recur_method',1) || 'anniversary';
- return () unless $recur_method eq 'prorate'
- || $recur_method eq 'subscription';
+ my $cust_main = $cust_pkg->cust_main;
- #false laziness w/prorate.pm::cutoff_day
- my $prorate_day = $cust_pkg->cust_main->prorate_day;
- $prorate_day ? ( $prorate_day )
- : split(/\s*,\s*/, $self->option('cutoff_day', 1) || '1');
+ if ( $cust_main->force_prorate_day and $cust_main->prorate_day ) {
+ return ( $cust_main->prorate_day );
+ } elsif ($recur_method eq 'prorate' || $recur_method eq 'subscription') {
+
+ return split(/\s*,\s*/, $self->option('cutoff_day', 1) || '1');
+ }
}
sub calc_recur_Common {
}
sub calc_recur_Common {
diff --git
a/FS/FS/part_pkg/subscription.pm
b/FS/FS/part_pkg/subscription.pm
index
0dfe049
..
bf644d4
100644
(file)
--- a/
FS/FS/part_pkg/subscription.pm
+++ b/
FS/FS/part_pkg/subscription.pm
@@
-88,6
+88,11
@@
use FS::part_pkg::flat;
sub calc_recur {
my($self, $cust_pkg, $sdate, $details, $param ) = @_;
my $cutoff_day = $self->option('cutoff_day', 1) || 1;
sub calc_recur {
my($self, $cust_pkg, $sdate, $details, $param ) = @_;
my $cutoff_day = $self->option('cutoff_day', 1) || 1;
+ my $cust_main = $cust_pkg->cust_main;
+ if ( $cust_main->force_prorate_day and $cust_main->prorate_day ) {
+ $cutoff_day = $cust_main->prorate_day;
+ }
+
my $mnow = $$sdate;
my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($mnow) )[0,1,2,3,4,5];
my $mnow = $$sdate;
my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($mnow) )[0,1,2,3,4,5];
diff --git
a/httemplate/edit/cust_main/billing.html
b/httemplate/edit/cust_main/billing.html
index
519f2f8
..
9836810
100644
(file)
--- a/
httemplate/edit/cust_main/billing.html
+++ b/
httemplate/edit/cust_main/billing.html
@@
-537,8
+537,14
@@
<TD ALIGN="right" WIDTH="200"><% mt('Prorate day (1-28)') |h %> </TD>
<TD>
<INPUT TYPE="text" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>" SIZE=3 MAXLENGTH=2>
<TD ALIGN="right" WIDTH="200"><% mt('Prorate day (1-28)') |h %> </TD>
<TD>
<INPUT TYPE="text" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>" SIZE=3 MAXLENGTH=2>
+ <& /elements/checkbox.html,
+ field => 'force_prorate_day',
+ value => 'Y',
+ curr_value => $cust_main->force_prorate_day
+ &>
+ <label><% emt('Force all packages to this day') %></label>
</TD>
</TD>
-
</TR>
+ </TR>
% } else {
<INPUT TYPE="hidden" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>">
% }
% } else {
<INPUT TYPE="hidden" NAME="prorate_day" VALUE="<% $cust_main->prorate_day %>">
% }