Merged changes from main trunk up to 2.2.7
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 5 Mar 2010 13:08:28 +0000 (13:08 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 5 Mar 2010 13:08:28 +0000 (13:08 +0000)
31 files changed:
CHANGELOG.txt
admin/backups.php
admin/create_coy.php
config.default.php
gl/gl_journal.php
gl/includes/db/gl_db_accounts.inc
gl/includes/db/gl_db_banking.inc
gl/manage/exchange_rates.php
includes/access_levels.inc
includes/session.inc
includes/ui/ui_lists.inc
js/inserts.js
lang/new_language_template/LC_MESSAGES/empty.po
manufacturing/includes/db/work_order_produce_items_db.inc
manufacturing/includes/db/work_order_requirements_db.inc
manufacturing/includes/db/work_orders_db.inc
manufacturing/includes/db/work_orders_quick_db.inc
manufacturing/work_order_add_finished.php
purchasing/includes/db/grn_db.inc
purchasing/includes/ui/po_ui.inc
reporting/includes/class.graphic.inc
reporting/includes/doctext.inc
reporting/includes/doctext2.inc
reporting/includes/pdf_report.inc
reporting/includes/reports_classes.inc
reporting/rep107.php
reporting/rep110.php
sales/customer_delivery.php
sales/manage/customer_branches.php
taxes/tax_calc.inc
update.html

index 0603c2ceb2fdb8edcfa3323fab00f75ea4aa7242..d21ca204f0473e77ecf5eabccd3678c782e7b4b5 100644 (file)
@@ -19,6 +19,95 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+05-Mar-2010 Merged changes from main trunk up to 2.2.7 as follows
+------------------------------- Release 2.2.7 ----------------------------------
+05-Mar-2010 Joe Hunt
+! Release 2.2.7
+! Removed redundant variable $use_new_account_types from config.php
+$ config.default.php
+  update.html
+! Removed redundant function get_gl_accounts_all in gl_db_accounts.inc
+$ /gl/includes/db/gl_db_accounts.inc
+
+02-Mar-2010 Joe Hunt
+# Bug sending email to a name with commas. Has been replaced with ''.
+$ /reporting/includes/pdf_report.inc
+
+01-Mar-2010 Janusz Dobrowolski
+# [0000212] Selecting branch from popup was not working.
+$ /sales/manage/customer_branches.php
+# [0000213] Date change on journal entry update.
+$ /gl/gl_journal.php
+
+01-Mar-2010 Joe Hunt
+! Allow change of password without script in Create/Update Company.
+$ /admin/create_coy.php
+
+28-Feb-2010 Joe Hunt
+# Fixed a non esisting voiding of Work Order Advanced and a couple of
+  bugs in the same operation. And a fix according to Vramak on the forum.
+  Wiki will be updated on how does the Work Order work
+$ /manufacturing/includes/db/work_orders_db.inc
+  /manufacturing/includes/db/work_orders_quick_db.inc
+  /manufacturing/includes/db/work_order_produce_items_db.inc
+  /manufacturing/includes/db/work_order_requirements_db.inc
+  /purchasing/includes/db/grn_db.inc
+  
+26-Feb-2010 Janusz Dobrowolski
+# [0000209],[0000210] Improper quantity/price handling on supplier change.
+$ /purchasing/includes/ui/po_ui.inc
+# [0000211] Typo in work order legend.
+$ /reporting/includes/doctext.inc
+  /reporting/includes/doctext2.inc
+# Restored Esc hot key on cancel buttons.
+$ /js/inserts.js
+
+26-Feb-2010 Joe Hunt
+# [0000208] Voiding a work order production does not revert raw material quantities 
+$ /manufacturing/includes/db/work_order_produce_items_db.inc
+
+25-Feb-2010 Janusz Dobrowolski
+# Fixed bug in quantity input
+$ /manufacturing/work_order_add_finished.php
+
+24-Feb-2010 Joe Hunt
+# Tax included calculation problem when more than 1 tax type in a group
+$ /taxes/tax_calc.inc
+! Small layout fixes
+$ /admin/backups.php
+  /includes/ui/ui_lists.inc
+  /reporting/rep107.php
+  /reporting/rep110.php
+  
+22-Feb-2010 Janusz Dobrowolski
+# Two smaller fixes in security area codes.
+$ /includes/access_levels.inc
+
+21-Feb-2010 Joe Hunt
+# Exchange rate doesn't update table immediately when adding new rate 
+  and no exchange rates there before.
+$ /gl/manage/exchange_rates.php
+# Bug in exchange variation calculation in certain situations. Again.
+$ /gl/includes/db/gl_db_banking.inc
+21-Feb-2010 Janusz Dobrowolski
+# Fixed check for language session var.
+$ /includes/session.inc
+
+19-Feb-2010 Joe Hunt/Ary Wibowo
+# Bug in exchange variation calculation in certain situations.
+$ /gl/includes/gl_db_banking.inc
+! Better and cleaner layout in graphics
+$ /reporting/includes/class.graphic.inc
+! Fixed better layout in customer delivery form
+$ /sales/customer_delivery.php
+
+17-Feb-2010 Joe Hunt
+# Missing border layout in report centre
+$ /reporting/includes/reports_classes.inc
+
+---------- End of changes from main trunk 2.2.6-2.2.7
+
 01-Mar-2010 Janusz Dobrowolski
 + Rewrite of FrontReport header API to accept externally defined headers in php and/or pdf form.
 $ /reporting/includes/class.pdf.inc
index 4bf99a4207a82c558ee02fb332ece51e98b67b00..9f6efa55a9a41c7f51ec9d96e8743b0973184de7 100644 (file)
@@ -99,7 +99,7 @@ function compress_list_row($label, $name, $value=null)
     if (function_exists("gzopen"))
        $ar_comps['gzip'] = "gzip";
 
-       echo "<tr><td>$label</td><td>";
+       echo "<tr><td class='label'>$label</td><td>";
        echo array_selector('comp', $value, $ar_comps);
        echo "</td></tr>";
 }
index 5049a332b8f02c1280d166133118ba140452dde1..29acd007ae6c31105881537f7529e5f13f2d55f6 100644 (file)
@@ -139,6 +139,17 @@ function handle_submit()
                        remove_connection($id);
                        return false;
                }
+       } else {
+               if ($_GET['c'] = 'u') {
+                       $conn = $db_connections[$id];
+                       if (($db = db_create_db($conn)) == 0)
+                       {
+                               display_error(_("Error connecting to Database: ") . $conn['dbname'] . _(", Please correct it"));
+                               $error = true;
+                       } else {
+                               db_query("UPDATE ".$conn['tbpref']."users set password = '".md5($_POST['admpassword']). "' WHERE user_id = 'admin'");
+                       }
+               }
        }
        $error = write_config_db($new);
        if ($error == -1)
@@ -306,7 +317,7 @@ function display_company_edit($selected_id)
                                document.forms[0].action='create_coy.php?c=u&ul=1&id=" . $n . "&fn=' + document.forms[0].uploadfile.value
                        }
                        else {
-                               document.forms[0].action='create_coy.php?c=u&id=" . $n . "&fn=' + document.forms[0].uploadfile.value
+                               document.forms[0].action='create_coy.php?c=u&id=" . $n . "'
                        }
                        document.forms[0].submit()
                }
index 3c2e67ebb1181663111ff192dfaf4a4c4cf8f0ac..22ab9cf1e39f73e82dede4edf5635dfb1fddf24f 100644 (file)
@@ -56,7 +56,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_
        // Main Title
        $app_title = "FrontAccounting";
        // application version
-       $version                = "2.3 CVS (m6)";
+       $version                = "2.3 CVS (m7)";
         // src-data compatibility check. Do not change.
        $core_version = "2.3";
 
@@ -212,7 +212,4 @@ if (!defined('ICON_EDIT'))
        define("ICON_ESCAPE", "escape.png");    
 }
 
-       /* allow using of multi level sub-types when digits are of same length in account types */
-       $use_new_account_types = 0;
-
 ?>
