Re: Not working: Automatic Increase of reference number fields in FA 2.4.2
@itronics: Should this not be adjusted as you had done earlier and committed?
It's much more fun, when you can discuss your problems with others...
You are not logged in. Please login or register.
FrontAccounting forum → Setup → Not working: Automatic Increase of reference number fields in FA 2.4.2
@itronics: Should this not be adjusted as you had done earlier and committed?
Solution for Bank Payments also as follows:
We update $_POST['ref'] just before check_reference() function runs. We do that by adding one line of code to gl/gl_bank.php
//// Update $_POST['ref'] before check_reference()
$_POST['ref'] = $Refs->get_next($_SESSION['pay_items']->trans_type, null, $_POST['date_']);
if (!check_reference($_POST['ref'], $_SESSION['pay_items']->trans_type, $_SESSION['pay_items']->order_id))
{
set_focus('ref');
$input_error = 1;
}
For Bank Account Transfers, the solution is similar to the others: we update the ref before the check_reference() runs. The file to edit is gl/bank_transfer.php
/////////////// update ref
$_POST['ref'] = $Refs->get_next(ST_BANKTRANSFER, null, $_POST['DatePaid']);
if (!check_reference($_POST['ref'], ST_BANKTRANSFER, $trans_no)) {
set_focus('ref');
return false;
}
@itronics: make something generic wherever there is a reference that clashes with existing ones.
@davidkumi, @itronics, @joe, @apmuthu
I have a suggestion and I have tested it with many transactions (not all) and it is working
Modify the function check_reference() with following single line change
function check_reference($reference, $trans_type, $trans_no=0, $context=null, $line=null)
{
global $Refs;
if (!$Refs->is_valid($reference, $trans_type, $context, $line))
{
display_error(_("The entered reference is invalid.")); return false;
}
elseif (!$Refs->is_new_reference($reference, $trans_type, $trans_no))
{
$_POST['ref'] = $Refs->get_next($trans_type, null, $context); //modified by faisal
// display_error( _("The entered reference is already in use.")); return false;
}
return true;
}
Before applying to my main server I request you all to please authenticate it. I don't know if it conflicts with some other behaviour of FA
I found one problem with this.
In Supplier Invoice and Supplier Credit Notes the name of reference input field is not ref but reference
Also we need to add following lines in copy_to_cart () function in sales_order_entry.php page
function copy_to_cart()
{
check_reference($_POST['ref'], $_SESSION['Items']->trans_type, $_SESSION['Items']->trans_no); //added by faisal
@joe: is this necessary?
@joe and @apmuthu,
It is necessary in two scenarios
1. You have more than one data entry operators who are recording bank transactions at the same time. Both have same Next Reference say BP115 on their forms. The person who will commit transaction lately will see the error Transaction Reference Already in Use
2. Even if we have only one Data Entry operator but it happens many times that the next reference stucks and don't increase itself. Then one needs to manually go to Transaction References Page and increase it.
This is my point of view.
I think you can fix it by overriding the cart_class like this.
function write($policy=0) {
begin_transaction(); // prevents partial database changes in case of direct delivery/invoice
if ($this->reference != 'auto' && $this->trans_no == 0 && !is_new_reference($this->reference, $this->trans_type))
{
$this->reference = $Refs->get_next($this->trans_type, null, array('date' => Today()));
}
if ($this->reference != 'auto' && $this->trans_no == 0 && !is_new_reference($this->reference, $this->trans_type))
{
commit_transaction();
return -1;
}
I have not tested. But you can give it a try to get next reference while processing it.
The effect of the return -1; above should be tested under various PHP dispensations - is it an error or is it a graceful change to a new_reference, the calling entity should know and act accordingly.
I am aware of these behaviours and the shown solutions are subject to be fixed.
This weekend I am having a meeting with Janusz and we are among others talking about the subjects.
So just stay put. We are trying to solve it the best ways.
Thanks for the various solutions
Joe
It would be nice to refresh the Extensions repo with the latest changes as in the FA24extensions repo. Tamil / Hindi translations are yet to be refreshed.
On a meeting this Weekend between me and @itronics (Janusz) we have decided to implement the automatic increase of document references shown by @kvvaradha. Slightly modified.
For backwards compatibility it is implemented as a Company Setup switch. 'Auto Increase of Document References'. You will have to mark this item for enabling this.
This change has been committed. You can download the files at the repo here
/Joe
@joe - this would be great piece of code to fix it for existing programs, i mean older version of FA.
@Joe, this fix works fine if the Value in Transaction References is a Not Used Value
But I am facing complaints from some of the clients and I couldn't figure out the reason that after some transactions specially in Bank Payment Entry the Value in Transaction References doesn't increment.
How to Fix this?
The solution with automatic increment of references only works with documents.
Joe
Wiki-ed it.
FrontAccounting forum → Setup → Not working: Automatic Increase of reference number fields in FA 2.4.2
Powered by PunBB, supported by Informer Technologies, Inc.
Currently installed 4 official extensions. Copyright © 2003–2009 PunBB.