summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-19 06:05:41 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-19 06:05:41 +0000
commitc2f3e31ee16b527315a3c6ffde4f4001c431f9ee (patch)
tree9b45b8246f4c1d64345f7cfa24aeba2f4ec4e6db /scripts
parentf97616a63f7c121d6cf5371fc249c8476b763c08 (diff)
Some voucher fixes
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1795 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'scripts')
-rw-r--r--scripts/vouchers.pl37
1 files changed, 31 insertions, 6 deletions
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 {