From c2f3e31ee16b527315a3c6ffde4f4001c431f9ee Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 19 Oct 2007 06:05:41 +0000 Subject: Some voucher fixes git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1795 4979c152-3d1c-0410-bac9-87ea11338e46 --- scripts/vouchers.pl | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/vouchers.pl b/scripts/vouchers.pl index 34305139..7e131bc2 100644 --- a/scripts/vouchers.pl +++ b/scripts/vouchers.pl @@ -16,7 +16,7 @@ use strict; sub create_batch { my ($request) = @_; $request->{hidden} = [ - batch_type => $request->{batch_type}, + {name => "batch_type", value => $request->{batch_type}}, ]; my $template = LedgerSMB::Template->new( user =>$request->{_user}, @@ -33,15 +33,40 @@ sub create_vouchers { # This is because these scripts import all functions into the *current* # namespace. People using fastcgi and modperl should *not* cache this # module at the moment. -- CT - my %vouchers_dispatch = ( + my ($request) = shift @_; + use LedgerSMB::Form; + + my $batch = LedgerSMB::Batch->new({base => $request}); + $batch->create; + + my $vouchers_dispatch = + { payable => {script => 'bin/ap.pl', function => sub {add()}}, receivable => {script => 'bin/ar.pl', function => sub {add()}}, payments => {script => 'bin/cp.pl', function => sub {payments()}}, receipts => {script => 'bin/cp.pl', function => sub {receipts()}}, - gl => {script => 'bin/gl.pl'. function => sub {add()}}, - ) - require $vouchers_dispatch{$request->{batch_type}}{script} - $vouchers_dispatch{$request->{batch_type}}{function}(); + gl => {script => 'bin/gl.pl', function => sub {add()}}, + }; + + # Note that the line below is generally considered incredibly bad form. + # However, the code we are including is going to require it for now. + no strict; + our $form = new Form; + our $locale = $request->{_locale}; + for (keys %$request){ + $form->{$_} = $request->{$_}; + } + + $form->{approved} = 0; + $form->{transdate} = $request->{batch_date}; + print STDERR "$request->{batch_type}\n"; + require $vouchers_dispatch->{$request->{batch_type}}{script}; + + my $script = $vouchers_dispatch->{$request->{batch_type}}{script}; + $script =~ s|.*/||; + $form->{script} = $script; + +\ $vouchers_dispatch->{$request->{batch_type}}{function}(); } sub list_vouchers { -- cgit v1.2.3