Modifying Purchase Invoice: removed obsolete grn removal button.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 3 Jul 2019 11:42:12 +0000 (13:42 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 19 Aug 2019 10:41:57 +0000 (12:41 +0200)
includes/access_levels.inc
purchasing/includes/db/invoice_db.inc
purchasing/includes/ui/invoice_ui.inc
purchasing/supplier_invoice.php

index 62a71cb61d4f334cefe22364f91cc618b936331a..a9fc84d8944845aa6b8a0fd9577af578e44b922a 100644 (file)
@@ -168,7 +168,6 @@ $security_areas =array(
        'SA_PURCHASEORDER' => array(SS_PURCH|3, _("Purchase order entry")),
        'SA_GRN' => array(SS_PURCH|4, _("Purchase receive")),
        'SA_SUPPLIERINVOICE' => array(SS_PURCH|5, _("Supplier invoices")),
-       'SA_GRNDELETE' => array(SS_PURCH|9, _("Deleting GRN items during invoice entry")),
        'SA_SUPPLIERCREDIT' => array(SS_PURCH|6, _("Supplier credit notes")),
        'SA_SUPPLIERPAYMNT' => array(SS_PURCH|7, _("Supplier payments")),
        'SA_SUPPLIERALLOC' => array(SS_PURCH|8, _("Supplier payments allocations")),
index 0a7f360b647af2638404c59b4d0347aded6f0de5..427b73dc0a564127fe32560a580bc4d219e41dd6 100644 (file)
@@ -658,52 +658,6 @@ function is_reference_already_there($supplier_id, $supp_reference, $trans_no=0)
        return $myrow[0] > 0;
 }
 
-function remove_not_invoice_item($id)
-{
-       begin_transaction();
-
-    $myrow = get_grn_item_detail($id);
-
-    $grn = get_grn_batch($myrow['grn_batch_id']);
-
-    $supp = get_supplier($grn["supplier_id"]);
-
-       $sql = "UPDATE ".TB_PREF."purch_order_details
-               SET quantity_received = qty_invoiced, quantity_ordered = qty_invoiced WHERE po_detail_item = ".$myrow["po_detail_item"];
-       db_query($sql, "The quantity invoiced of the purchase order line could not be updated");
-
-    $sql = "UPDATE ".TB_PREF."grn_items
-        SET qty_recd = quantity_inv WHERE id = ".$myrow["id"];
-    db_query($sql, "The quantity invoiced off the items received record could not be updated");
-
-    update_average_material_cost($grn["supplier_id"], $myrow["item_code"],
-        $myrow["unit_price"], -$myrow["QtyOstdg"], Today());
-
-    $price = $myrow['unit_price'];
-    if ($supp['tax_included'])
-        $price = get_tax_free_price_for_item($myrow['item_code'], $myrow['unit_price'], $supp['tax_group_id'], $supp['tax_included']);        
-
-    add_stock_move(ST_SUPPRECEIVE, $myrow["item_code"], $myrow['grn_batch_id'], $grn['loc_code'], sql2date($grn["delivery_date"]), "",
-        -$myrow["QtyOstdg"], $myrow['std_cost_unit'], $price);
-
-    $clearing_act = get_company_pref('grn_clearing_act');
-    if ($clearing_act) {    // otherwise GRN clearing account is not used
-        if (is_inventory_item($myrow['item_code']))
-        {
-            $total = 0;
-            $stock_gl_code = get_stock_gl_code($myrow['item_code']);
-            $date = sql2date($grn["delivery_date"]);
-            $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $myrow['grn_batch_id'], $date, $stock_gl_code["inventory_account"],
-                $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
-                -$myrow['QtyOstdg'] * $price, $grn["supplier_id"], "", 0, _("GRN Removal"));
-            $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $myrow['grn_batch_id'], $date, $clearing_act,
-                0, 0, -$total, null, "", 0, _("GRN Removal"));
-        }
-    }
-
-    commit_transaction();
-}
-
 function find_src_invoices($cart)
 {
        $invoices = $po_ids = array();
index 04a008793e1ecdadb60715260777de43c6ce72bd..39a4d5ba835bb96e37d048b8c479156451415aa3 100644 (file)
@@ -420,11 +420,6 @@ function display_grn_items_for_selection(&$supp_trans, $k)
                        submit_cells('grn_item_id'.$n, _("Add"), '', _("Add to Invoice"), true);
                else    
                        submit_cells('grn_item_id'.$n, _("Add"), '', _("Add to Credit Note"), true);
-               if (($supp_trans->trans_type == ST_SUPPINVOICE) && $_SESSION["wa_current_user"]->can_access('SA_GRNDELETE')) {  // Added 2008-10-18 by Joe Hunt. Special access rights needed.
-                       submit_cells('void_item_id'.$n, _("Remove"), '', _("WARNING! Be careful with removal. The operation is executed immediately and cannot be undone !!!"), true);
-                               submit_js_confirm('void_item_id'.$n,
-                                       sprintf(_('You are about to remove all yet non-invoiced items from delivery line #%d. This operation also irreversibly changes related order line. Do you want to continue ?'), $n));
-                       }
                        end_row();
        }
     }