\ No newline at end of file
index d515b179b8825c7d7f1ae9478d38a7092ac67312..035de8ac0c22fe4990911eb3496ccd09aac087a0 100644 (file)
@@ -118,10 +118,10 @@ function create_cart($type=0, $trans_no=0)
        } else {
                $cart->reference = $Refs->get_next(0);
                $cart->tran_date = new_doc_date();
+               if (!is_date_in_fiscalyear($cart->tran_date))
+                       $cart->tran_date = end_fiscalyear();
                $_POST['ref_original'] = -1;
        }
-       if (!is_date_in_fiscalyear($cart->tran_date))
-               $cart->tran_date = end_fiscalyear();
 
        $_POST['memo_'] = $cart->memo_;
        $_POST['ref'] = $cart->reference;
index 34bbdaabd1786c9b26131e4237515d1f0b6e791c..a4004d81339ee7b47571d6f47d1d2777caeb96b0 100644 (file)
@@ -50,31 +50,6 @@ function get_gl_accounts($from=null, $to=null, $type=null)
        return db_query($sql, "could not get gl accounts");
 }
 
-function get_gl_accounts_all($balance=-1)
-{
-       global $use_new_account_types;
-       
-       if ($balance == 1)
-               $where ="WHERE ctype>0 AND ctype<".CL_INCOME;
-       elseif ($balance == 0)  
-               $where ="WHERE ctype>".CL_EQUITY." OR ctype=0"; // backwards compatibility
-       $sql = "SELECT ".TB_PREF."chart_master.account_code, ".TB_PREF."chart_master.account_name, ".TB_PREF."chart_master.account_code2,
-               ".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.id AS AccountType,
-               ".TB_PREF."chart_types.parent, ".TB_PREF."chart_class.class_name AS AccountClassName, ".TB_PREF."chart_class.cid AS ClassID, 
-               ".TB_PREF."chart_class.ctype AS ClassType
-               FROM ".TB_PREF."chart_types INNER JOIN ".TB_PREF."chart_class ON ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid
-               LEFT JOIN ".TB_PREF."chart_master ON ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id ";
-       if ($balance != -1)
-               $sql .= $where;                                 
-       if (isset($use_new_account_types) && $use_new_account_types == 1)
-               $sql .= " ORDER BY ".TB_PREF."chart_class.cid, ".TB_PREF."chart_types.id, parent, ".TB_PREF."chart_master.account_code";
-       else
-               $sql .= " ORDER BY ".TB_PREF."chart_class.cid, IF(parent > 0,parent,".TB_PREF."chart_types.id), 
-                       IF(parent > 0,".TB_PREF."chart_types.id, parent), ".TB_PREF."chart_master.account_code";
-
-       return db_query($sql, "could not get gl accounts");
-}
-
 function get_gl_account($code)
 {
        $sql = "SELECT * FROM ".TB_PREF."chart_master WHERE account_code=".db_escape($code);
index afc9e516ccdad66570c4dd028863e230eb8e9353..cff9e70d0b1bda27aa4d9832a02fd27c5e42b5ac 100644 (file)
@@ -16,25 +16,25 @@ function add_exchange_variation($trans_type, $trans_no, $date_, $acc_id, $accoun
                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=".db_escape($acc_id)." AND trans_date<='".date2sql($date_)."'", 
-               "Transactions for account $account could not be calculated");
-       $row = db_fetch_row($result);
-       $foreign_amount = $row[0];
+       $for_amount = 0;
+
+       // We have to calculate all the currency accounts belonging to the GL account
+       // upto $date_ and calculate with the exchange rates. And then compare with the GL account balance.
+       // 2010-02-23 Joe Hunt with help of Ary Wibowo
+       $sql = "SELECT SUM(bt.amount) AS for_amount, ba.bank_curr_code          
+               FROM ".TB_PREF."bank_trans bt, ".TB_PREF."bank_accounts ba
+               WHERE ba.id = bt.bank_act AND ba.account_code = ".db_escape($account)." AND bt.trans_date<='".date2sql($date_)."'
+               GROUP BY ba.bank_curr_code";    
+       $result = db_query($sql, "Transactions for bank account $acc_id could not be calculated");
+       while ($row = db_fetch($result))
+       {
+               if ($row['for_amount'] == 0)
+                       continue;
+               $rate = get_exchange_rate_from_home_currency($row['bank_curr_code'], $date_);
+               $for_amount += round2($row['for_amount'] * $rate, user_price_dec());
+       }       
        $amount = get_gl_trans_from_to("", $date_, $account);
-       $diff = $amount - (round2($foreign_amount * $rate, user_price_dec()));
-*/
-       $result = db_query("SELECT SUM(bt.amount) AS foreign_amount, SUM(gt.amount) AS amount           
-               FROM ".TB_PREF."bank_trans bt,  ".TB_PREF."gl_trans gt, ".TB_PREF."bank_accounts ba
-               WHERE bt.bank_act=".db_escape($acc_id)." AND bt.trans_date<='".date2sql($date_)."'
-               AND ((bt.amount > 0 AND gt.amount > 0) OR (bt.amount <= 0 AND gt.amount <= 0)) 
-               AND bt.type = gt.type AND bt.trans_no = gt.type_no 
-               AND ba.id = bt.bank_act AND ba.account_code = gt.account",
-               "Transactions for account $account could not be calculated");
-       $row = db_fetch($result);
-       $diff = $row['amount'] - (round2($row['foreign_amount'] * $rate, user_price_dec()));
+       $diff = $amount - $for_amount;
        if ($diff != 0)
        {
                if ($trans_type == null)
index e50fc5f308ae6995876c35213866cffca5005969..05cbc04ef1315f02eafcc42c5fbedc346296dba5 100644 (file)
@@ -40,7 +40,12 @@ function check_data()
                set_focus('BuyRate');
                return false;
        }
-
+       if (get_date_exchange_rate($_POST['curr_abrev'], $_POST['date_']))
+       {
+               display_error( _("The exchange rate for the date is already there."));
+               set_focus('date_');
+               return false;
+       }
        return true;
 }
 
@@ -207,6 +212,8 @@ else
 
        br(1);
        $table->width = "40%";
+       if ($table->rec_count == 0)
+               $table->ready = false;
        display_db_pager($table);
        br(1);
     display_rate_edit();
