summaryrefslogtreecommitdiff
path: root/LedgerSMB/DBObject
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-12-17 23:22:43 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-12-17 23:22:43 +0000
commit32ec9551c2c00aa85c4479451e5d4d55d09679e0 (patch)
tree4c70b49ad3a9a1ae5b9754596584163c505091ab /LedgerSMB/DBObject
parentb707449f9197e3c63c8fa00a1edeb973dacd5262 (diff)
Batch enhancements
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1980 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/DBObject')
-rw-r--r--LedgerSMB/DBObject/Payment.pm22
1 files changed, 13 insertions, 9 deletions
diff --git a/LedgerSMB/DBObject/Payment.pm b/LedgerSMB/DBObject/Payment.pm
index 2d4ced79..f4382a28 100644
--- a/LedgerSMB/DBObject/Payment.pm
+++ b/LedgerSMB/DBObject/Payment.pm
@@ -382,7 +382,7 @@ sub get_payment_detail_data {
$inv->{invoices} = [];
@{$inv->{invoices}} = $self->_parse_array($tmp_invoices);
}
- # $self->{dbh}->commit; # Commit locks
+ $self->{dbh}->commit; # Commit locks
}
sub post_bulk {
@@ -398,6 +398,10 @@ sub post_bulk {
funcname => 'job__create'
);
$self->{job_id} = $job_ref->{job__create};
+
+ ($self->{job}) = $self->exec_method(
+ funcname => 'job__status'
+ );
}
$self->{payment_date} = $self->{datepaid};
for my $contact_row (1 .. $self->{contact_count}){
@@ -406,29 +410,29 @@ sub post_bulk {
my $invoice_array = "{}"; # Pg Array
for my $invoice_row (1 .. $self->{"invoice_count_$contact_id"}){
my $invoice_id = $self->{"invoice_${contact_id}_${invoice_row}"};
- print STDERR "invoice_${contact_id}_${invoice_row}: $invoice_id\n";
my $pay_amount = ($self->{"paid_$contact_id"} eq 'all' )
? $self->{"net_$invoice_id"}
: $self->{"payment_$invoice_id"};
- if (!$pay_amount){
- $pay_amount = 0;
- }
+ next if ! $pay_amount;
+ $pay_amount = $pay_amount * 1;
my $invoice_subarray = "{$invoice_id,$pay_amount}";
+ if ($invoice_subarray !~ /^\{\d+\,\-?\d*\.?\d+\}$/){
+ $self->error("Invalid subarray: $invoice_subarray");
+ }
+ $invoice_subarray =~ s/[^0123456789{},.]//;
if ($invoice_array eq '{}'){ # Omit comma
$invoice_array = "{$invoice_subarray}";
} else {
- $invoice_array =~ s/}$/,$invoice_subarray}/;
+ $invoice_array =~ s/\}$/,$invoice_subarray\}/;
}
}
$self->{transactions} = $invoice_array;
$self->{source} = $self->{"source_$contact_id"};
if ($queue_payments){
+ $self->{batch_class} = 3;
$self->exec_method(
funcname => 'payment_bulk_queue'
);
- ($self->{job}) = $self->exec_method(
- funcname => 'job__status'
- );
} else {
$self->exec_method(funcname => 'payment_bulk_post');
}