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

SF.net SVN: ledger-smb:[3327] trunk



Revision: 3327
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3327&view=rev
Author:   einhverfr
Date:     2011-06-25 08:47:04 +0000 (Sat, 25 Jun 2011)

Log Message:
-----------
First draft of missing contact APIs

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Company.pm
    trunk/LedgerSMB/DBObject/Employee.pm
    trunk/doc/manual/LedgerSMB-manual.tex
    trunk/sql/modules/Company.sql
    trunk/sql/modules/Entity.sql
    trunk/sql/modules/Person.sql

Modified: trunk/LedgerSMB/DBObject/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Company.pm	2011-06-25 06:13:00 UTC (rev 3326)
+++ trunk/LedgerSMB/DBObject/Company.pm	2011-06-25 08:47:04 UTC (rev 3327)
@@ -66,8 +66,108 @@
     $self->{dbh}->commit;
 }
 
+
 =over 
 
+=item delete_contact
+
+required request variables:
+
+contact_class_id:  int id of contact class
+contact: text of contact information
+
+Must include at least one of:
+
+credit_id: int of entity_credit_account.id, preferred value
+company_id:  int of company.id, only used if credit_id not set.
+
+returns true of a record was deleted.
+
+=back
+
+=cut
+
+sub delete_contact {
+    my ($self) = @_;
+    my $rv;
+    if ($self->{credit_id}){
+        ($rv) = $self->exec_method(funcname => 'eca__delete_contact');
+    } elsif ($self->{company_id}){
+        ($rv) = $self->exec_method(funcname => 'company__delete_contact');
+    } else {
+       $self->error($self->{_locale}->text(
+          'No company or credit id in LedgerSMB::DBObject::delete_contact'
+       ));
+    }
+    return $rv;
+}
+
+=over
+
+=item delete_location
+
+Deletes a record from the location side.
+
+Required request variables:
+
+location_id
+location_class_id
+
+One of:
+
+credit_id (preferred)
+company_id (as fallback)
+
+Returns true if a record was deleted.  False otherwise.
+
+=back
+
+=cut
+
+sub delete_location {
+    my ($self) = @_;
+    my $rv;
+    if ($self->{credit_id}){
+        ($rv) = $self->exec_method(funcname => 'eca__delete_location');
+    } elsif ($self->{company_id}){
+        ($rv) = $self->exec_method(funcname => 'company__delete_location');
+    } else {
+       $self->error($self->{_locale}->text(
+          'No company or credit id in LedgerSMB::DBObject::delete_location'
+       ));
+    }
+    return $rv;
+}
+
+
+=over 
+
+=item delete_bank_account
+
+Deletes a bank account
+
+Requires:
+
+entity_id
+bank_account_id
+
+Returns true if a record was deleted, false otherwise.
+
+=back
+
+=cut
+
+sub delete_bank_account {
+    my ($self) = @_;
+    my $rv;
+    ($rv) = $self->exec_method(funcname => 'entity__delete_bank_account',
+                               args => [$self->{entity_id}, 
+                                        $self->{bank_account_id}]);
+    return $rv;
+}
+
+=over 
+
 = item get_history 
 
 Retrieves customer/vendor purchase.

Modified: trunk/LedgerSMB/DBObject/Employee.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Employee.pm	2011-06-25 06:13:00 UTC (rev 3326)
+++ trunk/LedgerSMB/DBObject/Employee.pm	2011-06-25 08:47:04 UTC (rev 3327)
@@ -118,4 +118,75 @@
     return @results;
 }
 
+=over 
+
+=item delete_contact
+
+required request variables:
+
+contact_class_id:  int id of contact class
+contact: text of contact information
+person_id: int of entity_credit_account.id, preferred value
+
+
+=back
+
+=cut
+
+sub delete_contact {
+    my ($self) = @_;
+    $self->exec_method(funcname => 'person__delete_contact');
+}
+
+=over
+
+=item delete_location
+
+Deletes a record from the location side.
+
+Required request variables:
+
+location_id
+location_class_id
+person_id
+
+Returns true if a record was deleted.  False otherwise.
+
+=back
+
+=cut
+
+sub delete_location {
+    my ($self) = @_;
+    my $rv;
+    ($rv) = $self->exec_method(funcname => 'person__delete_location');
+    return $rv;
+}
+
+=over 
+
+=item delete_bank_account
+
+Deletes a bank account
+
+Requires:
+
+entity_id
+bank_account_id
+
+Returns true if a record was deleted, false otherwise.
+
+=back
+
+=cut
+
+sub delete_bank_account {
+    my ($self) = @_;
+    my $rv;
+    ($rv) = $self->exec_method(funcname => 'entity__delete_bank_account',
+                               args => [$self->{entity_id}, 
+                                        $self->{bank_account_id}]);
+    return $rv;
+}
+
 1;

Modified: trunk/doc/manual/LedgerSMB-manual.tex
===================================================================
--- trunk/doc/manual/LedgerSMB-manual.tex	2011-06-25 06:13:00 UTC (rev 3326)
+++ trunk/doc/manual/LedgerSMB-manual.tex	2011-06-25 08:47:04 UTC (rev 3327)
@@ -3306,7 +3306,7 @@
 
 \subsection{Brief Guide to the Source Code}
 
