projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
72456: Directions - override company_address [context bug fix]
[freeside.git]
/
FS
/
FS
/
cust_bill.pm
diff --git
a/FS/FS/cust_bill.pm
b/FS/FS/cust_bill.pm
index
7ea586a
..
79dbbba
100644
(file)
--- a/
FS/FS/cust_bill.pm
+++ b/
FS/FS/cust_bill.pm
@@
-37,6
+37,8
@@
use FS::cust_bill_pay_pkg;
use FS::cust_credit_bill_pkg;
use FS::discount_plan;
use FS::cust_bill_void;
use FS::cust_credit_bill_pkg;
use FS::discount_plan;
use FS::cust_bill_void;
+use FS::reason;
+use FS::reason_type;
use FS::L10N;
$DEBUG = 0;
use FS::L10N;
$DEBUG = 0;
@@
-212,7
+214,7
@@
sub insert {
}
}
-=item void
+=item void
[ REASON ]
Voids this invoice: deletes the invoice and adds a record of the voided invoice
to the FS::cust_bill_void table (and related tables starting from
Voids this invoice: deletes the invoice and adds a record of the voided invoice
to the FS::cust_bill_void table (and related tables starting from
@@
-224,6
+226,14
@@
sub void {
my $self = shift;
my $reason = scalar(@_) ? shift : '';
my $self = shift;
my $reason = scalar(@_) ? shift : '';
+ unless (ref($reason) || !$reason) {
+ $reason = FS::reason->new_or_existing(
+ 'class' => 'I',
+ 'type' => 'Invoice void',
+ 'reason' => $reason
+ );
+ }
+
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
local $SIG{QUIT} = 'IGNORE';
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
local $SIG{QUIT} = 'IGNORE';
@@
-238,7
+248,7
@@
sub void {
my $cust_bill_void = new FS::cust_bill_void ( {
map { $_ => $self->get($_) } $self->fields
} );
my $cust_bill_void = new FS::cust_bill_void ( {
map { $_ => $self->get($_) } $self->fields
} );
- $cust_bill_void->reason
($reason)
;
+ $cust_bill_void->reason
num($reason->reasonnum) if $reason
;
my $error = $cust_bill_void->insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
my $error = $cust_bill_void->insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
@@
-297,13
+307,13
@@
sub _delete {
foreach my $table (qw(
cust_credit_bill
foreach my $table (qw(
cust_credit_bill
- cust_bill_pay
- cust_pay_batch
cust_bill_pay_batch
cust_bill_pay_batch
+ cust_bill_pay
cust_bill_batch
cust_bill_pkg
)) {
#cust_event # problematic
cust_bill_batch
cust_bill_pkg
)) {
#cust_event # problematic
+ #cust_pay_batch # unnecessary
foreach my $linked ( $self->$table() ) {
my $error = $linked->delete;
foreach my $linked ( $self->$table() ) {
my $error = $linked->delete;
@@
-1105,9
+1115,8
@@
sub queueable_email {
my $self = qsearchs('cust_bill', { 'invnum' => $opt{invnum} } )
or die "invalid invoice number: " . $opt{invnum};
my $self = qsearchs('cust_bill', { 'invnum' => $opt{invnum} } )
or die "invalid invoice number: " . $opt{invnum};
- if ( $opt{mode} ) {
- $self->set('mode', $opt{mode});
- }
+ $self->set('mode', $opt{mode})
+ if $opt{mode};
my %args = map {$_ => $opt{$_}}
grep { $opt{$_} }
my %args = map {$_ => $opt{$_}}
grep { $opt{$_} }
@@
-1248,6
+1257,10
@@
sub batch_invoice {
batchnum => $bill_batch->batchnum,
invnum => $self->invnum,
});
batchnum => $bill_batch->batchnum,
invnum => $self->invnum,
});
+ if ( $self->mode ) {
+ $opt->{mode} ||= $self->mode;
+ $opt->{mode} = $opt->{mode}->modenum if ref $opt->{mode};
+ }
return $cust_bill_batch->insert($opt);
}
return $cust_bill_batch->insert($opt);
}
@@
-2661,10
+2674,12
@@
sub _items_usage_class_summary {
my %opt = @_;
my $escape = $opt{escape} || sub { $_[0] };
my %opt = @_;
my $escape = $opt{escape} || sub { $_[0] };
+ my $money_char = $opt{money_char};
my $invnum = $self->invnum;
my @classes = qsearch({
'table' => 'usage_class',
my $invnum = $self->invnum;
my @classes = qsearch({
'table' => 'usage_class',
- 'select' => 'classnum, classname, SUM(amount) AS amount',
+ 'select' => 'classnum, classname, SUM(amount) AS amount,'.
+ ' COUNT(*) AS calls, SUM(duration) AS duration',
'addl_from' => ' LEFT JOIN cust_bill_pkg_detail USING (classnum)' .
' LEFT JOIN cust_bill_pkg USING (billpkgnum)',
'extra_sql' => " WHERE cust_bill_pkg.invnum = $invnum".
'addl_from' => ' LEFT JOIN cust_bill_pkg_detail USING (classnum)' .
' LEFT JOIN cust_bill_pkg USING (billpkgnum)',
'extra_sql' => " WHERE cust_bill_pkg.invnum = $invnum".
@@
-2675,17
+2690,21
@@
sub _items_usage_class_summary {
my @l;
my $section = {
description => &{$escape}($self->mt('Usage Summary')),
my @l;
my $section = {
description => &{$escape}($self->mt('Usage Summary')),
- no_subtotal => 1,
usage_section => 1,
usage_section => 1,
+ subtotal => 0,
};
foreach my $class (@classes) {
};
foreach my $class (@classes) {
+ $section->{subtotal} += $class->get('amount');
push @l, {
'description' => &{$escape}($class->classname),
push @l, {
'description' => &{$escape}($class->classname),
- 'amount' => sprintf('%.2f', $class->amount),
+ 'amount' => $money_char.sprintf('%.2f', $class->get('amount')),
+ 'quantity' => $class->get('calls'),
+ 'duration' => $class->get('duration'),
'usage_classnum' => $class->classnum,
'section' => $section,
};
}
'usage_classnum' => $class->classnum,
'section' => $section,
};
}
+ $section->{subtotal} = $money_char.sprintf('%.2f', $section->{subtotal});
return @l;
}
return @l;
}
@@
-2830,8
+2849,7
@@
sub _items_total {
my ($previous_charges_desc, $new_charges_desc, $new_charges_amount);
if ( $conf->exists('previous_balance-exclude_from_total') ) {
my ($previous_charges_desc, $new_charges_desc, $new_charges_amount);
if ( $conf->exists('previous_balance-exclude_from_total') ) {
- # can we do some caching on this stuff? it's going to change infrequently
- # in production
+ # if enabled, specifically add a line for the previous balance total
$previous_charges_desc = $self->mt(
$conf->config('previous_balance-text') || 'Previous Balance'
);
$previous_charges_desc = $self->mt(
$conf->config('previous_balance-text') || 'Previous Balance'
);
@@
-2843,6
+2861,12
@@
sub _items_total {
total_amount => sprintf('%.2f',$pr_total)
};
}
total_amount => sprintf('%.2f',$pr_total)
};
}
+ }
+
+ if ( $conf->exists('previous_balance-exclude_from_total')
+ or !$self->enable_previous ) {
+ # show new charges only
+
$new_charges_desc = $self->mt(
$conf->config('previous_balance-text-total_new_charges')
|| 'Total New Charges'
$new_charges_desc = $self->mt(
$conf->config('previous_balance-text-total_new_charges')
|| 'Total New Charges'
@@
-2851,9
+2875,14
@@
sub _items_total {
$new_charges_amount = $self->charged;
} else {
$new_charges_amount = $self->charged;
} else {
+ # show new charges + previous invoice total
$new_charges_desc = $self->mt('Total Charges');
$new_charges_desc = $self->mt('Total Charges');
- $new_charges_amount = sprintf('%.2f',$self->charged + $pr_total);
+ if ( $self->enable_previous ) {
+ $new_charges_amount = sprintf('%.2f', $self->charged + $pr_total);
+ } else {
+ $new_charges_amount = sprintf('%.2f', $self->charged);
+ }
}
}
@@
-2913,6
+2942,18
@@
sub call_details {
( $header, grep { $_ ne $header } @details );
}
( $header, grep { $_ ne $header } @details );
}
+=item cust_pay_batch
+
+Returns all L<FS::cust_pay_batch> records linked to this invoice. Deprecated,
+will be removed.
+
+=cut
+
+sub cust_pay_batch {
+ carp "FS::cust_bill->cust_pay_batch is deprecated";
+ my $self = shift;
+ qsearch('cust_pay_batch', { 'invnum' => $self->invnum });
+}
=back
=back