summaryrefslogtreecommitdiff
path: root/LedgerSMB/Vendor.pm
blob: fe58b79fb3381c7445b171e7e697c2cd4192d54c (plain)
  1. package LedgerSMB::DBObject::Vendor;
  2. use base qw(LedgerSMB::DBObject::Company);
  3. use LedgerSMB::DBObject;
  4. sub save {
  5. my $self = shift @_;
  6. my $entity;
  7. # this is a fairly effective way of telling if we need to create a new
  8. # entity or not.
  9. if (!$self->{entity_id}) {
  10. $entity = LedgerSMB::Entity->new(base=>$request);
  11. }
  12. else {
  13. $entity = LedgerSMB::Entity->get(id=>$self->{entity_id});
  14. }
  15. $entity->set(name=> $reqeust->{first_name}." ".$request->{last_name} );
  16. $entity->set(entity_class=>2);
  17. $self->set(entity_id=>$entity->{id});
  18. $self->set(entity_class=> 1);
  19. $entity->save();
  20. if (!self->{entity_id}) {
  21. $self->{entity_id} = $entity->{id};
  22. }
  23. $self->SUPER::save();
  24. return $self->{id};
  25. }
  26. 1;