Fixed a couple of obvious errors.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 28 Oct 2013 07:09:27 +0000 (08:09 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 31 Oct 2013 18:48:06 +0000 (19:48 +0100)
gl/gl_journal.php
includes/db_pager.inc
includes/references.inc
purchasing/includes/db/invoice_db.inc
purchasing/includes/db/supp_trans_db.inc
purchasing/includes/purchasing_db.inc
purchasing/manage/suppliers.php
sales/customer_delivery.php
sales/includes/db/cust_trans_db.inc

index d516bdac8eaa8ff8e03367d750ba5684903f70e9..063dd8aed39165f77e39d3f3ac6088cb69f27f31 100644 (file)
@@ -21,6 +21,7 @@ include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/gl/includes/ui/gl_journal_ui.inc");
 include_once($path_to_root . "/gl/includes/gl_db.inc");
 include_once($path_to_root . "/gl/includes/gl_ui.inc");
+include_once($path_to_root . "/taxes/db/tax_types_db.inc");
 
 $js = '';
 if ($use_popup_windows)
index 6ad1755a752ff707d7e6b2218d5256383649bf7c..da4ee963c928ab380bd0ada46bfc6b5405dff816 100644 (file)
@@ -117,6 +117,11 @@ class db_pager {
                                        }
                        }
                }
+               //_vd($this->select);
+               //_vd($this->from);
+               //_vd($this->where);
+               //_vd($this->group);
+               //_vd($this->order);
        }
        //
        //      Set additional constraint on record set
@@ -203,7 +208,7 @@ class db_pager {
                } else 
                  return false;
                return true;
-       }           
+       }
        //
        //      Calculates page numbers for html controls.
        //
index 6a8c7af2d0f87044206bc2fb0f243697e90b1051..cd01ab6c67386032182dbda57e5a962390f1bea2 100644 (file)
@@ -123,17 +123,19 @@ function is_new_reference($ref, $type, $trans_no=0)
        }
 
        if ($db_type != null) {
-               $sql = "SELECT $db_ref FROM $db_name 
+               $sql = "SELECT $db_ref FROM $db_name tbl
                        LEFT JOIN ".TB_PREF."voided v ON 
-                               $db_name.$db_type=v.type AND $db_name.$db_trans=v.id
-                       WHERE $db_name.$db_ref=$ref AND ISNULL(v.id)
-                               AND $db_name.$db_type=$type";
+                               tbl.$db_type=v.type AND tbl.$db_trans=v.id
+                       WHERE $db_ref=$ref AND ISNULL(v.id)
+                               AND tbl.$db_type=$type";
        } else {
-               $sql = "SELECT $db_ref FROM $db_name 
+               $sql = "SELECT $db_ref ref FROM $db_name tbl
                        LEFT JOIN ".TB_PREF."voided v ON 
-                               v.type=$type AND $db_name.$db_trans=v.id
+                               v.type=$type AND tbl.$db_trans=v.id
                        WHERE $db_ref=$ref AND ISNULL(v.id)";
        }
+       if ($trans_no)
+                       $sql .= " AND tbl.`$db_trans` != ".db_escape($trans_no);
 
        $result = db_query($sql, "could not test for unique reference");
 
index 18939822d8676a704d579c3c1b4c9674573a25bd..72d01f114463311dbc4d634b557c2a115d54cc32 100644 (file)
@@ -200,12 +200,15 @@ function add_supp_invoice(&$supp_trans) // do not receive as ref because we chan
                                $taxitem['tax_type_id'], $taxitem['rate'], $supp_trans->tax_included, $taxitem['Value'],
                                $taxitem['Net'], $ex_rate, $date_, $supp_trans->supp_reference);
 
-                       if ($trans_type == ST_SUPPCREDIT)
-                               $taxitem['Value'] = -$taxitem['Value'];
-                       $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_,
-                               $taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'],
-                               $supp_trans->supplier_id,
-                               "A general ledger transaction for the tax amount could not be added");
+                       if (isset($taxitem['purchasing_gl_code']))
+                       {
+                               if ($trans_type == ST_SUPPCREDIT)
+                                       $taxitem['Value'] = -$taxitem['Value'];
+                               $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_,
+                                       $taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'],
+                                       $supp_trans->supplier_id,
+                                       "A general ledger transaction for the tax amount could not be added");
+                       }
                }
     }
     if ($trans_type == ST_SUPPCREDIT)
