+ return $self->{CustomerInfo} if $self->{CustomerInfo};
+ $self = $self->CustomerResolver;
+
+ my $rec = $self->_FreesideGetRecord() if $self;
+ if (!$rec) {
+ # AsStringLong will report an error;
+ # here, just avoid breaking things
+ my $error = {
+ AgentName => '',
+ CustomerClass => '',
+ CustomerTags => [],
+ Referral => '',
+ InvoiceEmail => '',
+ BillingType => '',
+ };
+ return $error;
+ }
+
+ my $cust_main = delete $rec->{_object};
+ my $agent = $cust_main->agent;
+ my $class = $cust_main->cust_class;
+ my $referral = qsearchs('part_referral', { refnum => $cust_main->refnum });
+ my @part_tags = $cust_main->part_tag;
+
+ my @lf = $cust_main->location_fields;
+ my $bill_location = $cust_main->bill_location;
+ my $ship_location = $cust_main->ship_location;
+
+ my $info = {
+ %$rec,
+
+ AgentName => ($agent ? ($agent->agentnum.': '.$agent->agent) : ''),
+ CustomerClass => ($class ? $class->classname : ''),
+ CustomerTags => [
+ sort { $a->{'name'} <=> $b->{'name'} }
+ map {
+ { name => $_->tagname, desc => $_->tagdesc, color => $_->tagcolor }
+ } @part_tags
+ ],
+ Referral => ($referral ? $referral->referral : ''),
+ InvoiceEmail => $cust_main->invoicing_list_emailonly_scalar,
+ BillingType => FS::payby->longname($cust_main->payby),
+ };
+
+ foreach my $field (@lf) {
+ $info->{"bill_$field"} = $bill_location->get($field);
+ $info->{"ship_$field"} = $ship_location->get($field);
+ }
+ $info->{"bill_location"} = $bill_location->location_label(no_prefix => 1);
+ $info->{"ship_location"} = $ship_location->location_label(no_prefix => 1);
+
+ return $self->{CustomerInfo} = $info;
+}
+
+sub ServiceInfo {
+ my $self = shift;
+ $self->{fstable} eq 'cust_svc' or return;
+ return $self->{ServiceInfo} if $self->{ServiceInfo};
+