index 9c502debbee2fd634ca801472afe87f44947885d..797f374e010ca1eefe0428c92d5d7109e4b03747 100644 (file)
@@ -199,7 +199,7 @@ $security_areas =array(
 
        'SA_WORKORDERANALYTIC' => array(SS_MANUF_A|1, _("Work order analytical reports and inquiries")),
        'SA_WORKORDERCOST' => array(SS_MANUF_A|2, _("Manufacturing cost inquiry")),
-       'SA_MANUFBULKREP' => array(SS_SALES_A|3, _("Work order bulk reports")),
+       'SA_MANUFBULKREP' => array(SS_MANUF_A|3, _("Work order bulk reports")),
        'SA_BOMREP' => array(SS_MANUF_A|4, _("Bill of materials reports")),
 //
 // Dimensions
@@ -222,7 +222,7 @@ $security_areas =array(
        'SA_CURRENCY' => array(SS_GL_C|6, _("Currencies")),
        'SA_BANKACCOUNT' => array(SS_GL_C|7, _("Bank accounts")),
        'SA_TAXRATES' => array(SS_GL_C|8, _("Tax rates")),
-       'SA_TAXGROUPS' => array(SS_GL_C|8, _("Tax groups")),
+       'SA_TAXGROUPS' => array(SS_GL_C|12, _("Tax groups")),
        'SA_FISCALYEARS' => array(SS_GL_C|9, _("Fiscal years maintenance")),
        'SA_GLSETUP' => array(SS_GL_C|10, _("Company GL setup")),
        'SA_GLACCOUNTTAGS' => array(SS_GL_C|11, _("GL Account tags")),
index d8f4af1dfb9b290776ad57b4840ceba5bdc0444f..5c5ec42be41a5e208924c0a6593a7e8fedf126b5 100644 (file)
@@ -183,7 +183,7 @@ header("Cache-control: private");
 get_text_init();
 
 // Page Initialisation
-if (!method_exists($_SESSION['language'], 'set_language')) 
+if (!isset($_SESSION['language']) || !method_exists($_SESSION['language'], 'set_language')) 
 {
        $l = array_search_value($dflt_lang, $installed_languages,  'code');
        $_SESSION['language'] = new language($l['name'], $l['code'], $l['encoding'],
index 6d24ed627e03096acf073a98241a1a5d1c217ba8..a5a96b082b82e22df5d889bb7c9d0b75db909499 100644 (file)
@@ -2048,7 +2048,8 @@ function quick_entries_list($name, $selected_id=null, $type=null, $submit_on_cha
 function quick_entries_list_cells($label, $name, $selected_id=null, $type, $submit_on_change=false)
 {
        if ($label != null)
-               echo "<td>$label</td><td>\n";
+               echo "<td>$label</td>\n";
+       echo "<td>";    
        echo quick_entries_list($name, $selected_id, $type, $submit_on_change);
        echo "</td>";
 }
index a6365d7578d42beb5270ff288b2254b330c9a13b..3ed5e314546cb0c744eeba59d8242a201e6f0351 100644 (file)
@@ -398,7 +398,7 @@ function setHotKeys() {
                        }
                        return stopEv(ev);
                }
-               if((ev.ctrlKey && key == 13) || (key == 27 && ev.altKey)) {
+               if((ev.ctrlKey && key == 13) || key == 27) {
                        _hotkeys.alt = false; // cancel link selection
                        _hotkeys.focus = -1;
                        ev.cancelBubble = true;
index ae93a925d745bd5edf30b85f9c068ea90f336bba..d0b822fb95f4783a8f169ce9a92ee4552efc65b7 100644 (file)
@@ -5,8 +5,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: FrontAccounting\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-02-16 15:47+0100\n"
-"PO-Revision-Date: 2010-02-16 15:48+0100\n"
+"POT-Creation-Date: 2010-02-25 17:05+0100\n"
+"PO-Revision-Date: 2010-02-25 17:05+0100\n"
 "Last-Translator: Translation Team <info@frontaccounting.net>\n"
 "Language-Team: Translators\n"
 "MIME-Version: 1.0\n"
index 6f5c001f3df137da8b039d45749195ac6b8f63a8..b9fd16f0e9198ad61d94b74a281e21b4aebc84b8 100644 (file)
@@ -42,7 +42,7 @@ function work_order_produce($woid, $ref, $quantity, $date_, $memo_, $close_wo)
 
        // -------------------------------------------------------------------------
 
-       work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, true);
+       work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, $id);
 
        // -------------------------------------------------------------------------
        // insert a +ve stock move for the item being manufactured
@@ -107,6 +107,8 @@ function void_work_order_produce($type_no)
        // deduct the quantity of this production from the parent work order
        work_order_update_finished_quantity($row["workorder_id"], -$row["quantity"]);
 
+       work_order_quick_costs($row['workorder_id'], $row['stock_id'], -$row['quantity'], sql2date($row['date_']), $type_no);
+
        // clear the production record
        $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".db_escape($type_no);
        db_query($sql, "Cannot void a wo production");
index ba53b5a2b2e69192a086342608545835560790c8..a722c1ed96465a5b4fbd5e2e13111d48b392e1c5 100644 (file)
@@ -57,10 +57,10 @@ function delete_wo_requirements($woid)
 
 //--------------------------------------------------------------------------------------
 
-function update_wo_requirement_issued($woReqID, $quantity)
+function update_wo_requirement_issued($woid, $stock_id, $quantity)
 {
        $sql = "UPDATE ".TB_PREF."wo_requirements SET units_issued = units_issued + ".db_escape($quantity)."
-               WHERE id = ".db_escape($woReqID);
+               WHERE workorder_id = ".db_escape($woid)." AND stock_id = ".db_escape($stock_id);
                                
        db_query($sql, "The work requirements issued quantity couldn't be updated");
 }
index 12f4049fc9183f0a4a826ee97a04ad6f3b2bdba7..1271f611428277a046f8b70d5c52e1a231d9ec32 100644 (file)
@@ -28,14 +28,10 @@ function add_material_cost($stock_id, $qty, $date_)
        $myrow = db_fetch($result);
        $material_cost =  $myrow['material_cost'];
        $qoh = get_qoh_on_date($stock_id, null, $date_);
-       /*
-       if ($qoh + $qty <= 0)
-               $material_cost = 0;
-       else
-       */
        if ($qoh < 0)
                $qoh = 0;
-       $material_cost = ($qoh * $material_cost + $qty * $m_cost) /     ($qoh + $qty);
+       if ($qoh + $qty != 0)   
+               $material_cost = ($qoh * $material_cost + $qty * $m_cost) /     ($qoh + $qty);
        $material_cost = round2($material_cost, $dec);  
        $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=$material_cost
                WHERE stock_id=".db_escape($stock_id);
@@ -54,14 +50,10 @@ function add_overhead_cost($stock_id, $qty, $date_, $costs)
        $myrow = db_fetch($result);
        $overhead_cost =  $myrow['overhead_cost'];
        $qoh = get_qoh_on_date($stock_id, null, $date_);
-       /*
-       if ($qoh + $qty <= 0)
-               $overhead_cost = 0;
-       else
-       */
        if ($qoh < 0)
                $qoh = 0;
-       $overhead_cost = ($qoh * $overhead_cost + $qty * $costs) /      ($qoh + $qty);
+       if ($qoh + $qty != 0)   
+               $overhead_cost = ($qoh * $overhead_cost + $qty * $costs) /      ($qoh + $qty);
        $overhead_cost = round2($overhead_cost, $dec);  
        $sql = "UPDATE ".TB_PREF."stock_master SET overhead_cost=".db_escape($overhead_cost)."
                WHERE stock_id=".db_escape($stock_id);
@@ -80,14 +72,10 @@ function add_labour_cost($stock_id, $qty, $date_, $costs)
        $myrow = db_fetch($result);
        $labour_cost =  $myrow['labour_cost'];
        $qoh = get_qoh_on_date($stock_id, null, $date_);
-       /*
-       if ($qoh + $qty <= 0)
-               $labour_cost = 0;
-       else
-       */
        if ($qoh < 0)
                $qoh = 0;
-       $labour_cost = ($qoh * $labour_cost + $qty * $costs) /  ($qoh + $qty);
+       if ($qoh + $qty != 0)   
+               $labour_cost = ($qoh * $labour_cost + $qty * $costs) /  ($qoh + $qty);
        $labour_cost = round2($labour_cost, $dec);      
        $sql = "UPDATE ".TB_PREF."stock_master SET labour_cost=".db_escape($labour_cost)."
                WHERE stock_id=".db_escape($stock_id);
@@ -104,16 +92,12 @@ function add_issue_cost($stock_id, $qty, $date_, $costs)
        $myrow = db_fetch($result);
        $material_cost =  $myrow['material_cost'];
        $dec = user_price_dec();
-       $material_cost = price_decimal_format($material_cost, $dec); 
+       price_decimal_format($material_cost, $dec); 
        $qoh = get_qoh_on_date($stock_id, null, $date_);
-       /*
-       if ($qoh + $qty  <= 0)
-               $material_cost = 0;
-       else
-       */
        if ($qoh < 0)
                $qoh = 0;
-       $material_cost = ($qty * $costs) /      ($qoh + $qty);
+       if ($qoh + $qty != 0)   
+               $material_cost = ($qty * $costs) /      ($qoh + $qty);
        $material_cost = round2($material_cost, $dec);  
        $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=material_cost+"
                .db_escape($material_cost)
@@ -310,13 +294,22 @@ function work_order_update_finished_quantity($woid, $quantity, $force_close=0)
 
 function void_work_order($woid)
 {
-       $work_order = get_work_order($woid);
+       begin_transaction();
 
+       $work_order = get_work_order($woid);
        if (!($work_order["type"] == WO_ADVANCED))
        {
-               begin_transaction();
-
-               $sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_issued=0 WHERE id = "
+               $date = sql2date($work_order['date_']);
+               $qty = $work_order['units_reqd'];
+               add_material_cost($work_order['stock_id'], -$qty, $date); // remove avg. cost for qty
+               $cost = get_gl_wo_cost($woid, WO_LABOUR); // get the labour cost and reduce avg cost
+               if ($cost != 0)
+                       add_labour_cost($work_order['stock_id'], -$qty, $date, $cost);
+               $cost = get_gl_wo_cost($woid, WO_OVERHEAD); // get the overhead cost and reduce avg cost
+               if ($cost != 0)
+                       add_overhead_cost($work_order['stock_id'], -$qty, $date, $cost);
+
+               $sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_reqd=0,units_issued=0 WHERE id = "
                        .db_escape($woid);
                db_query($sql, "The work order couldn't be voided");
 
@@ -328,13 +321,64 @@ function void_work_order($woid)
 
                // clear the requirements units received
                void_wo_requirements($woid);
-
-               commit_transaction();
        }
        else
        {
                // void everything inside the work order : issues, productions, payments
+               $date = sql2date($work_order['date_']);
+               add_material_cost($work_order['stock_id'], -$work_order['units_reqd'], $date); // remove avg. cost for qty
+               $result = get_work_order_productions($woid); // check the produced quantity
+               $qty = 0;
+               while ($row = db_fetch($result))
+               {
+                       $qty += $row['quantity'];
+                       // clear the production record
+                       $sql = "UPDATE ".TB_PREF."wo_manufacture SET quantity=0 WHERE id=".$$row['id'];
+                       db_query($sql, "Cannot void a wo production");
+                       
+                       void_stock_move(ST_MANURECEIVE, $row['id']); // and void the stock moves; 
+               }
+               $result = get_additional_issues($woid); // check the issued quantities
+               $cost = 0;
+               $issue_no = 0;
+               while ($row = db_fetch($result))
+               {
+                       $std_cost = get_standard_cost($row['stock_id']);
+                       $icost = $std_cost * $row['qty_issued'];
+                       $cost += $icost;
+                       if ($issue_no == 0)
+                               $issue_no = $row['issue_no'];
+                       // void the actual issue items and their quantities
+                       $sql = "UPDATE ".TB_PREF."wo_issue_items SET qty_issued = 0 WHERE issue_id="
+                               .db_escape($row['id']);
+                       db_query($sql,"A work order issue item could not be voided");
+               }       
+               if ($issue_no != 0)
+                       void_stock_move(ST_MANUISSUE, $issue_no); // and void the stock moves 
+               if ($cost != 0)
+                       add_issue_cost($work_order['stock_id'], -$qty, $date, $cost);
+
+               $cost = get_gl_wo_cost($woid, WO_LABOUR); // get the labour cost and reduce avg cost
+               if ($cost != 0)
+                       add_labour_cost($work_order['stock_id'], -$qty, $date, $cost);
+               $cost = get_gl_wo_cost($woid, WO_OVERHEAD); // get the overhead cost and reduce avg cost
+               if ($cost != 0)
+                       add_overhead_cost($work_order['stock_id'], -$qty, $date, $cost);
+               
+               $sql = "UPDATE ".TB_PREF."workorders SET closed=1,units_reqd=0,units_issued=0 WHERE id = "
+                       .db_escape($woid);
+               db_query($sql, "The work order couldn't be voided");
+
+               // void all related stock moves
+               void_stock_move(ST_WORKORDER, $woid);
+
+               // void any related gl trans
+               void_gl_trans(ST_WORKORDER, $woid, true);
+
+               // clear the requirements units received
+               void_wo_requirements($woid);
        }
+       commit_transaction();
 }
 
 function get_sql_for_work_orders($outstanding_only, $all_items)
@@ -410,5 +454,13 @@ function get_sql_for_where_used()
        return $sql;                    
 }
 //--------------------------------------------------------------------------------------
+function get_gl_wo_cost($woid, $cost_type)
+{
+       $cost = 0;
+       $result = get_gl_wo_cost_trans($woid, $cost_type);
+       while ($row = db_fetch($result))
+               $cost += -$row['amount'];
+       return $cost;   
+}
 
 ?>
\ No newline at end of file
index 1b254f753c2bb3bf316fce28c9b5994184b02356..92b984dde11d948cc5e266d7aa4c22727f863993 100644 (file)
@@ -73,7 +73,7 @@ function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type,
 
        // -------------------------------------------------------------------------
 
-       work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, false, $costs, $cr_acc, $labour, $cr_lab_acc);
+       work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, 0, $costs, $cr_acc, $labour, $cr_lab_acc);
 
        // -------------------------------------------------------------------------
 
@@ -87,7 +87,7 @@ function add_work_order_quick($wo_ref, $loc_code, $units_reqd, $stock_id, $type,
 
 //--------------------------------------------------------------------------------------
 
-function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced=false, $costs=0, $cr_acc="", $labour=0, $cr_lab_acc="")
+function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced=0, $costs=0, $cr_acc="", $labour=0, $cr_lab_acc="")
 {
        global $wo_cost_types;
        $result = get_bom($stock_id);
@@ -103,8 +103,9 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced
 
                if ($advanced)
                {
+                       update_wo_requirement_issued($woid, $bom_item['component'], $bom_item["quantity"] * $units_reqd);                       
                        // insert a -ve stock move for each item
-                       add_stock_move(ST_WORKORDER, $bom_item["component"], $woid,
+                       add_stock_move(ST_MANURECEIVE, $bom_item["component"], $advanced,
                                $bom_item["loc_code"], $date_, "", -$bom_item["quantity"] * $units_reqd, 0);
                }
                $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $bom_accounts["inventory_account"], 0, 0,
@@ -128,15 +129,9 @@ function work_order_quick_costs($woid, $stock_id, $units_reqd, $date_, $advanced
                }
                if ($issue_total != 0)
                        add_issue_cost($stock_id, $units_reqd, $date_, $issue_total);
-               $result = get_gl_wo_cost_trans($woid, WO_LABOUR);
-               $lcost = 0;
-               while ($row = db_fetch($result))
-                       $lcost += -$row['amount'];
+               $lcost = get_gl_wo_cost($woid, WO_LABOUR);
                add_labour_cost($stock_id, $units_reqd, $date_, $lcost * $units_reqd / $wo['units_reqd']);
-               $result = get_gl_wo_cost_trans($woid, WO_OVERHEAD);
-               $ocost = 0;
-               while ($row = db_fetch($result))
-                       $ocost += -$row['amount'];
+               $ocost = get_gl_wo_cost($woid, WO_OVERHEAD);
                add_overhead_cost($stock_id, $units_reqd, $date_, $ocost * $units_reqd / $wo['units_reqd']);
        }
        // credit additional costs
index a5e03ecbb9f0c83ad189b973210643c557d528aa..c23dc93f42ca7fe8977743f84c7fa11e27bf7311 100644 (file)
@@ -117,7 +117,7 @@ function can_process()
                $wo_details = get_work_order($_POST['selected_id']);
 
                $qoh = get_qoh_on_date($wo_details["stock_id"], $wo_details["loc_code"], $_POST['date_']);
-               if (-$_POST['quantity'] + $qoh < 0)
+               if (-input_num('quantity') + $qoh < 0)
                {
                        display_error(_("The unassembling cannot be processed because there is insufficient stock."));
                        set_focus('quantity');
@@ -135,7 +135,7 @@ function can_process()
                        if ($row['mb_flag'] == 'D') // service, non stock
                                continue;
                        $qoh = get_qoh_on_date($row["stock_id"], $row["loc_code"], $_POST['date_']);
-                       if ($qoh - $row['units_req'] * $_POST['quantity'] < 0)
+                       if ($qoh - $row['units_req'] * input_num('quantity') < 0)
                        {
                        display_error( _("The production cannot be processed because a required item would cause a negative inventory balance :") .
                                " " . $row['stock_id'] . " - " .  $row['description']);
@@ -164,7 +164,7 @@ if ((isset($_POST['Process']) || isset($_POST['ProcessAndClose'])) && can_proces
        if ($_POST['ProductionType'] == 0)
                $_POST['quantity'] = -$_POST['quantity'];
 
-        $id = work_order_produce($_POST['selected_id'], $_POST['ref'], $_POST['quantity'],
+        $id = work_order_produce($_POST['selected_id'], $_POST['ref'], input_num('quantity'),
                        $_POST['date_'], $_POST['memo_'], $close_wo);
 
        meta_forward($_SERVER['PHP_SELF'], "AddedID=".$_POST['selected_id']."&date=".$_POST['date_']);
@@ -181,10 +181,9 @@ start_form();
 hidden('selected_id', $_POST['selected_id']);
 //hidden('WOReqQuantity', $_POST['WOReqQuantity']);
 
+$dec = get_qty_dec($wo_details["stock_id"]);
 if (!isset($_POST['quantity']) || $_POST['quantity'] == '')
-{
-       $_POST['quantity'] = max($wo_details["units_reqd"] - $wo_details["units_issued"], 0);
-}
+       $_POST['quantity'] = qty_format(max($wo_details["units_reqd"] - $wo_details["units_issued"], 0), $wo_details["stock_id"], $dec);
 
 start_table($table_style2);
 br();
@@ -197,7 +196,7 @@ if (!isset($_POST['ProductionType']))
 yesno_list_row(_("Type:"), 'ProductionType', $_POST['ProductionType'],
        _("Produce Finished Items"), _("Return Items to Work Order"));
 
-small_qty_row(_("Quantity:"), 'quantity', null, null, null, get_qty_dec($wo_details["stock_id"]));
+small_qty_row(_("Quantity:"), 'quantity', null, null, null, $dec);
 
 date_row(_("Date:"), 'date_');
 
index 0b5c0eda85cf87bb60d83faccb9b3e8ad68084fc..51ebcba53dec4d7a17644d972887f4420db5e8b9 100644 (file)
@@ -24,7 +24,6 @@ function update_average_material_cost($supplier, $stock_id, $price, $qty, $date,
        {
                $ex_rate = get_exchange_rate_to_home_currency($currency, $date);
                $price_in_home_currency = $price / $ex_rate;
-               //$price_in_home_currency = to_home_currency($price, $currency, $date);
        }       
        else
                $price_in_home_currency = $price;
@@ -43,17 +42,8 @@ function update_average_material_cost($supplier, $stock_id, $price, $qty, $date,
        if ($adj_only)
        {
                if ($qoh > 0)
-               /*
-               if ($qoh <= 0)
-                       $material_cost = 0;
-               else
-               */
                        $material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) /     $qoh;
        }
-       /*
-       elseif ($qoh + $qty <= 0)
-               $material_cost = 0;
-       */      
        else
        {
                if ($qoh < 0)
@@ -61,8 +51,9 @@ function update_average_material_cost($supplier, $stock_id, $price, $qty, $date,
                        if ($qoh + $qty > 0)
                                $cost_adjust = true;
                        $qoh = 0;
-               }       
-               $material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) /     ($qoh + $qty);
+               }
+               if ($qoh + $qty != 0)
+                       $material_cost = ($qoh * $material_cost + $qty * $price_in_home_currency) /     ($qoh + $qty);
        }       
        $material_cost = round2($material_cost, $dec);
        if ($cost_adjust) // new 2010-02-10
index 7661fb9a1eb7f36b5d1ac1ac9470a70f3fc33329..c862cca236fbd0819bc0d14d38229886025cd939 100644 (file)
@@ -104,12 +104,15 @@ function display_po_header(&$order)
     }
 
        if ($order->supplier_id != get_post('supplier_id',-1)) {
+               $old_supp = $order->supplier_id;
                get_supplier_details_to_order($order, $_POST['supplier_id']);
                // supplier default price update
                foreach ($order->line_items as $line_no=>$item) {
                        $line = &$order->line_items[$line_no];
-                       $line->price =  get_purchase_price ($order->supplier_id, $_POST['stock_id']);
-                       $line->quantity =  get_purchase_conversion_factor ($order->supplier_id, $_POST['stock_id']);
+                       $line->price =  get_purchase_price ($order->supplier_id, $line->stock_id);
+                       $line->quantity =
+                               $line->quantity/get_purchase_conversion_factor ($old_supp, $line->stock_id)
+                                       *get_purchase_conversion_factor ($order->supplier_id, $line->stock_id);
                }
            $Ajax->activate('items_table');
        }
index 20022f1b809145dae49d0c2e73210b95ffe40bb5..c1133648eddd578edba73171f450009c6c341760 100644 (file)
@@ -222,8 +222,8 @@ class graph
         // Fill background
         imagefill($this->img, 0, 0, $this->color['background']);
         //imagefilledrectangle($this->img, 0, 0, $this->width, $this->height, $this->color['background']);
-        if ($border)
-               imagerectangle($this->img, 0, 0, $this->width-1, $this->height-1, imagecolorallocate($this->img, 100, 150, 200));
+        //if ($border)
+        //     imagerectangle($this->img, 0, 0, $this->width-1, $this->height-1, imagecolorallocate($this->img, 100, 150, 200));
 
         // Draw title
         if (!empty($this->title))
@@ -396,7 +396,8 @@ class graph
                 imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars']);
                 $this->_imagestring($this->img, $this->size, ($x2+7), ($y1+2), $this->number_formated($this->y[$i], $this->dec2), $this->color['bars_shadow']);
 
-                $this->_imagestring($this->img, $this->size, ($x1 - ((strlen($parameter)*7)+7)), ($y1+2), $parameter, $this->color['axis_values']);
+                //$this->_imagestring($this->img, $this->size, ($x1 - ((strlen($parameter)*7)+7)), ($y1+2), $parameter, $this->color['axis_values']);
+                $this->_imagestring($this->img, $this->size, 30, ($y1+2), $parameter, $this->color['axis_values']);
             }
         }
 
@@ -811,8 +812,10 @@ class graph
         {
             // Office
             case 1:
-                $this->color['title']       = imagecolorallocate($this->img,  50,  50,  50);
-                $this->color['background']  = imagecolorallocate($this->img, 238, 255, 238);
+                //$this->color['title']       = imagecolorallocate($this->img,  50,  50,  50);
+                $this->color['title']       = imagecolorallocate($this->img,  40,  70,  130);
+                //$this->color['background']  = imagecolorallocate($this->img, 238, 255, 238);
+                $this->color['background']  = imagecolorallocate($this->img, 255, 255, 255);
                 $this->color['axis_values'] = imagecolorallocate($this->img,  50,  50,  50);
                 $this->color['axis_line']   = imagecolorallocate($this->img, 100, 100, 100);
                 $this->color['bg_lines']    = imagecolorallocate($this->img, 220, 220, 220);
@@ -893,11 +896,13 @@ class graph
             // Spring
             case 3:
                 $this->color['title']       = imagecolorallocate($this->img, 250,  50,  50);
-                $this->color['background']  = imagecolorallocate($this->img, 250, 250, 220);
+                //$this->color['background']  = imagecolorallocate($this->img, 250, 250, 220);
+                $this->color['background']  = imagecolorallocate($this->img, 255, 255, 255);
                 $this->color['axis_values'] = imagecolorallocate($this->img,  50, 150,  50);
                 $this->color['axis_line']   = imagecolorallocate($this->img,  50, 100,  50);
                 $this->color['bg_lines']    = imagecolorallocate($this->img, 200, 224, 180);
-                $this->color['bg_legend']   = imagecolorallocate($this->img, 230, 230, 200);
+                //$this->color['bg_legend']   = imagecolorallocate($this->img, 230, 230, 200);
+                $this->color['bg_legend']   = imagecolorallocate($this->img, 255, 255, 255);
 
                 if (preg_match("/^(1|2)$/", $this->type))
                 {
index c76cfed9a7f92f80bc79de5aa8ca6b47fc9ac191..db0e8a888ce1eb09b4ca686558464bff8fbc5a77 100644 (file)
@@ -126,10 +126,10 @@ if (isset($header2type) || isset($linetype))
        $doc_Invoice_no = ($doctype==ST_CUSTDELIVERY ? _("Delivery Note No.") : 
                ($doctype == ST_CUSTPAYMENT ? _("Receipt No.") :
                ($doctype == ST_SUPPAYMENT ? _("Remittance No.") :
-               (($doctype==ST_SALESQUOTE || $doctype==ST_PURCHORDER || $doctype==ST_SALESORDER) ? _("Order no.") : 
-               ($doctype==ST_SALESINVOICE ? _("Invoice No.") : ($doctype==ST_WORKORDER ? _("Word Order No") : _("Credit No.")))))));
+               (($doctype==ST_SALESQUOTE || $doctype==ST_PURCHORDER || $doctype==ST_SALESORDER) ? _("Order No.") : 
+               ($doctype==ST_SALESINVOICE ? _("Invoice No.") : ($doctype==ST_WORKORDER ? _("Word Order No.") : _("Credit No.")))))));
        $doc_Delivery_no = _("Delivery Note No.");
