classnum of 0 is given, contacts with a null classnum are also included.
Arguments may also contain the dest flag names 'invoice' or 'message'.
-If given, contacts who's invoice_dest and/or invoice_message flags are
+If given, contacts who's invoice_dest and/or message_dest flags are
not set to 'Y' will be excluded.
=cut
# WHERE ...
# AND (
- # ( cust_contact.classnum IN (1,2,3) )
- # OR
- # ( cust_contact.classnum IS NULL )
- #
+ # (
+ # cust_contact.classnum IN (1,2,3)
+ # OR
+ # cust_contact.classnum IS NULL
+ # )
# AND (
- # ( cust_contact.invoice_dest = 'Y' )
+ # cust_contact.invoice_dest = 'Y'
# OR
- # ( cust_contact.message_dest = 'Y' )
+ # cust_contact.message_dest = 'Y'
# )
# )
$search->{extra_sql} .= ' AND ( ';
if (@or_classnum) {
- $search->{extra_sql} .= join ' OR ', map {" ($_) "} @or_classnum;
+ $search->{extra_sql} .= ' ( ';
+ $search->{extra_sql} .= join ' OR ', map {" $_ "} @or_classnum;
+ $search->{extra_sql} .= ' ) ';
$search->{extra_sql} .= ' AND ( ' if @and_dest;
}
if (@and_dest) {
- $search->{extra_sql} .= join ' OR ', map {" ($_) "} @and_dest;
+ $search->{extra_sql} .= join ' OR ', map {" $_ "} @and_dest;
$search->{extra_sql} .= ' ) ' if @or_classnum;
}
$name;
}
+=item batch_payment_payname
+
+Returns a name string for this customer, either "cust_batch_payment->payname" or "First Last" or "Company,
+based on if a company name exists and is the account being used a business account.
+
+=cut
+
+sub batch_payment_payname {
+ my $self = shift;
+ my $cust_pay_batch = shift;
+ my $name;
+
+ if ($cust_pay_batch->{Hash}->{payby} eq "CARD") { $name = $cust_pay_batch->payname; }
+ else { $name = $self->first .' '. $self->last; }
+
+ $name = $self->company
+ if (($cust_pay_batch->{Hash}->{paytype} eq "Business checking" || $cust_pay_batch->{Hash}->{paytype} eq "Business savings") && $self->company);
+
+ $name;
+}
+
=item service_contact
Returns the L<FS::contact> object for this customer that has the 'Service'