summaryrefslogtreecommitdiff
path: root/LedgerSMB/Reconciliation/CSV.pm
blob: c63ce3273f371bdd6ff81a5b3eb9901fbbae7ee1 (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. }
  43. return;
  44. }
  45. sub is_error {
  46. }
  47. sub error {
  48. }
  49. 1;