[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[4225] branches/1.3



Revision: 4225
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4225&view=rev
Author:   einhverfr
Date:     2011-12-17 11:22:07 +0000 (Sat, 17 Dec 2011)
Log Message:
-----------
Correcting errors paying foreign currency invoices

Modified Paths:
--------------
    branches/1.3/LedgerSMB/DBObject/Payment.pm
    branches/1.3/scripts/payment.pl
    branches/1.3/sql/modules/Payment.sql

Modified: branches/1.3/LedgerSMB/DBObject/Payment.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/Payment.pm	2011-12-17 10:35:48 UTC (rev 4224)
+++ branches/1.3/LedgerSMB/DBObject/Payment.pm	2011-12-17 11:22:07 UTC (rev 4225)
@@ -735,16 +735,15 @@
    if (!$db_exchangerate) {
    # We have to set the exchangerate
   
+   $self->call_procedure(procname => 'payments_set_exchangerate',  args => ["$self->{account_class}", $self->{exrate} ,"$self->{curr}", "$self->{datepaid}"]);
 
-   $self->call_procedure(procname => 'payments_set_exchangerate',  args => ["$self->{account_class}", "$self->{exchangerate}" ,"$self->{curr}", "$self->{datepaid}"]);
 
 
-
    }
-   elsif ($db_exchangerate != $self->{exchangerate} )
+   elsif ($db_exchangerate != $self->{exrate} )
    {
    # Something went wrong
-   $self->error("Exchange rate inconsistency with database, please try again")
+   $self->error($self->{_locale}->text("Exchange rate inconsistency with database.  Got [_1], expected [_2]", $self->{exrate}, $db_exchangerate));
    }
  }
  my @TMParray = $self->exec_method(funcname => 'payment_post');

Modified: branches/1.3/scripts/payment.pl
===================================================================
--- branches/1.3/scripts/payment.pl	2011-12-17 10:35:48 UTC (rev 4224)
+++ branches/1.3/scripts/payment.pl	2011-12-17 11:22:07 UTC (rev 4225)
@@ -950,7 +950,7 @@
        $topay_fx_value = $due_fx = $due_fx + $request->round_amount($array_options[$ref]->{discount}/$array_options[$ref]->{exchangerate});
         }
    } else {
-       $topay_fx_value = "N/A";
+   #    $topay_fx_value = "N/A";
    }
 
    

Modified: branches/1.3/sql/modules/Payment.sql
===================================================================
--- branches/1.3/sql/modules/Payment.sql	2011-12-17 10:35:48 UTC (rev 4224)
+++ branches/1.3/sql/modules/Payment.sql	2011-12-17 11:22:07 UTC (rev 4225)
@@ -1136,19 +1136,20 @@
 BEGIN
 select  * INTO current_exrate
         FROM  exchangerate 
-        WHERE transdate = in_date;
-IF current_exrate.transdate = in_date THEN
+        WHERE transdate = in_datepaid
+              AND curr = in_curr;
+IF current_exrate.transdate = in_datepaid THEN
    IF in_account_class = 2 THEN 
-      UPDATE exchangerate set buy = in_exchangerate  where transdate = in_date;
+      UPDATE exchangerate set buy = in_exchangerate  where transdate = in_datepaid;
    ELSE
-      UPDATE exchangerate set sell = in_exchangerate where transdate = in_date;
+      UPDATE exchangerate set sell = in_exchangerate where transdate = in_datepaid;
    END IF;
    RETURN 0; 
 ELSE
     IF in_account_class = 2 THEN
-     INSERT INTO exchangerate (curr, transdate, buy) values (in_currency, in_date, in_exchangerate);
+     INSERT INTO exchangerate (curr, transdate, buy) values (in_curr, in_datepaid, in_exchangerate);
   ELSE   
-     INSERT INTO exchangerate (curr, transdate, sell) values (in_currency, in_date, in_exchangerate);
+     INSERT INTO exchangerate (curr, transdate, sell) values (in_curr, in_datepaid, in_exchangerate);
   END IF;                                       
 RETURN 0;
 END IF;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.