Bug [0000047] Not possible to view delivery sequence
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 4 Sep 2008 13:35:44 +0000 (13:35 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 4 Sep 2008 13:35:44 +0000 (13:35 +0000)
Bug [0000048] Crediting invoice and choosing gl account for items to be written off doesn't work

CHANGELOG.txt
config.php
purchasing/includes/db/grn_db.inc
purchasing/includes/ui/invoice_ui.inc
purchasing/supplier_credit_grns.php
purchasing/supplier_invoice_grns.php
purchasing/view/view_po.php
purchasing/view/view_supp_credit.php
sales/includes/db/sales_credit_db.inc

index d0ddd6c2812fd8041a10e5f840e0d032ff27587b..a899566cac94f8ac0702edb572fe337adfd3da15 100644 (file)
@@ -19,6 +19,17 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+04-Sep-2008 Joe Hunt
+# Bug [0000047] Not possible to view delivery sequence
+$ /purchasing/supplier_credit_grns.php
+  /purchasing/supplier_invoice_grns.php
+  /purchasing/includes/db/grn_db.inc
+  /purchasing/includes/ui/invoice_ui.inc
+  /purchasing/view/view_po.php
+  /purchasing/view/view_supp_credit.php
+# Bug [0000048] Crediting invoice and choosing gl account for items to be written off doesn't work  
+$ /sales/includes/db/sales_credit_db.inc  
+
 03-Sep-2008 Janusz Dobrowolski
 # Fixed fatal error handling in php5
 $ /includes/errors.inc
index 68fa5aafb849366ed39ab4ad9b9ba55d3b3a0b1f..731e26f3aaf586121c1e1ea526a73124329ed6bc 100644 (file)
@@ -38,7 +38,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_
        // Main Title
        $app_title = "FrontAccounting";
        // application version
-       $version                = "2.0 RC2";
+       $version                = "2.0";
 
        // Build for development purposes
        $build_version  = date("d.m.Y", filemtime("$path_to_root/CHANGELOG.txt"));
index 0335e64f3b98c400116ee5efb5d903494e61ba04..3b5443f6db0882c0a01ae5f054c7be7273031dc9 100644 (file)
@@ -128,9 +128,19 @@ function add_grn_detail_item($grn_batch_id, $po_detail_item, $item_code, $descri
 }
 
 //----------------------------------------------------------------------------------------
+function get_grn_batch_from_item($item)
+{
+       $sql = "SELECT grn_batch_id FROM ".TB_PREF."grn_items WHERE id=$item";
+       $result = db_query($sql, "Could not retreive GRN batch id");
+       $row = db_fetch_row($result);
+       return $row[0];
+}
 
 function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date)
 {
+       $mcost = update_average_material_cost($supplier, $entered_grn->item_code,
+               $entered_grn->chg_price, $entered_grn->this_quantity_inv, $date);
+
        $sql = "SELECT ".TB_PREF."grn_batch.*, ".TB_PREF."grn_items.*
        FROM ".TB_PREF."grn_batch, ".TB_PREF."grn_items
        WHERE ".TB_PREF."grn_items.grn_batch_id=".TB_PREF."grn_batch.id
@@ -138,12 +148,19 @@ function set_grn_item_credited(&$entered_grn, $supplier, $transno, $date)
        AND ".TB_PREF."grn_items.item_code='$entered_grn->item_code' ";
        $result = db_query($sql, "Could not retreive GRNS");
        $myrow = db_fetch($result);
+
+       $sql = "UPDATE ".TB_PREF."purch_order_details
+        SET quantity_received = quantity_received + $entered_grn->this_quantity_inv,
+        std_cost_unit=$mcost,
+        act_price=$entered_grn->chg_price
+        WHERE po_detail_item = ".$myrow["po_detail_item"];
+       db_query($sql, "a purchase order details record could not be updated. This receipt of goods has not been processed ");
+
        //$sql = "UPDATE ".TB_PREF."grn_items SET qty_recd=0, quantity_inv=0 WHERE id=$entered_grn->id";
        $sql = "UPDATE ".TB_PREF."grn_items SET qty_recd=qty_recd+$entered_grn->this_quantity_inv,
                quantity_inv=quantity_inv+$entered_grn->this_quantity_inv WHERE id=$entered_grn->id";
        db_query($sql);
-       $mcost = update_average_material_cost($supplier, $entered_grn->item_code,
-               $entered_grn->chg_price, $entered_grn->this_quantity_inv, $date);
+
     add_stock_move(21, $entered_grn->item_code, $transno, $myrow['loc_code'], $date, "",
                $entered_grn->this_quantity_inv, $mcost, $supplier, 1, $entered_grn->chg_price);
 }
index 196db747f322249719b6716d1cfd413a82d9e63e..85ef98d053a6db3c9dec4c2cfd72551621bdb8dd 100644 (file)
@@ -297,7 +297,7 @@ function display_grn_items(&$supp_trans, $mode=0)
 
   div_start('grn_items');
        echo "<table width=100% $table_style>";
