From a4db318fa0c84e099e0970ca82e36215782d661e Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 3 Feb 2009 10:59:39 +0000 Subject: [PATCH] Merged bugfixes since 2.0.6 --- CHANGELOG.txt | 94 +++++++++++++++++++++++++ config.php | 4 +- gl/includes/db/gl_db_banking.inc | 62 +++++++++++++++- gl/manage/gl_account_classes.php | 7 +- includes/ui/items_cart.inc | 4 +- includes/ui/ui_view.inc | 5 +- purchasing/includes/db/invoice_db.inc | 1 + reporting/includes/class.pdf.inc | 1 + reporting/rep101.php | 12 +++- reporting/rep201.php | 12 +++- sales/credit_note_entry.php | 1 + sales/customer_credit_invoice.php | 7 +- sales/customer_delivery.php | 8 +++ sales/customer_invoice.php | 11 ++- sales/includes/db/payment_db.inc | 8 +-- sales/includes/db/sales_credit_db.inc | 3 +- sales/includes/db/sales_delivery_db.inc | 1 + sales/includes/db/sales_invoice_db.inc | 5 +- sales/includes/ui/sales_order_ui.inc | 43 ++++++----- sales/view/view_credit.php | 2 +- 20 files changed, 249 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0dcf2f2c..ea157c98 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,100 @@ Legend: ! -> Note $ -> Affected files +03-Feb-2009 Janusz Dobrowolski +! Merging bugfixes since 2.0.6 from main trunk (see below) +$ /config.php + /gl/includes/db/gl_db_banking.inc + /gl/manage/gl_account_classes.php + /includes/ui/items_cart.inc + /includes/ui/ui_view.inc + /purchasing/includes/db/invoice_db.inc + /reporting/rep101.php + /reporting/rep201.php + /reporting/includes/class.pdf.inc + /sales/credit_note_entry.php + /sales/customer_credit_invoice.php + /sales/customer_delivery.php + /sales/customer_invoice.php + /sales/includes/db/payment_db.inc + /sales/includes/db/sales_credit_db.inc + /sales/includes/db/sales_delivery_db.inc + /sales/includes/db/sales_invoice_db.inc + /sales/includes/ui/sales_order_ui.inc + /sales/view/view_credit.php + +------------------------------- Release 2.0.7 -------------------------------------------- +03-Feb-2009 Joe Hunt +! New release 2.0.7 +$ config.php + +22-Jan-2009 Joe Hunt +# Bug [0000112] It shows invoices as overdue still (in red), even though its been payed and allocated. +$ /sales/inquiry/customer_inquiry.php + +13-Jan-2009 Joe Hunt +# Bug [0000111] Accounts on Credit Hold can still process delivery notes on sales order and invoicing. +$ /sales/customer_delivery.php + /sales/customer_invoice.php + /sales/includes/ui/sales_order_ui.inc + +08-Jan-2009 Janusz Dobrowolski +# Numeric check on class id added. +$ /gl/manage/gl_account_classes.php + +02-Jan-2009 Joe Hunt +# [0000104] minor language updates in a few sales files +$ /sales/customer_invoice.php + +23-Dec-2008 Joe Hunt +# Fixed an accounting sync in GL when adding bank account transactions (no customer/supplier trans) +$ /gl/includes/db/gl_db_banking.inc + +22-Dec-2008 Janusz Dobrowolski +# [0000102] Credit note was stored without entered shippment cost and comment. +$ /sales/credit_note_entry.php +# [0000103] Error during save of modified freehand credit note. +$ /sales/includes/db/cust_trans_db.inc + +18-Dec-2008 Joe Hunt +# [0000101] Roll back of yeasterday issues +$ /purchasing/includes/db/invoice_db.inc + /purchasing/includes/db/supp_payment_db.inc + /sales/includes/db/payment_db.inc + /sales/includes/db/sales_credit_db.inc + /sales/includes/db/sales_invoice_db.inc + +17-Dec-2008 Joe Hunt +# [0000101] More wonderful rounding issues +$ /includes/ui/ui_view.inc + /purchasing/includes/db/invoice_db.inc + /purchasing/includes/db/supp_payment_db.inc + /sales/includes/db/payment_db.inc + /sales/includes/db/sales_credit_db.inc + /sales/includes/db/sales_delivery_db.inc + /sales/includes/db/sales_invoice_db.inc + +16-Dec-2008 Joe Hunt +# [0000100] Keep getting left allocated weird results (rounding problems). +$ /includes/ui/ui_view.inc + /purchasing/inquiry/supplier_allocation_inquiry.php + /reporting/rep101.php + /reporting/rep201.php + /sales/inquiry/customer_allocation_inquiry.php + +10-Dec-2008 Janusz Dobrowolski +# [0000099] New line added to inventory transfer/adjustment sometimes overwrites old one. +$ /includes/ui/items_cart.inc + +09-Dec-2008 Janusz Dobrowolski +# [0000098] Unable issue of credit note for invoice with removed item lines. +$ /sales/customer_credit_invoice.php +# [0000097] Can't void freehand customer credit note. +$ /sales/includes/db/sales_invoice_db.inc +# Fixed to hide empty credit note lines. +$ /sales/view/view_credit.php +------------------------------------------------------------------------------- + 03-Feb-2009 Janusz Dobrowolski # sql2date around row[date] in due date. $ /purchasing/inquiry/supplier_inquiry.php diff --git a/config.php b/config.php index a458b7c4..3e4399f0 100644 --- a/config.php +++ b/config.php @@ -23,7 +23,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ $debug = 1; $show_sql = 0; - $go_debug = 1; + $go_debug = 0; $pdf_debug = 0; // set $sql_trail to 1 only if you want to perform bugtracking sql trail // Warning: this produces huge amount of data in sql_trail table. @@ -46,7 +46,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ // Main Title $app_title = "FrontAccounting"; // application version - $version = "2.1.0 CVS"; + $version = "2.1.0 beta"; // Build for development purposes $build_version = date("d.m.Y", filemtime("$path_to_root/CHANGELOG.txt")); diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index 57412a23..bc4c0b5b 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -9,12 +9,52 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ +function add_exchange_variation($trans_type, $trans_no, $date_, $account, + $currency, $person_type_id=null, $person_id = "") +{ + if (is_company_currency($currency)) + return; + if ($date_ == null) + $date_ = Today(); + $rate = get_exchange_rate_from_home_currency($currency, $date_); + $result = db_query("SELECT SUM(amount) FROM ".TB_PREF."bank_trans WHERE + bank_act='$account' AND trans_date<='".date2sql($date_)."'", + "Transactions for account $account could not be calculated"); + $row = db_fetch_row($result); + $foreign_amount = $row[0]; + $amount = get_gl_trans_from_to("", $date_, $account); + $diff = $amount - (round2($foreign_amount * $rate, user_price_dec())); + if ($diff != 0) + { + if ($trans_type == null) + $trans_type = systypes::journal_entry(); + if ($trans_no == null) + $trans_no = get_next_trans_no($trans_type); + if ($person_type_id == null) + $person_type_id = payment_person_types::misc(); + add_gl_trans($trans_type, $trans_no, $date_, $account, 0, 0, _("Exchange Variance"), + -$diff, null, $person_type_id, $person_id); + add_gl_trans($trans_type, $trans_no, $date_, get_company_pref('exchange_diff_act'), 0, 0, + _("Exchange Variance"), $diff, null, $person_type_id, $person_id); + } +} + +function add_exchange_variation_all() +{ + $trans_no = get_next_trans_no(0); + $sql = "SELECT * FROM ".TB_PREF."bank_accounts"; + $result = db_query($sql, "could not retreive bank accounts"); + while ($myrow = db_fetch($result)) + add_exchange_variation(0, $trans_no, null, $myrow['account_code'], + $myrow['currency_code']); +} //---------------------------------------------------------------------------------- // Add bank tranfer to database. // // $from_account - source bank account id // $to_account - target bank account id // + function add_bank_transfer($from_account, $to_account, $date_, $amount, $ref, $memo_) { @@ -39,9 +79,13 @@ function add_bank_transfer($from_account, $to_account, $date_, payment_person_types::misc(), "", $currency, "Cannot insert a source bank transaction"); + add_exchange_variation($trans_type, $trans_no, $date_, $from_account, + $currency, payment_person_types::misc(), ""); + // do the destination account postings $total += add_gl_trans($trans_type, $trans_no, $date_, $to_gl_account, 0, 0, "", $amount, $currency); + /*Post a balance post if $total != 0 */ add_gl_balance($trans_type, $trans_no, $date_, -$total); @@ -49,6 +93,9 @@ function add_bank_transfer($from_account, $to_account, $date_, $date_, $amount, payment_person_types::misc(), "", $currency, "Cannot insert a destination bank transaction"); + add_exchange_variation($trans_type, $trans_no, $date_, $from_account, + $currency, payment_person_types::misc(), ""); + add_comments($trans_type, $trans_no, $date_, $memo_); references::save_last($ref, $trans_type); @@ -76,6 +123,8 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, if ($trans_type != systypes::bank_payment() && $trans_type != systypes::bank_deposit()) display_db_error("Invalid type ($trans_type) sent to add_bank_transaction"); + $do_exchange_variance = false; + begin_transaction(); $currency = get_bank_account_currency($from_account); @@ -113,6 +162,7 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, else { $trans_no = get_next_trans_no($trans_type); + $do_exchange_variance = true; } // do the source account postings @@ -141,8 +191,12 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, if ($is_bank_to) { add_bank_trans($trans_type, $trans_no, $gl_item->code_id, $ref, - $date_, $gl_item->amount, $person_type_id, $person_id, - $currency, "Cannot insert a destination bank transaction"); + $date_, $gl_item->amount, + $person_type_id, $person_id, $currency, + "Cannot insert a destination bank transaction"); + if ($do_exchange_variance) + add_exchange_variation($trans_type, $trans_no, $date_, $gl_item->code_id, + $currency, $person_type_id, $person_id); } // store tax details if the gl account is a tax account @@ -157,6 +211,10 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, 0, 0, $memo_, -$total, null, $person_type_id, $person_id); + if ($do_exchange_variance) + add_exchange_variation($trans_type, $trans_no, $date_, $from_account, + $currency, $person_type_id, $person_id); + add_comments($trans_type, $trans_no, $date_, $memo_); references::save_last($ref, $trans_type); diff --git a/gl/manage/gl_account_classes.php b/gl/manage/gl_account_classes.php index e0b6ff4e..6cc9a6d5 100644 --- a/gl/manage/gl_account_classes.php +++ b/gl/manage/gl_account_classes.php @@ -24,7 +24,12 @@ simple_page_mode(true); function can_process() { - + if (!is_numeric($_POST['id'])) + { + display_error( _("The account class ID must be numeric.")); + set_focus('id'); + return false; + } if (strlen($_POST['name']) == 0) { display_error( _("The account class name cannot be empty.")); diff --git a/includes/ui/items_cart.inc b/includes/ui/items_cart.inc index f4d223a2..8afd8981 100644 --- a/includes/ui/items_cart.inc +++ b/includes/ui/items_cart.inc @@ -76,7 +76,7 @@ class items_cart function remove_from_cart($line_no) { - unset($this->line_items[$line_no]); + array_splice($this->line_items, $line_no, 1); } function count_items() @@ -132,7 +132,7 @@ class items_cart { if (isset($index)) { - unset($this->gl_items[$index]); + array_splice($this->gl_items, $line_no, 1); } } diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 47e32672..63040d18 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -468,7 +468,7 @@ function display_edit_tax_items($taxes, $columns, $tax_included, $leftspan=0) { label_row($taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%)", number_format2($taxitem['Value'],user_price_dec()), "colspan=$columns align=right", "align=right",$leftspan); - $total += $taxitem['Value']; + $total += round2($taxitem['Value'], user_price_dec()); } } @@ -510,6 +510,8 @@ function display_allocations($alloc_result, $total) label_cell(systypes::name($alloc_row['type'])); label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no'])); label_cell(sql2date($alloc_row['tran_date'])); + $alloc_row['Total'] = round2($alloc_row['Total'], user_price_dec()); + $alloc_row['amt'] = round2($alloc_row['amt'], user_price_dec()); amount_cell($alloc_row['Total']); //amount_cell($alloc_row['Total'] - $alloc_row['PrevAllocs'] - $alloc_row['amt']); amount_cell($alloc_row['Total'] - $alloc_row['amt']); @@ -524,6 +526,7 @@ function display_allocations($alloc_result, $total) end_row(); start_row(); label_cell(_("Left to Allocate:"), "align=right colspan=5"); + $total = round2($total, user_price_dec()); amount_cell($total - $total_allocated); end_row(); diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index d2331c17..3abdf578 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -127,6 +127,7 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b foreach ($taxes as $taxitem) { + $taxitem['Value'] = round2($taxitem['Value'], user_price_dec()); $tax_total += $taxitem['Value']; } diff --git a/reporting/includes/class.pdf.inc b/reporting/includes/class.pdf.inc index 1fcda859..971e3c3f 100644 --- a/reporting/includes/class.pdf.inc +++ b/reporting/includes/class.pdf.inc @@ -100,6 +100,7 @@ class Cpdf extends TCPDF { { case "ar_EG" : $fontname = "ae_tholoth"; break; case "zh_CN" : $fontname = "gbsn00lp"; break; + case "zh_TW" : $fontname = "chinese_traditional_cid0"; break; default : $fontname = "dejavu"; break; } } diff --git a/reporting/rep101.php b/reporting/rep101.php index b51b4488..f8e04caa 100644 --- a/reporting/rep101.php +++ b/reporting/rep101.php @@ -134,20 +134,26 @@ function print_customer_balances() $trans['TotalAmount'] *= -1; if ($trans['TotalAmount'] > 0.0) { - $item[0] = abs($trans['TotalAmount']) * $rate; + $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec); $rep->TextCol(4, 5, number_format2($item[0], $dec)); } else { - $item[1] = Abs($trans['TotalAmount']) * $rate; + $item[1] = round2(Abs($trans['TotalAmount']) * $rate, $dec); $rep->TextCol(5, 6, number_format2($item[1], $dec)); } - $item[2] = $trans['Allocated'] * $rate; + $item[2] = round2($trans['Allocated'] * $rate, $dec); $rep->TextCol(6, 7, number_format2($item[2], $dec)); + /* if ($trans['type'] == 10) $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; else $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; + */ + if ($trans['type'] == 10) + $item[3] = $item[0] + $item[1] - $item[2]; + else + $item[3] = $item[0] - $item[1] + $item[2]; $rep->TextCol(7, 8, number_format2($item[3], $dec)); for ($i = 0; $i < 4; $i++) { diff --git a/reporting/rep201.php b/reporting/rep201.php index e0a882d0..cb65f7df 100644 --- a/reporting/rep201.php +++ b/reporting/rep201.php @@ -133,20 +133,26 @@ function print_supplier_balances() $rate = 1.0; if ($trans['TotalAmount'] > 0.0) { - $item[0] = Abs($trans['TotalAmount']) * $rate; + $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec); $rep->TextCol(4, 5, number_format2($item[0], $dec)); } else { - $item[1] = Abs($trans['TotalAmount']) * $rate; + $item[1] = round2(abs($trans['TotalAmount']) * $rate, $dec); $rep->TextCol(5, 6, number_format2($item[1], $dec)); } - $item[2] = $trans['Allocated'] * $rate; + $item[2] = round2($trans['Allocated'] * $rate, $dec); $rep->TextCol(6, 7, number_format2($item[2], $dec)); + /* if ($trans['type'] == 20) $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate; else $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate; + */ + if ($trans['type'] == 20) + $item[3] = $item[0] + $item[1] - $item[2]; + else + $item[3] = $item[0] - $item[1] + $item[2]; $rep->TextCol(7, 8, number_format2($item[3], $dec)); for ($i = 0; $i < 4; $i++) { diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index 348b2c3c..1de67a66 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -178,6 +178,7 @@ if (isset($_POST['ProcessCredit']) && can_process()) { if (!isset($_POST['WriteOffGLCode'])) { $_POST['WriteOffGLCode'] = 0; } + copy_to_cn(); $credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']); processing_end(); meta_forward($_SERVER['PHP_SELF'], "AddedID=$credit_no"); diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index 7d318a9f..00a6527f 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -152,6 +152,9 @@ function check_quantities() { $ok =1; foreach ($_SESSION['Items']->line_items as $line_no=>$itm) { + if ($itm->quantity == $itm->qty_done) { + continue; // this line was fully credited/removed + } if (isset($_POST['Line'.$line_no])) { if (check_num('Line'.$line_no, 0, $itm->quantity)) { $_SESSION['Items']->line_items[$line_no]->qty_dispatched = @@ -287,8 +290,8 @@ function display_credit_items() $k = 0; //row colour counter foreach ($_SESSION['Items']->line_items as $line_no=>$ln_itm) { - if ($ln_itm->quantity==$ln_itm->qty_done) { - continue; // this line was fully credited + if ($ln_itm->quantity == $ln_itm->qty_done) { + continue; // this line was fully credited/removed } alt_table_row_color($k); diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index d87c165a..1d11585f 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -373,6 +373,14 @@ end_table(); echo ""; end_table(1); // outer table +$row = get_customer_to_order($_SESSION['Items']->customer_id); +if ($row['dissallow_invoices'] == 1) +{ + display_error(_("The selected customer account is currently on hold. Please contact the credit control personnel to discuss.")); + end_form(); + end_page(); + exit(); +} display_heading(_("Delivery Items")); div_start('Items'); start_table("$table_style width=80%"); diff --git a/sales/customer_invoice.php b/sales/customer_invoice.php index afad4617..d5c39a3c 100644 --- a/sales/customer_invoice.php +++ b/sales/customer_invoice.php @@ -128,7 +128,7 @@ if ( (isset($_GET['DeliveryNumber']) && ($_GET['DeliveryNumber'] > 0) ) } elseif (isset($_GET['ModifyInvoice']) && $_GET['ModifyInvoice'] > 0) { if ( get_parent_trans(10, $_GET['ModifyInvoice']) == 0) { // 1.xx compatibility hack - echo"

