From e5aa2c6737821924b77734ccfee74f1930831234 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Thu, 6 Dec 2007 22:08:49 +0000 Subject: Misc fixes git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1955 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/Batch.pm | 1 + LedgerSMB/DBObject/Payment.pm | 32 ++++++++++++++++++++++++++++++++ LedgerSMB/GL.pm | 1 - 3 files changed, 33 insertions(+), 1 deletion(-) (limited to 'LedgerSMB') diff --git a/LedgerSMB/Batch.pm b/LedgerSMB/Batch.pm index 19cb656e..5c948f79 100644 --- a/LedgerSMB/Batch.pm +++ b/LedgerSMB/Batch.pm @@ -8,6 +8,7 @@ sub create { my ($ref) = $self->exec_method(funcname => 'batch_create'); print STDERR "$ref, $ref->{batch_create}, " . join (':', keys %$ref); $self->{id} = $ref->{batch_create}; + $self->{dbh}->commit; return $ref->{id}; } diff --git a/LedgerSMB/DBObject/Payment.pm b/LedgerSMB/DBObject/Payment.pm index d8af8a9f..2c523717 100644 --- a/LedgerSMB/DBObject/Payment.pm +++ b/LedgerSMB/DBObject/Payment.pm @@ -381,4 +381,36 @@ sub get_payment_detail_data { } } +sub post_bulk { + my ($self) = @_; + my $total_count = 0; + $self->{payment_date} = $self->{datepaid}; + for my $contact_row (1 .. $self->{contact_count}){ + my $contact_id = $self->{"contact_$contact_row"}; + next if (!$self->{"id_$contact_id"}); + 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; + } + my $invoice_subarray = "{$invoice_id,$pay_amount}"; + if ($invoice_array eq '{}'){ # Omit comma + $invoice_array = "{$invoice_subarray}"; + } else { + $invoice_array =~ s/}$/,$invoice_subarray}/; + } + } + $self->{transactions} = $invoice_array; + $self->{source} = $self->{"source_$contact_id"}; + $self->exec_method(funcname => 'payment_bulk_post'); + + } + $self->{dbh}->commit; +} + 1; diff --git a/LedgerSMB/GL.pm b/LedgerSMB/GL.pm index 7e4f8cc8..1c5cd97c 100644 --- a/LedgerSMB/GL.pm +++ b/LedgerSMB/GL.pm @@ -67,7 +67,6 @@ sub post_transaction { my ( $self, $myconfig, $form ) = @_; $form->{reference} = $form->update_defaults( $myconfig, 'glnumber', $dbh ) unless $form->{reference}; - my $null; my $project_id; my $department_id; -- cgit v1.2.3