[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3548] trunk/LedgerSMB/DBObject/Location.pm



Revision: 3548
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3548&view=rev
Author:   einhverfr
Date:     2011-07-20 23:08:21 +0000 (Wed, 20 Jul 2011)

Log Message:
-----------
Correcting errors saving user address.  Edit/delete still broken

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Location.pm

Modified: trunk/LedgerSMB/DBObject/Location.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Location.pm	2011-07-20 22:37:11 UTC (rev 3547)
+++ trunk/LedgerSMB/DBObject/Location.pm	2011-07-20 23:08:21 UTC (rev 3548)
@@ -1,3 +1,16 @@
+
+# A few things that are suboptimmal about this file.
+# 1)  No use of discovery in stored proc arg lists means that API's are brittle
+# 2)  Dynamic generation of sproc names makes this extremely hard to use to 
+# find if a sproc is used or not.  This also (as per #1) forces sprocs to share
+# exactly identical argument lists which is a problem in terms of API 
+# flexibility.  I am inclined to mark this "depricated" despite the fact that 
+# this is new code.    Right now this is only used by user management routines
+# and it should stay that way.
+#
+# --CT
+#
+
 package LedgerSMB::DBObject::Location;
 
 use base LedgerSMB::DBObject;
@@ -13,18 +26,26 @@
     my $type = shift @_;
     
     # assumes all the parameters are present...
+            'address1',
+            'address2',
+            'city',
+            'state',
+            'zipcode',
+            'country',
+            'companyname',            
     
     my ($ret) = $self->exec_method(funcname=>$type."__save_location", args=>[
         $self->{user_id}, # entity_id           
         $self->{location_id}, # location_id
-        $self->{location_class}, # location class, for _to_contact
-        $self->{line_one},
-        $self->{line_two},
+        $self->{location_class} || 1, # location class, for _to_contact
+        $self->{line_one} || $self->{'address1'},
+        $self->{line_two} || $self->{'address2'},
         $self->{line_three}, # address info
         $self->{city}, # city
         $self->{state}, # state/province
-        $self->{mail_code},
-        $self->{country} # obviously, country.
+        $self->{mail_code} || $self->{'zipcode'},
+        $self->{country}, # obviously, country.
+        $self->{old_location_class} || 1 # obviously, country.
     ]);
     $self->{id} = $ret->{$type."__save_location"};
     $self->{dbh}->commit();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.