summaryrefslogtreecommitdiff
path: root/LedgerSMB/Vendor.pm
diff options
context:
space:
mode:
authoraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-15 23:10:31 +0000
committeraurynn_cmd <aurynn_cmd@4979c152-3d1c-0410-bac9-87ea11338e46>2007-11-15 23:10:31 +0000
commitd340ccd5ecbb731c273a07876ad0dfc0a9b33379 (patch)
tree15acb5cc66a14c787ef49a6bab8910cdca0f82c9 /LedgerSMB/Vendor.pm
parentc366b783a65dfdd7dadb105962ae0807cddaa6b9 (diff)
Significant work on the Entity and Administrative code. It's buggy, so please test, etc. thoroughly.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1869 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Vendor.pm')
-rw-r--r--LedgerSMB/Vendor.pm46
1 files changed, 26 insertions, 20 deletions
diff --git a/LedgerSMB/Vendor.pm b/LedgerSMB/Vendor.pm
index 52aa4944..fe58b79f 100644
--- a/LedgerSMB/Vendor.pm
+++ b/LedgerSMB/Vendor.pm
@@ -1,33 +1,39 @@
package LedgerSMB::DBObject::Vendor;
-use base qw(LedgerSMB);
+use base qw(LedgerSMB::DBObject::Company);
use LedgerSMB::DBObject;
-sub save_to_db {
-
+sub save {
my $self = shift @_;
- my $id;
- if ($self->{id} >= 1) {
- $id = $self->{id};
+ my $entity;
+
+ # this is a fairly effective way of telling if we need to create a new
+ # entity or not.
+
+ if (!$self->{entity_id}) {
+
+ $entity = LedgerSMB::Entity->new(base=>$request);
}
else {
- $id = $self->next_vendor_id();
+
+ $entity = LedgerSMB::Entity->get(id=>$self->{entity_id});
}
- $id = $self->save($id, $self->{discount}, $self->{tax_included},
- $self->{creditlimit}, $self->{terms}, $self->{vendornumber},
- $self->{cc}, $self->{bcc}, $self->{business_id}, $self->{language},
- $self->{pricegroup}, $self->{currency}, $self->{startdate},
- $self->{enddate}
- );
- # Undef in the created field causes the system to use now() as the current
- # creation date.
- $self->location_save(
- $id, 1, $self->{line_one}, $self->{line_two}, $self->{line_three},
- $self->{city_province}, $self->{mailing_code}, $self->{country}, undef
+ $entity->set(name=> $reqeust->{first_name}." ".$request->{last_name} );
+ $entity->set(entity_class=>2);
+
+ $self->set(entity_id=>$entity->{id});
+ $self->set(entity_class=> 1);
+
+ $entity->save();
+ if (!self->{entity_id}) {
- );
- return $id;
+ $self->{entity_id} = $entity->{id};
+ }
+ $self->SUPER::save();
+
+ return $self->{id};
+
}
1; \ No newline at end of file