Merged bugfixes since 2.0.6
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 3 Feb 2009 10:59:39 +0000 (10:59 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 3 Feb 2009 10:59:39 +0000 (10:59 +0000)
20 files changed:
CHANGELOG.txt
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/includes/class.pdf.inc
reporting/rep101.php
reporting/rep201.php
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

index 0dcf2f2cef7bf48f8666edbe3b84292f502aa342..ea157c981ea3518a36510dbced02aa29b760293d 100644 (file)
@@ -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
index a458b7c4db09fa9a2767178df27b37e2b6bc9ab2..3e4399f0e0bbbbe0039d25897142865c56ad6049 100644 (file)
@@ -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"));
index 57412a23e129e7db65fd5fd973315b9f5ea42a9b..bc4c0b5bd5fd6c794999441d18cb49a1f858e78a 100644 (file)
@@ -9,12 +9,52 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
 ***********************************************************************/
+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);
index e0b6ff4ef3c54c74f3bf15b9b3bba67aea6c0bdd..6cc9a6d53aaf428c9773370d56096cebe0cd5c65 100644 (file)
@@ -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."));
index f4d223a2dd4c56a5d3645aae684ebfb7bec8a870..8afd898103fb39ad8d3bae8c0b1df1974987d6fc 100644 (file)
@@ -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);
                }
        }
 
index 47e3267274211c24e77f35ffa2e0fdc6f4c2f876..63040d18d996e825fe66e833757a51ceb5795240 100644 (file)
@@ -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();
 
index d2331c17174dbc4d37a385e0e7c374f5db050b72..3abdf578cc0cb085b72878a728bee62755b673b9 100644 (file)
@@ -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'];
     }
 
index 1fcda8596dbac483deff83eb50074df02105ccfa..971e3c3fa9460e3148d45561665c99ead331da00 100644 (file)
@@ -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;
                                }
                        }
index b51b44885ac72ecc772c733132401b68ecbbc4f6..f8e04caa6873816f1ef9afb1d14f02aed68a05e9 100644 (file)
@@ -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++)
                        {
index e0a882d0f48de28154a74225f94fe9b633599c62..cb65f7df3a2a135ca61af480e8bec742b6505051 100644 (file)
@@ -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++)
                        {
index 348b2c3c75ad40a0732eebf76ab731a4f8a09a2b..1de67a66cfae9e4eed290ce8b12274d1fbde1f4a 100644 (file)
@@ -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");
index 7d318a9f18a61b92f3e73c1d2c1ff1a731291eeb..00a6527f68944ad41013e97c5474108623979860 100644 (file)
@@ -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);
 
index d87c165a0d3e7f025f77455f7090fc5f2c04a7ff..1d11585f6e7bac0b5786dccc452197c30e6a0410 100644 (file)
@@ -373,6 +373,14 @@ end_table();
 echo "</td></tr>";
 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%");
index afad461764c3fc169601cb68d7fce81b942737dd..d5c39a3c945aa41ce126c2486ba9091e77901206 100644 (file)
@@ -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"<center><br><b>" . _("There in no delivery notes for this invoice.<br>
+               echo"<center><br><b>" . _("There are no delivery notes for this invoice.<br>
                Most likely this invoice was created in Front Accounting version prior to 2.0
                and therefore can not be modified.") . "</b></center>";
                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');
index d8049b318fef1b3742ea501d04b2113ceb8a6eab..4a5c932bc347e8adff0ac89b92d5dc94955784bd 100644 (file)
@@ -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*/
index 4f7e1a5a7f01bce70d43208da3ed875d839e014c..877bb9d7a61244112c09a056c8fd71c58e58cfbb 100644 (file)
@@ -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) {
index 4d4829b2a1e67a03adc3fc4d2df66327ea299174..9d1e267343bef3590430ec2fd0fb4fd07b8bc012 100644 (file)
@@ -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 */
index 2beb2bc8614e4c35d4ec15a64b4726ca8f141f6c..faf382ae894b36c95008b08ccdcc281c5ca1cd82 100644 (file)
@@ -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
index 5ef26f8cad0e7b3386da24c41a4cf16b772416f4..3950e133273704262df9f8ee00ef64c3b4ca3a5d 100644 (file)
@@ -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) {
index bdc506201073184e378228640768ee62aed42a2a..f488f3a9a9a319daf8facf45e5fdfe706973158d 100644 (file)
@@ -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"]),