-       $doc_Order_no = _("Order no.");
+       $doc_Order_no = _("Order No.");
 }
 if (isset($linetype))
 {
index 761f60f75a88f30cd019bd541b249b940905a9c6..aa5d3055aa8877058ad91e4bd1264a882d45cc8d 100644 (file)
@@ -126,9 +126,9 @@ if (isset($header2type) || isset($linetype))
                ($doctype == ST_CUSTPAYMENT ? "Receipt No." :
                ($doctype == ST_SUPPAYMENT ? "Remittance No." :
                (($doctype == ST_SALESQUOTE || $doctype==ST_PURCHORDER || $doctype==ST_SALESORDER) ? "Order no." : 
-               ($doctype==ST_SALESINVOICE ? "Invoice No." : ($doctype == ST_WORKORDER ? "Work Order No" : "Credit No."))))));
+               ($doctype==ST_SALESINVOICE ? "Invoice No." : ($doctype == ST_WORKORDER ? "Work Order No." : "Credit No."))))));
        $doc_Delivery_no = "Delivery Note No.";
-       $doc_Order_no = "Order no.";
+       $doc_Order_no = "Order No.";
 }
 if (isset($linetype))
 {
index b6962addd2403d9c8511a1e3f8239403718324bf..414151bafa3c8501e34d382bcaf7f586d0c50bf6 100644 (file)
@@ -1003,10 +1003,10 @@ class FrontReport extends Cpdf
                                        include("includes/doctext.inc");
                                }
                                require_once($path_to_root . "/reporting/includes/class.mail.inc");
