-package cust_bill_pay;
+package FS::cust_bill_pay;
use strict;
use vars qw( @ISA );
my $error =
$self->ut_numbern('billpaynum')
|| $self->ut_number('invnum')
- || $self->ut_numner('paynum')
+ || $self->ut_number('paynum')
|| $self->ut_money('amount')
|| $self->ut_numbern('_date')
;
=head1 VERSION
-$Id: cust_bill_pay.pm,v 1.5 2001-09-02 04:25:55 ivan Exp $
+$Id: cust_bill_pay.pm,v 1.6 2001-09-02 05:38:13 ivan Exp $
=head1 BUGS
-package cust_credit_refund;
+package FS::cust_credit_refund;
use strict;
use vars qw( @ISA );
my $error =
$self->ut_numbern('creditrefundnum')
|| $self->ut_number('crednum')
- || $self->ut_numner('refundnum')
+ || $self->ut_number('refundnum')
|| $self->ut_money('amount')
|| $self->ut_numbern('_date')
;
=head1 VERSION
-$Id: cust_credit_refund.pm,v 1.2 2001-09-02 01:27:11 ivan Exp $
+$Id: cust_credit_refund.pm,v 1.3 2001-09-02 05:38:13 ivan Exp $
=head1 BUGS
$dbh->rollback if $oldAutoCommit;
return $error;
}
+ warn $cust_bill_pay;
+ warn $cust_bill_pay->cust_bill;
+ warn $cust_bill_pay->cust_bill->custnum;
$self->custnum($cust_bill_pay->cust_bill->custnum);
}
}
+sub upgrade_replace { #1.3.x->1.4.x
+ my $self = shift;
+
+ 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;
+
+ my $error = $self->check;
+ return $error if $error;
+
+ my %new = $self->hash;
+ my $new = FS::cust_pay->new(\%new);
+
+ if ( $self->invnum ) {
+ my $cust_bill_pay = new FS::cust_bill_pay {
+ 'invnum' => $self->invnum,
+ 'paynum' => $self->paynum,
+ 'amount' => $self->paid,
+ '_date' => $self->_date,
+ };
+ $error = $cust_bill_pay->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ $new->custnum($cust_bill_pay->cust_bill->custnum);
+ } else {
+ die;
+ }
+
+ $error = $new->SUPER::replace($self);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ '';
+
+
+}
+
=item delete
Currently unimplemented (accounting reasons).
my $error =
$self->ut_numbern('paynum')
- || $self->ut_number('custnum')
+ || $self->ut_numbern('custnum')
|| $self->ut_money('paid')
|| $self->ut_numbern('_date')
|| $self->ut_textn('paybatch')
=head1 VERSION
-$Id: cust_pay.pm,v 1.5 2001-09-02 02:46:55 ivan Exp $
+$Id: cust_pay.pm,v 1.6 2001-09-02 05:38:13 ivan Exp $
=head1 BUGS
my $error = $self->check;
return $error if $error;
+ die;
+
if ( $self->crednum ) {
my $cust_credit_refund = new FS::cust_credit_refund {
- 'cred' => $self->cred,
+ 'crednum' => $self->crednum,
'refundnum' => $self->refundnum,
'amount' => $self->refund,
'_date' => $self->_date,
}
+sub upgrade_replace {
+ my $self = shift;
+
+ 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;
+
+ my $error = $self->check;
+ return $error if $error;
+
+ my %new = $self->hash;
+ my $new = FS::cust_refund->new(\%new);
+
+ if ( $self->crednum ) {
+ my $cust_credit_refund = new FS::cust_credit_refund {
+ 'crednum' => $self->crednum,
+ 'refundnum' => $self->refundnum,
+ 'amount' => $self->refund,
+ '_date' => $self->_date,
+ };
+ $error = $cust_credit_refund->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ $new->custnum($cust_credit_refund->cust_credit->custnum);
+ } else {
+ die;
+ }
+
+ $error = $new->SUPER::insert($self);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ '';
+
+}
+
=item delete
Currently unimplemented (accounting reasons).
=head1 VERSION
-$Id: cust_refund.pm,v 1.7 2001-09-02 04:25:55 ivan Exp $
+$Id: cust_refund.pm,v 1.8 2001-09-02 05:38:13 ivan Exp $
=head1 BUGS
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use FS::UID qw(adminsuidsetup);
+use FS::Record qw(qsearch);
+use FS::cust_pay;
+use FS::cust_refund;
+
+my $user = shift or die &usage;
+my $dbh = adminsuidsetup $user;
+
+#local $FS::UID::AutoCommit = 0; #quelle hack, in this case
+# $FS::UID::AutoCommit = 0; #quelle hack, in this case
+
+# apply payments to invoices
+
+foreach my $cust_pay ( qsearch('cust_pay', {} ) ) {
+ my $error = $cust_pay->upgrade_replace;
+ warn $error if $error;
+}
+
+# apply refunds to credits
+
+foreach my $cust_refund ( qsearch('cust_refund') ) {
+ my $error = $cust_refund->upgrade_replace;
+ warn $error if $error;
+}
+
+# ? apply credits to invoices
+