Topic: Stock goes negative even, the negative inventory is turned off

Yes,  I found an issue with Voiding Transaction. Let me explain the case.   I am just placing an direct GRN to receive 10 quantity of an item.  And I didn't make supplier invoice yet.

Than i made a sales of 5 quantity for the same item and now the stock balance is 5 quantity.  Now I am voiding the Direct GRN.

Actually the system has to stop me from voiding this Direct GRN. But it allows me to void the GRN. and stock goes to negative.

Also I found solution for this problem.

if (!exist_transaction($_POST['filterType'],$_POST['trans_no']))
        {
            display_error(_("The entered transaction does not exist or cannot be voided."));
            unset($_POST['trans_no']);
            unset($_POST['memo_']);
            unset($_POST['date_']);
            submit_center('ProcessVoiding', _("Void Transaction"), true, '', 'default');
        }
        else
        {
            display_warning(_("Are you sure you want to void this transaction ? This action cannot be undone."), 0, 1);
            br();
            submit_center_first('ConfirmVoiding', _("Proceed"), '', true);
            submit_center_last('CancelVoiding', _("Cancel"), '', 'cancel');
        }

This is default code. If we change it to be like this.

 if (!exist_transaction($_POST['filterType'],$_POST['trans_no']))
        {
            display_error(_("The entered transaction does not exist or cannot be voided."));
            unset($_POST['trans_no']);
            unset($_POST['memo_']);
            unset($_POST['date_']);
            submit_center('ProcessVoiding', _("Void Transaction"), true, '', 'default');
        }   else     {
            if($_POST['filterType'] == ST_SUPPRECEIVE){ 
                $result = get_grn_items($_POST['trans_no']);
                 if (db_num_rows($result) > 0)   {
                    while ($myrow = db_fetch($result))        {
                        if (is_inventory_item($myrow["item_code"]))    {
                            if (check_negative_stock($myrow["item_code"], -$myrow["qty_recd"], null, $_POST['date_']))    {
                                $stock = get_item($myrow["item_code"]);
                                display_error(_("The void cannot be processed because there is an insufficient quantity for item:") .
                                    " " . $stock['stock_id'] . " - " . $stock['description'] . " - " .
                                    _("Quantity On Hand") . " = " . number_format2(get_qoh_on_date($stock['stock_id'], null, 
                                    $_POST['date_']), get_qty_dec($stock['stock_id'])));
                                return false;
                            }
                        }
                    }
                }
            }
            display_warning(_("Are you sure you want to void this transaction ? This action cannot be undone."), 0, 1);
            br();
            submit_center_first('ConfirmVoiding', _("Proceed"), '', true);
            submit_center_last('CancelVoiding', _("Cancel"), '', 'cancel');
        }
Subscription service based on FA
HRM CRM POS batch Themes

Re: Stock goes negative even, the negative inventory is turned off

Also i forget to write it. Even if we void the supplier invoice and we can able to void the GRN.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Stock goes negative even, the negative inventory is turned off

@joe can you check this issue and fix it.

Subscription service based on FA
HRM CRM POS batch Themes

Re: Stock goes negative even, the negative inventory is turned off

@kvvaradha

Yes, I will have a look at this and be back tomorrow.

/Joe

Re: Stock goes negative even, the negative inventory is turned off

Ok, this was fixed tonight and committed to stable.

You can download a fixed file here

/Joe

Re: Stock goes negative even, the negative inventory is turned off

That's perfect.

Subscription service based on FA
HRM CRM POS batch Themes