" . _("There in no delivery notes for this invoice.
+ echo"

" . _("There are no delivery notes for this invoice.
Most likely this invoice was created in Front Accounting version prior to 2.0 and therefore can not be modified.") . "
"; display_footer_exit(); @@ -384,6 +384,15 @@ date_cells(_("Due Date"), 'due_date', '', $_POST['due_date'], 0, 0, 0, "class='t end_row(); end_table(); +$row = get_customer_to_order($_SESSION['Items']->customer_id); +if ($row['dissallow_invoices'] == 1) +{ + display_error(_("The selected customer account is currently on hold. Please contact the credit control personnel to discuss.")); + end_form(); + end_page(); + exit(); +} + display_heading(_("Invoice Items")); div_start('Items'); diff --git a/sales/includes/db/payment_db.inc b/sales/includes/db/payment_db.inc index d8049b31..4a5c932b 100644 --- a/sales/includes/db/payment_db.inc +++ b/sales/includes/db/payment_db.inc @@ -49,10 +49,10 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou } if (($discount + $amount) != 0) { - /* Now Credit Debtors account with receipts + discounts */ - $total += add_gl_trans_customer(12, $payment_no, $date_, - $debtors_account, 0, 0, -($discount + $amount), $customer_id, - "Cannot insert a GL transaction for the debtors account credit", $rate); + /* Now Credit Debtors account with receipts + discounts */ + $total += add_gl_trans_customer(12, $payment_no, $date_, + $debtors_account, 0, 0, -($discount + $amount), $customer_id, + "Cannot insert a GL transaction for the debtors account credit", $rate); } if ($discount != 0) { /* Now Debit discount account with discounts allowed*/ diff --git a/sales/includes/db/sales_credit_db.inc b/sales/includes/db/sales_credit_db.inc index 4f7e1a5a..877bb9d7 100644 --- a/sales/includes/db/sales_credit_db.inc +++ b/sales/includes/db/sales_credit_db.inc @@ -40,7 +40,8 @@ function write_credit_note($credit_note, $write_off_acc) $tax_total = 0; foreach ($taxes as $taxitem) { - $tax_total += $taxitem['Value']; + $taxitem['Value'] = round2($taxitem['Value'], user_price_dec()); + $tax_total += $taxitem['Value']; } if ($credit_note->tax_included == 0) { diff --git a/sales/includes/db/sales_delivery_db.inc b/sales/includes/db/sales_delivery_db.inc index 4d4829b2..9d1e2673 100644 --- a/sales/includes/db/sales_delivery_db.inc +++ b/sales/includes/db/sales_delivery_db.inc @@ -31,6 +31,7 @@ function write_sales_delivery(&$delivery,$bo_policy) $taxes = $delivery->get_taxes(); // all taxes with freight_tax foreach ($taxes as $taxitem) { + $taxitem['Value'] = round2($taxitem['Value'], user_price_dec()); $tax_total += $taxitem['Value']; } /* Insert/update the debtor_trans */ diff --git a/sales/includes/db/sales_invoice_db.inc b/sales/includes/db/sales_invoice_db.inc index 2beb2bc8..faf382ae 100644 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@ -44,6 +44,7 @@ function write_sales_invoice(&$invoice) $taxes = $invoice->get_taxes(); // all taxes with freight_tax foreach ($taxes as $taxitem) { + $taxitem['Value'] = round2($taxitem['Value'], user_price_dec()); $ov_gst += $taxitem['Value']; } @@ -203,11 +204,11 @@ function void_sales_invoice($type, $type_no) $deliveries = get_parent_trans($type, $type_no); - if (count($deliveries)) { + if ($deliveries !== 0) { $srcdetails = get_customer_trans_details(get_parent_type($type), $deliveries); while ($row = db_fetch($items_result)) { $src_line = db_fetch($srcdetails); - update_parent_line(10, $src_line['id'], -$row['quantity']); + update_parent_line($type, $src_line['id'], -$row['quantity']); } } // clear details after they've been reversed in the sales order diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 5ef26f8c..3950e133 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -245,25 +245,27 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group customer_branches_list_row(_("Branch:"), $_POST['customer_id'], 'branch_id', null, false, true, true); - if( ($order->customer_id != get_post('customer_id', -1)) || + if( ($order->customer_id != get_post('customer_id', -1)) || ($order->Branch != get_post('branch_id', -1)) || - list_updated('customer_id')) { - - if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "") + list_updated('customer_id')) { - // ignore errors on customer search box call - if ($_POST['customer_id'] == '') - $customer_error = _("No customer found for entered text."); + + if (!isset($_POST['branch_id']) || $_POST['branch_id'] == "") + { + // ignore errors on customer search box call + if ($_POST['customer_id'] == '') + $customer_error = _("No customer found for entered text."); + else + $customer_error = _("The selected customer does not have any branches. Please create at least one branch."); + unset($_POST['branch_id']); + $order->Branch = 0; + } else - $customer_error = _("The selected customer does not have any branches. Please create at least one branch."); - unset($_POST['branch_id']); - $order->Branch = 0; - } else - { + { $old_order = (PHP_VERSION<5) ? $order : clone( $order ); - $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']); + $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']); $_POST['Location'] = $order->Location; $_POST['deliver_to'] = $order->deliver_to; $_POST['delivery_address'] = $order->delivery_address; @@ -286,13 +288,13 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group // change prices if necessary // what about discount in template case? if ($old_order->customer_currency != $order->customer_currency) { - $change_prices = 1; + $change_prices = 1; } if ($old_order->sales_type != $order->sales_type) { // || $old_order->default_discount!=$order->default_discount $_POST['sales_type'] = $order->sales_type; - $Ajax->activate('sales_type'); - $change_prices = 1; + $Ajax->activate('sales_type'); + $change_prices = 1; } if ($old_order->dimension_id != $order->dimension_id) { $_POST['dimension_id'] = $order->dimension_id; @@ -304,8 +306,15 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group } unset($old_order); } - set_global_customer($_POST['customer_id']); + set_global_customer($_POST['customer_id']); } // changed branch + else + { + $row = get_customer_to_order($_POST['customer_id']); + if ($row['dissallow_invoices'] == 1) + $customer_error = _("The selected customer account is currently on hold. Please contact the credit control personnel to discuss."); + + } } if ($order->trans_type != 30) { diff --git a/sales/view/view_credit.php b/sales/view/view_credit.php index bdc50620..f488f3a9 100644 --- a/sales/view/view_credit.php +++ b/sales/view/view_credit.php @@ -96,7 +96,7 @@ if (db_num_rows($result) > 0) while ($myrow2 = db_fetch($result)) { - + if ($myrow2["quantity"] == 0) continue; alt_table_row_color($k); $value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), -- 2.30.2