summaryrefslogtreecommitdiff
path: root/LedgerSMB/Reconciliation/CSV.pm
blob: f95bf194d5a8f97d8ea5489254e743a6d389b5e8 (plain)
  1. # CSV parser is basically a framework to handle any CSV files or fixed-width format files.
  2. # Parsers are defined in CSV/parser_type.
  3. package LedgerSMB::Reconciliation::CSV;
  4. use base qw/LedgerSMB/;
  5. use Datetime;
  6. sub load_file {
  7. my $self = shift @_;
  8. my $filename = shift @_;
  9. my $contents;
  10. do {
  11. local $/; # I think this is the right way to outrageously cheat
  12. open(FH,$filename);
  13. $contents = <FH>;
  14. }
  15. return $contents;
  16. }
  17. sub process {
  18. # thoroughly implementation-dependent.
  19. my $self = shift @_;
  20. my $contents = $self->load_file($self->{csv_filename});
  21. foreach my $line (split /\n/,$contents) {
  22. # Unpack for the format it is inexplicably in
  23. ($accno,
  24. $checkno,
  25. $issuedate
  26. $amount
  27. $cleared,
  28. $last_three) = unpack("A10A10A6A10A6A3",$line);
  29. push @{ $self->{entries} }, {
  30. account_num => $accno,
  31. scn => $checkno,
  32. issue_date => $issuedate,
  33. amount => $amount,
  34. cleared_date => $cleared
  35. };
  36. }
  37. # Okay, now how do I test to see if this is actually, y'know, bad data.
  38. for my $line (@{ $self->{entries} }) {
  39. # First check the account number.
  40. # According to the docs I have, it's all numbers.
  41. }
  42. return;
  43. }
  44. sub is_error {
  45. }
  46. sub error {
  47. }
  48. 1;