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?

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

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;
    }

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

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;
    }

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

@itronics: make something generic wherever there is a reference that clashes with existing ones.

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

@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

www.boxygen.pk

56 (edited by boxygen 04/06/2018 06:46:21 am)

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

I found one problem with this.

In Supplier Invoice and Supplier Credit Notes the name of reference input field is not ref but reference

www.boxygen.pk

57 (edited by boxygen 04/06/2018 05:43:32 pm)

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

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
www.boxygen.pk

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

@joe: is this necessary?

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

@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.

www.boxygen.pk

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

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.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

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.

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

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

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

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.

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

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

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

@joe - this would be great piece of code to fix  it for existing programs, i mean older version of FA.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

@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?

www.boxygen.pk

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

The solution with automatic increment of references  only works with documents.

Joe

Re: Not working: Automatic Increase of reference number fields in FA 2.4.2

Wiki-ed it.