@@ -453,11 +448,7 @@ function display_grn_items(&$supp_trans, $mode=0)
        if ($mode == 1)
        {
                if ($supp_trans->trans_type == ST_SUPPINVOICE)
-               {
                        $heading = _("Items Received Yet to be Invoiced");
-               if ($_SESSION["wa_current_user"]->can_access('SA_GRNDELETE'))   // Added 2008-10-18 by Joe Hunt. Only admins can remove GRNs
-                               $heading2 = _("WARNING! Be careful with removal. The operation is executed immediately and cannot be undone !!!");
-               }
                else
                        $heading = _("Delivery Item Selected For Adding To A Supplier Credit Note");
        }
@@ -501,8 +492,6 @@ function display_grn_items(&$supp_trans, $mode=0)
                _("Received On"), _("Quantity Received"), _("Quantity Invoiced"),
                _("Qty Yet To Invoice"), $supp_trans->tax_included ? _("Price after Tax") : _("Price before Tax"), 
                _("Total"), "");
-       if (($supp_trans->trans_type == ST_SUPPINVOICE) && $_SESSION["wa_current_user"]->can_access('SA_GRNDELETE'))    // Added 2008-10-18 by Joe Hunt. Only admins can remove GRNs
-               $th[] = "";
                if ($supp_trans->trans_type == ST_SUPPCREDIT)
                {
                        $th[7] = _("Qty Yet To Credit");
@@ -548,8 +537,6 @@ function display_grn_items(&$supp_trans, $mode=0)
                        if ($mode == 1)
                        {
                                delete_button_cell("Delete" . $entered_grn->id, _("Edit"), _('Edit document line'));
-                               if (($supp_trans->trans_type == ST_SUPPINVOICE) && $_SESSION["wa_current_user"]->can_access('SA_GRNDELETE'))      
-                                       label_cell("");
                        }       
                        end_row();
 
index 0dc1a77ad90444f74649e2ceefbec5e118c8dd13..e75ec45c76ffee42926d70a64a84feea4f6e36e0 100644 (file)
@@ -356,18 +356,6 @@ if ($id5 != -1)
        $Ajax->activate('gl_items');
 }
 
-$id2 = -1;
-if ($_SESSION["wa_current_user"]->can_access('SA_GRNDELETE'))
-{
-       $id2 = find_submit('void_item_id');
-       if ($id2 != -1) 
-       {
-               remove_not_invoice_item($id2);
-               display_notification(sprintf(_('All yet non-invoiced items on delivery line # %d has been removed.'), $id2));
-
-       }
-}
-
 if (isset($_POST['go']))
 {
        $Ajax->activate('gl_items');
@@ -395,7 +383,7 @@ else {
 
 //-----------------------------------------------------------------------------------------
 
-if ($id != -1 || $id2 != -1)
+if ($id != -1)
 {
        $Ajax->activate('grn_items');
        $Ajax->activate('inv_tot');