$error = $self->check_invoicing_list( $invoicing_list );
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- return "checking invoicing_list (transaction rolled back): $error";
+ #return "checking invoicing_list (transaction rolled back): $error";
+ return $error;
}
$self->invoicing_list( $invoicing_list );
}
;
return $error if $error;
+ if ( $conf->exists('cust_main-require_phone')
+ && ! length($self->daytime) && ! length($self->night)
+ ) {
+
+ my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
+ ? 'Day Phone'
+ : FS::Msgcat::_gettext('daytime');
+ my $night_label = FS::Msgcat::_gettext('night') =~ /^(night)?$/
+ ? 'Night Phone'
+ : FS::Msgcat::_gettext('night');
+
+ return "$daytime_label or $night_label is required"
+
+ }
+
my @addfields = qw(
last first company address1 address2 city county state zip
country daytime night fax
$payinfo =~ s/[^\d\@]//g;
if ( $conf->exists('echeck-nonus') ) {
$payinfo =~ /^(\d+)\@(\d+)$/ or return 'invalid echeck account@aba';
+ $payinfo = "$1\@$2";
} else {
$payinfo =~ /^(\d+)\@(\d{9})$/ or return 'invalid echeck account@aba';
+ $payinfo = "$1\@$2";
}
- $payinfo = "$1\@$2";
$self->payinfo($payinfo);
$self->paycvv('');
my $join = FS::part_event_condition->join_conditions_sql;
my $order = FS::part_event_condition->order_conditions_sql;
+ my $mine =
+ '( '
+ . join ( ' OR ' , map {
+ "( part_event.eventtable = " . dbh->quote($_)
+ . " AND tablenum IN( SELECT " . dbdef->table($_)->primary_key . " from $_ where custnum = " . dbh->quote( $self->custnum ) . "))" ;
+ } FS::part_event->eventtables)
+ . ') ';
#here is the agent virtualization
my $agent_virt = " ( part_event.agentnum IS NULL
'addl_from' => "LEFT JOIN part_event USING ( eventpart ) $join",
'hashref' => { 'status' => 'done' },
'extra_sql' => " AND statustext IS NOT NULL AND statustext != '' ".
- " AND $is_realtime_event AND $agent_virt $order" # LIMIT 1"
+ " AND $mine AND $is_realtime_event AND $agent_virt $order" # LIMIT 1"
});
my %seen_invnum = ();
sub check_invoicing_list {
my( $self, $arrayref ) = @_;
- foreach my $address ( @{$arrayref} ) {
+
+ foreach my $address ( @$arrayref ) {
if ($address eq 'FAX' and $self->getfield('fax') eq '') {
return 'Can\'t add FAX invoice destination with a blank FAX number.';
: $cust_main_invoice->checkdest
;
return $error if $error;
+
}
+
+ return "Email address required"
+ if $conf->exists('cust_main-require_invoicing_list_email')
+ && ! grep { $_ !~ /^([A-Z]+)$/ } @$arrayref;
+
'';
}
LEFT JOIN part_event_option AS peo_agentnum
ON ( part_event.eventpart = peo_agentnum.eventpart
AND peo_agentnum.optionname = 'agentnum'
- AND peo_agentnum.optionvalue ~ '(^|,)agentnum(,|$)'
+ AND peo_agentnum.optionvalue ~ '(^|,)}. $agentnum. q{agentnum(,|$)'
)
LEFT JOIN part_event_option AS peo_cust_bill_age
ON ( part_event.eventpart = peo_cust_bill_age.eventpart
#'hashref' => { 'optionname' => $option },
'hashref' => { 'part_event_option.optionname' => $option },
'extra_sql' => " AND event = 'cust_bill_send_agent' ".
+ " AND disabled != 'Y' ".
" AND peo_agentnum.optionname = 'agentnum' ".
" AND agentnum IS NULL OR agentnum = $agentnum ".
" ORDER BY
}
+sub queued_bill {
+ ## actual sub, not a method, designed to be called from the queue.
+ ## sets up the customer, and calls the bill_and_collect
+ my (%args) = @_; #, ($time, $invoice_time, $check_freq, $resetup) = @_;
+ my $cust_main = qsearchs( 'cust_main', { custnum => $args{'custnum'} } );
+ $cust_main->bill_and_collect(
+ %args,
+ );
+}
+
=back
=head1 BUGS