summaryrefslogtreecommitdiff
path: root/LedgerSMB/DBObject/Customer.pm
blob: 3805762f1cc896ab00faf72f792c01dc8dd34f77 (plain)
  1. package LedgerSMB::DBObject::Customer;
  2. use base qw(LedgerSMB::DBObject);
  3. use LedgerSMB::DBObject;
  4. use LedgerSMB::Entity;
  5. use strict;
  6. my $CUSTOMER_ENTITY_CLASS = 2;
  7. sub save {
  8. my $self = shift @_;
  9. # This saves both the entity and the credit account. -- CT
  10. $self->{entity_class} = $CUSTOMER_ENTITY_CLASS;
  11. my ($ref) = $self->exec_method(funcname => 'entity_credit_save');
  12. $self->{entity_id} = $ref->{entity_credit_save};
  13. $self->{dbh}->commit;
  14. }
  15. sub get_metadata {
  16. my $self = shift @_;
  17. @{$self->{location_class_list}} =
  18. $self->exec_method(funcname => 'location_list_class');
  19. @{$self->{country_list}} =
  20. $self->exec_method(funcname => 'location_list_country');
  21. @{$self->{contact_class_list}} =
  22. $self->exec_method(funcname => 'entity_list_contact_class');
  23. }
  24. sub save_location {
  25. my $self = shift @_;
  26. $self->{entity_class} = $CUSTOMER_ENTITY_CLASS;
  27. $self->{country_id} = $self->{country};
  28. $self->exec_method(funcname => 'customer_location_save');
  29. $self->{dbh}->commit;
  30. }
  31. sub save_contact {
  32. my ($self) = @_;
  33. $self->exec_method(funcname => 'company__save_contact');
  34. $self->{dbh}->commit;
  35. }
  36. sub save_bank_account {
  37. my $self = shift @_;
  38. $self->exec_method(funcname => 'entity__save_bank_account');
  39. $self->{dbh}->commit;
  40. }
  41. sub get {
  42. my $self = shift @_;
  43. my ($ref) = $self->exec_method(funcname => 'customer__retrieve');
  44. $self->merge($ref);
  45. $self->{name} = $self->{legal_name};
  46. @{$self->{locations}} = $self->exec_method(
  47. funcname => 'company__list_locations');
  48. @{$self->{contacts}} = $self->exec_method(
  49. funcname => 'company__list_contacts');
  50. @{$self->{bank_account}} = $self->exec_method(
  51. funcname => 'company__list_bank_account');
  52. @{$self->{notes}} = $self->exec_method(
  53. funcname => 'company__list_notes');
  54. }
  55. sub search {
  56. }
  57. 1;