Changed so exchange variances is stamped on invoice GL instead of payment GL
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 14 Mar 2009 00:12:24 +0000 (00:12 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 14 Mar 2009 00:12:24 +0000 (00:12 +0000)
  if invoice date is later than payment date

CHANGELOG.txt
includes/banking.inc

index f50ce0b599dbb72bec7856fb9e06f93fd191aa77..e4959d2998ec54bd2ab6f187fe7b2210c1328cc5 100644 (file)
@@ -19,6 +19,11 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+14-Mar-2009 Joe Hunt
+! Changed so exchange variances is stamped on invoice GL instead of payment GL
+  if invoice date is later than payment date
+$ /includes/banking.inc
+
 13-Mar-2009 Janusz Dobrowolski/Joe Hunt
 # GL line delete bug fixed.
 $ /gl/includes/ui/gl_bank_ui.inc
index 4de6ae471fa1430a9f56222fd88def42ff71aa40..cf532ea05ec95548da9b870edbe694c8fc4e1ec4 100644 (file)
@@ -171,6 +171,7 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am
                $ar_ap_act = $trans['receivables_account'];
                $person_id = $trans['debtor_no'];
                $curr = $trans['curr_code'];
+               $date = sql2date($trans['tran_date']);
        }
        else
        {
@@ -180,6 +181,7 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am
                $ar_ap_act = $supp_accs['payable_account'];
                $person_id = $trans['supplier_id'];
                $curr = $trans['SupplierCurrCode'];
+               $date = sql2date($trans['tran_date']);
        }
        if (is_company_currency($curr))
                return;
@@ -193,9 +195,18 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am
                if ($neg)
                        $diff = -$diff;
                $exc_var_act = get_company_pref('exchange_diff_act');
-               $memo = systypes::name($type)." ".$trans_no;
-               add_gl_trans($pyt_type, $pyt_no, $pyt_date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id);
-               add_gl_trans($pyt_type, $pyt_no, $pyt_date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id);
+               if (date1_greater_date2($date, $pyt_date))
+               {
+                       $memo = systypes::name($pyt_type)." ".$pyt_no;
+                       add_gl_trans($type, $trans_no, $date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id);
+                       add_gl_trans($type, $trans_no, $date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id);
+               }
+               else
+               {
+                       $memo = systypes::name($type)." ".$trans_no;
+                       add_gl_trans($pyt_type, $pyt_no, $pyt_date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id);
+                       add_gl_trans($pyt_type, $pyt_no, $pyt_date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id);
+               }
        }
 }