#return "Can't change _date!" unless $old->_date eq $new->_date;
return "Can't change _date" unless $old->_date == $new->_date;
return "Can't change charged" unless $old->charged == $new->charged
- || $old->charged == 0;
+ || $old->charged == 0
+ || $new->{'Hash'}{'cc_surcharge_replace_hack'};
'';
}
+
+=item add_cc_surcharge
+
+Giant hack
+
+=cut
+
+sub add_cc_surcharge {
+ my ($self, $pkgnum, $amount) = (shift, shift, shift);
+
+ my $error;
+ my $cust_bill_pkg = new FS::cust_bill_pkg({
+ 'invnum' => $self->invnum,
+ 'pkgnum' => $pkgnum,
+ 'setup' => $amount,
+ });
+ $error = $cust_bill_pkg->insert;
+ return $error if $error;
+
+ $self->{'Hash'}{'cc_surcharge_replace_hack'} = 1;
+ $self->charged($self->charged+$amount);
+ $error = $self->replace;
+ return $error if $error;
+
+ $self->apply_payments_and_credits;
+}
+
+
=item check
Checks all fields to make sure this is a valid invoice. If there is an error,
}
sub realtime_bop {
- my( $self, $method ) = @_;
+ my( $self, $method ) = (shift,shift);
+ my %opt = @_;
my $cust_main = $self->cust_main;
my $balance = $cust_main->balance;
#this didn't do what we want, it just calls apply_payments_and_credits
# 'apply' => 1,
'apply_to_invoice' => 1,
+ %opt,
#what we want:
#this changes application behavior: auto payments
#triggered against a specific invoice are now applied
'template' => [ '{', '}' ],
);
+ warn "$me print_generic creating template\n"
+ if $DEBUG > 1;
+
#create the template
my $template = $params{template} ? $params{template} : $self->_agent_template;
my $templatefile = "invoice_$format";
@invoice_template = _translate_old_latex_format(@invoice_template);
}
+ warn "$me print_generic creating T:T object\n"
+ if $DEBUG > 1;
+
my $text_template = new Text::Template(
TYPE => 'ARRAY',
SOURCE => \@invoice_template,
DELIMITERS => $delimiters{$format},
);
+ warn "$me print_generic compiling T:T object\n"
+ if $DEBUG > 1;
+
$text_template->compile()
or die "Can't compile $templatefile: $Text::Template::ERROR\n";
);
my $embolden_function = $embolden_functions{$format};
+ warn "$me generating template variables\n"
+ if $DEBUG > 1;
# generate template variables
my $returnaddress;
}
+ warn "$me generating invoice data\n"
+ if $DEBUG > 1;
+
my $agentnum = $self->cust_main->agentnum;
my %invoice_data = (
}
$invoice_data{'summarypage'} = $summarypage;
- #do variable substitution in notes, footer, smallfooter
+ warn "$me substituting variables in notes, footer, smallfooter\n"
+ if $DEBUG > 1;
+
foreach my $include (qw( notes footer smallfooter coupon )) {
my $inc_file = $conf->key_orbase("invoice_${format}$include", $template);
$invoice_data{'buf'} = \@buf;
$invoice_data{'sections'} = \@sections;
+ warn "$me generating sections\n"
+ if $DEBUG > 1;
+
my $previous_section = { 'description' => 'Previous Charges',
'subtotal' => $other_money_char.
sprintf('%.2f', $pr_total),
)
{
+ warn "$me adding previous balances\n"
+ if $DEBUG > 1;
+
foreach my $line_item ( $self->_items_previous ) {
my $detail = {
}
if ( $conf->exists('svc_phone-did-summary') ) {
+ warn "$me adding DID summary\n"
+ if $DEBUG > 1;
+
my ($didsummary,$minutes) = $self->_did_summary;
my $didsummary_desc = 'DID Activity Summary (Past 30 days)';
push @detail_items,
foreach my $section (@sections, @$late_sections) {
+ warn "$me adding section \n". Dumper($section)
+ if $DEBUG > 1;
+
# begin some normalization
$section->{'subtotal'} = $section->{'amount'}
if $multisection
);
}
+ warn "$me setting options\n"
+ if $DEBUG > 1;
+
my $multilocation = scalar($cust_main->cust_location); #too expensive?
my %options = ();
$options{'section'} = $section if $multisection;
$options{'multilocation'} = $multilocation;
$options{'multisection'} = $multisection;
+ warn "$me searching for line items\n"
+ if $DEBUG > 1;
+
foreach my $line_item ( $self->_items_pkg(%options) ) {
+
+ warn "$me adding line item $line_item\n"
+ if $DEBUG > 1;
+
my $detail = {
ext_description => [],
};
unshift @sections, $previous_section if $pr_total;
}
+ warn "$me adding taxes\n"
+ if $DEBUG > 1;
+
foreach my $tax ( $self->_items_tax ) {
$taxtotal += $tax->{'amount'};
sub _items_pkg {
my $self = shift;
my %options = @_;
+
+ warn "$me _items_pkg searching for all package line items\n"
+ if $DEBUG > 1;
+
my @cust_bill_pkg = grep { $_->pkgnum } $self->cust_bill_pkg;
+
+ warn "$me _items_pkg filtering line items\n"
+ if $DEBUG > 1;
my @items = $self->_items_cust_bill_pkg(\@cust_bill_pkg, @_);
+
if ($options{section} && $options{section}->{condensed}) {
+
+ warn "$me _items_pkg condensing section\n"
+ if $DEBUG > 1;
+
my %itemshash = ();
local $Storable::canonical = 1;
foreach ( @items ) {
}
keys %itemshash;
}
+
+ warn "$me _items_pkg returning ". scalar(@items). " items\n"
+ if $DEBUG > 1;
+
@items;
}
{
$discount_show_always = ($cust_bill_pkg->cust_bill_pkg_discount
- && $conf->exists('discount-show-always'));
+ && $conf->exists('discount-show-always'));
foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) {
if ( $_ && !$cust_bill_pkg->hidden ) {
$_->{amount} =~ s/^\-0\.00$/0.00/;
$_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ),
push @b, { %$_ }
- unless ( $_->{amount} == 0 && !$discount_show_always );
+ unless ( $_->{amount} == 0 && !$discount_show_always );
}
}