summaryrefslogtreecommitdiff
path: root/LedgerSMB/DBObject
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-12-06 22:08:49 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-12-06 22:08:49 +0000
commite5aa2c6737821924b77734ccfee74f1930831234 (patch)
tree3880d2f8f07c04e2e83ebcf63a8c7bfd9880be1f /LedgerSMB/DBObject
parent54f827658f696a0cf3209b19d432a624f1f6b02b (diff)
Misc fixes
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1955 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/DBObject')
-rw-r--r--LedgerSMB/DBObject/Payment.pm32
1 files changed, 32 insertions, 0 deletions
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;