From 32ec9551c2c00aa85c4479451e5d4d55d09679e0 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Mon, 17 Dec 2007 23:22:43 +0000 Subject: Batch enhancements git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1980 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/DBObject/Payment.pm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'LedgerSMB/DBObject') 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'); } -- cgit v1.2.3