-                       $mail = new email($this->company['coy_name'], $this->company['email']);
+                       $mail = new email(str_replace(",", "", $this->company['coy_name']), $this->company['email']);
                                if (!isset($myrow['email']) || $myrow['email'] == '') 
                                        $myrow['email'] = isset($myrow['contact_email']) ? $myrow['contact_email'] : '';
-                       $to = $myrow['DebtorName'] . " <" . $myrow['email'] . ">";
+                       $to = str_replace(",", "", $myrow['DebtorName']) . " <" . $myrow['email'] . ">";
                        $msg = $doc_Dear_Sirs . " " . $myrow['DebtorName'] . ",\n\n" . $doc_AttachedFile . " " . $subject .
                                "\n\n";
                                if (isset($myrow['dimension_id']) && $myrow['dimension_id'] > 0 && $doctype == ST_SALESINVOICE) // helper for payment links
index 97bfa0f6e2845a4b5aba147316831815a8d48968..f9fa8696934174b212ccde8e0f1e613f5f74532d 100644 (file)
@@ -50,7 +50,7 @@ class BoxReports
                                .$_SERVER['PHP_SELF']."?Class=$class_counter'"
                                ." class='menu_option' id='".default_focus()."'"
                                ." onclick='return showClass($class_counter);'$acc[1]>$acc[0]</a> <br>";
