# 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.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
#
# Account reconciliation module
#======================================================================
use SL::RC;
+use SL::Locale::String qw(t8);
require "bin/mozilla/common.pl";
RC->paymentaccounts(\%::myconfig, $::form);
+ setup_rc_reconciliation_action_bar();
+
$::form->header;
print $::form->parse_html_template('rc/step1', {
selection_sub => sub { ("$_[0]{accno}--$_[0]{description}")x2 },
$::lxdebug->leave_sub;
}
-sub continue { call_sub($main::form->{"nextsub"}); }
-
sub get_payments {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('cash');
+ $::lxdebug->enter_sub;
+ $::auth->assert('cash');
- ($form->{accno}, $form->{account}) = split /--/, $form->{accno};
+ ($::form->{accno}, $::form->{account}) = split /--/, $::form->{accno};
- RC->payment_transactions(\%myconfig, \%$form);
+ RC->payment_transactions(\%::myconfig, $::form);
- &display_form;
+ display_form();
- $main::lxdebug->leave_sub();
+ $::lxdebug->leave_sub;
}
sub display_form {
my $statementbalance = $::form->parse_amount(\%::myconfig, $::form->{statementbalance});
my $difference = $statementbalance - $clearedbalance - $cleared;
+ setup_rc_display_form_action_bar();
+
$::form->header;
print $::form->parse_html_template('rc/step2', {
is_asset => $::form->{category} eq 'A',
}
sub update {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
+ $::lxdebug->enter_sub;
+ $::auth->assert('cash');
- $main::auth->assert('cash');
+ # reset difference as it doesn't always arrive here empty
+ $::form->{difference} = 0;
- RC->payment_transactions(\%myconfig, \%$form);
+ RC->payment_transactions(\%::myconfig, $::form);
my $i;
- foreach my $ref (@{ $form->{PR} }) {
- if (!$ref->{fx_transaction}) {
- $i++;
- $ref->{cleared} = ($form->{"cleared_$i"}) ? "checked" : "";
- }
+ for my $ref (@{ $::form->{PR} }) {
+ next if $ref->{fx_transaction};
+ $i++;
+ $ref->{cleared} = $::form->{"cleared_$i"};
}
- &display_form;
+ display_form();
- $main::lxdebug->leave_sub();
+ $::lxdebug->leave_sub;
}
-sub select_all {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
-
- $main::auth->assert('cash');
+sub reconcile {
+ $::lxdebug->enter_sub;
+ $::auth->assert('cash');
- RC->payment_transactions(\%myconfig, \%$form);
+ $::form->{callback} = "$::form->{script}?action=reconciliation";
- map { $_->{cleared} = "checked" unless $_->{fx_transaction} }
- @{ $form->{PR} };
+ $::form->error($::locale->text('Out of balance!')) if $::form->{difference} *= 1;
- &display_form;
+ RC->reconcile(\%::myconfig, $::form);
+ $::form->redirect;
- $main::lxdebug->leave_sub();
+ $::lxdebug->leave_sub;
}
-sub done {
- $main::lxdebug->enter_sub();
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
-
- $main::auth->assert('cash');
-
- $form->{callback} = "$form->{script}?action=reconciliation";
-
- $form->error($locale->text('Out of balance!')) if ($form->{difference} *= 1);
-
- RC->reconcile(\%myconfig, \%$form);
- $form->redirect;
-
- $main::lxdebug->leave_sub();
+sub setup_rc_reconciliation_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Show'),
+ submit => [ '#form', { action => "get_payments" } ],
+ accesskey => 'enter',
+ ],
+ );
+ }
}
+sub setup_rc_display_form_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Update'),
+ submit => [ '#form', { action => "update" } ],
+ accesskey => 'enter',
+ ],
+ action => [
+ t8('Reconcile'),
+ submit => [ '#form', { action => "reconcile" } ],
+ ],
+ );
+ }
+}