kivitendo/bin/mozilla/rc.pl @ 14dca9b8
d319704a | Moritz Bunkus | #=====================================================================
|
||
# LX-Office ERP
|
||||
# Copyright (C) 2004
|
||||
# Based on SQL-Ledger Version 2.1.9
|
||||
# Web http://www.lx-office.org
|
||||
#
|
||||
#=====================================================================
|
||||
# SQL-Ledger Accounting
|
||||
# Copyright (c) 2002
|
||||
#
|
||||
# Author: Dieter Simader
|
||||
# Email: dsimader@sql-ledger.org
|
||||
# Web: http://www.sql-ledger.org
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#======================================================================
|
||||
#
|
||||
# Account reconciliation module
|
||||
#
|
||||
#======================================================================
|
||||
use SL::RC;
|
||||
40782548 | Moritz Bunkus | require "bin/mozilla/common.pl";
|
||
8f35ef1f | Sven Schöling | use strict;
|
||
d319704a | Moritz Bunkus | 1;
|
||
# end of main
|
||||
sub reconciliation {
|
||||
b390c388 | Sven Schöling | $::lxdebug->enter_sub;
|
||
$::auth->assert('cash');
|
||||
8f35ef1f | Sven Schöling | |||
b390c388 | Sven Schöling | RC->paymentaccounts(\%::myconfig, $::form);
|
||
d319704a | Moritz Bunkus | |||
b390c388 | Sven Schöling | $::form->header;
|
||
print $::form->parse_html_template('rc/step1', {
|
||||
selection_sub => sub { ("$_[0]{accno}--$_[0]{description}")x2 },
|
||||
});
|
||||
d319704a | Moritz Bunkus | |||
b390c388 | Sven Schöling | $::lxdebug->leave_sub;
|
||
d319704a | Moritz Bunkus | }
|
||
590bb235 | Sven Schöling | sub continue { call_sub($::form->{"nextsub"}); }
|
||
d319704a | Moritz Bunkus | |||
sub get_payments {
|
||||
590bb235 | Sven Schöling | $::lxdebug->enter_sub;
|
||
$::auth->assert('cash');
|
||||
8c7e4493 | Moritz Bunkus | |||
590bb235 | Sven Schöling | ($::form->{accno}, $::form->{account}) = split /--/, $::form->{accno};
|
||
d319704a | Moritz Bunkus | |||
590bb235 | Sven Schöling | RC->payment_transactions(\%::myconfig, $::form);
|
||
d319704a | Moritz Bunkus | |||
590bb235 | Sven Schöling | display_form();
|
||
d319704a | Moritz Bunkus | |||
590bb235 | Sven Schöling | $::lxdebug->leave_sub;
|
||
d319704a | Moritz Bunkus | }
|
||
sub display_form {
|
||||
da6943d4 | Sven Schöling | $::lxdebug->enter_sub;
|
||
$::auth->assert('cash');
|
||||
d319704a | Moritz Bunkus | |||
da6943d4 | Sven Schöling | my @options;
|
||
push @options, $::locale->text('From') . " " . $::locale->date(\%::myconfig, $::form->{fromdate}, 0) if $::form->{fromdate};
|
||||
push @options, $::locale->text('Until') . " " . $::locale->date(\%::myconfig, $::form->{todate}, 0) if $::form->{todate};
|
||||
my $ml = ($::form->{category} eq 'A') ? -1 : 1;
|
||||
my $beginningbalance = $::form->{beginningbalance} * $ml;
|
||||
my $clearedbalance =
|
||||
my $balance = $beginningbalance;
|
||||
my $i = 0;
|
||||
my $last_id = 0;
|
||||
my ($last_fx, @rows, $cleared, $totaldebits, $totalcredits, $fx);
|
||||
for my $ref (@{ $::form->{PR} }) {
|
||||
$balance += $ref->{amount} * $ml;
|
||||
$cleared += $ref->{amount} * $ml if $ref->{cleared};
|
||||
$totaldebits += $ref->{amount} * -1 if $ref->{amount} < 0;
|
||||
$totalcredits += $ref->{amount} if $ref->{amount} >= 0;
|
||||
$fx += $ref->{amount} * $ml if $ref->{fx_transaction};
|
||||
$i++ if (!$ref->{fx_transaction} && !$last_fx) || $last_id != $ref->{id};
|
||||
$last_fx = $ref->{fx_transaction};
|
||||
$last_id = $ref->{id};
|
||||
push @rows, { %$ref, balance => $balance, i => $i };
|
||||
d319704a | Moritz Bunkus | }
|
||
da6943d4 | Sven Schöling | my $statementbalance = $::form->parse_amount(\%::myconfig, $::form->{statementbalance});
|
||
my $difference = $statementbalance - $clearedbalance - $cleared;
|
||||
d319704a | Moritz Bunkus | |||
da6943d4 | Sven Schöling | $::form->header;
|
||
print $::form->parse_html_template('rc/step2', {
|
||||
is_asset => $::form->{category} eq 'A',
|
||||
option => \@options,
|
||||
DATA => \@rows,
|
||||
total => {
|
||||
credit => $totalcredits,
|
||||
debit => $totaldebits,
|
||||
},
|
||||
balance => {
|
||||
beginning => $beginningbalance,
|
||||
cleared => $clearedbalance,
|
||||
statement => $statementbalance,
|
||||
},
|
||||
difference => $difference,
|
||||
rowcount => $i,
|
||||
fx => $fx,
|
||||
});
|
||||
d319704a | Moritz Bunkus | |||
da6943d4 | Sven Schöling | $::lxdebug->leave_sub;
|
||
d319704a | Moritz Bunkus | }
|
||
sub update {
|
||||
590bb235 | Sven Schöling | $::lxdebug->enter_sub;
|
||
$::auth->assert('cash');
|
||||
8c7e4493 | Moritz Bunkus | |||
de905cc7 | Geoffrey Richardson | # reset difference as it doesn't always arrive here empty
|
||
$::form->{difference} = 0;
|
||||
590bb235 | Sven Schöling | RC->payment_transactions(\%::myconfig, $::form);
|
||
d319704a | Moritz Bunkus | |||
8f35ef1f | Sven Schöling | my $i;
|
||
590bb235 | Sven Schöling | for my $ref (@{ $::form->{PR} }) {
|
||
next if $ref->{fx_transaction};
|
||||
$i++;
|
||||
$ref->{cleared} = $::form->{"cleared_$i"};
|
||||
d319704a | Moritz Bunkus | }
|
||
590bb235 | Sven Schöling | display_form();
|
||
d319704a | Moritz Bunkus | |||
590bb235 | Sven Schöling | $::lxdebug->leave_sub;
|
||
d319704a | Moritz Bunkus | }
|
||
sub done {
|
||||
590bb235 | Sven Schöling | $::lxdebug->enter_sub;
|
||
$::auth->assert('cash');
|
||||
8c7e4493 | Moritz Bunkus | |||
590bb235 | Sven Schöling | $::form->{callback} = "$::form->{script}?action=reconciliation";
|
||
d319704a | Moritz Bunkus | |||
590bb235 | Sven Schöling | $::form->error($::locale->text('Out of balance!')) if $::form->{difference} *= 1;
|
||
d319704a | Moritz Bunkus | |||
590bb235 | Sven Schöling | RC->reconcile(\%::myconfig, $::form);
|
||
$::form->redirect;
|
||||
d319704a | Moritz Bunkus | |||
590bb235 | Sven Schöling | $::lxdebug->leave_sub;
|
||
d319704a | Moritz Bunkus | }
|