-                       $st_reports .= "<table id='TAB_" . $class_counter ."' $style cellpadding=0 cellspacing=0 border=0 width='100%'><tr><td><b>" . _("Reports For Class: ") . "&nbsp;$key</b></td></tr>\n";
+                       $st_reports .= "<table id='TAB_" . $class_counter ."' $style cellpadding=0 cellspacing=0 width='100%'><tr><td><b>" . _("Reports For Class: ") . "&nbsp;$key</b></td></tr>\n";
                        foreach($value as $report)
                        {
                                $acc = access_string($report->name);
@@ -62,7 +62,7 @@ class BoxReports
 
                                        $action = $path_to_root.'/reporting/prn_redirect.php';
        
-                                       $st_params = "<table border=0><tr><td>\n"
+                                       $st_params = "<table><tr><td>\n"
                                                . "<form method='POST' action='$action' target='_blank'>\n";
                                        $st_params .= submit('Rep'.$report->id,  
                                                _("Display: ") . access_string($report->name, true),
@@ -99,9 +99,9 @@ class BoxReports
                                        }
                                </script>
                                ";
-               $st .= "<table align='center' width='80%'><tr valign='top'>";
+               $st .= "<table align='center' width='80%' style='border:1px solid #cccccc;'><tr valign='top'>";
                $st .= "<td width='30%'>$st_classes</td>";
-               $st .= "<td width='35%'>$st_reports</td>";
+               $st .= "<td width='35%' style='border-left:1px solid #cccccc;border-right:1px solid #cccccc;padding-left:3px;'>$st_reports</td>";
                $st .= "<td width='35%'>$st_params</td>";
                $st .= "</tr></table><br>";
 
index 91c7a8d34bc887b0807cecf1d6bd236848f16009..d80046525d51e41f4f15aef17af756c017e05c23 100644 (file)
@@ -182,7 +182,7 @@ function print_invoices()
                        if ($tax_item['included_in_price'])
                        {
                                        $rep->TextCol(3, 7, $doc_Included . " " . $tax_item['tax_type_name'] .
-                                               " (" . $tax_item['rate'] . "%) " . $doc_Amount . ":" . $DisplayTax, -2);
+                                               " (" . $tax_item['rate'] . "%) " . $doc_Amount . ": " . $DisplayTax, -2);
                                }
                        else
                        {
index 05bb3048e57c6e8b1a5cf34f00ff54574b6ff0f2..ca7a27fbf676873e5f5545a93cebba63368ee62e 100644 (file)
@@ -177,7 +177,7 @@ function print_deliveries()
                                if ($tax_item['included_in_price'])
                                {
                                                $rep->TextCol(3, 7, $doc_Included . " " . $tax_item['tax_type_name'] .
-                                                       " (" . $tax_item['rate'] . "%) " . $doc_Amount . ":" . $DisplayTax, -2);
+                                                       " (" . $tax_item['rate'] . "%) " . $doc_Amount . ": " . $DisplayTax, -2);
                                        }
                                else
                                {
index 82ae32a008f34c221a1cc6a14cd69756374ad8f2..c263ea06c510e5cf5b55c3864b1b1bc08225afaa 100644 (file)
@@ -377,7 +377,9 @@ start_table("$table_style width=90%");
 if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) {
        $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->payment, $_POST['DispatchDate']);
 }
-date_row(_("Invoice Dead-line"), 'due_date', '', null, 0, 0, 0, "class='tableheader2'");
+start_row();
+date_cells(_("Invoice Dead-line"), 'due_date', '', null, 0, 0, 0, "class='tableheader2'");
+end_row();
 end_table();
 
 echo "</td></tr>";
