From ea471f0c21d91b7b29ba03038015f67083df496f Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Tue, 10 May 2011 10:09:59 +0200 Subject: [PATCH 1/1] Improved notification in revaluation of currencies and fixed a summation bug. --- gl/includes/db/gl_db_banking.inc | 15 +++++++-------- gl/manage/revaluate_currencies.php | 7 +++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index e4343a3b..6c4395d5 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -91,12 +91,8 @@ function get_cust_account_home_balance($debtor_no, $rec_account, $to_date) $to = date2sql($to_date); $sql = "SELECT SUM(amount) FROM ".TB_PREF."gl_trans t - LEFT JOIN ".TB_PREF."debtors_master d ON t.person_id = d.debtor_no - LEFT JOIN ".TB_PREF."debtor_trans dt ON (t.type=dt.type AND t.type_no=dt.trans_no) - LEFT JOIN ".TB_PREF."cust_branch br ON dt.branch_code = br.branch_code - WHERE br.debtor_no=".db_escape($debtor_no)." AND t.account=br.receivables_account AND t.account='$rec_account' - AND person_id=br.debtor_no AND person_type_id=".PT_CUSTOMER." - AND t.tran_date <= '$to'"; + WHERE t.person_id=".db_escape($debtor_no)." AND t.account='$rec_account' + AND person_type_id=".PT_CUSTOMER." AND t.tran_date <= '$to'"; $result = db_query($sql, "The AR balance for customer $debtor_no could not be calculated"); $row = db_fetch_row($result); return $row[0]; @@ -159,8 +155,9 @@ function add_exchange_variation_all($date=null, $ref="", $memo) //------------- BEGIN inserted for revaluation of customer/supplier currencies 2011-05-08 Joe Hunt. if ($date == null) $date = Today(); - // debtors $exchange_act = get_company_pref('exchange_diff_act'); + $je = 0; + // debtors $res = get_cust_account_curr_balances($date); while($row = db_fetch($res)) @@ -173,6 +170,7 @@ function add_exchange_variation_all($date=null, $ref="", $memo) $amount = $foreign - $home; add_cust_supp_revaluation($row['receivables_account'], $exchange_act, $date, $amount, PT_CUSTOMER, $row['debtor_no'], $memo); + $je++; } } // creditors @@ -188,12 +186,13 @@ function add_exchange_variation_all($date=null, $ref="", $memo) $amount = $foreign - $home; add_cust_supp_revaluation($row['payable_account'], $exchange_act, $date, $amount, PT_SUPPLIER, $row['supplier_id'], $memo); + $je++; } } //------------- END commit_transaction(); - return ($exchanged ? $trans_no : 0); + return array(($exchanged ? $trans_no : 0), $je); } //---------------------------------------------------------------------------------- // Add bank tranfer to database. diff --git a/gl/manage/revaluate_currencies.php b/gl/manage/revaluate_currencies.php index 78c5cbbb..a35c4a91 100644 --- a/gl/manage/revaluate_currencies.php +++ b/gl/manage/revaluate_currencies.php @@ -25,6 +25,7 @@ page(_($help_context = "Revaluation of Currency Accounts"), false, false, "", $j if (isset($_GET['AddedID'])) { $trans_no = $_GET['AddedID']; + $JE = $_GET['JE']; $trans_type = ST_JOURNAL; if ($trans_no == 0) @@ -35,6 +36,8 @@ if (isset($_GET['AddedID'])) display_note(get_gl_view_str($trans_type, $trans_no, _("&View the GL Journal Entries for this Transfer"))); } + if ($JE > 0) + display_notification_centered(sprintf(_("%d Journal Entries for AR/AP accounts have been added"), $JE)); //display_footer_exit(); } @@ -81,9 +84,9 @@ function handle_submit() if (!check_data()) return; - $trans_no = add_exchange_variation_all($_POST['date'], $_POST['ref'], $_POST['memo_']); + $trans = add_exchange_variation_all($_POST['date'], $_POST['ref'], $_POST['memo_']); - meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no"); + meta_forward($_SERVER['PHP_SELF'], "AddedID=".$trans[0]."&JE=".$trans[1]); //clear_data(); } -- 2.30.2