1 package FS::cust_pkg::API;
8 +{ ( map { $_=>$self->$_ } $self->fields ),
13 # currently only handles location change...
14 # eventually have it handle all sorts of package changes
19 return { 'error' => 'Cannot change canceled package' }
20 if $self->get('cancel');
24 # update location--accepts raw fields OR location
26 foreach my $field ( qw(
43 $location_hash{$field} = $opt{$field} if $opt{$field};
45 return { 'error' => 'Cannot pass both locationnum and location fields' }
46 if $opt{'locationnum'} && %location_hash;
49 my $cust_location = FS::cust_location->new({
50 'custnum' => $self->custnum,
53 $changeopt{'cust_location'} = $cust_location;
54 } elsif ($opt{'locationnum'}) {
55 $changeopt{'locationnum'} = $opt{'locationnum'};
58 # not quite "nothing changed" because passed changes might be identical to current record,
59 # we don't currently check for that, don't want to imply that we do...but maybe we should?
60 return { 'error' => 'No changes passed to method' }
61 unless $changeopt{'cust_location'} || $changeopt{'locationnum'};
63 $changeopt{'keep_dates'} = 1;
65 my $pkg_or_error = $self->change( \%changeopt );
66 my $error = ref($pkg_or_error) ? '' : $pkg_or_error;
68 return { 'error' => $error } if $error;
70 # return all fields? we don't yet expose them through FS::API
71 return { map { $_ => $pkg_or_error->get($_) } qw( pkgnum locationnum ) };