projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b9f68ca
)
RT#42043: Check for cancelled packages with a cancellation date age option [age_newes...
author
Jonathan Prykop
<jonathan@freeside.biz>
Thu, 4 Aug 2016 04:04:05 +0000
(23:04 -0500)
committer
Jonathan Prykop
<jonathan@freeside.biz>
Thu, 4 Aug 2016 04:04:05 +0000
(23:04 -0500)
FS/FS/part_event/Condition.pm
patch
|
blob
|
history
FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm
patch
|
blob
|
history
FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm
patch
|
blob
|
history
httemplate/edit/process/part_event.html
patch
|
blob
|
history
httemplate/elements/tr-freq.html
patch
|
blob
|
history
diff --git
a/FS/FS/part_event/Condition.pm
b/FS/FS/part_event/Condition.pm
index
36fbe9a
..
d1d5196
100644
(file)
--- a/
FS/FS/part_event/Condition.pm
+++ b/
FS/FS/part_event/Condition.pm
@@
-312,7
+312,7
@@
sub option_age_from {
} elsif ( $age =~ /^(\d+)d$/i ) {
$mday -= $1;
} elsif ( $age =~ /^(\d+)h$/i ) {
} elsif ( $age =~ /^(\d+)d$/i ) {
$mday -= $1;
} elsif ( $age =~ /^(\d+)h$/i ) {
- $hour -= $
hour
;
+ $hour -= $
1
;
} else {
die "unparsable age: $age";
}
} else {
die "unparsable age: $age";
}
diff --git
a/FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm
b/FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm
index
353e646
..
d54fb88
100644
(file)
--- a/
FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm
+++ b/
FS/FS/part_event/Condition/hasnt_pkg_class_cancelled.pm
@@
-21,9
+21,16
@@
sub option_fields {
'type' => 'select-pkg_class',
'multiple' => 1,
},
'type' => 'select-pkg_class',
'multiple' => 1,
},
- 'age' => { 'label' => 'Cancellation in last',
- 'type' => 'freq',
- },
+ 'age_newest' => { 'label' => 'Cancelled more than',
+ 'type' => 'freq',
+ 'post_text' => ' ago (blank for no limit)',
+ 'allow_blank' => 1,
+ },
+ 'age' => { 'label' => 'Cancelled less than',
+ 'type' => 'freq',
+ 'post_text' => ' ago (blank for no limit)',
+ 'allow_blank' => 1,
+ },
);
}
);
}
@@
-32,11
+39,12
@@
sub condition {
my $cust_main = $self->cust_main($object);
my $cust_main = $self->cust_main($object);
- my $age = $self->option_age_from('age', $opt{'time'} );
+ my $oldest = length($self->option('age')) ? $self->option_age_from('age', $opt{'time'} ) : 0;
+ my $newest = $self->option_age_from('age_newest', $opt{'time'} );
+
+ my $pkgclass = $self->option('pkgclass') || {};
- #XXX test
- my $hashref = $self->option('pkgclass') || {};
- ! grep { $hashref->{ $_->part_pkg->classnum } && $_->get('cancel') > $age }
+ ! grep { $pkgclass->{ $_->part_pkg->classnum } && ($_->get('cancel') > $oldest) && ($_->get('cancel') <= $newest) }
$cust_main->cancelled_pkgs;
}
$cust_main->cancelled_pkgs;
}
diff --git
a/FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm
b/FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm
index
b4ff6c3
..
42845cb
100644
(file)
--- a/
FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm
+++ b/
FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm
@@
-18,8
+18,15
@@
sub option_fields {
'type' => 'select-part_pkg',
'multiple' => 1,
},
'type' => 'select-part_pkg',
'multiple' => 1,
},
- 'age
' => { 'label' => 'Cancellation in last
',
+ 'age
_newest' => { 'label' => 'Cancelled more than
',
'type' => 'freq',
'type' => 'freq',
+ 'post_text' => ' ago (blank for no limit)',
+ 'allow_blank' => 1,
+ },
+ 'age' => { 'label' => 'Cancelled less than',
+ 'type' => 'freq',
+ 'post_text' => ' ago (blank for no limit)',
+ 'allow_blank' => 1,
},
);
}
},
);
}
@@
-29,10
+36,12
@@
sub condition {
my $cust_main = $self->cust_main($object);
my $cust_main = $self->cust_main($object);
- my $age = $self->option_age_from('age', $opt{'time'} );
+ my $oldest = length($self->option('age')) ? $self->option_age_from('age', $opt{'time'} ) : 0;
+ my $newest = $self->option_age_from('age_newest', $opt{'time'} );
my $if_pkgpart = $self->option('if_pkgpart') || {};
my $if_pkgpart = $self->option('if_pkgpart') || {};
- ! grep { $if_pkgpart->{ $_->pkgpart } && $_->get('cancel') > $age }
+
+ ! grep { $if_pkgpart->{ $_->pkgpart } && ($_->get('cancel') > $oldest) && ($_->get('cancel') <= $newest) }
$cust_main->cancelled_pkgs;
}
$cust_main->cancelled_pkgs;
}
diff --git
a/httemplate/edit/process/part_event.html
b/httemplate/edit/process/part_event.html
index
bac6924
..
0293af8
100644
(file)
--- a/
httemplate/edit/process/part_event.html
+++ b/
httemplate/edit/process/part_event.html
@@
-39,8
+39,8
@@
split(/\0/, $value)
};
} elsif ( $info->{'type'} eq 'freq' ) {
split(/\0/, $value)
};
} elsif ( $info->{'type'} eq 'freq' ) {
- $value = '0' if !length($value);
- $value .= $params->{$cgi_field.'_units'};
+ $value = '0' if !length($value)
and !$info->{'allow_blank'}
;
+ $value .= $params->{$cgi_field.'_units'}
if length($value)
;
}
#warn "value of $cgi_field is $value\n";
}
#warn "value of $cgi_field is $value\n";
diff --git
a/httemplate/elements/tr-freq.html
b/httemplate/elements/tr-freq.html
index
cb58bf6
..
795684c
100644
(file)
--- a/
httemplate/elements/tr-freq.html
+++ b/
httemplate/elements/tr-freq.html
@@
-15,7
+15,7
@@
<% $freq eq $units ? 'SELECTED' : '' %>
><% $freq{$freq} %>
% }
<% $freq eq $units ? 'SELECTED' : '' %>
><% $freq{$freq} %>
% }
- </SELECT>
+ </SELECT>
<% $opt{'post_text'} || '' %>
</TD>
</TD>