RT#29296: API stuff: Add new locations [API bug fixes]
authorJonathan Prykop <jonathan@freeside.biz>
Tue, 19 Apr 2016 17:16:15 +0000 (12:16 -0500)
committerJonathan Prykop <jonathan@freeside.biz>
Tue, 19 Apr 2016 17:16:15 +0000 (12:16 -0500)
FS/FS/API.pm
FS/FS/cust_pkg/API.pm

index 77ae03b..1c4cbd9 100644 (file)
@@ -589,7 +589,7 @@ containing the new values.
 =cut
 
 sub change_package_location {
-  my $self = shift;
+  my $class = shift;
   my %opt  = @_;
   return _shared_secret_error() unless _check_shared_secret($opt{'secret'});
 
@@ -597,13 +597,10 @@ sub change_package_location {
     or return { 'error' => 'Unknown pkgnum' };
 
   my %changeopt;
-  $changeopt{'pkgnum'} = $pkgnum;
 
-  my $cust_location = FS::cust_location->new({
-    'custnum' => $cust_pkg->custnum,
-    %location_hash,
-  });
-  $changeopt{'cust_location'} = $cust_location;
+  foreach my $field ('locationnum',FS::cust_location::API::API_editable_fields()) {
+    $changeopt{$field} = $opt{$field} if $opt{$field};
+  }
 
   $cust_pkg->API_change(%changeopt);
 }
index 6e03b8e..7ef3f72 100644 (file)
@@ -19,7 +19,7 @@ sub API_change {
   my %opt = @_;
 
   return { 'error' => 'Cannot change canceled package' }
-    if $self->cancel;
+    if $self->get('cancel');
 
   my %changeopt;