my $custnum = $cust_main->custnum;
+my @subnames = grep { /.+/ } map { /^subnum(\d+)$/ ? $1 : '' } $cgi->param;
+my @subitems = map { [ $cgi->param("subnum$_"), $cgi->param("subamount$_"), $cgi->param("taxXlocationnum$_") ] }
+ @subnames;
+{ local $^W = 0; @subitems = grep { $_->[1] + 0 } @subitems; }
+
+my %options = ();
+$options{subitems} = \@subitems if scalar(@subitems);
+
my $new;
# $new = new FS::cust_refund ( {
# 'reason' => 'Refunding payment', #enter reason in UI
#}
-my $error = $new->insert( 'manual' => 1 );
+
+$options{manual} = 1;
+my $error = $new->insert( %options );
</%init>