+ #create the template
+ my $templatefile = 'invoice_template';
+ $templatefile .= "_$template" if $template;
+ my @invoice_template = $conf->config($templatefile)
+ or die "cannot load config file $templatefile";
+ $invoice_lines = 0;
+ foreach ( grep /invoice_lines\(\d+\)/, @invoice_template ) { #kludgy
+ /invoice_lines\((\d+)\)/;
+ $invoice_lines += $1;
+ }
+ die "no invoice_lines() functions in template?" unless $invoice_lines;
+ my $invoice_template = new Text::Template (
+ TYPE => 'ARRAY',
+ SOURCE => [ map "$_\n", @invoice_template ],
+ ) or die "can't create new Text::Template object: $Text::Template::ERROR";
+ $invoice_template->compile()
+ or die "can't compile template: $Text::Template::ERROR";
+