Supplier Invoices, Supplier Credit Notes: fixed editon form bugs, fixed reference...
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 8 Nov 2015 19:08:08 +0000 (20:08 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 8 Nov 2015 19:08:08 +0000 (20:08 +0100)
purchasing/includes/db/invoice_db.inc
purchasing/includes/purchasing_db.inc
purchasing/includes/ui/invoice_ui.inc
purchasing/supplier_credit.php

index 3bd100302c7860aacad78f9f08bd9be0a400a049..372aca3c2fbfeee730863bce684eebad6c9fa8cb 100644 (file)
@@ -367,8 +367,9 @@ function add_supp_invoice(&$supp_trans)
 
        $Refs->save($trans_type, $invoice_id, $supp_trans->reference);
 
-       if ($supp_trans->src_docs)
+       if (count($supp_trans->src_docs) == 1)
        {
+               $invoice_no = key($supp_trans->src_docs);
                $invoice_alloc_balance = get_supp_trans_allocation_balance(ST_SUPPINVOICE, $supp_trans->src_docs);
                if ($invoice_alloc_balance > 0) 
                {       //the invoice is not already fully allocated 
index 86a8418152495d99fe828b55c56c36559fbd853a..94f2f72f408d1f541c144c38c1f1d3d6a67eb356 100644 (file)
@@ -121,7 +121,8 @@ function get_po_prepayments($supp_trans)
        $allocations = array();
        $line_ids = array();
        foreach($supp_trans->grn_items as $item)
-               $line_ids[] = $item->po_detail_item;
+               if ($item->po_detail_item)
+                       $line_ids[] = $item->po_detail_item;
 
        if (!count($line_ids))
                return $allocations;
index 7470300dd71b0118dfe51e07e8c24f02f3bed22b..1b53f6c3bd5ddbe4f5b85d25fe56414221a2f4b7 100644 (file)
@@ -359,16 +359,15 @@ function display_grn_items_for_selection(&$supp_trans, $k)
                        $result = get_grn_items(0, $supp_trans->supplier_id, false, true, 0, $_POST['receive_begin'], $_POST['receive_end']);
                elseif ($supp_trans->src_docs)
                        $result = get_grn_items(0, $supp_trans->supplier_id, false, true, array_keys($supp_trans->src_docs));
-               else    
+               else
                        $result = get_grn_items(0, $supp_trans->supplier_id, false, true);
        }
     if (db_num_rows($result) == 0)
     {
        return false;
     }
-    
-    /*Set up a table to show the outstanding GRN items for selection */
 
+    /*Set up a table to show the outstanding GRN items for selection */
     while ($myrow = db_fetch($result))
     {
                $grn_already_on_invoice = false;
@@ -383,18 +382,17 @@ function display_grn_items_for_selection(&$supp_trans, $k)
 
        if ($grn_already_on_invoice == false)
        {
-
                        alt_table_row_color($k);
 
                        $n = $myrow["id"];
-               label_cell(get_trans_view_str(ST_SUPPRECEIVE, $myrow["grn_batch_id"]));
-               hidden('qty_recd'.$n, $myrow["qty_recd"], false);
-               hidden('item_code'.$n, $myrow["item_code"], false);
-               hidden('item_description'.$n, $myrow["description"], false);
-               hidden('prev_quantity_inv'.$n, $myrow['quantity_inv'], false);
-               hidden('order_price'.$n, $myrow['unit_price'], false);
-               hidden('std_cost_unit'.$n, $myrow['std_cost_unit'], false);
-               hidden('po_detail_item'.$n, $myrow['po_detail_item'], false);
+                       label_cell(get_trans_view_str(ST_SUPPRECEIVE, $myrow["grn_batch_id"]));
+                       hidden('qty_recd'.$n, $myrow["qty_recd"]);
+               hidden('item_code'.$n, $myrow["item_code"]);
+               hidden('item_description'.$n, $myrow["description"]);
+               hidden('prev_quantity_inv'.$n, $myrow['quantity_inv']);
+               hidden('order_price'.$n, $myrow['unit_price']);
+               hidden('std_cost_unit'.$n, $myrow['std_cost_unit']);
+               hidden('po_detail_item'.$n, $myrow['po_detail_item']);
                label_cell(get_trans_view_str(ST_PURCHORDER, $myrow["purch_order_no"]));
             label_cell($myrow["item_code"]);
             label_cell($myrow["description"]);
index 35012f297532c3c22e0b16444a167928f86f53ec..08040582a3b7dec469eec0a7c5ab6f6a5554bd45 100644 (file)
@@ -47,7 +47,7 @@ if (isset($_GET['New']))
        if (isset($_GET['invoice_no']))
        {
                $_SESSION['supp_trans'] = new supp_trans(ST_SUPPINVOICE, $_GET['invoice_no']);
-               $_SESSION['supp_trans']->src_doc = $_GET['invoice_no'];
+               $_SESSION['supp_trans']->src_docs = array( $_GET['invoice_no'] => $_SESSION['supp_trans']->supp_reference);
 
 
                $_SESSION['supp_trans']->trans_type = ST_SUPPCREDIT;