projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix long package locations showing up as line item on typeset invoices, RT#10093
[freeside.git]
/
FS
/
FS
/
cust_pkg.pm
diff --git
a/FS/FS/cust_pkg.pm
b/FS/FS/cust_pkg.pm
index
e93476d
..
c327ec6
100644
(file)
--- a/
FS/FS/cust_pkg.pm
+++ b/
FS/FS/cust_pkg.pm
@@
-153,6
+153,10
@@
date
date
date
+=item contract_end
+
+date
+
=item cancel
date
=item cancel
date
@@
-259,7
+263,7
@@
sub insert {
$self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) );
}
$self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) );
}
- foreach my $action ( qw(expire adjourn) ) {
+ foreach my $action ( qw(expire adjourn
contract_end
) ) {
my $months = $self->part_pkg->option("${action}_months",1);
if($months and !$self->$action) {
my $start = $self->start_date || $self->setup || time;
my $months = $self->part_pkg->option("${action}_months",1);
if($months and !$self->$action) {
my $start = $self->start_date || $self->setup || time;
@@
-1114,7
+1118,7
@@
Options are:
=over 4
=over 4
-=item loca
it
onnum
+=item loca
ti
onnum
New locationnum, to change the location for this package.
New locationnum, to change the location for this package.
@@
-1131,9
+1135,15
@@
New pkgpart (see L<FS::part_pkg>).
New refnum (see L<FS::part_referral>).
New refnum (see L<FS::part_referral>).
+=item keep_dates
+
+Set to true to transfer billing dates (start_date, setup, last_bill, bill,
+susp, adjourn, cancel, expire, and contract_end) to the new package.
+
=back
=back
-At least one option must be specified (otherwise, what's the point?)
+At least one of locationnum, cust_location, pkgpart, refnum must be specified
+(otherwise, what's the point?)
Returns either the new FS::cust_pkg object or a scalar error.
Returns either the new FS::cust_pkg object or a scalar error.
@@
-1191,6
+1201,13
@@
sub change {
$opt->{'locationnum'} = $opt->{'cust_location'}->locationnum;
}
$opt->{'locationnum'} = $opt->{'cust_location'}->locationnum;
}
+ if ( $opt->{'keep_dates'} ) {
+ foreach my $date ( qw(setup bill last_bill susp adjourn cancel expire
+ start_date contract_end ) ) {
+ $hash{$date} = $self->getfield($date);
+ }
+ }
+
# Create the new package.
my $cust_pkg = new FS::cust_pkg {
custnum => $self->custnum,
# Create the new package.
my $cust_pkg = new FS::cust_pkg {
custnum => $self->custnum,
@@
-1240,7
+1257,7
@@
sub change {
? ()
: ( 'null' => 1 )
)
? ()
: ( 'null' => 1 )
)
- if $part_pkg->can('reset_usage') && ! $part_pkg->option('usage_rollover');
+ if $part_pkg->can('reset_usage') && ! $part_pkg->option('usage_rollover'
,1
);
if ($error) {
$dbh->rollback if $oldAutoCommit;
if ($error) {
$dbh->rollback if $oldAutoCommit;
@@
-1371,6
+1388,18
@@
sub calc_recur {
$self->part_pkg->calc_recur($self, @_);
}
$self->part_pkg->calc_recur($self, @_);
}
+=item base_recur
+
+Calls the I<base_recur> of the FS::part_pkg object associated with this billing
+item.
+
+=cut
+
+sub base_recur {
+ my $self = shift;
+ $self->part_pkg->base_recur($self, @_);
+}
+
=item calc_remain
Calls the I<calc_remain> of the FS::part_pkg object associated with this
=item calc_remain
Calls the I<calc_remain> of the FS::part_pkg object associated with this
@@
-1796,7
+1825,7
@@
Class method that returns the list of possible status strings for packages
=cut
tie my %statuscolor, 'Tie::IxHash',
=cut
tie my %statuscolor, 'Tie::IxHash',
- 'not yet billed' => '00
0000',
+ 'not yet billed' => '00
9999', #teal? cyan?
'one-time charge' => '000000',
'active' => '00CC00',
'suspended' => 'FF9900',
'one-time charge' => '000000',
'active' => '00CC00',
'suspended' => 'FF9900',
@@
-2526,6
+2555,22
@@
sub cancel_sql {
"cust_pkg.cancel IS NOT NULL AND cust_pkg.cancel != 0";
}
"cust_pkg.cancel IS NOT NULL AND cust_pkg.cancel != 0";
}
+=item status_sql
+
+Returns an SQL expression to give the package status as a string.
+
+=cut
+
+sub status_sql {
+"CASE
+ WHEN cust_pkg.cancel IS NOT NULL THEN 'cancelled'
+ WHEN cust_pkg.susp IS NOT NULL THEN 'suspended'
+ WHEN cust_pkg.setup IS NULL THEN 'not yet billed'
+ WHEN ".onetime_sql()." THEN 'one-time charge'
+ ELSE 'active'
+END"
+}
+
=item search HASHREF
(Class method)
=item search HASHREF
(Class method)
@@
-2794,7
+2839,7
@@
sub search {
"NOT (".FS::cust_pkg->onetime_sql . ")";
}
else {
"NOT (".FS::cust_pkg->onetime_sql . ")";
}
else {
- foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
+ foreach my $field (qw( setup last_bill bill adjourn susp expire c
ontract_end c
ancel )) {
next unless exists($params->{$field});
next unless exists($params->{$field});
@@
-3219,6
+3264,9
@@
sub bulk_change {
sub _upgrade_data { # class method
my ($class, %opts) = @_;
$class->_upgrade_otaker(%opts);
sub _upgrade_data { # class method
my ($class, %opts) = @_;
$class->_upgrade_otaker(%opts);
+ my $sql =('UPDATE cust_pkg SET contract_end = NULL WHERE contract_end = -1');
+ my $sth = dbh->prepare($sql);
+ $sth->execute or die $sth->errstr;
}
=back
}
=back