Topic: Bank Account Reconciliation

I am working on a bank account reconciliation enhancement. Simple to start, and then enhance with ability to postpone reconciliation, etc.

I started by adding a column to the bank_trans table called 'reconciled'. I copied the page '/gl/inquiry/bank_inquiry.php' and called it '/gl/bank_account_reconcile.php' and began modifying it. That page was the closest page to what I was looking for, so I thought it would be a good start.

I did all the basic changes: added a menu item in the GL/Banking menu, change the $path_to_root, changed the page name...

It didnt take me long to run into a problem.

Using your functions to create the form fields, I add the ability to display unreconciled lines only, or all lines.

Here's the form... All I did was add the yesno_list_cells function call.

start_form();
start_table("class='tablestyle_noborder'");
start_row();
bank_accounts_list_cells(_("Account:"), 'bank_account', null);

date_cells(_("From:"), 'TransAfterDate', '', null, -30);
date_cells(_("To:"), 'TransToDate');

//Added 1/8/09
yesno_list_cells(_("Show Reconciled:"), 'ShowReconciled', 1);

submit_cells('Show',_("Show"),'','', true);
end_row();
end_table();
end_form();

Then prior to the creation of $sql, it retrieves the values of the from and to dates:

$date_after = date2sql($_POST['TransAfterDate']);
$date_to = date2sql($_POST['TransToDate']);

I added the following lines immediately after the above two lines:

//Added 1/8/09 DEBUG
$show_reconciled=$POST['ShowReconciled'];
echo ">>>>>>>>".$show_reconciled."<<<<<<<<<<<";

The HTML looks good, 'ShowReconciled' is part of the form that is submitted, but no matter what I do, $show_reconciled has no value when the form is submitted...

I've done a fair amount of PHP programming, and I've spent way too much time trying to figure this out on my own. Can someone tell me why I can't retrieve the value of this form field when the form is submitted? And, not just why I can't, but an example of how I can?

Once this is done I plan on creating a full blown bank reconciliation function. I have searched online, and it doesn't appear as if anyone else has done it, and I would be happy to give the code to the community once it's working.

Re: Bank Account Reconciliation

Your ambition is very much appreciated. I cannot tell you, what is going wrong here, without seeing all the file, but if I understand you right, you want a column in the bank inquiry with checkboxes, to mark the transactions as reconciled, right?
In version 2.1, I think this could be included in the bank inquiry. We will then have to add a field in the bank_trans table, reconciled.
And when users click this column, the transaction should be updated with a mark.
I guess this would be the best way of doing it, right?

/Joe

Re: Bank Account Reconciliation

Thats exactly right. Except I also plan on maintaining a reconciled date, and ending balance (which would become the beginning balance for the next reconciliation)

I've written a page like this before, from scratch, and in PHP, so the logic and complexity arent my issue. My issue is doing it within the constraints of your coding practices.

How bout this? Here's the code, maybe you can tell me why it doesn't retrieve the ShowReconciled value when I try to get it from the $_POST array:

<?php

$page_security = 8;
$path_to_root="..";
include_once($path_to_root . "/includes/session.inc");

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");

include_once($path_to_root . "/gl/includes/gl_db.inc");
include_once($path_to_root . "/includes/banking.inc");

$js = "";
if ($use_popup_windows)
    $js .= get_js_open_window(800, 500);
if ($use_date_picker)
    $js .= get_js_date_picker();
page(_("Reconcile Bank Account"), false, false, "", $js);

check_db_has_bank_accounts(_("There are no bank accounts defined in the system."));

//-----------------------------------------------------------------------------------
// Ajax updates
//
if (get_post('Show'))
{
    $Ajax->activate('trans_tbl');
}
//------------------------------------------------------------------------------------------------


start_form();
start_table("class='tablestyle_noborder'");
start_row();
bank_accounts_list_cells(_("Account:"), 'bank_account', null);

date_cells(_("From:"), 'TransAfterDate', '', null, -30);
date_cells(_("To:"), 'TransToDate');
//Added 1/8/09
yesno_list_cells(_("Show Reconciled:"), 'ShowReconciled', 1);

submit_cells('Show',_("Show"),'','', true);
end_row();
end_table();
end_form();

//------------------------------------------------------------------------------------------------

