summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-25 19:59:02 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-25 19:59:02 +0000
commitd63d2487d738b5273f0bb00d9caf8dce591ac91e (patch)
tree45b495c53edee39fb68bf1d96342d0909001e129
parente351ede55ad2450b952680c4fad04c2523f49faa (diff)
More postfactoring
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1901 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--LedgerSMB/DBObject/Company.pm26
-rw-r--r--LedgerSMB/DBObject/Customer.pm30
-rw-r--r--LedgerSMB/DBObject/Employee.pm13
-rw-r--r--LedgerSMB/DBObject/Vendor.pm31
4 files changed, 42 insertions, 58 deletions
diff --git a/LedgerSMB/DBObject/Company.pm b/LedgerSMB/DBObject/Company.pm
index 30023c92..0ce2f6ee 100644
--- a/LedgerSMB/DBObject/Company.pm
+++ b/LedgerSMB/DBObject/Company.pm
@@ -4,14 +4,29 @@ package LedgerSMB::DBObject::Company;
use base qw(LedgerSMB::DBObject);
use strict;
-sub save_credit {
+sub set_entity_class {
my $self = shift @_;
+ if (!defined $self->{entity_class}){
+ $self->error("Entity ID Not Set and No Entity Class Defined!");
+ }
+}
+sub save {
+ my $self = shift @_;
+ $self->set_entity_class();
my ($ref) = $self->exec_method(funcname => 'entity_credit_save');
$self->{entity_id} = $ref->{entity_credit_save};
$self->{dbh}->commit;
}
+sub save_location {
+ my $self = shift @_;
+ $self->{country_id} = $self->{country};
+ $self->exec_method(funcname => 'company__location_save');
+
+ $self->{dbh}->commit;
+}
+
sub get_metadata {
my $self = shift @_;
@@ -37,8 +52,15 @@ sub save_bank_account {
$self->{dbh}->commit;
}
-sub get_company{
+sub get {
my $self = shift @_;
+
+ $self->set_entity_class()
+ my ($ref) = $self->exec_method(funcname => 'entity__retrieve_credit');
+ $self->merge($ref);
+
+ $self->{name} = $self->{legal_name};
+
@{$self->{locations}} = $self->exec_method(
funcname => 'company__list_locations');
diff --git a/LedgerSMB/DBObject/Customer.pm b/LedgerSMB/DBObject/Customer.pm
index a9bcffc7..6c52a2d9 100644
--- a/LedgerSMB/DBObject/Customer.pm
+++ b/LedgerSMB/DBObject/Customer.pm
@@ -3,38 +3,16 @@ package LedgerSMB::DBObject::Customer;
use base qw(LedgerSMB::DBObject::Company);
use strict;
-my $CUSTOMER_ENTITY_CLASS = 2;
+my $ENTITY_CLASS = 2;
-sub save {
+sub set_entity_class {
my $self = shift @_;
-
- $self->{entity_class} = $CUSTOMER_ENTITY_CLASS;
- $self->save_credit(); # inherited from Company
-}
-
-
-sub save_location {
- my $self = shift @_;
- $self->{entity_class} = $CUSTOMER_ENTITY_CLASS;
- $self->{country_id} = $self->{country};
- $self->exec_method(funcname => 'company__location_save');
-
- $self->{dbh}->commit;
+ $self->{entity_class} = $ENTITY_CLASS;
}
+
-sub get {
- my $self = shift @_;
- $self->{entity_class} = $CUSTOMER_ENTITY_CLASS;
- my ($ref) = $self->exec_method(funcname => 'entity__retrieve_credit');
- $self->merge($ref);
-
- $self->{name} = $self->{legal_name};
- $self->get_company();
-}
-
-
sub search {
diff --git a/LedgerSMB/DBObject/Employee.pm b/LedgerSMB/DBObject/Employee.pm
new file mode 100644
index 00000000..ddc453a6
--- /dev/null
+++ b/LedgerSMB/DBObject/Employee.pm
@@ -0,0 +1,13 @@
+package LedgerSMB::DBObject::Employee;
+
+use base qw(LedgerSMB::DBObject::Company);
+use strict;
+
+my $ENTITY_CLASS = 3;
+
+sub set_entity_class {
+ my $self = shift @_;
+ $self->{entity_class} = $ENTITY_CLASS;
+}
+
+1;
diff --git a/LedgerSMB/DBObject/Vendor.pm b/LedgerSMB/DBObject/Vendor.pm
index e2fa26d8..d6bb7bf1 100644
--- a/LedgerSMB/DBObject/Vendor.pm
+++ b/LedgerSMB/DBObject/Vendor.pm
@@ -5,38 +5,9 @@ use strict;
my $ENTITY_CLASS = 1;
-sub save {
- my $self = shift @_;
-
- $self->{entity_class} = $ENTITY_CLASS;
- $self->save_credit(); # inherited from Company
-}
-
-
-sub save_location {
- my $self = shift @_;
- $self->{entity_class} = $ENTITY_CLASS;
- $self->{country_id} = $self->{country};
- $self->exec_method(funcname => 'company__location_save');
-
- $self->{dbh}->commit;
-}
-
-
-
-sub get {
+sub set_entity_class {
my $self = shift @_;
$self->{entity_class} = $ENTITY_CLASS;
- my ($ref) = $self->exec_method(funcname => 'entity__retrieve_credit');
- $self->merge($ref);
-
- $self->{name} = $self->{legal_name};
- $self->get_company();
}
-
-
-sub search {
-
-}
1;