-       $th = array(_("Delivery Sequence #"), _("Item"), _("Description"),
+       $th = array(_("Delivery"), _("Item"), _("Description"),
                _("Quantity"), _("Price"), _("Line Value"));
 
        table_header($th);
@@ -312,7 +312,8 @@ function display_grn_items(&$supp_trans, $mode=0)
 
                alt_table_row_color($k);
 
-               label_cell(get_trans_view_str(25,$entered_grn->id));
+                       $grn_batch = get_grn_batch_from_item($entered_grn->id);
+               label_cell(get_trans_view_str(25,$grn_batch));
                        label_cell($entered_grn->item_code);
                        label_cell($entered_grn->item_description);
                        qty_cell(abs($entered_grn->this_quantity_inv), false, get_qty_dec($entered_grn->item_code));
index b9bfbe3369a3e2273f2e492b728d807c4617bfde..6c3abd1f3f10a4ff43f364577529c7408eaa8291 100644 (file)
@@ -11,6 +11,8 @@ include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
 $js = "";
 if ($use_date_picker)
        $js .= get_js_date_picker();
+if ($use_popup_windows)
+       $js .= get_js_open_window(900, 500);
 page(_("Select Received Items to Add"), false, false, "", $js);
 
 if (!isset($_SESSION['supp_trans']))
@@ -161,7 +163,7 @@ if ($id || get_post('AddGRNToTrans'))
 {
        $Ajax->activate('grn_selector');
 }
-if (get_post('AddGRNToTrans')) 
+if (get_post('AddGRNToTrans'))
 {
        $Ajax->activate('grn_table');
        $Ajax->activate('grn_items');
index 541a4c4da42b439417055114918a2d7c5af9993e..c334a699c31bbf6b517dd90072acf5e8945e6469 100644 (file)
@@ -11,6 +11,8 @@ include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
 $js = "";
 if ($use_date_picker)
        $js .= get_js_date_picker();
+if ($use_popup_windows)
+       $js .= get_js_open_window(900, 500);
 page(_("Select Received Items to Add"), false, false, "", $js);
 
 if (!isset($_SESSION['supp_trans']))
@@ -194,7 +196,7 @@ if (find_submit('grn_item_id') || get_post('AddGRNToTrans'))
 {
        $Ajax->activate('grn_selector');
 }
-if (get_post('AddGRNToTrans')) 
+if (get_post('AddGRNToTrans'))
 {
        $Ajax->activate('grn_table');
        $Ajax->activate('grn_items');
index fe1648222a364cecd5cb8fa08093dd76f30a199b..144192df7f1021a43d5a9f40d0308352648c300b 100644 (file)
@@ -6,10 +6,14 @@ $path_to_root="../..";
 include($path_to_root . "/purchasing/includes/po_class.inc");
 
 include($path_to_root . "/includes/session.inc");
-page(_("View Purchase Order"), true);
-
 include($path_to_root . "/purchasing/includes/purchasing_ui.inc");
 
+$js = "";
+if ($use_popup_windows)
+       $js .= get_js_open_window(900, 500);
+page(_("View Purchase Order"), true, false, "", $js);
+
+
 if (!isset($_GET['trans_no']))
 {
        die ("<br>" . _("This page must be called with a purchase order number to review."));
index d5fc40e108ec5ed4d09dd3d96afc2c2ceaa7388b..64ed9b8cd812e5ec37e57c39ff25c823dea1e9ee 100644 (file)
@@ -6,14 +6,17 @@ $path_to_root="../..";
 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
 include_once($path_to_root . "/includes/session.inc");
 
-page(_("View Supplier Credit Note"), true);
-
 include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc");
 
+$js = "";
+if ($use_popup_windows)
+       $js .= get_js_open_window(900, 500);
+page(_("View Supplier Credit Note"), true, false, "", $js);
+
 if (isset($_GET["trans_no"]))
 {
        $trans_no = $_GET["trans_no"];
-} 
+}
 elseif (isset($_POST["trans_no"]))
 {
        $trans_no = $_POST["trans_no"];
@@ -58,7 +61,7 @@ end_table(1);
 
 $voided = is_voided_display(21, $trans_no, _("This credit note has been voided."));
 
-if (!$voided) 
+if (!$voided)
 {
        $tax_total = 0; // ??????
        display_allocations_from(payment_person_types::supplier(), $supp_trans->supplier_id, 21, $trans_no, -($supp_trans->ov_amount + $tax_total));
index 2faf9e7eb8c3a2957d14f7e8fdee605c17fca9a5..e5041a20a04f1b6460366cc4d594eaf8bd6505b8 100644 (file)
@@ -17,7 +17,7 @@ function write_credit_note($credit_note, $write_off_acc)
                $trans_no = key($trans_no);
        }
 
-       $credit_type = $write_off_acc == 0 ? 'Return' : 'Writeoff';
+       $credit_type = $write_off_acc == 0 ? 'Return' : 'WriteOff';
 
        begin_transaction();
 
@@ -205,11 +205,12 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_,
        $dim2 = ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_codes["dimension2_id"]);
 
        /* insert gl_trans to credit stock and debit cost of sales at standard cost*/
-       if ($order_line->standard_cost != 0) {
+       $standard_cost = get_standard_cost($order_line->stock_id);
+       if ($standard_cost != 0) {
                /*first the cost of sales entry*/
 
                add_gl_trans_std_cost(11, $credit_no, $date_, $stock_gl_codes["cogs_account"],
-                       $dim, $dim2, "", -($order_line->standard_cost * $order_line->qty_dispatched),
+                       $dim, $dim2, "", -($standard_cost * $order_line->qty_dispatched),
                        payment_person_types::customer(), $order->customer_id,
                        "The cost of sales GL posting could not be inserted");
 
@@ -222,7 +223,7 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_,
                }
 
                add_gl_trans_std_cost(11, $credit_no, $date_, $stock_entry_account, 0, 0,
-                       "", ($order_line->standard_cost * $order_line->qty_dispatched),
+                       "", ($standard_cost * $order_line->qty_dispatched),
                        payment_person_types::customer(), $order->customer_id,
                        "The stock side (or write off) of the cost of sales GL posting could not be inserted");