//Added 1/8/09 DEBUG
$show_reconciled=get_post('ShowReconciled');
echo ">>>>>>>>".$show_reconciled."<<<<<<<<<<<";

$date_after = date2sql($_POST['TransAfterDate']);
$date_to = date2sql($_POST['TransToDate']);

if (!isset($_POST['bank_account']))
    $_POST['bank_account'] = "";
    $sql = "SELECT ".TB_PREF."bank_trans.*,name AS BankTransType FROM ".TB_PREF."bank_trans, ".TB_PREF."bank_trans_types
    WHERE ".TB_PREF."bank_trans.reconciled=0 and ".TB_PREF."bank_trans.bank_act = '" . $_POST['bank_account'] . "'
    AND trans_date >= '$date_after'
    AND trans_date <= '$date_to'
    AND ".TB_PREF."bank_trans_types.id = ".TB_PREF."bank_trans.bank_trans_type_id
    ORDER BY trans_date,".TB_PREF."bank_trans.id";
$result = db_query($sql,"The transactions for '" . $_POST['bank_account'] . "' could not be retrieved");

div_start('trans_tbl');
$act = get_bank_account($_POST["bank_account"]);
display_heading($act['bank_account_name']." - ".$act['bank_curr_code']);

start_table($table_style);

$th = array(_("Type"), _("#"), _("Reference"), _("Type"), _("Date"),
    _("Debit"), _("Credit"), _("Balance"), _("Person/Item"), "");
table_header($th);

$sql = "SELECT SUM(amount) FROM ".TB_PREF."bank_trans WHERE bank_act='" . $_POST['bank_account'] . "'
    AND trans_date < '$date_after'";
$before_qty = db_query($sql, "The starting balance on hand could not be calculated");

start_row("class='inquirybg'");
label_cell("<b>"._("Opening Balance")." - ".$_POST['TransAfterDate']."</b>", "colspan=5");
$bfw_row = db_fetch_row($before_qty);
$bfw = $bfw_row[0];
display_debit_or_credit_cells($bfw);
label_cell("");

end_row();
$running_total = $bfw;
$j = 1;
$k = 0; //row colour counter
while ($myrow = db_fetch($result))
{

    alt_table_row_color($k);

    $running_total += $myrow["amount"];

    $trandate = sql2date($myrow["trans_date"]);
    label_cell(systypes::name($myrow["type"]));
    label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"]));
    label_cell(get_trans_view_str($myrow["type"],$myrow["trans_no"],$myrow['ref']));
    label_cell($myrow["BankTransType"]);
    label_cell($trandate);
    display_debit_or_credit_cells($myrow["amount"]);
    amount_cell($running_total);
    label_cell(payment_person_types::person_name($myrow["person_type_id"],$myrow["person_id"]));
    label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"]));
    end_row();
    //Removed by Rob Mallon on 1/8/09
    //if ($j == 12)
    //{
    //    $j = 1;
    //    table_header($th);
    //}
    //$j++;
}
//end of while loop

start_row("class='inquirybg'");
label_cell("<b>" . _("Ending Balance")." - ". $_POST['TransToDate']. "</b>", "colspan=5");
display_debit_or_credit_cells($running_total);
label_cell("");
end_row();
end_table(2);
div_end();
//------------------------------------------------------------------------------------------------

end_page();

?>

All I did so far was what I explained in my first post... I added a Yes/No select to the form, and tried to display it's value in a debugging echo statement.

I understand that $show_reconciled will have no value the first time the page is displayed, but I can't understand why $show_reconciled has no value when the 'Show' button is used to submit the form.

