summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-04-25 16:14:54 -0700
committerIvan Kohler <ivan@freeside.biz>2014-04-25 16:14:54 -0700
commite91ed1c4a81c25757f812b3ec8238645b836b235 (patch)
tree383216a6a36c1e73f754be4d43196fe3d1d36cd2
parentc931539d1b09590c37576efff8128ae9095c758a (diff)
parent41b1a4d9e2cf8270f3e4d0b8d5ac02b875b46f0c (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
-rw-r--r--FS/FS/Cursor.pm2
-rw-r--r--FS/FS/cust_event_fee.pm9
-rw-r--r--FS/FS/cust_main/Billing.pm5
-rw-r--r--FS/FS/cust_main/Location.pm21
-rw-r--r--FS/FS/part_event/Action/cust_fee.pm3
-rw-r--r--FS/FS/pay_batch/nacha.pm2
6 files changed, 29 insertions, 13 deletions
diff --git a/FS/FS/Cursor.pm b/FS/FS/Cursor.pm
index ec7af93c1..469a678d5 100644
--- a/FS/FS/Cursor.pm
+++ b/FS/FS/Cursor.pm
@@ -57,7 +57,7 @@ sub new {
my $sth = dbh->prepare($statement)
or die dbh->errstr;
- my $bind = 0;
+ my $bind = 1;
foreach my $value ( @{ $q->{value} } ) {
my $bind_type = shift @{ $q->{bind_type} };
$sth->bind_param($bind++, $value, $bind_type );
diff --git a/FS/FS/cust_event_fee.pm b/FS/FS/cust_event_fee.pm
index 181640ddc..e88dcc4b7 100644
--- a/FS/FS/cust_event_fee.pm
+++ b/FS/FS/cust_event_fee.pm
@@ -151,6 +151,15 @@ sub by_cust {
table => 'cust_event_fee',
addl_from => 'JOIN cust_event USING (eventnum) ' .
'JOIN part_event USING (eventpart) ' .
+ 'JOIN cust_pay_batch ON (cust_event.tablenum = cust_pay_batch.paybatchnum)',
+ extra_sql => "$where eventtable = 'cust_pay_batch' ".
+ "AND cust_pay_batch.custnum = $custnum",
+ %params
+ }),
+ qsearch({
+ table => 'cust_event_fee',
+ addl_from => 'JOIN cust_event USING (eventnum) ' .
+ 'JOIN part_event USING (eventpart) ' .
'JOIN cust_pkg ON (cust_event.tablenum = cust_pkg.pkgnum)',
extra_sql => "$where eventtable = 'cust_pkg' ".
"AND cust_pkg.custnum = $custnum",
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index 94a0069cc..63c7f2b58 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -570,7 +570,10 @@ sub bill {
my $object = $event_fee->cust_event->cust_X;
my $part_fee = $event_fee->part_fee;
my $cust_bill;
- if ( $object->isa('FS::cust_main') or $object->isa('FS::cust_pkg') ) {
+ if ( $object->isa('FS::cust_main')
+ or $object->isa('FS::cust_pkg')
+ or $object->isa('FS::cust_pay_batch') )
+ {
# Not the real cust_bill object that will be inserted--in particular
# there are no taxes yet. If you want to charge a fee on the total
# invoice amount including taxes, you have to put the fee on the next
diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm
index 4f382af43..9899f7230 100644
--- a/FS/FS/cust_main/Location.pm
+++ b/FS/FS/cust_main/Location.pm
@@ -4,6 +4,7 @@ use strict;
use vars qw( $DEBUG $me @location_fields );
use FS::Record qw(qsearch qsearchs);
use FS::UID qw(dbh);
+use FS::Cursor;
use FS::cust_location;
use Carp qw(carp);
@@ -137,6 +138,7 @@ sub _upgrade_data {
|| new FS::contact_class { classname => 'Service'};
if ( !$service_contact_class->classnum ) {
+ warn "Creating service contact class.\n";
$error = $service_contact_class->insert;
die "error creating contact class for Service: $error" if $error;
}
@@ -158,11 +160,12 @@ sub _upgrade_data {
}
}
- foreach my $cust_main (qsearch('cust_main', {
- bill_locationnum => '',
- address1 => { op=>'!=', value=>'' },
- }))
- {
+ warn "Migrating customer locations.\n";
+ my $search = FS::Cursor->new('cust_main',
+ { bill_locationnum => '',
+ address1 => { op=>'!=', value=>'' }
+ });
+ while (my $cust_main = $search->fetch) {
# Step 1: extract billing and service addresses into cust_location
my $custnum = $cust_main->custnum;
my $bill_location = FS::cust_location->new(
@@ -287,9 +290,9 @@ sub _upgrade_data {
if $error;
# Step 4: set packages at the "default service location" to ship_location
- foreach my $cust_pkg (
- qsearch('cust_pkg', { custnum => $custnum, locationnum => '' })
- ) {
+ my $pkg_search =
+ FS::Cursor->new('cust_pkg', { custnum => $custnum, locationnum => '' });
+ while (my $cust_pkg = $pkg_search->fetch) {
# not a location change
$cust_pkg->set('locationnum', $cust_main->ship_locationnum);
$error = $cust_pkg->replace;
@@ -297,7 +300,7 @@ sub _upgrade_data {
if $error;
}
- } #foreach $cust_main
+ } #while (my $cust_main...)
# repair an error in earlier upgrades
if (!FS::upgrade_journal->is_done('cust_location_censustract_repair')
diff --git a/FS/FS/part_event/Action/cust_fee.pm b/FS/FS/part_event/Action/cust_fee.pm
index 9373091ab..27ca2a1d0 100644
--- a/FS/FS/part_event/Action/cust_fee.pm
+++ b/FS/FS/part_event/Action/cust_fee.pm
@@ -6,7 +6,8 @@ use base qw( FS::part_event::Action::Mixin::fee );
sub description { 'Charge a fee based on the customer\'s current invoice'; }
sub eventtable_hashref {
- { 'cust_main' => 1 };
+ { 'cust_main' => 1,
+ 'cust_pay_batch' => 1 };
}
sub hold_until_bill { 1 }
diff --git a/FS/FS/pay_batch/nacha.pm b/FS/FS/pay_batch/nacha.pm
index d6786e035..c8d784d70 100644
--- a/FS/FS/pay_batch/nacha.pm
+++ b/FS/FS/pay_batch/nacha.pm
@@ -148,7 +148,7 @@ $DEBUG = 0;
$transaction_code. #Transaction Code
$aba. #Receiving DFI Identification, check digit
substr($account.(' 'x17), 0, 17). #DFI Account number (Left justify)
- sprintf('%010d', $cust_pay_batch->amount * 100). #Amount
+ sprintf('%010.0f', $cust_pay_batch->amount * 100). #Amount
$cust_identifier. #Individual Identification Number, 15 char
$cust_name. #Individual name (22-char)
' '. #2 char "company internal use if desired"