summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cust_bill.pm67
-rw-r--r--FS/FS/cust_bill_pkg.pm19
-rw-r--r--FS/FS/part_export/sqlradius.pm3
-rw-r--r--FS/FS/part_pkg/flat.pm4
-rw-r--r--FS/FS/part_pkg/flat_comission.pm2
-rw-r--r--FS/FS/part_pkg/flat_comission_cust.pm2
-rw-r--r--FS/FS/part_pkg/flat_comission_pkg.pm2
-rw-r--r--FS/FS/part_pkg/flat_delayed.pm2
-rw-r--r--FS/FS/part_pkg/prepaid.pm28
-rw-r--r--FS/FS/part_pkg/prorate.pm2
-rw-r--r--FS/FS/part_pkg/sesmon_hour.pm2
-rw-r--r--FS/FS/part_pkg/sesmon_minute.pm2
-rw-r--r--FS/FS/part_pkg/sql_external.pm2
-rw-r--r--FS/FS/part_pkg/sql_generic.pm2
-rw-r--r--FS/FS/part_pkg/sqlradacct_hour.pm2
-rw-r--r--FS/FS/part_pkg/subscription.pm2
-rw-r--r--FS/FS/part_pkg/voip_sqlradacct.pm2
17 files changed, 96 insertions, 49 deletions
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 26c3d4bc4..8b34cb918 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -818,7 +818,7 @@ sub send_csv {
) or die "can't create csv";
print CSV $csv->string. "\n";
- #new charges (false laziness w/print_text)
+ #new charges (false laziness w/print_text and _items stuff)
foreach my $cust_bill_pkg ( $self->cust_bill_pkg ) {
my($pkg, $setup, $recur, $sdate, $edate);
@@ -1061,7 +1061,7 @@ L<Time::Local> and L<Date::Parse> for conversion functions.
=cut
-#still some false laziness w/print_text
+#still some false laziness w/_items stuff (and send_csv)
sub print_text {
my( $self, $today, $template ) = @_;
@@ -1102,50 +1102,49 @@ sub print_text {
( grep { ! $_->pkgnum } $self->cust_bill_pkg ), #then taxes
) {
- if ( $cust_bill_pkg->pkgnum > 0 ) {
+ my $desc = $cust_bill_pkg->desc;
- my $cust_pkg = qsearchs('cust_pkg', { pkgnum =>$cust_bill_pkg->pkgnum } );
- my $part_pkg = qsearchs('part_pkg', { pkgpart=>$cust_pkg->pkgpart } );
- my $pkg = $part_pkg->pkg;
+ if ( $cust_bill_pkg->pkgnum > 0 ) {
if ( $cust_bill_pkg->setup != 0 ) {
- my $description = $pkg;
+ my $description = $desc;
$description .= ' Setup' if $cust_bill_pkg->recur != 0;
push @buf, [ $description,
$money_char. sprintf("%10.2f", $cust_bill_pkg->setup) ];
push @buf,
map { [ " ". $_->[0]. ": ". $_->[1], '' ] }
- $cust_pkg->h_labels($self->_date);
+ $cust_bill_pkg->cust_pkg->h_labels($self->_date);
}
if ( $cust_bill_pkg->recur != 0 ) {
push @buf, [
- "$pkg (" . time2str("%x", $cust_bill_pkg->sdate) . " - " .
- time2str("%x", $cust_bill_pkg->edate) . ")",
+ "$desc (" . time2str("%x", $cust_bill_pkg->sdate) . " - " .
+ time2str("%x", $cust_bill_pkg->edate) . ")",
$money_char. sprintf("%10.2f", $cust_bill_pkg->recur)
];
push @buf,
map { [ " ". $_->[0]. ": ". $_->[1], '' ] }
- $cust_pkg->h_labels($cust_bill_pkg->edate, $cust_bill_pkg->sdate);
+ $cust_bill_pkg->cust_pkg->h_labels( $cust_bill_pkg->edate,
+ $cust_bill_pkg->sdate );
}
push @buf, map { [ " $_", '' ] } $cust_bill_pkg->details;
} else { #pkgnum tax or one-shot line item
- my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc')
- ? ( $cust_bill_pkg->itemdesc || 'Tax' )
- : 'Tax';
+
if ( $cust_bill_pkg->setup != 0 ) {
- push @buf, [ $itemdesc,
+ push @buf, [ $desc,
$money_char. sprintf("%10.2f", $cust_bill_pkg->setup) ];
}
if ( $cust_bill_pkg->recur != 0 ) {
- push @buf, [ "$itemdesc (". time2str("%x", $cust_bill_pkg->sdate). " - "
- . time2str("%x", $cust_bill_pkg->edate). ")",
+ push @buf, [ "$desc (". time2str("%x", $cust_bill_pkg->sdate). " - "
+ . time2str("%x", $cust_bill_pkg->edate). ")",
$money_char. sprintf("%10.2f", $cust_bill_pkg->recur)
];
}
+
}
+
}
push @buf,['','-----------'];
@@ -1305,7 +1304,7 @@ L<Time::Local> and L<Date::Parse> for conversion functions.
=cut
-#still some false laziness w/print_text
+#still some false laziness w/print_text (mostly print_text should use _items stuff though)
sub print_latex {
my( $self, $today, $template ) = @_;
@@ -1999,21 +1998,19 @@ sub _items_cust_bill_pkg {
my @b = ();
foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
- if ( $cust_bill_pkg->pkgnum > 0 ) {
+ my $desc = $cust_bill_pkg->desc;
- my $cust_pkg = qsearchs('cust_pkg', { pkgnum =>$cust_bill_pkg->pkgnum } );
- my $part_pkg = qsearchs('part_pkg', { pkgpart=>$cust_pkg->pkgpart } );
- my $pkg = $part_pkg->pkg;
+ if ( $cust_bill_pkg->pkgnum > 0 ) {
if ( $cust_bill_pkg->setup != 0 ) {
- my $description = $pkg;
+ my $description = $desc;
$description .= ' Setup' if $cust_bill_pkg->recur != 0;
- my @d = $cust_pkg->h_labels_short($self->_date);
+ my @d = $cust_bill_pkg->cust_pkg->h_labels_short($self->_date);
push @d, $cust_bill_pkg->details if $cust_bill_pkg->recur == 0;
push @b, {
description => $description,
#pkgpart => $part_pkg->pkgpart,
- pkgnum => $cust_pkg->pkgnum,
+ pkgnum => $cust_bill_pkg->pkgnum,
amount => sprintf("%.2f", $cust_bill_pkg->setup),
ext_description => \@d,
};
@@ -2021,33 +2018,31 @@ sub _items_cust_bill_pkg {
if ( $cust_bill_pkg->recur != 0 ) {
push @b, {
- description => "$pkg (" .
+ description => "$desc (" .
time2str('%x', $cust_bill_pkg->sdate). ' - '.
time2str('%x', $cust_bill_pkg->edate). ')',
#pkgpart => $part_pkg->pkgpart,
- pkgnum => $cust_pkg->pkgnum,
+ pkgnum => $cust_bill_pkg->pkgnum,
amount => sprintf("%.2f", $cust_bill_pkg->recur),
- ext_description => [ $cust_pkg->h_labels_short($cust_bill_pkg->edate,
- $cust_bill_pkg->sdate),
- $cust_bill_pkg->details,
- ],
+ ext_description =>
+ [ $cust_bill_pkg->cust_pkg->h_labels_short( $cust_bill_pkg->edate,
+ $cust_bill_pkg->sdate),
+ $cust_bill_pkg->details,
+ ],
};
}
} else { #pkgnum tax or one-shot line item (??)
- my $itemdesc = defined $cust_bill_pkg->dbdef_table->column('itemdesc')
- ? ( $cust_bill_pkg->itemdesc || 'Tax' )
- : 'Tax';
if ( $cust_bill_pkg->setup != 0 ) {
push @b, {
- 'description' => $itemdesc,
+ 'description' => $desc,
'amount' => sprintf("%.2f", $cust_bill_pkg->setup),
};
}
if ( $cust_bill_pkg->recur != 0 ) {
push @b, {
- 'description' => "$itemdesc (".
+ 'description' => "$desc (".
time2str("%x", $cust_bill_pkg->sdate). ' - '.
time2str("%x", $cust_bill_pkg->edate). ')',
'amount' => sprintf("%.2f", $cust_bill_pkg->recur),
diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index 22673234c..77429f287 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -204,6 +204,25 @@ sub details {
#qsearch ( 'cust_bill_pkg_detail', { 'lineitemnum' => $self->lineitemnum });
}
+=item desc
+
+Returns a description for this line item. For typical line items, this is the
+I<pkg> field of the corresponding B<FS::part_pkg> object (see L<FS::part_pkg>).
+For one-shot line items and named taxes, it is the I<itemdesc> field of this
+line item, and for generic taxes, simply returns "Tax".
+
+=cut
+
+sub desc {
+ my $self = shift;
+
+ if ( $self->pkgnum > 0 ) {
+ $self->cust_pkg->part_pkg->pkg;
+ } else {
+ $self->itemdesc || 'Tax';
+ }
+}
+
=back
=head1 BUGS
diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm
index 03802b2a7..772da1255 100644
--- a/FS/FS/part_export/sqlradius.pm
+++ b/FS/FS/part_export/sqlradius.pm
@@ -529,7 +529,8 @@ sub update_svc_acct {
warn " svc_acct.seconds found (". $svc_acct->seconds.
") - decrementing\n"
if $DEBUG;
- $svc_acct->decrement_seconds($AcctSessionTime);
+ my $error = $svc_acct->decrement_seconds($AcctSessionTime);
+ die $error if $error;
$status = 'done';
} else {
warn " no existing seconds value for svc_acct - skiping\n" if $DEBUG;
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index 2a460b0c9..f2f3a8d9a 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -78,4 +78,8 @@ sub is_free_options {
qw( setup_fee recur_fee );
}
+sub is_prepaid {
+ 0; #no, we're postpaid
+}
+
1;
diff --git a/FS/FS/part_pkg/flat_comission.pm b/FS/FS/part_pkg/flat_comission.pm
index 21c03c294..442415e08 100644
--- a/FS/FS/part_pkg/flat_comission.pm
+++ b/FS/FS/part_pkg/flat_comission.pm
@@ -3,7 +3,7 @@ package FS::part_pkg::flat_comission;
use strict;
use vars qw(@ISA %info);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/flat_comission_cust.pm b/FS/FS/part_pkg/flat_comission_cust.pm
index 9f2e6ca0b..4abe66ad2 100644
--- a/FS/FS/part_pkg/flat_comission_cust.pm
+++ b/FS/FS/part_pkg/flat_comission_cust.pm
@@ -3,7 +3,7 @@ package FS::part_pkg::flat_comission_cust;
use strict;
use vars qw(@ISA %info);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/flat_comission_pkg.pm b/FS/FS/part_pkg/flat_comission_pkg.pm
index 20d235c40..0f4d02a58 100644
--- a/FS/FS/part_pkg/flat_comission_pkg.pm
+++ b/FS/FS/part_pkg/flat_comission_pkg.pm
@@ -3,7 +3,7 @@ package FS::part_pkg::flat_comission_pkg;
use strict;
use vars qw(@ISA %info);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/flat_delayed.pm b/FS/FS/part_pkg/flat_delayed.pm
index 4a04583d6..ec11699d9 100644
--- a/FS/FS/part_pkg/flat_delayed.pm
+++ b/FS/FS/part_pkg/flat_delayed.pm
@@ -3,7 +3,7 @@ package FS::part_pkg::flat_delayed;
use strict;
use vars qw(@ISA %info);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/prepaid.pm b/FS/FS/part_pkg/prepaid.pm
new file mode 100644
index 000000000..5e7d2baae
--- /dev/null
+++ b/FS/FS/part_pkg/prepaid.pm
@@ -0,0 +1,28 @@
+package FS::part_pkg::prepaid;
+
+use strict;
+use vars qw(@ISA %info);
+use FS::part_pkg::flat;
+
+@ISA = qw(FS::part_pkg::flat);
+
+%info = (
+ 'name' => 'Prepaid, flat rate',
+ 'fields' => {
+ 'setup_fee' => { 'name' => 'One-time setup fee for this package',
+ 'default' => 0,
+ },
+ 'recur_fee' => { 'name' => 'Initial and recharge fee for this package',
+ 'default' => 0,
+ }
+ },
+ 'fieldorder' => [ 'setup_fee', 'recur_fee', ],
+ 'weight' => 25,
+);
+
+sub is_prepaid {
+ 1;
+}
+
+1;
+
diff --git a/FS/FS/part_pkg/prorate.pm b/FS/FS/part_pkg/prorate.pm
index f8a482645..86c64d53a 100644
--- a/FS/FS/part_pkg/prorate.pm
+++ b/FS/FS/part_pkg/prorate.pm
@@ -4,7 +4,7 @@ use strict;
use vars qw(@ISA %info);
use Time::Local qw(timelocal);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/sesmon_hour.pm b/FS/FS/part_pkg/sesmon_hour.pm
index 41c7f25c3..b80fac3e4 100644
--- a/FS/FS/part_pkg/sesmon_hour.pm
+++ b/FS/FS/part_pkg/sesmon_hour.pm
@@ -3,7 +3,7 @@ package FS::part_pkg::sesmon_hour;
use strict;
use vars qw(@ISA %info);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/sesmon_minute.pm b/FS/FS/part_pkg/sesmon_minute.pm
index cd859bfe3..6af7c0870 100644
--- a/FS/FS/part_pkg/sesmon_minute.pm
+++ b/FS/FS/part_pkg/sesmon_minute.pm
@@ -3,7 +3,7 @@ package FS::part_pkg::sesmon_minute;
use strict;
use vars qw(@ISA %info);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/sql_external.pm b/FS/FS/part_pkg/sql_external.pm
index 28a489767..6aba9153b 100644
--- a/FS/FS/part_pkg/sql_external.pm
+++ b/FS/FS/part_pkg/sql_external.pm
@@ -4,7 +4,7 @@ use strict;
use vars qw(@ISA %info);
use DBI;
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/sql_generic.pm b/FS/FS/part_pkg/sql_generic.pm
index 646957c9c..b8ee286e1 100644
--- a/FS/FS/part_pkg/sql_generic.pm
+++ b/FS/FS/part_pkg/sql_generic.pm
@@ -4,7 +4,7 @@ use strict;
use vars qw(@ISA %info);
use DBI;
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/sqlradacct_hour.pm b/FS/FS/part_pkg/sqlradacct_hour.pm
index 7ecb97026..19887ea0d 100644
--- a/FS/FS/part_pkg/sqlradacct_hour.pm
+++ b/FS/FS/part_pkg/sqlradacct_hour.pm
@@ -3,7 +3,7 @@ package FS::part_pkg::sqlradacct_hour;
use strict;
use vars qw(@ISA %info);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/subscription.pm b/FS/FS/part_pkg/subscription.pm
index e03573b7b..36b5a96fb 100644
--- a/FS/FS/part_pkg/subscription.pm
+++ b/FS/FS/part_pkg/subscription.pm
@@ -4,7 +4,7 @@ use strict;
use vars qw(@ISA %info);
use Time::Local qw(timelocal);
#use FS::Record qw(qsearch qsearchs);
-use FS::part_pkg;
+use FS::part_pkg::flat;
@ISA = qw(FS::part_pkg::flat);
diff --git a/FS/FS/part_pkg/voip_sqlradacct.pm b/FS/FS/part_pkg/voip_sqlradacct.pm
index db38a44de..382ebac3a 100644
--- a/FS/FS/part_pkg/voip_sqlradacct.pm
+++ b/FS/FS/part_pkg/voip_sqlradacct.pm
@@ -4,7 +4,7 @@ use strict;
use vars qw(@ISA $DEBUG %info);
use Date::Format;
use FS::Record qw(qsearchs qsearch);
-use FS::part_pkg;
+use FS::part_pkg::flat;
#use FS::rate;
use FS::rate_prefix;