Topic: Voiding purchase order deliveries in 2.4.1

In 2.3, one can void a PO delivery by voiding the invoice and then voiding the PO delivery.  The voiding of the invoice clears quantity in supp_inv_items.  This allows the void of the PO delivery to proceed because it calls:

function exists_grn_on_invoices($grn_batch)
{
        $sql = "SELECT ".TB_PREF."supp_invoice_items.id FROM ".TB_PREF."supp_invoice_items,".TB_PREF."grn_items
                WHERE ".TB_PREF."supp_invoice_items.grn_item_id=".TB_PREF."grn_items.id
                AND quantity != 0
                AND grn_batch_id=".db_escape($grn_batch);
        $result = db_query($sql, "Cannot query GRNs");

    return (db_num_rows($result) > 0);
}

and disallows the void only if "quantity != 0".

This code changed in 2.4.1.   It now calls exists_grn() which simply checks for a grn_batch entry, and if it exists it disallows the void.   Yet the grn_batch entry still exists after an invoice has been voided and thus returns the error:

         The entered transaction does not exist or cannot be voided.

To test this, create a direct supplier invoice in both 2.3 and 2.4.1, void the invoice and then void the PO Delivery.

Re: Voiding purchase order deliveries in 2.4.1

@joe: any fix?

Re: Voiding purchase order deliveries in 2.4.1

Will send this to Janusz.

Joe

Re: Voiding purchase order deliveries in 2.4.1

The faulty behaviour existing in 2.3 was fixed in 2.4.1. If you want remove invalid PO you have to explicitly void related GRNs first.
There cannot be hanging GRNs without PO in database.
Janusz

5 (edited by Braath Waate 07/19/2017 04:19:12 pm)

Re: Voiding purchase order deliveries in 2.4.1

That makes sense, however I don't know how to do it.

If I try to void the PO Delivery (GRN) before removing the invoice, the message

       The entered transaction does not exist or cannot be voided

still occurs.

Note that the code that actually voids the transaction (void_transaction) still calls exists_grn_on_invoices():

                case ST_SUPPRECEIVE : // it's a GRN
                        if (exists_grn_on_invoices($type_no))
                                return _('This GRN cannot be voided because it was already invoiced.');

But this seems to be prevented from running now by the earlier call to exists_grn() in admin/void_transaction.php.