summaryrefslogtreecommitdiff
path: root/LedgerSMB/Batch.pm
blob: 142a6bb4563217c7d1faa294fb6f4c01358fbac1 (plain)
  1. package LedgerSMB::Batch;
  2. use base qw(LedgerSMB::DBObject);
  3. sub create {
  4. $self = shift @_;
  5. my ($ref) = $self->exec_method(funcname => 'batch_create');
  6. $self->{id} = $ref->{batch_create};
  7. $self->{dbh}->commit;
  8. return $ref->{id};
  9. }
  10. sub delete_voucher {
  11. my ($self, $voucher_id) = @_;
  12. $self->call_procedure(procname => 'voucher__delete', args => [$voucher_id]);
  13. $self->{dbh}->commit;
  14. }
  15. sub get_search_criteria {
  16. $self = shift @_;
  17. @{$self->{batch_classes}} = $self->exec_method(
  18. funcname => 'batch_list_classes'
  19. );
  20. @{$self->{batch_users}} = $self->exec_method(
  21. funcname => 'batch_get_users'
  22. );
  23. unshift @{$self->{batch_users}}, {username => $self->{_locale}->text('Any'), id => '0', entity_id => ''};
  24. }
  25. sub get_search_results {
  26. my ($self) = @_;
  27. @{$self->{search_results}} = $self->exec_method(funcname => 'batch_search');
  28. return @{$self->{search_results}};
  29. }
  30. sub post {
  31. my ($self) = @_;
  32. ($self->{post_return_ref}) = $self->exec_method(funcname => 'batch_post');
  33. $self->{dbh}->commit;
  34. return $self->{post_return_ref};
  35. }
  36. sub delete {
  37. my ($self) = @_;
  38. ($self->{delete_ref}) = $self->exec_method(funcname => 'batch_delete');
  39. $self->{dbh}->commit;
  40. return $self->{delete_ref};
  41. }
  42. sub list_vouchers {
  43. my ($self) = @_;
  44. @{$self->{vouchers}} = $self->exec_method(funcname => 'voucher_list');
  45. return @{$self->{vouchers}};
  46. }
  47. 1;