index 72bb9f29e9bcdc8c8f827b48c3c92211d1e89169..91c291a0c0b164b0cfedf6b26d4dd2d3c2da1317 100644 (file)
@@ -157,7 +157,7 @@ function del_link($row) {
 }
 
 function select_link($row) {
-       return button("Select".$row["branch_code"],_("Select"), '', ICON_ADD, 'selector');
+       return button("Select".$row["branch_code"], $row["branch_code"], '', ICON_ADD, 'selector');
 }
 
 start_form();
index 1230d8e70685cddb777ea44424387a9b4c57eb6a..3f54bd226aa65ee6871e86e30598f11f57d9ec37 100644 (file)
@@ -162,13 +162,10 @@ function get_tax_for_items($items, $prices, $shipping_cost, $tax_group, $tax_inc
                        {
                                $index = $item_tax['tax_type_id'];
                                if($tax_included==1) {// 2008-11-26 Joe Hunt Taxes are stored without roundings
-                                 //$ret_tax_array[$index]['Value'] += round($prices[$i] * $item_tax['rate'] 
-                                 //    / ($item_tax['rate'] + 100),  user_price_dec());
-                                 $ret_tax_array[$index]['Value'] += ($prices[$i] * $item_tax['rate'] / ($item_tax['rate'] + 100));
-                                 $ret_tax_array[$index]['Net'] += ($prices[$i] * 100 / ($item_tax['rate'] + 100));
+                                 $nprice = get_tax_free_price_for_item($items[$i], $prices[$i], $tax_group, $tax_included);
+                                 $ret_tax_array[$index]['Value'] += ($nprice * $item_tax['rate'] / 100);
+                                 $ret_tax_array[$index]['Net'] += $nprice;
                                } else {
-                                 //$ret_tax_array[$index]['Value'] += 
-                                 //    round($prices[$i] * $item_tax['rate'] / 100,  user_price_dec());
                                  $ret_tax_array[$index]['Value'] += ($prices[$i] * $item_tax['rate'] / 100);
                                  $ret_tax_array[$index]['Net'] += $prices[$i];
                                }
@@ -182,18 +179,26 @@ function get_tax_for_items($items, $prices, $shipping_cost, $tax_group, $tax_inc
                $item_taxes = get_shipping_tax_as_array();
                if ($item_taxes != null) 
                {
+                       if ($tax_included == 1)
+                       {
+                               $tax_rate = 0;
+                               foreach ($item_taxes as $item_tax)
+                               {
+                                       $index = $item_tax['tax_type_id'];
+                                       if(isset($ret_tax_array[$index])) {
+                                               $tax_rate += $item_tax['rate'];
+                                       }
+                               }
+                               $shipping_net = round2($shipping_cost / (1 + ($tax_rate / 100)), user_price_dec());
+                       }       
                        foreach ($item_taxes as $item_tax) 
                        {
                                $index = $item_tax['tax_type_id'];
                                if(isset($ret_tax_array[$index])) {
                                  if($tax_included==1) {// 2008-11-26 Joe Hunt Taxes are stored without roundings
-                                       //$ret_tax_array[$index]['Value'] += round($shipping_cost * $item_tax['rate'] 
-                                       //  / ($item_tax['rate'] + 100),  user_price_dec());
-                                       $ret_tax_array[$index]['Value'] += ($shipping_cost * $item_tax['rate'] / ($item_tax['rate'] + 100));
-                                   $ret_tax_array[$index]['Net'] += ($shipping_cost * 100 / ($item_tax['rate'] + 100));
+                                       $ret_tax_array[$index]['Value'] += ($shipping_net * $item_tax['rate'] / 100);
+                                   $ret_tax_array[$index]['Net'] += $shipping_net;
                                  } else {
-                                       //$ret_tax_array[$index]['Value'] += 
-                                       //  round($shipping_cost * $item_tax['rate'] / 100,  user_price_dec());
                                        $ret_tax_array[$index]['Value'] += ($shipping_cost * $item_tax['rate'] / 100);
                                    $ret_tax_array[$index]['Net'] += $shipping_cost;
                                 }
index df509509a6a8c5d39e2a6018dc9f7ed95ebeb1da..596ab68dbaf7f8f6e48f1dccf945851322d24dd9 100644 (file)
@@ -18,13 +18,13 @@ these files. </li></ul><ol>
         </ol>
 
       </li><li>Upload all the new files.
-      </li><li>Look into the file, <span style="font-weight: bold; font-style: italic;">config.default.php and compare with your own config.php</span> file. You should update the the following in your config.php:<br /><br /></li><ul><li><small>Change the $version in your <span style="font-weight: bold;">config.php</span> file, about line 59, from "2.X.X" to "2.2.6".</small></li><li><small>Copy &nbsp;the 2 lines from config.default file, about line &nbsp;122:<br /><br /><span style="font-family: monospace;">$table_style &nbsp;&nbsp;&nbsp; = "class='tablestyle'";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style2 &nbsp;&nbsp;&nbsp; = "class='tablestyle2'";</span><br style="font-family: monospace;" /><br />into&nbsp;config.php about line &nbsp;122 and replace these 4 lines:<br /><br /><span style="font-family: monospace;">if (!isset($_SESSION['bordercolor']))</span><br style="font-family: monospace;" /><span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; $_SESSION['bordercolor'] = "#8cacbb";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style &nbsp;&nbsp;&nbsp; = "cellpadding=3 border=1 bordercolor='".$_SESSION['bordercolor']."' class='tablestyle'";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style2 &nbsp;&nbsp;&nbsp; = "cellpadding=3 border=1 bordercolor='#cccccc' class='tablestyle2'";</span><br style="font-family: monospace;" /><br />If this is an update from 2.2.3, 2.2.4 , 2.2.5 to 2.2.6&nbsp; </small><small>you are<span style="font-weight: bold;"> </span><span style="font-style: italic; font-weight: bold;">done and &nbsp;should ignore the the rest of the items in this note</span>.<br /></small></li><li><small>Copy these 2 lines from <span style="font-weight: bold;">config.default.php</span> at the bottom into <span style="font-weight: bold;">config.php</span> at the bottom:<br /><span style="font-family: monospace;"><br />/* allow using of multi level sub-types when digits are of same length in account types */</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$use_new_account_types = 0;</span><br style="font-family: monospace;" /><span style="font-family: monospace;">Change this to 1 if you want to use new multi level sup-types.</span><br style="font-family: monospace;" /></small></li><li><small>If this is an update from "2.2.X" to "2.2.5" you are<span style="font-weight: bold;"> </span><span style="font-style: italic; font-weight: bold;">done and &nbsp;should ignore the the rest of the items in this note</span>.<br /></small></li><li><small>Copy these 2 lines from <span style="font-weight: bold;">config.default.php</span> about line 80-82 into <span style="font-weight: bold;">config.php</span> about line 80:<br /><br /><span style="font-family: monospace;">/* Show users online discretetely in the footer */</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$show_users_online = 0;</span><br style="font-family: monospace;" /><span style="font-family: monospace;">Change this to 1 if you want to show users online.</span><br style="font-family: monospace;" /></small></li><li><small>Replace the 2 lines about line 110-111 in <span style="font-weight: bold;">config.php</span>:<br /><br /><span style="font-family: monospace;">$table_style &nbsp;&nbsp;&nbsp; = "cellpadding=3 border=1 bordercolor='#8cacbb' style='border-collapse: collapse'";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style2 &nbsp;&nbsp; &nbsp;= "cellpadding=3 border=1 bordercolor='#cccccc' style='border-collapse: collapse'";</span><br style="font-family: monospace;" /></small></li><li><small>With these 4 lines from <span style="font-weight: bold;">config.default.php</span>:<br /><br /><span style="font-family: monospace;">if (!isset($_SESSION['bordercolor']))</span><br style="font-family: monospace;" /><span style="font-family: monospace;">&nbsp; &nbsp; $_SESSION['bordercolor'] = "#8cacbb";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style &nbsp;&nbsp;&nbsp; = "cellpadding=3 border=1 bordercolor='".$_SESSION['bordercolor']."' class='tablestyle'";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style2 &nbsp;&nbsp;&nbsp; = "cellpadding=3 border=1 bordercolor='#cccccc' class='tablestyle2'";</span><br style="font-family: monospace;" /></small></li><li><small>Remove these 2 lines from <span style="font-weight: bold;">config.php</span> about line 176-177:<br /><br /><span style="font-family: monospace;">/* default start-up tab (orders/AP/stock/manuf/proj/GL/system) */</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$def_app = "orders";</span><br style="font-family: monospace;" /></small></li><li><small>Copy these 3 lines from config.default.php about line 113-115<br /><br /><span style="font-family: monospace;">// defalt dateformats and dateseps indexes used before user login</span></small><br style="font-family: monospace;" /><small style="font-family: monospace;">$dflt_date_fmt = 0;</small><br style="font-family: monospace;" /><small><span style="font-family: monospace;">$dflt_date_sep = 0;</span><br style="font-family: monospace;" /></small></li><li><small>Copy these 2 lines from <span style="font-weight: bold;">config.default.php</span> about line 211-212:<br /><br /><span style="font-family: monospace;">define("ICON_SUBMIT", "ok.gif");&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // new in 2.2</span><br style="font-family: monospace;" /><span style="font-family: monospace;">define("ICON_ESCAPE", "escape.png");&nbsp;&nbsp;&nbsp; // new in 2.2</span><br style="font-family: monospace;" /></small></li><li><small>And paste them into <span style="font-weight: bold;">config.php</span> about line 209</small></li><li><small>If you use gregorian calendar and have non-workdays on Friday and first day of week = Saturday<br />then you &nbsp;should &nbsp;set this line in <span style="font-weight: bold;">config.php</span> about line&nbsp; 95.<br /></small><pre><small>$date_system = 3;</small></pre></li><li><small>If you want to use FrontAccounting help wiki then set this line in config.php about line 85<br /></small><pre><small>$help_base_url = "http://frontaccounting.net/fawiki?n=Help.";<br /></small></pre></li></ul><li>Rename or remove the /install folder (you have already performed the install
+      </li><li>Look into the file, <span style="font-weight: bold; font-style: italic;">config.default.php and compare with your own config.php</span> file. You should update the the following in your config.php:<br /><br /></li><ul><li><small>Change the $version in your <span style="font-weight: bold;">config.php</span> file, about line 59, from "2.X.X" to "2.2.7".<br /><br />if this is an update from 2.2.6 to 2.276&nbsp;</small><small> </small><small>you are<span style="font-weight: bold;"> </span><span style="font-style: italic; font-weight: bold;">done and &nbsp;should ignore the the rest of the items in this note</span>.</small></li><li><small>Copy &nbsp;the 2 lines from config.default file, about line &nbsp;122:<br /><br /><span style="font-family: monospace;">$table_style &nbsp;&nbsp;&nbsp; = "class='tablestyle'";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style2 &nbsp;&nbsp;&nbsp; = "class='tablestyle2'";</span><br style="font-family: monospace;" /><br />into&nbsp;config.php about line &nbsp;122 and replace these 4 lines:<br /><br /><span style="font-family: monospace;">if (!isset($_SESSION['bordercolor']))</span><br style="font-family: monospace;" /><span style="font-family: monospace;">&nbsp;&nbsp;&nbsp; $_SESSION['bordercolor'] = "#8cacbb";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style &nbsp;&nbsp;&nbsp; = "cellpadding=3 border=1 bordercolor='".$_SESSION['bordercolor']."' class='tablestyle'";</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$table_style2 &nbsp;&nbsp;&nbsp; = "cellpadding=3 border=1 bordercolor='#cccccc' class='tablestyle2'";</span><br style="font-family: monospace;" /><br />If this is an update from 2.2.3, 2.2.4 , 2.2.5 to 2.2.7&nbsp; </small><small>you are<span style="font-weight: bold;"> </span><span style="font-style: italic; font-weight: bold;">done and &nbsp;should ignore the the rest of the items in this note</span>.<br /></small></li><li><small>Copy these 2 lines from <span style="font-weight: bold;">config.default.php</span> about line 80-82 into <span style="font-weight: bold;">config.php</span> about line 80:<br /><br /><span style="font-family: monospace;">/* Show users online discretetely in the footer */</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$show_users_online = 0;</span><br style="font-family: monospace;" /><span style="font-family: monospace;">Change this to 1 if you want to show users online.</span><br style="font-family: monospace;" /></small></li><li><small>Remove these 2 lines from <span style="font-weight: bold;">config.php</span> about line 176-177:<br /><br /><span style="font-family: monospace;">/* default start-up tab (orders/AP/stock/manuf/proj/GL/system) */</span><br style="font-family: monospace;" /><span style="font-family: monospace;">$def_app = "orders";</span><br style="font-family: monospace;" /></small></li><li><small>Copy these 3 lines from config.default.php about line 113-115<br /><br /><span style="font-family: monospace;">// defalt dateformats and dateseps indexes used before user login</span></small><br style="font-family: monospace;" /><small style="font-family: monospace;">$dflt_date_fmt = 0;</small><br style="font-family: monospace;" /><small><span style="font-family: monospace;">$dflt_date_sep = 0;</span><br style="font-family: monospace;" /></small></li><li><small>Copy these 2 lines from <span style="font-weight: bold;">config.default.php</span> about line 211-212:<br /><br /><span style="font-family: monospace;">define("ICON_SUBMIT", "ok.gif");&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // new in 2.2</span><br style="font-family: monospace;" /><span style="font-family: monospace;">define("ICON_ESCAPE", "escape.png");&nbsp;&nbsp;&nbsp; // new in 2.2</span><br style="font-family: monospace;" /></small></li><li><small>And paste them into <span style="font-weight: bold;">config.php</span> about line 209</small></li><li><small>If you use gregorian calendar and have non-workdays on Friday and first day of week = Saturday<br />then you &nbsp;should &nbsp;set this line in <span style="font-weight: bold;">config.php</span> about line&nbsp; 95.<br /></small><pre><small>$date_system = 3;</small></pre></li><li><small>If you want to use FrontAccounting help wiki then set this line in config.php about line 85<br /></small><pre><small>$help_base_url = "http://frontaccounting.net/fawiki?n=Help.";<br /></small></pre></li></ul><li>Rename or remove the /install folder (you have already performed the install
 process earlier).<br /></li></ul><ol>
 
 
 
     </ol>
-  </li><li><strong>You
+  </li><li><strong>There are no database changes during a major and minor release. Like from 2.2 to 2.2.1 - 2.2.X .</strong></li><li><strong>If you are upgrading from an earlier installation you
 must immediately
 login on company 0, the first company you created, as&nbsp;admin
 (called the superadmin). If you use a theme other than the standard 3,
@@ -35,7 +35,7 @@ to the 'Setup' tab and run 'Software
 Upgrade'.
 Mark the checkbox 'Install' and press 'Upgrade System'. &nbsp;You must
 also do this if you upgrade from 2.2 Beta to 2.2 RC. This will
-upgrade ALL your companies.<br /></strong></li><li style="font-weight: bold;">If something goes wrong during upgrade, you can enter here again and try 'Force Upgrade', and press 'Upgrade System' again.<br /></li><li><strong>There are no database changes during a major and minor release. Like from 2.2 to 2.2.1 - 2.2.X .<br /></strong></li><li style="font-weight: bold;">Enter
+upgrade ALL your companies.<br /></strong></li><li style="font-weight: bold;">If something goes wrong during upgrade, you can enter here again and try 'Force Upgrade', and press 'Upgrade System' again.<br /></li><li style="font-weight: bold;">Enter
 'Setup' tab, 'System and Generel GL Setup'. &nbsp;Set the correct
 Accounts for Retained Earnings, Profit/Loss Year and Bank Charge.<br /></li><li style="font-weight: bold;">Enter
 'Setup' tab, 'Access Setup'. Check all the roles and change as you