[freeside-commits] freeside/FS/FS cust_pkg.pm, 1.183, 1.184 cust_svc.pm, 1.84, 1.85 part_pkg.pm, 1.113, 1.114 svc_Common.pm, 1.60, 1.61
Erik Levinson
levinse at wavetail.420.am
Thu Dec 9 11:26:21 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv14877/FS/FS
Modified Files:
cust_pkg.pm cust_svc.pm part_pkg.pm svc_Common.pm
Log Message:
-change ikano.pm to use the new part_pkg_vendor, RT7111
-implement service expiry and add export expire to ikano, RT7111
-fix edit part_pkg bug, RT7111
Index: svc_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_Common.pm,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -w -d -r1.60 -r1.61
--- svc_Common.pm 1 Dec 2010 05:56:09 -0000 1.60
+++ svc_Common.pm 9 Dec 2010 19:26:19 -0000 1.61
@@ -375,6 +375,40 @@
'';
}
+=item expire DATE
+
+Currently this will only run expire exports if any are attached
+
+=cut
+
+sub expire {
+ my($self,$date) = (shift,shift);
+
+ return 'Expire date must be specified' unless $date;
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ my $export_args = [$date];
+ my $error = $self->export('expire', @$export_args);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ '';
+}
+
=item replace [ OLD_RECORD ] [ HASHREF | OPTION => VALUE ]
Replaces OLD_RECORD with this one. If there is an error, returns the error,
Index: part_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg.pm,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -w -d -r1.113 -r1.114
--- part_pkg.pm 8 Dec 2010 21:37:44 -0000 1.113
+++ part_pkg.pm 9 Dec 2010 19:26:19 -0000 1.114
@@ -21,6 +21,7 @@
use FS::part_pkg_taxproduct;
use FS::part_pkg_link;
use FS::part_pkg_discount;
+use FS::part_pkg_vendor;
@ISA = qw( FS::m2m_Common FS::option_Common );
$DEBUG = 0;
@@ -456,7 +457,7 @@
my($exportnum,$vendor_pkg_id);
while ( ($exportnum,$vendor_pkg_id)
= each %{$options->{'part_pkg_vendor'}} ) {
- my $replaced = 0;
+ my $noinsert = 0;
foreach my $part_pkg_vendor ( @part_pkg_vendor ) {
if($exportnum == $part_pkg_vendor->exportnum
&& $vendor_pkg_id ne $part_pkg_vendor->vendor_pkg_id) {
@@ -466,11 +467,16 @@
$dbh->rollback if $oldAutoCommit;
return "Error replacing part_pkg_vendor record: $error";
}
- $replaced = 1;
+ $noinsert = 1;
+ last;
+ }
+ elsif($exportnum == $part_pkg_vendor->exportnum
+ && $vendor_pkg_id eq $part_pkg_vendor->vendor_pkg_id) {
+ $noinsert = 1;
last;
}
}
- unless ( $replaced ) {
+ unless ( $noinsert ) {
my $ppv = new FS::part_pkg_vendor( {
'pkgpart' => $new->pkgpart,
'exportnum' => $exportnum,
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -w -d -r1.183 -r1.184
--- cust_pkg.pm 8 Dec 2010 00:36:18 -0000 1.183
+++ cust_pkg.pm 9 Dec 2010 19:26:19 -0000 1.184
@@ -661,7 +661,25 @@
}
my %svc;
- unless ( $date ) {
+ if ( $date ) {
+ # copied from below
+ foreach my $cust_svc (
+ #schwartz
+ map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, $_->svc_x->table_info->{'cancel_weight'} ]; }
+ qsearch( 'cust_svc', { 'pkgnum' => $self->pkgnum } )
+ ) {
+
+ my $error = $cust_svc->cancel( ('date' => $date) );
+
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error expiring cust_svc: $error";
+ }
+ }
+
+ } else {
foreach my $cust_svc (
#schwartz
map { $_->[0] }
Index: cust_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_svc.pm,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -w -d -r1.84 -r1.85
--- cust_svc.pm 5 Aug 2010 04:17:07 -0000 1.84
+++ cust_svc.pm 9 Dec 2010 19:26:19 -0000 1.85
@@ -109,7 +109,7 @@
=cut
sub cancel {
- my $self = shift;
+ my($self,%opt) = @_;
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
@@ -133,7 +133,13 @@
my $svc = $self->svc_x;
if ($svc) {
-
+ if ( %opt && $opt{'date'} ) {
+ my $error = $svc->expire($opt{'date'});
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error expiring service: $error";
+ }
+ } else {
my $error = $svc->cancel;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
@@ -144,8 +150,9 @@
$dbh->rollback if $oldAutoCommit;
return "Error deleting service: $error";
}
+ }
- } else {
+ } elsif ( !%opt ) {
#huh?
warn "WARNING: no svc_ record found for svcnum ". $self->svcnum.
More information about the freeside-commits
mailing list