/doc/todo/git_attribution/

rnate' title='Atom feed' href='https://source.jones.dk/ledger-smb/atom/LedgerSMB/RC.pm?h=master' type='application/atom+xml'/>
summaryrefslogtreecommitdiff
path: root/LedgerSMB/RC.pm
blob: 5952a2cedb6b759f179f72ee6c39abc9f645e248 (plain)
  1. #=====================================================================
  2. # LedgerSMB
  3. # Small Medium Business Accounting software
  4. #
  5. # Copyright (C) 2006
  6. # This work contains copyrighted information from a number of sources all used
  7. # with permission.
  8. #
  9. # This file contains source code included with or based on SQL-Ledger which
  10. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  11. # under the GNU General Public License version 2 or, at your option, any later
  12. # version. For a full list including contact information of contributors,
  13. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  14. #
  15. # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  16. # Copyright (C) 2002
  17. #
  18. # Author: DWS Systems Inc.
  19. # Web: http://www.sql-ledger.org
  20. #
  21. # Contributors:
  22. #
  23. #======================================================================
  24. #
  25. # This file has NOT undergone whitespace cleanup.
  26. #
  27. #======================================================================
  28. #
  29. # Account reconciliation routines
  30. #
  31. #======================================================================
  32. package RC;
  33. sub paymentaccounts {
  34. my ($self, $myconfig, $form) = @_;
  35. # connect to database
  36. my $dbh = $form->dbconnect($myconfig);
  37. my $query = qq|SELECT accno, description
  38. FROM chart
  39. WHERE link LIKE '%_paid%'
  40. AND (category = 'A' OR category = 'L')
  41. ORDER BY accno|;
  42. my $sth = $dbh->prepare($query);
  43. $sth->execute || $form->dberror($query);
  44. while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
  45. push @{ $form->{PR} }, $ref;
  46. }
  47. $sth->finish;
  48. $form->all_years($myconfig, $dbh);
  49. $dbh->disconnect;
  50. }
  51. sub payment_transactions {
  52. my ($self, $myconfig, $form) = @_;
  53. # connect to database, turn AutoCommit off
  54. my $dbh = $form->dbconnect_noauto($myconfig);
  55. my $query;
  56. my $sth;
  57. $query = qq|SELECT category FROM chart
  58. WHERE accno = '$form->{accno}'|;
  59. ($form->{category}) = $dbh->selectrow_array($query);
  60. my $cleared;
  61. ($form->{fromdate}, $form->{todate}) = $form->from_to($form->{year}, $form->{month}, $form->{interval}) if $form->{year} && $form->{month};
  62. my $transdate = qq| AND ac.transdate < date '$form->{fromdate}'|;
  63. if (! $form->{fromdate}) {
  64. $cleared = qq| AND ac.cleared = '1'|;
  65. $transdate = "";
  66. }
  67. # get beginning balance
  68. $query = qq|SELECT sum(ac.amount)
  69. FROM acc_trans ac
  70. JOIN chart ch ON (ch.id = ac.chart_id)
  71. WHERE ch.accno = '$form->{accno}'
  72. $transdate
  73. $cleared
  74. |;