From: ivan Date: Thu, 7 Feb 2002 22:29:35 +0000 (+0000) Subject: delete payments X-Git-Tag: freeside_1_4_0pre11~94 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=69c6e80a7253f927af1780a3e0dd3fcf50110599 delete payments --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index cc91e8292..873ee75a9 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -268,6 +268,13 @@ httemplate/docs/config.html }, { + 'key' => 'deletepayments', + 'section' => 'UI', + 'description' => 'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments.', + 'type' => 'checkbox', + }, + + { 'key' => 'dirhash', 'section' => 'shell', 'description' => 'Optional numeric value to control directory hashing. If positive, hashes directories for the specified number of levels from the front of the username. If negative, hashes directories for the specified number of levels from the end of the username. Some examples: ', diff --git a/FS/FS/cust_bill_pay.pm b/FS/FS/cust_bill_pay.pm index 1c838b932..913704bef 100644 --- a/FS/FS/cust_bill_pay.pm +++ b/FS/FS/cust_bill_pay.pm @@ -125,12 +125,16 @@ sub insert { =item delete -Currently unimplemented (accounting reasons). +Deletes this payment application, unless the closed flag for the parent payment +(see L) is set. =cut sub delete { - return "Can't (yet?) delete cust_bill_pay records!"; + my $self = shift; + return "Can't delete application for closed payment" + if $self->cust_pay->closed =~ /^Y/i; + $self->SUPER::delete(@_); } =item replace OLD_RECORD @@ -195,7 +199,7 @@ sub cust_bill { =head1 VERSION -$Id: cust_bill_pay.pm,v 1.11 2002-01-24 16:58:47 ivan Exp $ +$Id: cust_bill_pay.pm,v 1.12 2002-02-07 22:29:34 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 51c7b29e1..839571a95 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -211,14 +211,44 @@ sub upgrade_replace { #1.3.x->1.4.x =item delete -Currently unimplemented (accounting reasons). +Deletes this payment and all associated applications (see L), +unless the closed flag is set. =cut sub delete { my $self = shift; return "Can't delete closed payment" if $self->closed =~ /^Y/i; - $self->SUPER::delete(@_); + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + foreach my $cust_bill_pay ( $self->cust_bill_pay ) { + my $error = $cust_bill_pay->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + + my $error = $self->SUPER::delete(@_); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + + ''; + } =item replace OLD_RECORD @@ -318,7 +348,7 @@ sub unapplied { =head1 VERSION -$Id: cust_pay.pm,v 1.15 2002-01-29 16:33:15 ivan Exp $ +$Id: cust_pay.pm,v 1.16 2002-02-07 22:29:34 ivan Exp $ =head1 BUGS diff --git a/Makefile b/Makefile index 0f86b49d2..e5b6ad1ac 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,8 @@ aspdocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* cp -pr httemplate aspdocs touch aspdocs -masondocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* +#masondocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* +masondocs: httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* rm -rf masondocs cp -pr httemplate masondocs ( cd masondocs; \ diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi index 8321048e7..d75c45081 100755 --- a/httemplate/browse/agent_type.cgi +++ b/httemplate/browse/agent_type.cgi @@ -1,4 +1,4 @@ - + <% print header("Agent Type Listing", menubar( @@ -7,7 +7,7 @@ print header("Agent Type Listing", menubar( " particular agents.

", &table(), < Agent Type - Packages + Packages END @@ -47,7 +47,7 @@ END } print <Add a new agent type + Add a new agent type diff --git a/httemplate/browse/nas.cgi b/httemplate/browse/nas.cgi index b392dc083..2bac9909f 100755 --- a/httemplate/browse/nas.cgi +++ b/httemplate/browse/nas.cgi @@ -45,6 +45,7 @@ foreach my $nas ( sort { $a->nasnum <=> $b->nasnum } qsearch( 'nas', {} ) ) { print "
"; } +#Time::Duration?? sub pretty_interval { my $interval = shift; my %howlong = ( diff --git a/httemplate/misc/delete-cust_pay.cgi b/httemplate/misc/delete-cust_pay.cgi new file mode 100755 index 000000000..3fb786d7d --- /dev/null +++ b/httemplate/misc/delete-cust_pay.cgi @@ -0,0 +1,17 @@ + +<% + +#untaint paynum +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/ || die "Illegal paynum"; +my $paynum = $1; + +my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}); +my $custnum = $cust_pay->custnum; + +my $error = $cust_pay->delete; +eidiot($error) if $error; + +print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); + +%> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 9595a07e1..dc4760d73 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -1,4 +1,4 @@ - + <% my $conf = new FS::Conf; @@ -324,6 +324,16 @@ print ""; #formatting print ""; +print < +function areyousure(href) { + if (confirm("Are you sure you want to delete this payment?") + == true) + window.location.href = href; +} + +END + #formatting print qq!

Payment History!. qq! ( !. @@ -371,8 +381,11 @@ foreach my $bill (@bills) { my $target = "$payby$payinfo"; $payby =~ s/^BILL$/Check #/ if $payinfo; $payby =~ s/^(CARD|COMP)$/$1 /; + my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments') + ? qq! (delete)! + : ''; push @history, - "$date\tPayment, Invoice #$invnum ($payby$payinfo)\t\t$paid\t\t\t$target"; + "$date\tPayment, Invoice #$invnum ($payby$payinfo)$delete\t\t$paid\t\t\t$target"; } my(@cust_credit_bill)= @@ -430,11 +443,15 @@ foreach my $payment (@unapplied_payments) { my $target = "$payby$payinfo"; $payby =~ s/^BILL$/Check #/ if $payinfo; $payby =~ s/^(CARD|COMP)$/$1 /; + my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments') + ? qq! (delete)! + : ''; push @history, $payment->_date. "\t". - ''. 'Unapplied payment #' . - $payment->paynum . " ($payby$payinfo)". + $payment->paynum . " ($payby$payinfo) ". + '('. + "apply)$delete". "\t\t" . $payment->unapplied . "\t\t\t$target"; }