From e5dfe76f59198db0d3b6267d5a09e62de14514e6 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Wed, 30 Jul 2008 20:26:15 +0000 Subject: Adding custom batch type handles git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2224 4979c152-3d1c-0410-bac9-87ea11338e46 --- scripts/vouchers.pl | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/vouchers.pl b/scripts/vouchers.pl index 314dbd2d..047afcb7 100644 --- a/scripts/vouchers.pl +++ b/scripts/vouchers.pl @@ -15,6 +15,24 @@ use LedgerSMB::Voucher; use LedgerSMB::Template; use strict; +# custom_batch_types hash provides hooks for handling additional batch types +# beyond the default types. Entries can be added in a custom file. +# Each entry is a hash, keyed by name, with the following keys: +# * map_to int (maps to another type, not needed for new types in batch_class +# table) +# * select_method (maps to the selection stored proc) +# +# for example: +# $custom_batch_types->{ap_sample} = +# {map_to => 1, +# select_method => 'custom_sample_ap_select'}; +# +# --CT + +our $custom_batch_types = {}; + +eval { do "scripts/custom/vouchers.pl"}; + sub create_batch { my ($request) = @_; $request->{hidden} = [ @@ -74,14 +92,14 @@ sub add_vouchers { function => sub { my ($request) = @_; $request->{account_class} = 1; - LedgerSMB::Scripts::payment::get_search_criteria($request); + LedgerSMB::Scripts::payment::get_search_criteria($request, $custom_batch_types); }}, receipt_reversal => { script => 'scripts/payment.pl', function => sub { my ($request) = @_; $request->{account_class} = 2; - LedgerSMB::Scripts::payment::get_search_criteria($request); + LedgerSMB::Scripts::payment::get_search_criteria($request, $custom_batch_types); }}, @@ -125,7 +143,7 @@ sub add_vouchers { sub search_batch { my ($request) = @_; my $batch_request = LedgerSMB::Batch->new(base => $request); - $batch_request->get_search_criteria(); + $batch_request->get_search_criteria($custom_batch_types); my $template = LedgerSMB::Template->new( user => $request->{_user}, locale => $request->{_locale}, @@ -139,7 +157,7 @@ sub search_batch { sub list_batches { my ($request) = @_; my $batch = LedgerSMB::Batch->new(base => $request); - my @search_results = $batch->get_search_results; + my @search_results = $batch->get_search_results({custom_types => $custom_batch_types}); $batch->{script} = "vouchers.pl"; my @columns = -- cgit v1.2.3