-TODO: Check lines of code again, update this section
+TODO: Check lines of code again, update this section 
 
 LedgerSMB is an application with over 34000 lines of code. While
 it is not possible to cover the entire application here, a brief overview
@@ -3342,7 +3342,10 @@
 Finally, the sql directory provides the database schemas and upgrade
 scripts.
 
+\subsection{Structure of Old and New Code}
 
+TODO:  Add this
+
 \subsection{Data Entry Screens}
 
 One can customize the data entry screens to optimize work flow, display

Modified: trunk/sql/modules/Company.sql
===================================================================
--- trunk/sql/modules/Company.sql	2011-06-25 06:13:00 UTC (rev 3326)
+++ trunk/sql/modules/Company.sql	2011-06-25 08:47:04 UTC (rev 3327)
@@ -778,6 +778,34 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+CREATE OR REPLACE FUNCTION company__delete_contact
+(in_company_id int, in_contact_class_id int, in_contact text)
+returns bool as $$
+BEGIN
+
+DELETE FROM company_to_contact
+ WHERE company_id = in_company_id and contact_class_id = in_contact_class_id
+       and contact= in_contact;
+RETURN FOUND;
+
+END;
+
+$$ language plpgsql;
+
+CREATE OR REPLACE FUNCTION eca__delete_contact
+(in_credit_id int, in_contact_class_id int, in_contact text)
+returns bool as $$
+BEGIN
+
+DELETE FROM eca_to_contact
+ WHERE credit_id = in_credit_id and contact_class_id = in_contact_class_id
+       and contact= in_contact;
+RETURN FOUND;
+
+END;
+
+$$ language plpgsql;
+
 CREATE OR REPLACE FUNCTION company__save_contact
 (in_entity_id int, in_contact_class int, in_description text, in_contact text)
 RETURNS INT AS
@@ -947,6 +975,37 @@
 
 $$ language 'plpgsql';
 
+CREATE OR REPLACE FUNCTION eca__delete_location
+(in_credit_id int, in_location_id int, in_location_class int)
+RETURNS BOOL AS
+$$
+BEGIN
+
+DELETE FROM eca_to_location
+ WHERE credit_id = in_credit_id AND location_id = in_location_id 
+       AND location_class = in_location_class;
+
+RETURN FOUND;
+
+END;
+$$ language plpgsql;
+
+CREATE OR REPLACE FUNCTION company__delete_location
+(in_company_id int, in_location_id int, in_location_class int)
+RETURNS BOOL AS
+$$
+BEGIN
+
+DELETE FROM eca_to_location
+ WHERE company_id = in_company_id AND location_id = in_location_id 
+       AND location_class = in_location_class;
+
+RETURN FOUND;
+
+END;
+$$ language plpgsql;
+
+
 CREATE OR REPLACE FUNCTION eca__get_location(
     in_credit_id int,
     in_class text

Modified: trunk/sql/modules/Entity.sql
===================================================================
--- trunk/sql/modules/Entity.sql	2011-06-25 06:13:00 UTC (rev 3326)
+++ trunk/sql/modules/Entity.sql	2011-06-25 08:47:04 UTC (rev 3327)
@@ -85,3 +85,20 @@
 $$ language plpgsql;
 
 
+CREATE OR REPLACE FUNCTION entity__delete_bank_account
+(in_entity_id int, in_id int)
+RETURNS bool AS
+$$
+BEGIN
+
+UPDATE entity_credit_account SET bank_account = NULL
+ WHERE entity_id = in_entity_id AND bank_account = in_id;
+
+DELETE FROM entity_bank_account
+ WHERE id = in_id AND entity_id = in_entity_id;
+
+RETURN FOUND;
+
+END;
+$$ LANGUAGE plpgsql;
+

Modified: trunk/sql/modules/Person.sql
===================================================================
--- trunk/sql/modules/Person.sql	2011-06-25 06:13:00 UTC (rev 3326)
+++ trunk/sql/modules/Person.sql	2011-06-25 08:47:04 UTC (rev 3327)
@@ -90,6 +90,20 @@
 
 --
 
+CREATE OR REPLACE FUNCTION person__delete_contact
+(in_person_id int, in_contact_class_id int, in_contact text)
+returns bool as $$
+BEGIN
+
+DELETE FROM person_to_contact
+ WHERE person_id = in_person_id and contact_class_id = in_contact_class_id
+       and contact= in_contact;
+RETURN FOUND;
+
+END;
+
+$$ language plpgsql;
+
 CREATE OR REPLACE FUNCTION person__save_contact
 (in_entity_id int, in_contact_class int, in_contact_orig text, in_contact_new TEXT)
 RETURNS INT AS
@@ -161,7 +175,22 @@
 $$ LANGUAGE PLPGSQL;
 		
 --
+CREATE OR REPLACE FUNCTION person__delete_location
+(in_person_id int, in_location_id int, in_location_class int)
+RETURNS BOOL AS
+$$
+BEGIN
 
+DELETE FROM eca_to_location
+ WHERE person_id = in_person_id AND location_id = in_location_id 
+       AND location_class = in_location_class;
+
+RETURN FOUND;
+
+END;
+$$ language plpgsql;
+
+
 create or replace function person__save_location(
     in_entity_id int, 
     in_location_id int,


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