(In case you missed it in my first post, I am using /gl/inquiry/bank_inquiry.php as my base page. With the exception of the changes I mentioned, this page should look very familiar to you smile

Thanks for your quick response. I am the business owner as well as a PHP developer. I am EXTREMELY interested in using this program to run my business, but the lack of bank account reconciliation is a deal breaker. I figured adding it myself would be good for me, as well as the entire FrontAccounting community.

Re: Bank Account Reconciliation

Hello hugerobot,

Your problem is that you try to display ShowReconcile with echo(), but you have set submit button to send request in asynchronous (ajax) mode. When you change the 5th argument of submit_cells to false you will see the result you wish. Or use display_error/notification() for debugging in ajax mode.

BTW. Could you explain us why is the reconciliation process so crucial for you, and why  one step process of entering bank deposit/payments is not enough?

Janusz

Re: Bank Account Reconciliation

Thanks. I will try that when I get home.

I am using this software to replace quickbooks. I have gone from one location to 2, and by May I will have 5 locations, so quickbooks was no longer able to suite my needs.

I dont really know how to answer your question... Why wouldnt everyone want to be able to reconcile their bank account? My bank account gl account matches my bank statement line-for-line. I reconcile my account once a week at least.

When I get the application finished I will let you know. I would be glad to share it if you'd like to use it.

Thanks for your quick responses. As a programmer and a business owner, its nice to know there's support out there!

Re: Bank Account Reconciliation

Well, seems the bank reconciliation is US specific procedure. I also have small business here in Poland and I have no need for it. We use www bank interface to send payments and track all deposits received on bank account. I have nothing to reconcile with bank statement because the data about payments/deposits/transfers/charges are entered daily from the same source (ie bank www listings) as the monthly bank statement. They are exactly the same.
I would like to know how it is made in your case, so you need to check the transactions one by one with weekly statement?

Janusz

Re: Bank Account Reconciliation

I have technicians who work for me. They collect customer checks throughout the week, and enter the invoices into the system. All customer payments are put in a 'Bank Deposit Holding' bank account.

At the end of the week the checks are sent to me and I make a deposit, and a transfer entry from 'Bank Deposit Holding' to 'Checking Account'. This way my deposit entry matches my actual bank deposit.

In addition, some goods are purchased for resale locally, some online, some phone orders using a debit card. The same is true for other expenses.

This makes for lots of transactions, many happening before they are entered into the system, and inevitably some are missed. Bank account reconciliation ensures that if there are debits to my bank account that I am unaware of I can go back and make the correct entries in the system so that my books match my bank's records. Is this that uncommon?! I guess justifying this feature seems strange to me. But I've always done business this way, so it's all I know.

It's not going to hurt anything by being there... and from what I've been reading online, the lack of bank account reconciliation is one of the reasons why people don't adopt this software. I'm sure you've read this article, but I'll post it here in case:

http://www.nmqb.co.uk/open-source-billing-applications/

You guys come out on top, but your lack of reconciliation was one of two reasons it wasn't chosen... 

Your software is free to use, but I make money using it, and I love to program. If I can contribute to your success by offering this enhancement, it would be my pleasure. It's the least I can do.

Rob

Re: Bank Account Reconciliation

Hello again hugerobot. I like your persistence smile
When you explain this it makes sense.
Please continue with the job you have started, and please try to not do it complicated. We try to use the KISS (keep it simple st....). I guess you know that expression, right? smile. We will then incorporate it in the program core.
We were planning to ship release 2.1 beta next week, but we are willing to wait for this wonderful thing. Do you  think you can have it finished next week? We will not stress you, just curiousity.

/Joe

Re: Bank Account Reconciliation

I'm done with what I set out to accomplish. It completely suites my needs but for it to be a fully featured utility it should have a little more flexibility.

As the program works now, there is no method for postponing a reconciliation. This can be frustrating if you begin the process, and then need to go back and make entries to correct balance errors. Currently, this would mean that you need to abandon your current reconciliation, make your entries, and then start the reconciliation over.

For me, this is usually not a big deal, since i reconcile every week or so (it's addicting... sometimes I do it every day. Anyone in my situation knows what I mean.)

That being said, it works great for me, it's very simple to use. So how do I get this to you so you?

To install, it requires the following PHP changes:
the menu entry in /applications/generalledger.php
the new page: /gl/bank_account_reconcile.php

and the following MySQL changes:
the column reconciled int(1) at the end of the bank_trans table
the columns last_reconciled_date timestamp,beginning_reconcile_balance double, and ending_reconcile_balance double at the end of the bank_accounts table

A few notes... for the most part, the code is clean, and I tried to adhere to your coding practices, use your ui functions, etc..., but because it uses javascript for tracking running totals as the user clicks the checkboxes, I needed to create my own checkbox element (not the check_cells function). Also the javascript is a little sloppy in places.. I was having trouble with string to number conversion, rounding, etc... and the final result was the best I could get it. It's right, but occasionally it displays more than 2 decimal places and I cant seem to make that stop (ie 250.35000 instead of 250.35). Honestly, once the numbers were calculating right, I just left it alone. With as touchy as javascript is, I didnt even want to mess with cleaning it up.

Feel free to clean it up, or enhance it as you see fit. I am excited to share this with you.
Rob

Re: Bank Account Reconciliation

Joe, I emailed the page, and the change to the generalledger.php menu to you.

Re: Bank Account Reconciliation

Thank you very much Rob, I will start immediately fixing it into the core source at 2.1 unstable.

/Joe

Re: Bank Account Reconciliation

I might have been a little too excited when I submitted it...

I have noticed a few things that need to be added to make it usable to everyone (not just me).

Beginning balance needs to editable. It shouldn't need to be changed, but the first time you reconcile an account you may need to enter it. It will be populated automatically, but editable as well.

I need to include a reset button on the form. I'm not going to do a check all/check none, but the ability to start from scratch without refreshing the page is worthwhile.

I will probably do these changes over the weekend and re-email the page to you. it will only require changes to the new page.

Thanks. This is the first time I've contributed to an open source project, and I'm hooked. I don't think you've heard the last of me!

Rob

Re: Bank Account Reconciliation

Yes, I detected that. The beginning and ending balance was not updated into the table bank_accounts.
The file you copied from was from release 2.0.6, therefore I had to change the file a bit. I also eliminated some warnings. But it doesn't matter. This is only minor things, so please resend the file as you have it and I will extract the changes into the 2.1 file.
I think this is nice work, Rob.

/Joe

Re: Bank Account Reconciliation

The CVS repository for unstable 2.1 is now updated with Bank Reconciliation. I will ask Janusz to upload this to Demo 2.1 unstable.
Here is how it works according to hugerobot:

1. Select the account you want to reconcile.
2. Get your bank statement (from the bank)
3. The first time you reconcile you will need to enter a reconcile date and a start balance... 
   Or 0 for the start balance if it is actually a new account.
4. Enter the end balance from the statement
5. Check entries that match the entries from your bank statement
6. If all entries match, 'Difference' should be 0. If it is, you are done and you 
   have reconciled your account for the period.
7. Click reconcile to record the reconciliation.
8. All checked items are recorded as reconciled in the bank_trans table and the ending balance
   and reconciled date is recorded for that account in the bank_accounts table.
9. The next time you reconcile against a bank statement, the ending balance from the last 
   reconciliation is automatically used as the starting balance for this reconciliation..    
   You enter the ending balance for this reconciliation and repeat steps 5-8

/Joe

15 (edited by rodw 03/06/2010 09:44:36 pm)

Re: Bank Account Reconciliation

This was great work and I spent most of my day in this module yesterday entering 4 months data for my country. The bank rec worked flawlessly.

Another reason we need a bank reconcliation is that if we take our trial balance to an external accountant to prepare our books and tax returns at year end is that he will want to see a bank reconciliation report to demonstrate that all of our data is included.

So what about a Bank Reconciliation Summary Report to take to him?
I hope I get this right - Something like:

1. Bank statement closing balance: $xxx

Add: Unpresented Payments:
Payment 1 $xxx
Payment 2 $xxx
...
Payment n $xxx
2. Total Unpresented Payments   $xxx

Less: Unpresented Deposits:
Deposit 1 $xxx
Deposit 2 $xxx
...
Deposit n $xxx
3. Total Unpresented Deposits $xxx

4. Calculated Reconciled Balance (1+2-3) $yyy
5. Cashbook Computer Balance $yyy

6. Difference (4-5) $0.00

I wish I knew how to program in php or I would have a go at this. I guess you would need to select the bank account and reconciliation date (from the drop down in the existing bank rec) befre printing the report.

It is nice to be able to attach this report to each bank statement and your accountant will get really excited and start recommending FA to his clients!

[b]RodW[/b]
Brisbane, QLD, Australia

Re: Bank Account Reconciliation

Hello All

Has there been any progress on including the Bank Reconciliation Summary Report as outlined by rodw from Brisbane into FA. I am from Australia too and this feature is basic in many other accounting systems.

Warwick.