summaryrefslogtreecommitdiff
path: root/httemplate/edit/process
diff options
context:
space:
mode:
authorjeff <jeff>2009-10-28 19:01:18 +0000
committerjeff <jeff>2009-10-28 19:01:18 +0000
commit2cb70470a8e5c3287146008e4ce2c4eb9f242373 (patch)
treee8d161557d4420f988245f3bf00d25d80b1d73d4 /httemplate/edit/process
parent57f5975a062022e280680feed1f692f3e937414b (diff)
UI changes for credit applications include on the fly tax calculations #4729
Diffstat (limited to 'httemplate/edit/process')
-rwxr-xr-xhttemplate/edit/process/cust_credit_bill.cgi6
-rw-r--r--httemplate/edit/process/elements/ApplicationCommon.html18
2 files changed, 23 insertions, 1 deletions
diff --git a/httemplate/edit/process/cust_credit_bill.cgi b/httemplate/edit/process/cust_credit_bill.cgi
index c0f34ae5b..d3847dc40 100755
--- a/httemplate/edit/process/cust_credit_bill.cgi
+++ b/httemplate/edit/process/cust_credit_bill.cgi
@@ -10,4 +10,10 @@
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Apply credit');
+if ( $cgi->param('src_amount') ) {
+ die "access denied"
+ unless ( $FS::CurrentUser::CurrentUser->access_right('Post credit') &&
+ $FS::CurrentUser::CurrentUser->access_right('Delete credit') );
+}
+
</%init>
diff --git a/httemplate/edit/process/elements/ApplicationCommon.html b/httemplate/edit/process/elements/ApplicationCommon.html
index 3cb7ae6bf..c7bdd3ea2 100644
--- a/httemplate/edit/process/elements/ApplicationCommon.html
+++ b/httemplate/edit/process/elements/ApplicationCommon.html
@@ -34,6 +34,8 @@ Examples:
my %opt = @_;
+my $error = '';
+
my $src_thing = ucfirst($opt{'src_thing'});
my $src_table = $opt{'src_table'};
my $src_pkey = dbdef->table($src_table)->primary_key;
@@ -58,6 +60,10 @@ my @subitems = map { [ $cgi->param("subnum$_"), $cgi->param("subamount$_"), $cgi
my %options = ();
$options{subitems} = \@subitems if scalar(@subitems);
+
+my $oldAutoCommit = $FS::UID::AutoCommit;
+local $FS::UID::AutoCommit = 0;
+my $dbh = dbh;
my $new;
# $new = new FS::cust_refund ( {
@@ -70,6 +76,11 @@ my $new;
# } );
#} else {
+ if ($src->amount != $cgi->param('src_amount')) {
+ $src->amount($cgi->param('src_amount'));
+ $error = $src->replace;
+ }
+
my $class = 'FS::'. $opt{link_table};
$new = $class->new( {
@@ -82,6 +93,11 @@ my $new;
$options{manual} = 1;
-my $error = $new->insert( %options );
+$error ||= $new->insert( %options );
+if ($error) {
+ $dbh->rollback if $oldAutoCommit;
+} else {
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+}
</%init>