summaryrefslogtreecommitdiff
path: root/doc/todo/git_attribution
ModeNameSize
-rw-r--r--discussion.mdwn4290logplain
rsion. For a full list including contact information of contributors,
  • # maintainers, and copyright holders, see the CONTRIBUTORS file.
  • #
  • # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  • # Copyright (C) 2003
  • #
  • # Author: DWS Systems Inc.
  • # Web: http://www.sql-ledger.org
  • #
  • # Contributors:
  • #
  • #
  • #======================================================================
  • #
  • # This file has undergone whitespace cleanup.
  • #
  • #======================================================================
  • #
  • # Check and receipt printing payment module backend routines
  • # Number to text conversion routines are in
  • # locale/{countrycode}/Num2text
  • #
  • #======================================================================
  • package CP;
  • sub new {
  • my ($type, $countrycode) = @_;
  • $self = {};
  • if ($countrycode) {
  • if (-f "locale/$countrycode/Num2text") {
  • require "locale/$countrycode/Num2text";
  • } else {
  • use LedgerSMB::Num2text;
  • }
  • } else {
  • use LedgerSMB::Num2text;
  • }
  • bless $self, $type;
  • }
  • sub paymentaccounts {
  • my ($self, $myconfig, $form) = @_;
  • # connect to database
  • my $dbh = $form->dbconnect($myconfig);
  • my $query = qq|SELECT accno, description, link
  • FROM chart
  • WHERE link LIKE '%$form->{ARAP}%'
  • ORDER BY accno|;
  • my $sth = $dbh->prepare($query);
  • $sth->execute || $form->dberror($query);
  • $form->{PR}{$form->{ARAP}} = ();
  • $form->{PR}{"$form->{ARAP}_paid"} = ();
  • while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
  • foreach my $item (split /:/, $ref->{link}) {
  • if ($item eq $form->{ARAP}) {
  • push @{ $form->{PR}{$form->{ARAP}} }, $ref;
  • }
  • if ($item eq "$form->{ARAP}_paid") {
  • push @{ $form->{PR}{"$form->{ARAP}_paid"} }, $ref;
  • }
  • }
  • }
  • $sth->finish;
  • # get currencies and closedto
  • $query = qq|SELECT curr, closedto, current_date
  • FROM defaults|;
  • ($form->{currencies}, $form->{closedto}, $form->{datepaid}) = $dbh->selectrow_array($query);
  • if ($form->{payment} eq 'payments') {
  • # get language codes
  • $query = qq|SELECT *
  • FROM language
  • ORDER BY 2|;
  • $sth = $dbh->prepare($query);
  • $sth->execute || $self->dberror($query);
  • $form->{all_language} = ();
  • while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
  • push @{ $form->{all_language} }, $ref;
  • }
  • $sth->finish;
  • $form->all_departments($myconfig, $dbh, $form->{vc});
  • }
  • $dbh->disconnect;
  • }
  • sub get_openvc {
  • my ($self, $myconfig, $form) = @_;
  • my $dbh = $form->dbconnect($myconfig);
  • my $arap = ($form->{vc} eq 'customer') ? 'ar' : 'ap';
  • my $query = qq|SELECT count(*)
  • FROM $form->{vc} ct, $arap a
  • WHERE a.$form->{vc}_id = ct.id
  • AND a.amount != a.paid|;
  • my ($count) = $dbh->selectrow_array($query);
  • my $sth;
  • my $ref;
  • my $i = 0;
  • my $where = qq|WHERE a.$form->{vc}_id = ct.id
  • AND a.amount != a.paid|;
  • if ($form->{$form->{vc}}) {
  • my $var = $form->like(lc $form->{$form->{vc}});
  • $where .= " AND lower(name) LIKE '$var'";
  • }
  • # build selection list
  • $query = qq|SELECT DISTINCT ct.*
  • FROM $form->{vc} ct, $arap a
  • $where
  • ORDER BY name|;
  • $sth = $dbh->prepare($query);
  • $sth->execute || $form->dberror($query);
  • while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
  • $i++;
  • push @{ $form->{name_list} }, $ref;
  • }
  • $sth->finish;
  • $form->all_departments($myconfig, $dbh, $form->{vc});
  • # get language codes
  • $query = qq|SELECT *
  • FROM language
  • ORDER BY 2|;
  • $sth = $dbh->prepare($query);
  • $sth->execute || $self->dberror($query);
  • $form->{all_language} = ();
  • while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
  • push @{ $form->{all_language} }, $ref;
  • }
  • $sth->finish;
  • # get currency for first name
  • if (@{ $form->{name_list} }) {
  • $query = qq|SELECT curr
  • FROM $form->{vc}
  • WHERE id = $form->{name_list}->[0]->{id}|;
  • ($form->{currency}) = $dbh->selectrow_array($query);
  • $form->{currency} ||= $form->{defaultcurrency};
  • }
  • $dbh->disconnect;
  • $i;
  • }
  • sub get_openinvoices {
  • my ($self, $myconfig, $form) = @_;
  • my $null;
  • my $department_id;
  • # connect to database
  • my $dbh = $form->dbconnect($myconfig);
  • my $where = qq|WHERE a.$form->{vc}_id = $form->{"$form->{vc}_id"}
  • AND a.amount != a.paid|;
  • $where .= qq| AND a.curr = '$form->{currency}'| if $form->{currency};
  • my $sortorder = "transdate, invnumber";
  • my ($buysell);
  • if ($form->{vc} eq 'customer') {
  • $buysell = "buy";
  • } else {
  • $buysell = "sell";
  • }
  • if ($form->{payment} eq 'payments') {
  • $where = qq|WHERE a.amount != a.paid|;
  • $where .= qq| AND a.curr = '$form->{currency}'| if $form->{currency};
  • if ($form->{duedatefrom}) {
  • $where .= qq| AND a.duedate >= '$form->{duedatefrom}'|;
  • }
  • if ($form->{duedateto}) {