summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-15 00:06:50 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-15 00:06:50 +0000
commitcf1348aeeaa44679abd7eaa7966414eb3a1fc361 (patch)
tree53dd834157fce3f32a2236e2771216d82d7652c9 /LedgerSMB
parent84a11c32e68a9a57378a5d38886f1cb2cb547393 (diff)
Adding not-yet-documented Payment.pm
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1603 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/DBObject/Payment.pm59
1 files changed, 59 insertions, 0 deletions
diff --git a/LedgerSMB/DBObject/Payment.pm b/LedgerSMB/DBObject/Payment.pm
new file mode 100644
index 00000000..8d299311
--- /dev/null
+++ b/LedgerSMB/DBObject/Payment.pm
@@ -0,0 +1,59 @@
+
+=head1: LedgerSMB::DBObject::Payment: Stub function for payments.
+=head1: Copyright (c) 2007. LedgerSMB Core Team
+
+=cut
+
+package LedgerSMB::DBObject::Payment;
+use base qw(LedgerSMB::DBObject);
+use strict;
+use Math::BigFloat lib => 'GMP';
+our $VERSION = '0.1.0';
+
+sub get_open_accounts {
+ my ($self) = @_;
+ @{$self->{accounts}} =
+ $self->exec_method(funcname => 'payment_get_open_accounts');
+ return @{$self->{accounts}};
+}
+
+sub get_all_accounts {
+ my ($self) = @_;
+ @{$self->{accounts}} =
+ $self->exec_method(funcname => 'payment_get_all_accounts');
+ return @{$self->{accounts}};
+}
+
+sub get_open_invoices {
+ my ($self) = @_;
+ @{$self->{open_invoices}} =
+ $self->exec_method(funcname => 'payment_get_open_invoices');
+ return @{$self->{open_invoices}};
+}
+
+sub get_all_contact_invoices {
+ my ($self) = @_;
+ @{$self->{contacts}} =
+ $self->exec_method(funcname => 'payment_get_all_contact_invoices');
+
+ # When arrays of complex types are supported by all versions of Postgres
+ # that this application supports, we should look at doing type conversions
+ # in DBObject so this sort of logic is unncessary. -- CT
+ for my $contact (@{$self->{contacts}}){
+ my @invoices = $self->parse_array($contact->{invoices});
+ my $processed_invoices = [];
+ for my $invoice (@invoices){
+ my $new_invoice = {};
+ for (qw(invoice_id invnumber invoice_date amount discount due)){
+ $new_invoice->{$_} = shift @$invoice;
+ if ($_ =~ /^(amount|discount|due)$/){
+ $new_invoice->{$_} =
+ Math::BigFloat->new($new_invoice->{$_});
+ }
+ }
+ push(@$processed_invoices, $new_invoice);
+ }
+ $contact->{invoice} = $processed_invoices;
+ }
+ return @{$self->{contacts}};
+}