diff options
author | Ivan Kohler <ivan@freeside.biz> | 2015-11-05 10:44:38 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2015-11-05 10:44:38 -0800 |
commit | 5da68ff1a7c638e30cbafbc9b0749f1e82b333df (patch) | |
tree | ecbcbc0b06cb8af969987ad10e1d85ccf38e56da /FS | |
parent | 88ed72cdd96321a0eeaacc3107da413ab6e9dc98 (diff) | |
parent | 052eb9b8d16c4e81c0b6c609674e9ab768cb817d (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/AccessRight.pm | 2 | ||||
-rw-r--r-- | FS/FS/Schema.pm | 20 | ||||
-rw-r--r-- | FS/FS/Upgrade.pm | 5 | ||||
-rw-r--r-- | FS/FS/access_right.pm | 4 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 14 | ||||
-rw-r--r-- | FS/FS/cust_bill_pkg.pm | 14 | ||||
-rw-r--r-- | FS/FS/cust_bill_pkg_void.pm | 31 | ||||
-rw-r--r-- | FS/FS/cust_bill_void.pm | 31 | ||||
-rw-r--r-- | FS/FS/cust_credit.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_credit_void.pm | 15 | ||||
-rw-r--r-- | FS/FS/cust_main/Billing_Realtime.pm | 7 | ||||
-rw-r--r-- | FS/FS/cust_pay.pm | 19 | ||||
-rw-r--r-- | FS/FS/cust_pay_void.pm | 15 | ||||
-rw-r--r-- | FS/FS/reason_Mixin.pm | 167 | ||||
-rw-r--r-- | FS/FS/reason_type.pm | 4 | ||||
-rwxr-xr-x | FS/bin/freeside-paymentech-download | 2 | ||||
-rwxr-xr-x | FS/bin/freeside-paymentech-upload | 2 |
17 files changed, 272 insertions, 82 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 95cf29a8b..a96a6cb41 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -232,7 +232,7 @@ tie my %rights, 'Tie::IxHash', 'Refund Echeck payment', 'Delete refund', #NEW 'Add on-the-fly credit reason', #NEW - 'Add on-the-fly void credit reason', + 'Add on-the-fly void reason', 'Add on-the-fly refund reason', #NEW ], diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 447302b36..6b5d6586c 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -735,8 +735,9 @@ sub tables_hashref { #void fields 'void_date', @date_type, '', '', - 'reason', 'varchar', 'NULL', $char_d, '', '', - 'void_usernum', 'int', 'NULL', '', '', '', + 'reason', 'varchar', 'NULL', $char_d, '', '', + 'reasonnum', 'int', 'NULL', '', '', '', + 'void_usernum', 'int', 'NULL', '', '', '', ], 'primary_key' => 'invnum', 'unique' => [ [ 'custnum', 'agent_invid' ] ], #agentnum? huh @@ -750,6 +751,9 @@ sub tables_hashref { { columns => [ 'statementnum' ], table => 'cust_statement', #_void? both? }, + { columns => [ 'reasonnum' ], + table => 'reason', + }, { columns => [ 'void_usernum' ], table => 'access_user', references => [ 'usernum' ], @@ -1197,8 +1201,9 @@ sub tables_hashref { 'feepart', 'int', 'NULL', '', '', '', #void fields 'void_date', @date_type, '', '', - 'reason', 'varchar', 'NULL', $char_d, '', '', - 'void_usernum', 'int', 'NULL', '', '', '', + 'reason', 'varchar', 'NULL', $char_d, '', '', + 'reasonnum', 'int', 'NULL', '', '', '', + 'void_usernum', 'int', 'NULL', '', '', '', ], 'primary_key' => 'billpkgnum', 'unique' => [], @@ -1209,6 +1214,9 @@ sub tables_hashref { { columns => [ 'invnum' ], table => 'cust_bill_void', }, + { columns => [ 'reasonnum' ], + table => 'reason', + }, #pkgnum 0 and -1 are used for special things #{ columns => [ 'pkgnum' ], # table => 'cust_pkg', @@ -2523,6 +2531,7 @@ sub tables_hashref { #void fields 'void_date', @date_type, '', '', 'reason', 'varchar', 'NULL', $char_d, '', '', + 'reasonnum', 'int', 'NULL', '', '', '', 'void_usernum', 'int', 'NULL', '', '', '', ], 'primary_key' => 'paynum', @@ -2544,6 +2553,9 @@ sub tables_hashref { { columns => [ 'gatewaynum' ], table => 'payment_gateway', }, + { columns => [ 'reasonnum' ], + table => 'reason', + }, { columns => [ 'void_usernum' ], table => 'access_user', references => [ 'usernum' ], diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm index 263230b34..bffda566f 100644 --- a/FS/FS/Upgrade.pm +++ b/FS/FS/Upgrade.pm @@ -350,6 +350,11 @@ sub upgrade_data { #customer credits 'cust_credit' => [], + # reason / void_reason migration to reasonnum / void_reasonnum + 'cust_credit_void' => [], + 'cust_bill_void' => [], + 'cust_bill_pkg_void' => [], + #duplicate history records 'h_cust_svc' => [], diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index 40475ec00..0da718c64 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -251,9 +251,7 @@ sub _upgrade_data { # class method 'List customers' => 'List contacts', 'Backdate payment' => 'Backdate credit', 'Generate quotation' => 'Disable quotation', - 'Void credit' => 'Void credit', - 'Unvoid credit' => 'Unvoid credit', - 'Add on-the-fly void credit reason' => 'Add on-the-fly void credit reason', + 'Add on-the-fly void credit reason' => 'Add on-the-fly void reason', '_ALL' => 'Employee preference telephony integration', ); diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 6546bfa95..138d0fab8 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -37,6 +37,8 @@ use FS::cust_bill_pay_pkg; use FS::cust_credit_bill_pkg; use FS::discount_plan; use FS::cust_bill_void; +use FS::reason; +use FS::reason_type; use FS::L10N; $DEBUG = 0; @@ -212,7 +214,7 @@ sub insert { } -=item void +=item void [ REASON ] Voids this invoice: deletes the invoice and adds a record of the voided invoice to the FS::cust_bill_void table (and related tables starting from @@ -224,6 +226,14 @@ sub void { my $self = shift; my $reason = scalar(@_) ? shift : ''; + unless (ref($reason) || !$reason) { + $reason = FS::reason->new_or_existing( + 'class' => 'X', + 'type' => 'Void invoice', + 'reason' => $reason + ); + } + local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -238,7 +248,7 @@ sub void { my $cust_bill_void = new FS::cust_bill_void ( { map { $_ => $self->get($_) } $self->fields } ); - $cust_bill_void->reason($reason); + $cust_bill_void->reasonnum($reason->reasonnum) if $reason; my $error = $cust_bill_void->insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index 5861ee47f..aea776a80 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -26,6 +26,8 @@ use FS::cust_bill_pkg_tax_location_void; use FS::cust_bill_pkg_tax_rate_location_void; use FS::cust_tax_exempt_pkg_void; use FS::cust_bill_pkg_fee_void; +use FS::reason; +use FS::reason_type; use FS::Cursor; @@ -322,7 +324,7 @@ sub insert { } -=item void +=item void [ REASON ] Voids this line item: deletes the line item and adds a record of the voided line item to the FS::cust_bill_pkg_void table (and related tables). @@ -333,6 +335,14 @@ sub void { my $self = shift; my $reason = scalar(@_) ? shift : ''; + unless (ref($reason) || !$reason) { + $reason = FS::reason->new_or_existing( + 'class' => 'X', + 'type' => 'Void invoice', + 'reason' => $reason + ); + } + local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -347,7 +357,7 @@ sub void { my $cust_bill_pkg_void = new FS::cust_bill_pkg_void ( { map { $_ => $self->get($_) } $self->fields } ); - $cust_bill_pkg_void->reason($reason); + $cust_bill_pkg_void->reasonnum($reason->reasonnum) if $reason; my $error = $cust_bill_pkg_void->insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; diff --git a/FS/FS/cust_bill_pkg_void.pm b/FS/FS/cust_bill_pkg_void.pm index 080452e19..991dd37dd 100644 --- a/FS/FS/cust_bill_pkg_void.pm +++ b/FS/FS/cust_bill_pkg_void.pm @@ -1,7 +1,8 @@ package FS::cust_bill_pkg_void; -use base qw( FS::TemplateItem_Mixin FS::Record ); +use base qw( FS::TemplateItem_Mixin FS::reason_Mixin FS::Record ); use strict; +use vars qw( $me $DEBUG ); use FS::Record qw( qsearch qsearchs dbh fields ); use FS::cust_bill_void; use FS::cust_bill_pkg_detail; @@ -13,6 +14,9 @@ use FS::cust_bill_pkg_tax_location; use FS::cust_bill_pkg_tax_rate_location; use FS::cust_tax_exempt_pkg; +$me = '[ FS::cust_bill_pkg_void ]'; +$DEBUG = 0; + =head1 NAME FS::cust_bill_pkg_void - Object methods for cust_bill_pkg_void records @@ -104,6 +108,13 @@ unitrecur hidden +=item reason + +freeform string (deprecated) + +=item reasonnum + +reason for voiding the payment (see L<FS::reson>) =back @@ -134,6 +145,10 @@ sub discount_table { 'cust_bill_pkg_discount_void'; } Adds this record to the database. If there is an error, returns the error, otherwise returns false. +=item reason + +Returns the text of the associated void reason (see L<FS::reason>) for this. + =item unvoid "Un-void"s this line item: Deletes the voided line item from the database and @@ -242,6 +257,8 @@ sub check { || $self->ut_moneyn('unitrecur') || $self->ut_enum('hidden', [ '', 'Y' ]) || $self->ut_numbern('feepart') + || $self->ut_textn('reason') + || $self->ut_foreign_keyn('reasonnum', 'reason', 'reasonnum') ; return $error if $error; @@ -266,6 +283,18 @@ sub cust_bill_pkg_fee { qsearch( 'cust_bill_pkg_fee_void', { 'billpkgnum' => $self->billpkgnum } ); } + +# _upgrade_data +# +# Used by FS::Upgrade to migrate to a new database. +sub _upgrade_data { # class method + my ($class, %opts) = @_; + + warn "$me upgrading $class\n" if $DEBUG; + + $class->_upgrade_reasonnum(%opts); +} + =back =head1 BUGS diff --git a/FS/FS/cust_bill_void.pm b/FS/FS/cust_bill_void.pm index f3dba9081..50f69c9fa 100644 --- a/FS/FS/cust_bill_void.pm +++ b/FS/FS/cust_bill_void.pm @@ -1,13 +1,18 @@ package FS::cust_bill_void; -use base qw( FS::Template_Mixin FS::cust_main_Mixin FS::otaker_Mixin FS::Record ); +use base qw( FS::Template_Mixin FS::cust_main_Mixin FS::otaker_Mixin + FS::reason_Mixin FS::Record ); use strict; +use vars qw( $me $DEBUG ); use FS::Record qw( qsearch qsearchs dbh fields ); use FS::cust_statement; use FS::access_user; use FS::cust_bill_pkg_void; use FS::cust_bill; +$me = '[ FS::cust_bill_void ]'; +$DEBUG = 0; + =head1 NAME FS::cust_bill_void - Object methods for cust_bill_void records @@ -82,9 +87,13 @@ promised_date void_date -=item reason +=item reason + +freeform string (deprecated) -reason +=item reasonnum + +reason for voiding the payment (see L<FS::reson>) =item void_usernum @@ -216,6 +225,7 @@ sub check { || $self->ut_numbern('void_date') || $self->ut_textn('reason') || $self->ut_numbern('void_usernum') + || $self->ut_foreign_keyn('reasonnum', 'reason', 'reasonnum') ; return $error if $error; @@ -259,6 +269,10 @@ sub void_access_user { =item cust_bill_pkg +=item reason + +Returns the text of the associated void reason (see L<FS::reason>) for this. + =cut sub cust_bill_pkg { #actually cust_bill_pkg_void objects @@ -339,6 +353,17 @@ sub search_sql_where { sub enable_previous { 0 } +# _upgrade_data +# +# Used by FS::Upgrade to migrate to a new database. +sub _upgrade_data { # class method + my ($class, %opts) = @_; + + warn "$me upgrading $class\n" if $DEBUG; + + $class->_upgrade_reasonnum(%opts); +} + =back =head1 BUGS diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index 2f2338ee4..032953532 100644 --- a/FS/FS/cust_credit.pm +++ b/FS/FS/cust_credit.pm @@ -377,7 +377,7 @@ sub void { my $cust_credit_void = new FS::cust_credit_void ( { map { $_ => $self->get($_) } $self->fields } ); - $cust_credit_void->set('void_reasonnum', $reason->reasonnum); + $cust_credit_void->set('void_reasonnum', $reason->reasonnum) if $reason; my $error = $cust_credit_void->insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; diff --git a/FS/FS/cust_credit_void.pm b/FS/FS/cust_credit_void.pm index 9c92068eb..60beaa655 100644 --- a/FS/FS/cust_credit_void.pm +++ b/FS/FS/cust_credit_void.pm @@ -2,12 +2,16 @@ package FS::cust_credit_void; use base qw( FS::otaker_Mixin FS::cust_main_Mixin FS::reason_Mixin FS::Record ); use strict; +use vars qw( $me $DEBUG ); use FS::Record qw(qsearchs); # qsearch qsearchs); use FS::CurrentUser; use FS::access_user; use FS::cust_credit; use FS::UID qw( dbh ); +$me = '[ FS::cust_credit_void ]'; +$DEBUG = 0; + =head1 NAME FS::cust_credit_void - Object methods for cust_credit_void objects @@ -190,6 +194,17 @@ sub void_reason { return $reason_text; } +# _upgrade_data +# +# Used by FS::Upgrade to migrate to a new database. +sub _upgrade_data { # class method + my ( $class, %opts ) = @_; + + warn "$me upgrading $class\n" if $DEBUG; + + $class->_upgrade_reasonnum(%opts); +} + =back =head1 BUGS diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index 403d8dd1c..c700cf7f8 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -267,7 +267,10 @@ sub _bop_defaults { } } - $options->{payinfo} = $self->payinfo unless exists( $options->{payinfo} ); + unless ( exists( $options->{'payinfo'} ) ) { + $options->{'payinfo'} = $self->payinfo; + $options->{'paymask'} = $self->paymask; + } # Default invoice number if the customer has exactly one open invoice. if( ! $options->{'invnum'} ) { @@ -889,7 +892,7 @@ sub _realtime_bop_result { '_date' => '', 'payby' => $cust_pay_pending->payby, 'payinfo' => $options{'payinfo'}, - 'paymask' => $options{'paymask'}, + 'paymask' => $options{'paymask'} || $cust_pay_pending->paymask, 'paydate' => $cust_pay_pending->paydate, 'pkgnum' => $cust_pay_pending->pkgnum, 'discount_term' => $options{'discount_term'}, diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index d9ae0d39e..4d06862d6 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -2,9 +2,9 @@ package FS::cust_pay; use strict; use base qw( FS::otaker_Mixin FS::payinfo_transaction_Mixin FS::cust_main_Mixin - FS::Record ); + FS::reason_Mixin FS::Record); use vars qw( $DEBUG $me $conf @encrypted_fields - $unsuspendauto $ignore_noapply + $unsuspendauto $ignore_noapply ); use Date::Format; use Business::CreditCard; @@ -24,6 +24,8 @@ use FS::cust_pkg; use FS::cust_pay_void; use FS::upgrade_journal; use FS::Cursor; +use FS::reason; +use FS::reason_type; $DEBUG = 0; @@ -438,6 +440,15 @@ adds a record of the voided payment to the FS::cust_pay_void table. sub void { my $self = shift; + my $reason = shift; + + unless (ref($reason) || !$reason) { + $reason = FS::reason->new_or_existing( + 'class' => 'X', + 'type' => 'Void payment', + 'reason' => $reason + ); + } local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -453,7 +464,7 @@ sub void { my $cust_pay_void = new FS::cust_pay_void ( { map { $_ => $self->get($_) } $self->fields } ); - $cust_pay_void->reason(shift) if scalar(@_); + $cust_pay_void->reasonnum($reason->reasonnum) if $reason; my $error = $cust_pay_void->insert; my $cust_pay_pending = @@ -1023,6 +1034,8 @@ sub _upgrade_data { #class method warn "$me upgrading $class\n" if $DEBUG; + $class->_upgrade_reasonnum(%opt); + local $FS::payinfo_Mixin::ignore_masked_payinfo = 1; ## diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm index b2f777b32..8fd539616 100644 --- a/FS/FS/cust_pay_void.pm +++ b/FS/FS/cust_pay_void.pm @@ -1,6 +1,6 @@ package FS::cust_pay_void; use base qw( FS::otaker_Mixin FS::payinfo_transaction_Mixin FS::cust_main_Mixin - FS::Record ); + FS::reason_Mixin FS::Record ); use strict; use vars qw( @encrypted_fields $otaker_upgrade_kludge ); @@ -88,7 +88,9 @@ Desired pkgnum when using experimental package balances. =item void_date -=item reason +=item reason - a freeform string (deprecated) + +=item reasonnum - Reason for voiding the payment (see L<FS::reson>) =back @@ -189,6 +191,7 @@ sub check { || $self->ut_numbern('void_date') || $self->ut_textn('reason') || $self->payinfo_check + || $self->ut_foreign_keyn('reasonnum', 'reason', 'reasonnum') ; return $error if $error; @@ -221,10 +224,18 @@ sub void_access_user { qsearchs('access_user', { 'usernum' => $self->void_usernum } ); } +=item reason + +Returns the text of the associated void reason (see L<FS::reason>) for this. + +=cut + # Used by FS::Upgrade to migrate to a new database. sub _upgrade_data { # class method my ($class, %opts) = @_; + $class->_upgrade_reasonnum(%opts); + my $sql = "SELECT usernum FROM access_user WHERE username = ( SELECT history_user FROM h_cust_pay_void WHERE paynum = ? AND history_action = 'insert' ORDER BY history_date LIMIT 1 ) "; my $sth = dbh->prepare($sql) or die dbh->errstr; diff --git a/FS/FS/reason_Mixin.pm b/FS/FS/reason_Mixin.pm index a3975419c..af9aa50e6 100644 --- a/FS/FS/reason_Mixin.pm +++ b/FS/FS/reason_Mixin.pm @@ -6,18 +6,21 @@ use FS::Record qw( qsearch qsearchs dbdef ); use FS::access_user; use FS::UID qw( dbh ); use FS::reason; +use FS::reason_type; our $DEBUG = 0; our $me = '[FS::reason_Mixin]'; =item reason -Returns the text of the associated reason (see L<FS::reason>) for this credit. +Returns the text of the associated reason (see L<FS::reason>) for this credit / +voided payment / voided invoice. =cut sub reason { - my ($self, $value, %options) = @_; + my $self = shift; + my $reason_text; if ( $self->reasonnum ) { my $reason = FS::reason->by_key($self->reasonnum); @@ -36,61 +39,117 @@ sub reason { # FS::reason->new_or_existing # Used by FS::Upgrade to migrate reason text fields to reasonnum. -sub _upgrade_reasonnum { # class method - my $class = shift; - my $table = $class->table; - - if (defined dbdef->table($table)->column('reason')) { - - warn "$me Checking for unmigrated reasons\n" if $DEBUG; - - my @cust_refunds = qsearch({ 'table' => $table, - 'hashref' => {}, - 'extra_sql' => 'WHERE reason IS NOT NULL', - }); - - if (scalar(grep { $_->getfield('reason') =~ /\S/ } @cust_refunds)) { - warn "$me Found unmigrated reasons\n" if $DEBUG; - my $hashref = { 'class' => 'F', 'type' => 'Legacy' }; - my $reason_type = qsearchs( 'reason_type', $hashref ); - unless ($reason_type) { - $reason_type = new FS::reason_type( $hashref ); - my $error = $reason_type->insert(); - die "$class had error inserting FS::reason_type into database: $error\n" - if $error; - } - - $hashref = { 'reason_type' => $reason_type->typenum, - 'reason' => '(none)' - }; - my $noreason = qsearchs( 'reason', $hashref ); - unless ($noreason) { - $hashref->{'disabled'} = 'Y'; - $noreason = new FS::reason( $hashref ); - my $error = $noreason->insert(); - die "can't insert legacy reason '(none)' into database: $error\n" - if $error; - } - - foreach my $cust_refund ( @cust_refunds ) { - my $reason = $cust_refund->getfield('reason'); - warn "Contemplating reason $reason\n" if $DEBUG > 1; - if ($reason =~ /\S/) { - $cust_refund->reason($reason, 'reason_type' => $reason_type->typenum) - or die "can't insert legacy reason $reason into database\n"; - }else{ - $cust_refund->reasonnum($noreason->reasonnum); +sub _upgrade_reasonnum { # class method + my $class = shift; + my $table = $class->table; + + for my $fieldname (qw(reason void_reason)) { + if ( defined dbdef->table($table)->column($fieldname) + && defined dbdef->table($table)->column( $fieldname . 'num' ) ) + { + + warn "$me Checking for unmigrated reasons\n" if $DEBUG; + + my @legacy_reason_records = qsearch( + { + 'table' => $table, + 'hashref' => {}, + 'extra_sql' => 'WHERE ' . $fieldname . ' IS NOT NULL', + } + ); + + if ( + scalar( + grep { $_->getfield($fieldname) =~ /\S/ } + @legacy_reason_records + ) + ) + { + warn "$me Found unmigrated reasons\n" if $DEBUG; + + my $reason_type = + _upgrade_get_legacy_reason_type( $class, $table ); + my $noreason = _upgrade_get_no_reason( $class, $reason_type ); + + foreach my $record_to_upgrade (@legacy_reason_records) { + my $reason = $record_to_upgrade->getfield($fieldname); + warn "Contemplating reason $reason\n" if $DEBUG > 1; + if ( $reason =~ /\S/ ) { + my $reason = + _upgrade_get_reason( $class, $reason, $reason_type ); + $record_to_upgrade->set( $fieldname . 'num', + $reason->reasonnum ); + } + else { + $record_to_upgrade->set( $fieldname . 'num', + $noreason->reasonnum ); + } + + $record_to_upgrade->setfield( $fieldname, '' ); + my $error = $record_to_upgrade->replace; + + my $primary_key = $record_to_upgrade->primary_key; + warn "*** WARNING: error replacing $fieldname in $class " + . $record_to_upgrade->get($primary_key) + . ": $error ***\n" + if $error; + } + } } + } +} - $cust_refund->setfield('reason', ''); - my $error = $cust_refund->replace; - - warn "*** WARNING: error replacing reason in $class ". - $cust_refund->refundnum. ": $error ***\n" - if $error; - } +# _upgrade_get_legacy_reason_type is class method supposed to be used only +# within the reason_Mixin class which will either find or create a reason_type +sub _upgrade_get_legacy_reason_type { + + my $class = shift; + my $table = shift; + + my $reason_class = + ( $table =~ /void/ ) ? 'X' : 'F'; # see FS::reason_type (%class_name) + my $reason_type_params = { 'class' => $reason_class, 'type' => 'Legacy' }; + my $reason_type = qsearchs( 'reason_type', $reason_type_params ); + unless ($reason_type) { + $reason_type = new FS::reason_type($reason_type_params); + my $error = $reason_type->insert(); + die "$class had error inserting FS::reason_type into database: $error\n" + if $error; } - } + return $reason_type; +} + +# _upgrade_get_no_reason is class method supposed to be used only within the +# reason_Mixin class which will either find or create a default (no reason) +# reason +sub _upgrade_get_no_reason { + + my $class = shift; + my $reason_type = shift; + return _upgrade_get_reason( $class, '(none)', $reason_type ); +} + +# _upgrade_get_reason is class method supposed to be used only within the +# reason_Mixin class which will either find or create a reason +sub _upgrade_get_reason { + + my $class = shift; + my $reason_text = shift; + my $reason_type = shift; + + my $reason_params = { + 'reason_type' => $reason_type->typenum, + 'reason' => $reason_text + }; + my $reason = qsearchs( 'reason', $reason_params ); + unless ($reason) { + $reason_params->{'disabled'} = 'Y'; + $reason = new FS::reason($reason_params); + my $error = $reason->insert(); + die "can't insert legacy reason '$reason_text' into database: $error\n" + if $error; + } + return $reason; } 1; diff --git a/FS/FS/reason_type.pm b/FS/FS/reason_type.pm index 17a716712..4042972b4 100644 --- a/FS/FS/reason_type.pm +++ b/FS/FS/reason_type.pm @@ -11,7 +11,7 @@ our %class_name = ( 'R' => 'credit', 'S' => 'suspend', 'F' => 'refund', - 'X' => 'void credit', + 'X' => 'void', # credit/invoice/payment ); our %class_purpose = ( @@ -19,7 +19,7 @@ our %class_purpose = ( 'R' => 'explain why a customer was credited', 'S' => 'explain why a customer package was suspended', 'F' => 'explain why a customer was refunded', - 'X' => 'explain why a credit was voided', + 'X' => 'explain why a transaction was voided', ); =head1 NAME diff --git a/FS/bin/freeside-paymentech-download b/FS/bin/freeside-paymentech-download index 1b2f95175..9a1f609bc 100755 --- a/FS/bin/freeside-paymentech-download +++ b/FS/bin/freeside-paymentech-download @@ -20,7 +20,7 @@ getopts('vta:'); sub log_and_die { my $message = shift; - my $log = FS::Log->new('freeside-paymenttech-download'); + my $log = FS::Log->new('freeside-paymentech-download'); $log->error($message); die $message; } diff --git a/FS/bin/freeside-paymentech-upload b/FS/bin/freeside-paymentech-upload index a6e6a5d28..5ae147d07 100755 --- a/FS/bin/freeside-paymentech-upload +++ b/FS/bin/freeside-paymentech-upload @@ -20,7 +20,7 @@ getopts('avtp:'); sub log_and_die { my $message = shift; - my $log = FS::Log->new('freeside-paymenttech-upload'); + my $log = FS::Log->new('freeside-paymentech-upload'); $log->error($message); die $message; } |