summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-11-21 18:23:51 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-11-21 18:23:51 +0000
commit343c6184f7ac98ae28f4bd457a0b2c17d12530ce (patch)
tree09938a13b305106ba0ce8175e89f280447b5f096 /LedgerSMB
parent3f70ce6626d1985425893f4104f87de7b46ab45a (diff)
Committing David Mora's single payment interface enhancements
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2410 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r--LedgerSMB/CP.pm1
-rw-r--r--LedgerSMB/DBObject/Payment.pm42
-rw-r--r--LedgerSMB/Num2text.pm2
3 files changed, 43 insertions, 2 deletions
diff --git a/LedgerSMB/CP.pm b/LedgerSMB/CP.pm
index b901354b..2f3d5307 100644
--- a/LedgerSMB/CP.pm
+++ b/LedgerSMB/CP.pm
@@ -37,6 +37,7 @@
package CP;
use LedgerSMB::Sysconfig;
+
sub new {
my ( $type, $countrycode ) = @_;
diff --git a/LedgerSMB/DBObject/Payment.pm b/LedgerSMB/DBObject/Payment.pm
index b148165e..65526609 100644
--- a/LedgerSMB/DBObject/Payment.pm
+++ b/LedgerSMB/DBObject/Payment.pm
@@ -19,6 +19,7 @@ included COPYRIGHT and LICENSE files for more information.
=cut
package LedgerSMB::DBObject::Payment;
+use LedgerSMB::Num2text;
use base qw(LedgerSMB::DBObject);
use strict;
use Math::BigFloat lib => 'GMP';
@@ -547,7 +548,46 @@ This method uses payment_post to store a payment (not a bulk payment) on the dat
sub post_payment {
my ($self) = @_;
- $self->exec_method(funcname => 'payment_post');
+ # We have to check if it was a fx_payment
+ $self->{currency} = $self->{curr};
+
+
+ if ("$self->{currency}" ne $self->get_default_currency()) {
+ # First we have to check for an exchangerate on this date
+ my $db_exchangerate = $self->get_exchange_rate($self->{curr},$self->{datepaid});
+ if (!$db_exchangerate) {
+ # We have to set the exchangerate
+
+
+ $self->call_procedure(procname => 'payments_set_exchangerate', args => ["$self->{account_class}", "$self->{exchangerate}" ,"$self->{curr}", "$self->{datepaid}"]);
+
+
+
+ }
+ elsif ($db_exchangerate != $self->{exchangerate} )
+ {
+ # Something went wrong
+ $self->error("Exchange rate inconsistency with database, please try again")
+ }
+ }
+ my @TMParray = $self->exec_method(funcname => 'payment_post');
$self->{dbh}->commit();
+ $self->{payment_id} = $TMParray[0]->{payment_post};
+ return $self->{payment_id};
+}
+
+=item gather_printable_info
+
+This method retrieves all the payment related info needed to build a
+document and print it. IT IS NECESSARY TO ALREADY HAVE payment_id on $self
+
+=cut
+
+
+sub gather_printable_info {
+my ($self) = @_;
+@{$self->{header_info}} = $self->exec_method(funcname => 'payment_gather_header_info');
+@{$self->{line_info}} = $self->exec_method(funcname => 'payment_gather_line_info');
}
+
1;
diff --git a/LedgerSMB/Num2text.pm b/LedgerSMB/Num2text.pm
index 57accc3b..aceb4840 100644
--- a/LedgerSMB/Num2text.pm
+++ b/LedgerSMB/Num2text.pm
@@ -121,7 +121,7 @@ sub num2text {
sub num2text_en {
my ( $self, $amount ) = @_;
-
+
return $self->{numbername}{0} unless $amount;
my @textnumber = ();