diff options
Diffstat (limited to 'LedgerSMB/Vendor.pm')
-rw-r--r-- | LedgerSMB/Vendor.pm | 46 |
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 |