@@ -217,6 +220,8 @@ function add_supp_invoice(&$supp_trans) // do not receive as ref because we chan
                $supp_trans->supplier_id,
                "The general ledger transaction for the control total could not be added");
 
+       $to_allocate = ($invoice_items_total + $item_added_tax + $supp_trans->ov_discount);
+
     foreach ($supp_trans->gl_codes as $entered_gl_code)
     {
            /*GL Items are straight forward - just do the debit postings to the GL accounts specified -
index 6af755e659c6c466e0e72b8f4ff22e977f8c7c79..081e8580e62c2359a10ba69cc745998940a6ddd5 100644 (file)
@@ -214,7 +214,7 @@ function get_sql_for_supplier_inquiry($filter, $after_date, $to_date, $supplier_
                        $sql = $sql2;
        } 
        elseif (!isset($filter) || $filter == ALL_TEXT || $filter == '6') {
-               $sql = "SELECT * FROM (($sql) UNION ($sql2)) as tr";
+               $sql = "SELECT * FROM (($sql) UNION ($sql2)) as tr WHERE 1";
        }
 
        if (isset($filter) && $filter != ALL_TEXT)
index 2c480c7e52c8c3c7fb9dca4615d7ba3f9942af09..ac9e5e5e6d4991144517ba4c5527b55eb2add739 100644 (file)
@@ -9,6 +9,8 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
+include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc");
+
 include_once($path_to_root . "/includes/banking.inc");
 
 include_once($path_to_root . "/includes/date_functions.inc");
index bc8f3f28ccde84a6f9bd29a7ed815311fff9c54e..552d4e04fbcde05e19b6a22a0aa2fba4afb72a3d 100644 (file)
@@ -132,6 +132,7 @@ function supplier_settings(&$supplier_id)
        gl_all_accounts_list_row(_("Purchase Discount Account:"), 'payment_discount_account', $_POST['payment_discount_account']);
        if (!$supplier_id) {
                table_section_title(_("Contact Data"));
+               text_row(_("Contact Person:"), 'contact', null, 42, 40);
                text_row(_("Phone Number:"), 'phone', null, 32, 30);
                text_row(_("Secondary Phone Number:"), 'phone2', null, 32, 30);
                table_section_title(_("Contact Data"));
index 4363493bfb678e8edb40477be50b3735ae9be8f5..41e3726b48a1a3f86b327f12fb31467ca426aa2d 100644 (file)
@@ -94,16 +94,16 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) {
                check_deferred_income_act(_("You have to set Deferred Income Account in GL Setup to entry prepayment invoices."));
 
        if ($ord->count_items() == 0) {
-               echo "<br><center><b>" . _("This order has no items. There is nothing to delivery.") .
-                       "</center></b>";
                hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php",
                        _("Select a different sales order to delivery"), "OutstandingOnly=1");
+               echo "<br><center><b>" . _("This order has no items. There is nothing to delivery.") .
+                       "</center></b>";
                display_footer_exit();
-       } else if (!$ord->prep_amount) {
-               echo "<br><center><b>"._("This prepayment order is not yet ready for delivery due to insufficient amount received.")
-                       ."</center></b>";
+       } else if (!$ord->is_released()) {
                hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php",_("Select a different sales order to delivery"),
                        "OutstandingOnly=1");
+               echo "<br><center><b>"._("This prepayment order is not yet ready for delivery due to insufficient amount received.")
+                       ."</center></b>";
                display_footer_exit();
        }
        // Adjust Shipping Charge based upon previous deliveries TAM
index eb65752f817e501fb4d842557d8f250fed5387e8..36697ced6f553f4a549b8860089aad5470df2184 100644 (file)
@@ -105,7 +105,7 @@ function write_customer_trans($trans_type, $trans_no, $debtor_no, $BranchNo,
                ship_via=".db_escape($ship_via).", alloc=$AllocAmt,
                dimension_id=".db_escape($dimension_id).", dimension2_id=".db_escape($dimension2_id).",
                payment_terms=".db_escape($payment_terms, true).",
-               tax_included=".db_escape($tax_included)."
+               tax_included=".db_escape($tax_included).",
                prep_amount =".db_escape($prep_amount)."
                WHERE trans_no=".db_escape($trans_no)." AND type=".db_escape($trans_type);
        }