From 91bede4226ba8b45151f0501ac88eb946ed5f2a1 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Mon, 28 Oct 2013 08:09:27 +0100 Subject: [PATCH] Fixed a couple of obvious errors. --- gl/gl_journal.php | 1 + includes/db_pager.inc | 7 ++++++- includes/references.inc | 14 ++++++++------ purchasing/includes/db/invoice_db.inc | 17 +++++++++++------ purchasing/includes/db/supp_trans_db.inc | 2 +- purchasing/includes/purchasing_db.inc | 2 ++ purchasing/manage/suppliers.php | 1 + sales/customer_delivery.php | 10 +++++----- sales/includes/db/cust_trans_db.inc | 2 +- 9 files changed, 36 insertions(+), 20 deletions(-) diff --git a/gl/gl_journal.php b/gl/gl_journal.php index d516bdac..063dd8ae 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -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) diff --git a/includes/db_pager.inc b/includes/db_pager.inc index 6ad1755a..da4ee963 100644 --- a/includes/db_pager.inc +++ b/includes/db_pager.inc @@ -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. // diff --git a/includes/references.inc b/includes/references.inc index 6a8c7af2..cd01ab6c 100644 --- a/includes/references.inc +++ b/includes/references.inc @@ -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"); diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index 18939822..72d01f11 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -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 - diff --git a/purchasing/includes/db/supp_trans_db.inc b/purchasing/includes/db/supp_trans_db.inc index 6af755e6..081e8580 100644 --- a/purchasing/includes/db/supp_trans_db.inc +++ b/purchasing/includes/db/supp_trans_db.inc @@ -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) diff --git a/purchasing/includes/purchasing_db.inc b/purchasing/includes/purchasing_db.inc index 2c480c7e..ac9e5e5e 100644 --- a/purchasing/includes/purchasing_db.inc +++ b/purchasing/includes/purchasing_db.inc @@ -9,6 +9,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ +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"); diff --git a/purchasing/manage/suppliers.php b/purchasing/manage/suppliers.php index bc8f3f28..552d4e04 100644 --- a/purchasing/manage/suppliers.php +++ b/purchasing/manage/suppliers.php @@ -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")); diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index 4363493b..41e3726b 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -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 "
" . _("This order has no items. There is nothing to delivery.") . - "
"; hyperlink_params($path_to_root . "/sales/inquiry/sales_orders_view.php", _("Select a different sales order to delivery"), "OutstandingOnly=1"); + echo "
" . _("This order has no items. There is nothing to delivery.") . + "
"; display_footer_exit(); - } else if (!$ord->prep_amount) { - echo "
"._("This prepayment order is not yet ready for delivery due to insufficient amount received.") - ."
"; + } 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 "
"._("This prepayment order is not yet ready for delivery due to insufficient amount received.") + ."
"; display_footer_exit(); } // Adjust Shipping Charge based upon previous deliveries TAM diff --git a/sales/includes/db/cust_trans_db.inc b/sales/includes/db/cust_trans_db.inc index eb65752f..36697ced 100644 --- a/sales/includes/db/cust_trans_db.inc +++ b/sales/includes/db/cust_trans_db.inc @@ -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); } -- 2.30.2