diff -ur hpgs_fa/config_db.php hpgs_fa_test/config_db.php
--- hpgs_fa/config_db.php	2019-07-17 12:09:39.634938746 +0500
+++ hpgs_fa_test/config_db.php	2021-06-09 19:57:11.067719136 +0500
@@ -28,7 +28,7 @@
     'name' => 'HPGS',
     'host' => '127.0.0.1',
     'port' => '3306',
-    'dbname' => 'fa_hpgs',
+    'dbname' => 'fa_hpgs_test',
     'collation' => 'utf8_xx',
     'tbpref' => '0_',
     'dbuser' => 'root',
diff -ur hpgs_fa/gl/gl_bank.php hpgs_fa_test/gl/gl_bank.php
--- hpgs_fa/gl/gl_bank.php	2019-07-24 20:42:30.170938746 +0500
+++ hpgs_fa_test/gl/gl_bank.php	2021-06-09 23:04:31.163719136 +0500
@@ -178,12 +178,14 @@
 
 		$cart->original_amount = $bank_trans['amount'];
 		$result = get_gl_trans($type, $trans_no);
+		$bank_total = 0;
 		if ($result) {
 			while ($row = db_fetch($result)) {
 				if (is_bank_account($row['account'])) {
 					// date exchange rate is currenly not stored in bank transaction,
 					// so we have to restore it from original gl amounts
-					$ex_rate = $bank_trans['amount']/$row['amount'];
+					$bank_total += $row['amount'];
+					//$ex_rate = $bank_trans['amount']/$row['amount'];
 				} else {
 					$cart->add_gl_item( $row['account'], $row['dimension_id'],
 						$row['dimension2_id'], $row['amount'], $row['memo_']);
@@ -192,6 +194,8 @@
 		}
 
 		// apply exchange rate
+		// ADEEL: 20210609 calculate ex_rate in the end, as now we have multiple entries for gl_ledger for the same trans_no because of changes done to write_bank_trans, previously there was only one bank account gl entry. We simply total all the gl entries for the bank accounts 
+		$ex_rate = $bank_trans['amount']/$bank_total;
 		foreach($cart->gl_items as $line_no => $line)
 			$cart->gl_items[$line_no]->amount *= $ex_rate;
 
diff -ur hpgs_fa/gl/includes/db/gl_db_banking.inc hpgs_fa_test/gl/includes/db/gl_db_banking.inc
--- hpgs_fa/gl/includes/db/gl_db_banking.inc	2019-07-10 12:33:24.262938746 +0500
+++ hpgs_fa_test/gl/includes/db/gl_db_banking.inc	2021-06-09 22:59:41.683719136 +0500
@@ -485,6 +485,11 @@
     		$gl_item->dimension_id, $gl_item->dimension2_id, $gl_item->reference,
     		$gl_item->amount, $currency, $person_type_id, $person_id);
 
+		// do the source account postings
+		add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, 
+		     $gl_item->dimension_id, $gl_item->dimension2_id, $memo_,
+		     -$gl_item->amount, null, $person_type_id, $person_id);
+
     	if ($is_bank_to)
     	{
     		add_bank_trans($trans_type, $trans_no, $is_bank_to, $ref,
@@ -507,8 +512,9 @@
 	}
 
 	// do the source account postings
-    add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, 0, 0, $memo_,
-    	-$total, null, $person_type_id, $person_id);
+	//ADEEL: 20210609 save transactions in corresponding account with dimension
+        //add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, 0, 0, $memo_,
+    	//-$total, null, $person_type_id, $person_id);
 
     if ($do_exchange_variance)
     {
diff -ur hpgs_fa/tmp/errors.log hpgs_fa_test/tmp/errors.log
--- hpgs_fa/tmp/errors.log	2021-06-26 10:40:51.543719136 +0500
+++ hpgs_fa_test/tmp/errors.log	2021-06-09 14:44:17.579719136 +0500
@@ -161,7 +161,3 @@
 [08-Jun-2021 07:47:19 Europe/Berlin] 0:Owais:gl_bank_ui.inc:161: Invalid argument supplied for foreach()
 [08-Jun-2021 10:20:10 Europe/Berlin] 0:Owais:gl_bank_ui.inc:161: Invalid argument supplied for foreach()
 [09-Jun-2021 11:44:17 Europe/Berlin] 0:Owais:gl_bank_ui.inc:161: Invalid argument supplied for foreach()
-[16-Jun-2021 09:17:50 Europe/Berlin] 0:Owais:gl_bank_ui.inc:161: Invalid argument supplied for foreach()
-[22-Jun-2021 13:11:18 Europe/Berlin] 0:Owais:gl_bank_ui.inc:161: Invalid argument supplied for foreach()
-[24-Jun-2021 12:00:43 Europe/Berlin] 0:admin:gl_journal.php:464: Creating default object from empty value
-[26-Jun-2021 07:40:51 Europe/Berlin] 0:admin:gl_journal.php:464: Creating default object from empty value
diff -ur hpgs_fa/tmp/faillog.php hpgs_fa_test/tmp/faillog.php
--- hpgs_fa/tmp/faillog.php	2021-06-28 13:08:52.759719136 +0500
+++ hpgs_fa_test/tmp/faillog.php	2021-06-21 17:36:38.847719136 +0500
@@ -5,12 +5,12 @@
 $login_faillog = array (
   0 => 
   array (
-    '202.47.46.20' => 0,
+    '72.255.9.74' => 0,
     'last' => '',
   ),
   1 => 
   array (
-    '202.47.46.20' => 0,
+    '39.48.247.35' => 0,
     'last' => '',
   ),
   2 => 
@@ -35,7 +35,7 @@
   ),
   5 => 
   array (
-    '202.47.46.20' => 0,
+    '103.244.176.41' => 0,
     'last' => '',
   ),
   8 => 
