From: Janusz Dobrowolski Date: Mon, 8 Dec 2008 16:21:30 +0000 (+0000) Subject: Merged changes in main trunk up to 2.0.6 (see CHANGELOG) X-Git-Tag: v2.4.2~19^2~1685 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=b6af4ea4c99734cfd051395289107bbba5a405e9;p=fa-stable.git Merged changes in main trunk up to 2.0.6 (see CHANGELOG) --- diff --git a/admin/create_coy.php b/admin/create_coy.php index dc420a16..9811d994 100644 --- a/admin/create_coy.php +++ b/admin/create_coy.php @@ -146,19 +146,10 @@ function handle_submit() { return false; } - $index = ""; if ($new) { - $cdir = $comp_path.'/'.$id; - @mkdir($cdir); - save_to_file($cdir.'/'.'index.php', 0, $index); - - foreach($comp_subdirs as $dir) - { - @mkdir($cdir.'/'.$dir); - save_to_file($cdir.'/'.$dir.'/'.'index.php', 0, $index); - } + create_comp_dirs("$comp_path/$id", $comp_subdirs); } return true; } diff --git a/admin/db/maintenance_db.inc b/admin/db/maintenance_db.inc index ff7db9ca..1d9a0273 100644 --- a/admin/db/maintenance_db.inc +++ b/admin/db/maintenance_db.inc @@ -642,5 +642,21 @@ function save_to_file($backupfile, $zip, $fileData) } } - +function create_comp_dirs($comp_path, $comp_subdirs) +{ + $index = ""; + $cdir = $comp_path; + @mkdir($cdir); + $f = @fopen("$cdir/index.php", "wb"); + @fwrite($f, $index); + @fclose($f); + + foreach($comp_subdirs as $dir) + { + @mkdir($cdir.'/'.$dir); + $f = @fopen("$cdir/$dir/index.php", "wb"); + @fwrite($f, $index); + @fclose($f); + } +} ?> \ No newline at end of file diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index 518e73c1..ca3d5867 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -20,8 +20,9 @@ function add_bank_transfer($from_account, $to_account, $date_, $from_gl_account = get_bank_gl_account($from_account); $to_gl_account = get_bank_gl_account($to_account); + $total = 0; // do the source account postings - add_gl_trans($trans_type, $trans_no, $date_, $from_gl_account, 0, 0, "", + $total += add_gl_trans($trans_type, $trans_no, $date_, $from_gl_account, 0, 0, "", -$amount, $currency); add_bank_trans($trans_type, $trans_no, $from_account, $ref, @@ -30,9 +31,11 @@ function add_bank_transfer($from_account, $to_account, $date_, "Cannot insert a source bank transaction"); // do the destination account postings - add_gl_trans($trans_type, $trans_no, $date_, $to_gl_account, 0, 0, "", + $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); + add_bank_trans($trans_type, $trans_no, $to_account, $ref, $date_, $amount, payment_person_types::misc(), "", $currency, "Cannot insert a destination bank transaction"); @@ -108,9 +111,11 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, -$total_amount, $currency, $person_type_id, $person_id); add_bank_trans($trans_type, $trans_no, $from_account, $ref, - $date_, -$total_amount, $person_type_id, $person_id, - $currency, "Cannot insert a source bank transaction"); - + $date_, -$total_amount, + $person_type_id, $person_id, + $currency, + "Cannot insert a source bank transaction"); + $total = 0; foreach ($items->gl_items as $gl_item) { $is_bank_to = is_bank_account($gl_item->code_id); @@ -122,7 +127,7 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, } // do the destination account postings - add_gl_trans($trans_type, $trans_no, $date_, $gl_item->code_id, + $total += add_gl_trans($trans_type, $trans_no, $date_, $gl_item->code_id, $gl_item->dimension_id, $gl_item->dimension2_id, $gl_item->reference, $gl_item->amount, $currency, $person_type_id, $person_id); @@ -134,6 +139,10 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_, } } + // do the source account postings + add_gl_trans($trans_type, $trans_no, $date_, $bank_gl_account, 0, 0, "", + -$total, null, $person_type_id, $person_id); + add_comments($trans_type, $trans_no, $date_, $memo_); references::save_last($ref, $trans_type); diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index 30750bbb..af74ee3c 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -18,10 +18,10 @@ function add_gl_trans($type, $trans_id, $date_, $account, $dimension, $dimension if ($rate == 0) $amount_in_home_currency = to_home_currency($amount, $currency, $date_); else - $amount_in_home_currency = round($amount * $rate, user_price_dec()); + $amount_in_home_currency = round2($amount * $rate, user_price_dec()); } else - $amount_in_home_currency = $amount; + $amount_in_home_currency = round2($amount, user_price_dec()); if ($dimension == null || $dimension < 0) $dimension = 0; if ($dimension2 == null || $dimension2 < 0) @@ -52,7 +52,8 @@ function add_gl_trans($type, $trans_id, $date_, $account, $dimension, $dimension if ($err_msg == "") $err_msg = "The GL transaction could not be inserted"; - return db_query($sql, $err_msg); + db_query($sql, $err_msg); + return $amount_in_home_currency; } //-------------------------------------------------------------------------------- @@ -68,9 +69,20 @@ function add_gl_trans_std_cost($type, $trans_id, $date_, $account, $dimension, $ return add_gl_trans($type, $trans_id, $date_, $account, $dimension, $dimension2, $memo_, $amount, null, $person_type_id, $person_id, $err_msg); else - return null; + return 0; } +// Function for even out rounding problems +function add_gl_balance($type, $trans_id, $date_, $amount, $person_type_id=null, $person_id=null) +{ + $amount = round2($amount, user_price_dec()); + if ($amount != 0) + return add_gl_trans($type, $trans_id, $date_, get_company_pref('exchange_diff_act'), 0, 0, "", + $amount, null, $person_type_id, $person_id, "The balanced GL transaction could not be inserted"); + else + return 0; +} + //-------------------------------------------------------------------------------- function get_gl_transactions($from_date, $to_date, $trans_no=0, diff --git a/includes/banking.inc b/includes/banking.inc index 39b904c8..49fb68b1 100644 --- a/includes/banking.inc +++ b/includes/banking.inc @@ -116,7 +116,7 @@ function get_exchange_rate_to_home_currency($currency_code, $date_) function to_home_currency($amount, $currency_code, $date_) { $ex_rate = get_exchange_rate_to_home_currency($currency_code, $date_); - return round($amount / $ex_rate, user_price_dec()); + return round2($amount / $ex_rate, user_price_dec()); } //---------------------------------------------------------------------------------- @@ -174,8 +174,8 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am } if (is_company_currency($curr)) return; - $inv_amt = round($amount * $trans['rate'], user_price_dec()); - $pay_amt = round($amount * $pyt_trans['rate'], user_price_dec()); + $inv_amt = round2($amount * $trans['rate'], user_price_dec()); + $pay_amt = round2($amount * $pyt_trans['rate'], user_price_dec()); if ($inv_amt != $pay_amt) { $diff = $inv_amt - $pay_amt; diff --git a/includes/current_user.inc b/includes/current_user.inc index 1a9396d3..fbd54bf1 100644 --- a/includes/current_user.inc +++ b/includes/current_user.inc @@ -123,12 +123,20 @@ class current_user //-------------------------------------------------------------------------- +function round2($number, $decimals=0) +{ + $delta = ($number < 0 ? -.000001 : .000001); + return round($number+$delta, $decimals); +} + function number_format2($number, $decimals=0) { global $thoseps, $decseps; $tsep = $thoseps[$_SESSION["wa_current_user"]->prefs->tho_sep()]; $dsep = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()]; - return number_format($number, $decimals, $dsep, $tsep); + //return number_format($number, $decimals, $dsep, $tsep); + $delta = ($number < 0 ? -.000001 : .000001); + return number_format($number+$delta, $decimals, $dsep, $tsep); } // // Current ui mode. diff --git a/manufacturing/view/wo_production_view.php b/manufacturing/view/wo_production_view.php index 64e287e7..1558f67c 100644 --- a/manufacturing/view/wo_production_view.php +++ b/manufacturing/view/wo_production_view.php @@ -5,7 +5,10 @@ $path_to_root="../.."; include_once($path_to_root . "/includes/session.inc"); -page(_("View Work Order Production"), true); +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); +page(_("View Work Order Production"), true, false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); diff --git a/purchasing/includes/db/invoice_db.inc b/purchasing/includes/db/invoice_db.inc index ab76757c..96fa45ce 100644 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@ -91,12 +91,20 @@ function get_deliveries_between($stock_id, $from, $to) { $from = date2sql($from); $to = date2sql($to); - $sql = "SELECT SUM(-qty), AVG(standard_cost) FROM ".TB_PREF."stock_moves + $sql = "SELECT SUM(-qty), SUM(-qty*standard_cost) FROM ".TB_PREF."stock_moves WHERE type=13 AND stock_id='$stock_id' AND tran_date>='$from' AND tran_date<='$to' GROUP BY stock_id"; $result = db_query($sql, "The deliveries could not be updated"); return db_fetch_row($result); } + +function get_diff_in_home_currency($supplier, $old_date, $date, $amount1, $amount2) +{ + $currency = get_supplier_currency($supplier); + $amount1 = to_home_currency($amount1, $currency, $old_date); + $amount2 = to_home_currency($amount2, $currency, $date); + return $amount2 - $amount1; +} //---------------------------------------------------------------------------------------- function add_supp_invoice($supp_trans) // do not receive as ref because we change locally @@ -133,9 +141,10 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang $supp_trans->reference, $supp_trans->supp_reference, $invoice_items_total, $tax_total, $supp_trans->ov_discount); + $total = 0; /* Now the control account */ $supplier_accounts = get_supplier_accounts($supp_trans->supplier_id); - add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier_accounts["payable_account"], 0, 0, + $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $supplier_accounts["payable_account"], 0, 0, -($invoice_items_total + $tax_total + $supp_trans->ov_discount), $supp_trans->supplier_id, "The general ledger transaction for the control total could not be added"); @@ -151,7 +160,6 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang between the std cost and the currency cost charged as converted at the ex rate of of the invoice is written off to the purchase price variance account applicable to the item being invoiced. */ - foreach ($supp_trans->gl_codes as $entered_gl_code) { @@ -162,7 +170,7 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang $entered_gl_code->amount = -$entered_gl_code->amount; $memo_ = $entered_gl_code->memo_; - add_gl_trans_supplier($trans_type, $invoice_id, $date_, $entered_gl_code->gl_code, + $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $entered_gl_code->gl_code, $entered_gl_code->gl_dim, $entered_gl_code->gl_dim2, $entered_gl_code->amount, $supp_trans->supplier_id); add_supp_invoice_gl_item($trans_type, $invoice_id, $entered_gl_code->gl_code, @@ -181,7 +189,7 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang $line_tax = $entered_grn->full_charge_price($supp_trans->tax_group_id) - $line_taxfree; $stock_gl_code = get_stock_gl_code($entered_grn->item_code); - add_gl_trans_supplier($trans_type, $invoice_id, $date_, $stock_gl_code["inventory_account"], + $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $stock_gl_code["inventory_account"], $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $entered_grn->this_quantity_inv * $line_taxfree, $supp_trans->supplier_id); // -------------- if price changed since po received. 16 Aug 2008 Joe Hunt @@ -197,41 +205,39 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang $old_price = $old[2]; - - /* If statement is removed. Should always check for deliveries nomatter if there has been a price change. */ //if ($old_price != $entered_grn->chg_price) // price-change, so update //{ - $diff = $entered_grn->chg_price - $old_price; - $old_date = sql2date($old[1]); - // only update the diff (last parameter, adj_only is set to true). - $mat_cost = update_average_material_cost($supp_trans->supplier_id, $entered_grn->item_code, - $diff, $entered_grn->this_quantity_inv, $old_date, true); - // added 2008-12-08 Joe Hunt. Update the purchase data table - add_or_update_purchase_data($supp_trans->supplier_id, $entered_grn->item_code, $entered_grn->chg_price); - - // function just above this - $deliveries = get_deliveries_between($entered_grn->item_code, $old_date, $date_); - if ($deliveries[0] != 0) // have deliveries been done during the period? + //$diff = $entered_grn->chg_price - $old_price; + $old_date = sql2date($old[1]); + $diff = get_diff_in_home_currency($supp_trans->supplier_id, $old_date, $date_, $old_price, + $entered_grn->chg_price); + // always return due to change in currency. + $mat_cost = update_average_material_cost(null, $entered_grn->item_code, + $diff, $entered_grn->this_quantity_inv, $old_date, true); + // added 2008-12-08 Joe Hunt. Update the purchase data table + add_or_update_purchase_data($supp_trans->supplier_id, $entered_grn->item_code, $entered_grn->chg_price); + $deliveries = get_deliveries_between($entered_grn->item_code, $old_date, Today()); // extend the period, if invoice is before any deliveries. + if ($deliveries[0] != 0) // have deliveries been done during the period? + { + $deliveries[1] /= $deliveries[0]; + $amt = ($mat_cost - $deliveries[1]) * $deliveries[0]; // $amt in home currency + if ($amt != 0.0) { - - $amt = ($mat_cost - $deliveries[1]) * $deliveries[0]; // $amt in home currency - if ($amt != 0.0) - { - add_gl_trans($trans_type, $invoice_id, $date_, $stock_gl_code["cogs_account"], - $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], _("Cost diff."), - $amt, null, null, null, - "The general ledger transaction could not be added for the price variance of the inventory item"); - add_gl_trans($trans_type, $invoice_id, $date_, $stock_gl_code["inventory_account"], - 0, 0, _("Cost diff."), -$amt, null, null, null, - "The general ledger transaction could not be added for the price variance of the inventory item"); - } - update_stock_move_pid(13, $entered_grn->item_code, $old_date, $date_, 0, $mat_cost); - } - update_stock_move_pid(25, $entered_grn->item_code, $old_date, $old_date, $supp_trans->supplier_id, $mat_cost); - //} + add_gl_trans($trans_type, $invoice_id, $date_, $stock_gl_code["cogs_account"], + $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], _("Cost diff."), + $amt, null, null, null, + "The general ledger transaction could not be added for the price variance of the inventory item"); + add_gl_trans($trans_type, $invoice_id, $date_, $stock_gl_code["inventory_account"], + 0, 0, _("Cost diff."), -$amt, null, null, null, + "The general ledger transaction could not be added for the price variance of the inventory item"); + } + update_stock_move_pid(13, $entered_grn->item_code, $old_date, $date_, 0, $mat_cost); + } + update_stock_move_pid(25, $entered_grn->item_code, $old_date, $old_date, $supp_trans->supplier_id, $mat_cost); + //} } // ---------------------------------------------------------------------- @@ -251,12 +257,16 @@ function add_supp_invoice($supp_trans) // do not receive as ref because we chang add_supp_invoice_tax_item($trans_type, $invoice_id, $taxitem['tax_type_id'], $taxitem['rate'], 0, $taxitem['Value']); - add_gl_trans_supplier($trans_type, $invoice_id, $date_, + $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'], $supp_trans->supplier_id, "A general ledger transaction for the tax amount could not be added"); } } + + /*Post a balance post if $total != 0 */ + add_gl_balance($trans_type, $invoice_id, $date_, -$total, payment_person_types::supplier(), $supp_trans->supplier_id); + add_comments($trans_type, $invoice_id, $date_, $supp_trans->Comments); references::save_last($supp_trans->reference, $trans_type); @@ -371,20 +381,22 @@ function void_supp_invoice($type, $type_no) $old = update_supp_received_items_for_invoice($details_row["grn_item_id"], $details_row["po_detail_item_id"], -$details_row["quantity"], $details_row["FullUnitPrice"]); - $diff = $details_row["FullUnitPrice"] - $old[2]; + //$diff = $details_row["FullUnitPrice"] - $old[2]; $old_date = sql2date($old[1]); $batch = get_grn_batch_from_item($details_row["grn_item_id"]); $grn = get_grn_batch($batch); + $diff = get_diff_in_home_currency($grn["supplier_id"], $old_date, $date_, $old[2], + $details_row["FullUnitPrice"]); // Only adjust the avg for the diff - $mat_cost = update_average_material_cost($grn["supplier_id"], $details_row["stock_id"], - $diff, -$details_row["quantity"], $date_, true); + $mat_cost = update_average_material_cost(null, $details_row["stock_id"], + $diff, -$details_row["quantity"], $date_, true); $deliveries = get_deliveries_between($details_row["stock_id"], $old_date, $date_); if ($deliveries[0] != 0) // have deliveries been done during the period? { - + $deliveries[1] /= $deliveries[0]; $amt = ($mat_cost - $deliveries[1]) * $deliveries[0]; // $amt in home currency if ($amt != 0.0) { diff --git a/purchasing/includes/db/supp_payment_db.inc b/purchasing/includes/db/supp_payment_db.inc index d15deb80..5d9b382b 100644 --- a/purchasing/includes/db/supp_payment_db.inc +++ b/purchasing/includes/db/supp_payment_db.inc @@ -16,8 +16,8 @@ function add_supp_payment($supplier_id, $date_, $bank_account, } else { - $supp_amount = $amount / $rate; - $supp_discount = $discount / $rate; + $supp_amount = round($amount / $rate, user_price_dec()); + $supp_discount = round($discount / $rate, user_price_dec()); } @@ -30,24 +30,27 @@ function add_supp_payment($supplier_id, $date_, $bank_account, // Now debit creditors account with payment + discount + $total = 0; $supplier_accounts = get_supplier_accounts($supplier_id); - - add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payable_account"], 0, 0, + $total += add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payable_account"], 0, 0, $supp_amount + $supp_discount, $supplier_id, "", $rate); // Now credit discount received account with discounts if ($supp_discount != 0) { - add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payment_discount_account"], 0, 0, + $total += add_gl_trans_supplier($trans_type, $payment_id, $date_, $supplier_accounts["payment_discount_account"], 0, 0, -$supp_discount, $supplier_id, "", $rate); } if ($supp_amount != 0) { - add_gl_trans_supplier($trans_type, $payment_id, $date_, $bank_gl_account, 0, 0, + $total += add_gl_trans_supplier($trans_type, $payment_id, $date_, $bank_gl_account, 0, 0, -$supp_amount, $supplier_id, "", $rate); } + /*Post a balance post if $total != 0 */ + add_gl_balance($trans_type, $payment_id, $date_, -$total, payment_person_types::supplier(), $supplier_id); + /*now enter the bank_trans entry */ add_bank_trans($trans_type, $payment_id, $bank_account, $ref, $date_, -($amount), payment_person_types::supplier(), diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index 007ee29a..07d83546 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -361,7 +361,7 @@ class FrontReport extends Cpdf function NewLine($l=1, $np=0) { $this->row -= ($l * $this->lineHeight); - if ($np > 0 && $this->row < $this->bottomMargin + ($np * $this->lineHeight)) + if ($this->row < $this->bottomMargin + ($np * $this->lineHeight)) $this->Header(); } diff --git a/reporting/rep107.php b/reporting/rep107.php index 1288e517..05b28c3f 100644 --- a/reporting/rep107.php +++ b/reporting/rep107.php @@ -104,7 +104,7 @@ function print_invoices() $SubTotal = 0; while ($myrow2=db_fetch($result)) { - $Net = round($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), + $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"],$dec); diff --git a/reporting/rep109.php b/reporting/rep109.php index 1bbf662a..2a89aeeb 100644 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@ -92,7 +92,7 @@ function print_sales_orders() $SubTotal = 0; while ($myrow2=db_fetch($result)) { - $Net = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), + $Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"],$dec); diff --git a/reporting/rep110.php b/reporting/rep110.php index 659a4a49..3ec50038 100644 --- a/reporting/rep110.php +++ b/reporting/rep110.php @@ -83,7 +83,7 @@ function print_deliveries() $SubTotal = 0; while ($myrow2=db_fetch($result)) { - $Net = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), + $Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"],$dec); diff --git a/reporting/rep209.php b/reporting/rep209.php index b59ca1ad..41d0ca3d 100644 --- a/reporting/rep209.php +++ b/reporting/rep209.php @@ -116,7 +116,7 @@ function print_po() $myrow2['quantiry_ordered'] = round($myrow2['quantiry_ordered'] / $data['conversion_factor'], user_qty_dec()); } } - $Net = round(($myrow2["unit_price"] * $myrow2["quantity_ordered"]), + $Net = round2(($myrow2["unit_price"] * $myrow2["quantity_ordered"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"],$dec); diff --git a/reporting/rep302.php b/reporting/rep302.php index 47bf8448..68758cd4 100644 --- a/reporting/rep302.php +++ b/reporting/rep302.php @@ -26,23 +26,22 @@ function getTransactions($category, $location) ".TB_PREF."stock_category.description AS cat_description, ".TB_PREF."stock_master.stock_id, ".TB_PREF."stock_master.description, - ".TB_PREF."stock_moves.loc_code, - SUM(".TB_PREF."stock_moves.qty) AS qty_on_hand - FROM ".TB_PREF."stock_master, - ".TB_PREF."stock_category, - ".TB_PREF."stock_moves - WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."stock_moves.stock_id - AND ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id + IF(".TB_PREF."stock_moves.stock_id IS NULL, '', ".TB_PREF."stock_moves.loc_code) AS loc_code, + SUM(IF(".TB_PREF."stock_moves.stock_id IS NULL,0,".TB_PREF."stock_moves.qty)) AS qty_on_hand + FROM (".TB_PREF."stock_master, + ".TB_PREF."stock_category) + LEFT JOIN ".TB_PREF."stock_moves ON + (".TB_PREF."stock_master.stock_id=".TB_PREF."stock_moves.stock_id OR ".TB_PREF."stock_master.stock_id IS NULL) + WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id AND (".TB_PREF."stock_master.mb_flag='B' OR ".TB_PREF."stock_master.mb_flag='M')"; if ($category != 0) $sql .= " AND ".TB_PREF."stock_master.category_id = '$category'"; if ($location != 'all') $sql .= " AND ".TB_PREF."stock_moves.loc_code = '$location'"; $sql .= " GROUP BY ".TB_PREF."stock_master.category_id, - ".TB_PREF."stock_master.description, ".TB_PREF."stock_category.description, - ".TB_PREF."stock_moves.stock_id, - ".TB_PREF."stock_master.stock_id + ".TB_PREF."stock_master.stock_id, + ".TB_PREF."stock_master.description ORDER BY ".TB_PREF."stock_master.category_id, ".TB_PREF."stock_master.stock_id"; @@ -55,9 +54,10 @@ function getCustQty($stockid, $location) $sql = "SELECT SUM(".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_sent) AS qty_demand FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders - WHERE ".TB_PREF."sales_order_details.order_no=".TB_PREF."sales_orders.order_no AND - ".TB_PREF."sales_orders.from_stk_loc ='$location' AND - ".TB_PREF."sales_order_details.stk_code = '$stockid'"; + WHERE ".TB_PREF."sales_order_details.order_no=".TB_PREF."sales_orders.order_no AND "; + if ($location != "") + $sql .= TB_PREF."sales_orders.from_stk_loc ='$location' AND "; + $sql .= TB_PREF."sales_order_details.stk_code = '$stockid'"; $TransResult = db_query($sql,"No transactions were returned"); $DemandRow = db_fetch($TransResult); @@ -73,9 +73,10 @@ function getCustAsmQty($stockid, $location) ".TB_PREF."bom, ".TB_PREF."stock_master WHERE ".TB_PREF."sales_order_details.stk_code=".TB_PREF."bom.parent AND - ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND - ".TB_PREF."sales_orders.from_stk_loc='$location' AND - ".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND + ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND "; + if ($location != "") + $sql .= TB_PREF."sales_orders.from_stk_loc ='$location' AND "; + $sql .= TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND ".TB_PREF."bom.component='$stockid' AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.parent AND ".TB_PREF."stock_master.mb_flag='A'"; @@ -98,8 +99,9 @@ function getSuppQty($stockid, $location) FROM ".TB_PREF."purch_order_details, ".TB_PREF."purch_orders WHERE ".TB_PREF."purch_order_details.order_no = ".TB_PREF."purch_orders.order_no - AND ".TB_PREF."purch_order_details.item_code = '$stockid' - AND ".TB_PREF."purch_orders.into_stock_location= '$location'"; + AND ".TB_PREF."purch_order_details.item_code = '$stockid'"; + if ($location != "") + $sql .= " AND ".TB_PREF."purch_orders.into_stock_location= '$location'"; $TransResult = db_query($sql,"No transactions were returned"); $DemandRow = db_fetch($TransResult); @@ -196,10 +198,13 @@ function print_inventory_planning() $catt = $trans['cat_description']; $rep->NewLine(); } - - $custqty = getCustQty($trans['stock_id'], $trans['loc_code']); - $custqty += getCustAsmQty($trans['stock_id'], $trans['loc_code']); - $suppqty = getSuppQty($trans['stock_id'], $trans['loc_code']); + if ($location == 'all') + $loc_code = ""; + else + $loc_code = $trans['loc_code']; + $custqty = getCustQty($trans['stock_id'], $loc_code); + $custqty += getCustAsmQty($trans['stock_id'], $loc_code); + $suppqty = getSuppQty($trans['stock_id'], $loc_code); $period = getPeriods($trans['stock_id'], $trans['loc_code']); $rep->NewLine(); $dec = get_qty_dec($trans['stock_id']); diff --git a/reporting/rep303.php b/reporting/rep303.php index c984b3cb..bc04f769 100644 --- a/reporting/rep303.php +++ b/reporting/rep303.php @@ -26,13 +26,13 @@ function getTransactions($category, $location) ".TB_PREF."stock_category.description AS cat_description, ".TB_PREF."stock_master.stock_id, ".TB_PREF."stock_master.description, - ".TB_PREF."stock_moves.loc_code, - SUM(".TB_PREF."stock_moves.qty) AS QtyOnHand - FROM ".TB_PREF."stock_master, - ".TB_PREF."stock_category, - ".TB_PREF."stock_moves - WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."stock_moves.stock_id - AND ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id + IF(".TB_PREF."stock_moves.stock_id IS NULL, '', ".TB_PREF."stock_moves.loc_code) AS loc_code, + SUM(IF(".TB_PREF."stock_moves.stock_id IS NULL,0,".TB_PREF."stock_moves.qty)) AS QtyOnHand + FROM (".TB_PREF."stock_master, + ".TB_PREF."stock_category) + LEFT JOIN ".TB_PREF."stock_moves ON + (".TB_PREF."stock_master.stock_id=".TB_PREF."stock_moves.stock_id OR ".TB_PREF."stock_master.stock_id IS NULL) + WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id AND (".TB_PREF."stock_master.mb_flag='B' OR ".TB_PREF."stock_master.mb_flag='M')"; if ($category != 0) $sql .= " AND ".TB_PREF."stock_master.category_id = '$category'"; @@ -53,9 +53,10 @@ function getDemandQty($stockid, $location) $sql = "SELECT SUM(".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_sent) AS QtyDemand FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders - WHERE ".TB_PREF."sales_order_details.order_no=".TB_PREF."sales_orders.order_no AND - ".TB_PREF."sales_orders.from_stk_loc ='$location' AND - ".TB_PREF."sales_order_details.stk_code = '$stockid'"; + WHERE ".TB_PREF."sales_order_details.order_no=".TB_PREF."sales_orders.order_no AND "; + if ($location != "") + $sql .= TB_PREF."sales_orders.from_stk_loc ='$location' AND "; + $sql .= TB_PREF."sales_order_details.stk_code = '$stockid'"; $TransResult = db_query($sql,"No transactions were returned"); $DemandRow = db_fetch($TransResult); @@ -71,9 +72,10 @@ function getDemandAsmQty($stockid, $location) ".TB_PREF."bom, ".TB_PREF."stock_master WHERE ".TB_PREF."sales_order_details.stk_code=".TB_PREF."bom.parent AND - ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND - ".TB_PREF."sales_orders.from_stk_loc='$location' AND - ".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND + ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND "; + if ($location != "") + $sql .= TB_PREF."sales_orders.from_stk_loc ='$location' AND "; + $sql .= TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND ".TB_PREF."bom.component='$stockid' AND ".TB_PREF."stock_master.stock_id=".TB_PREF."bom.parent AND ".TB_PREF."stock_master.mb_flag='A'"; @@ -163,8 +165,12 @@ function print_stock_check() $catt = $trans['cat_description']; $rep->NewLine(); } - $demandqty = getDemandQty($trans['stock_id'], $trans['loc_code']); - $demandqty += getDemandAsmQty($trans['stock_id'], $trans['loc_code']); + if ($location == 'all') + $loc_code = ""; + else + $loc_code = $trans['loc_code']; + $demandqty = getDemandQty($trans['stock_id'], $loc_code); + $demandqty += getDemandAsmQty($trans['stock_id'], $loc_code); $rep->NewLine(); $dec = get_qty_dec($trans['stock_id']); $rep->TextCol(0, 1, $trans['stock_id']); diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index 8e5da8e8..3c275dbb 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -366,13 +366,13 @@ $th = array(_("Item Code"), _("Item Description"), _("Ordered"), _("Units"), _(" table_header($th); $k = 0; $has_marked = false; -$show_qoh = true; foreach ($_SESSION['Items']->line_items as $line=>$ln_itm) { if ($ln_itm->quantity==$ln_itm->qty_done) { continue; //this line is fully delivered } // if it's a non-stock item (eg. service) don't show qoh + $show_qoh = true; if (sys_prefs::allow_negative_stock() || !has_stock_holding($ln_itm->mb_flag) || $ln_itm->qty_dispatched == 0) { $show_qoh = false; diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index 628ab43a..96faeb1c 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -306,7 +306,7 @@ class cart function remove_from_cart($line_no) { - unset($this->line_items[$line_no]); + array_splice($this->line_items, $line_no, 1); } function clear_items() diff --git a/sales/includes/db/payment_db.inc b/sales/includes/db/payment_db.inc index 15ec3584..c960dd33 100644 --- a/sales/includes/db/payment_db.inc +++ b/sales/includes/db/payment_db.inc @@ -20,9 +20,9 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou void_gl_trans(12, $trans_no, true); void_cust_allocations(12, $trans_no, $date_); } - + $total = 0; /* Bank account entry first */ - add_gl_trans_customer(12, $payment_no, $date_, + $total += add_gl_trans_customer(12, $payment_no, $date_, $bank_gl_account, 0, 0, $amount, $customer_id, "Cannot insert a GL transaction for the bank account debit", $rate); @@ -40,18 +40,20 @@ function write_customer_payment($trans_no, $customer_id, $branch_id, $bank_accou if (($discount + $amount) != 0) { /* Now Credit Debtors account with receipts + discounts */ - add_gl_trans_customer(12, $payment_no, $date_, + $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*/ - add_gl_trans_customer(12, $payment_no, $date_, + $total += add_gl_trans_customer(12, $payment_no, $date_, $discount_account, 0, 0, $discount, $customer_id, "Cannot insert a GL transaction for the payment discount debit", $rate); } + /*Post a balance post if $total != 0 */ + add_gl_balance(12, $payment_no, $date_, -$total, payment_person_types::customer(), $customer_id); + /*now enter the bank_trans entry */ add_bank_trans(12, $payment_no, $bank_account, $ref, $date_, $amount, payment_person_types::customer(), $customer_id, diff --git a/sales/includes/db/sales_credit_db.inc b/sales/includes/db/sales_credit_db.inc index 94dbe8a2..16efab69 100644 --- a/sales/includes/db/sales_credit_db.inc +++ b/sales/includes/db/sales_credit_db.inc @@ -98,7 +98,7 @@ function write_credit_note($credit_note, $write_off_acc) } } - + $total = 0; foreach ($credit_note->line_items as $credit_line) { if ($credit_invoice && $credit_line->qty_dispatched!=$credit_line->qty_old ) { @@ -120,7 +120,7 @@ function write_credit_note($credit_note, $write_off_acc) add_credit_movements_item($credit_note, $credit_line, $credit_type, $line_taxfree_price+$line_tax, $credit_invoice); - add_gl_trans_credit_costs($credit_note, $credit_line, $credit_no, + $total += add_gl_trans_credit_costs($credit_note, $credit_line, $credit_no, $credit_date, $credit_type, $write_off_acc, $branch_data); } /*end of credit_line loop */ @@ -129,14 +129,14 @@ function write_credit_note($credit_note, $write_off_acc) if (($credit_note_total + $credit_note->freight_cost) != 0) { - add_gl_trans_customer(11, $credit_no, $credit_date, $branch_data["receivables_account"], 0, 0, + $total += add_gl_trans_customer(11, $credit_no, $credit_date, $branch_data["receivables_account"], 0, 0, -($credit_note_total + $credit_note->freight_cost + $items_added_tax + $freight_added_tax), $credit_note->customer_id, "The total debtor GL posting for the credit note could not be inserted"); } if ($credit_note->freight_cost !=0) { - add_gl_trans_customer(11, $credit_no, $credit_date, $company_data["freight_act"], 0, 0, + $total += add_gl_trans_customer(11, $credit_no, $credit_date, $company_data["freight_act"], 0, 0, $credit_note->get_tax_free_shipping(), $credit_note->customer_id, "The freight GL posting for this credit note could not be inserted"); } @@ -147,11 +147,14 @@ function write_credit_note($credit_note, $write_off_acc) add_customer_trans_tax_detail_item(11, $credit_no, $taxitem['tax_type_id'], $taxitem['rate'], $credit_note->tax_included, $taxitem['Value']); - add_gl_trans_customer(11, $credit_no, $credit_date, $taxitem['sales_gl_code'], 0, 0, + $total += add_gl_trans_customer(11, $credit_no, $credit_date, $taxitem['sales_gl_code'], 0, 0, $taxitem['Value'], $credit_note->customer_id, "A tax GL posting for this credit note could not be inserted"); } } + /*Post a balance post if $total != 0 */ + add_gl_balance(11, $credit_no, $credit_date, -$total, payment_person_types::customer(), $credit_note->customer_id); + add_comments(11, $credit_no, $credit_date, $credit_note->Comments); if ($trans_no == 0) { @@ -213,12 +216,13 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_, $dim2 = ($order->dimension2_id != $customer['dimension2_id'] ? $order->dimension2_id : ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_codes["dimension2_id"])); + $total = 0; /* insert gl_trans to credit stock and debit cost of sales at standard cost*/ $standard_cost = get_standard_cost($order_line->stock_id); if ($standard_cost != 0) { /*first the cost of sales entry*/ - add_gl_trans_std_cost(11, $credit_no, $date_, $stock_gl_codes["cogs_account"], + $total += add_gl_trans_std_cost(11, $credit_no, $date_, $stock_gl_codes["cogs_account"], $dim, $dim2, "", -($standard_cost * $order_line->qty_dispatched), payment_person_types::customer(), $order->customer_id, "The cost of sales GL posting could not be inserted"); @@ -231,7 +235,7 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_, $stock_entry_account = $stock_gl_code["inventory_account"]; } - add_gl_trans_std_cost(11, $credit_no, $date_, $stock_entry_account, 0, 0, + $total += add_gl_trans_std_cost(11, $credit_no, $date_, $stock_entry_account, 0, 0, "", ($standard_cost * $order_line->qty_dispatched), payment_person_types::customer(), $order->customer_id, "The stock side (or write off) of the cost of sales GL posting could not be inserted"); @@ -256,19 +260,20 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_, $sales_account = $branch_data['sales_account']; else $sales_account = $stock_gl_codes['sales_account']; - add_gl_trans_customer(11, $credit_no, $date_, $sales_account, $dim, $dim2, + $total += add_gl_trans_customer(11, $credit_no, $date_, $sales_account, $dim, $dim2, ($line_taxfree_price * $order_line->qty_dispatched), $order->customer_id, "The credit note GL posting could not be inserted"); if ($order_line->discount_percent != 0) { - add_gl_trans_customer(11, $credit_no, $date_, $branch_data["sales_discount_account"], + $total += add_gl_trans_customer(11, $credit_no, $date_, $branch_data["sales_discount_account"], $dim, $dim2, -($line_taxfree_price * $order_line->qty_dispatched * $order_line->discount_percent), $order->customer_id, "The credit note discount GL posting could not be inserted"); } /*end of if discount !=0 */ } /*if line_price!=0 */ + return $total; } ?> \ No newline at end of file diff --git a/sales/includes/db/sales_invoice_db.inc b/sales/includes/db/sales_invoice_db.inc index 31f7a1a2..1c9837f9 100644 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@ -73,7 +73,7 @@ function write_sales_invoice(&$invoice) void_cust_allocations(10, $invoice_no); // ? void_customer_trans_tax_details(10, $invoice_no); } - + $total = 0; foreach ($invoice->line_items as $invoice_line) { $line_taxfree_price = get_tax_free_price_for_item($invoice_line->stock_id, @@ -109,13 +109,13 @@ function write_sales_invoice(&$invoice) ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_code["dimension_id"])); $dim2 = ($invoice->dimension2_id != $customer['dimension2_id'] ? $invoice->dimension2_id : ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"])); - add_gl_trans_customer(10, $invoice_no, $date_, $sales_account, $dim, $dim2, + $total += add_gl_trans_customer(10, $invoice_no, $date_, $sales_account, $dim, $dim2, (-$line_taxfree_price * $invoice_line->qty_dispatched), $invoice->customer_id, "The sales price GL posting could not be inserted"); if ($invoice_line->discount_percent != 0) { - add_gl_trans_customer(10, $invoice_no, $date_, + $total += add_gl_trans_customer(10, $invoice_no, $date_, $branch_data["sales_discount_account"], $dim, $dim2, ($line_taxfree_price * $invoice_line->qty_dispatched * $invoice_line->discount_percent), $invoice->customer_id, "The sales discount GL posting could not be inserted"); @@ -124,14 +124,14 @@ function write_sales_invoice(&$invoice) } /*quantity dispatched is more than 0 */ } /*end of delivery_line loop */ - /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */ if (($items_total + $charge_shipping) != 0) { - add_gl_trans_customer(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0, + $total += add_gl_trans_customer(10, $invoice_no, $date_, $branch_data["receivables_account"], 0, 0, ($items_total + $charge_shipping + $items_added_tax + $freight_added_tax), $invoice->customer_id, "The total debtor GL posting could not be inserted"); } + if ($charge_shipping != 0) { - add_gl_trans_customer(10, $invoice_no, $date_, $company_data["freight_act"], 0, 0, + $total += add_gl_trans_customer(10, $invoice_no, $date_, $company_data["freight_act"], 0, 0, -$invoice->get_tax_free_shipping(), $invoice->customer_id, "The freight GL posting could not be inserted"); } @@ -141,12 +141,15 @@ function write_sales_invoice(&$invoice) add_customer_trans_tax_detail_item(10, $invoice_no, $taxitem['tax_type_id'], $taxitem['rate'], $invoice->tax_included, $taxitem['Value']); - add_gl_trans_customer(10, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0, + $total += add_gl_trans_customer(10, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0, (-$taxitem['Value']), $invoice->customer_id, "A tax GL posting could not be inserted"); } } + /*Post a balance post if $total != 0 */ + add_gl_balance(10, $invoice_no, $date_, -$total, payment_person_types::customer(), $invoice->customer_id); + add_comments(10, $invoice_no, $date_, $invoice->Comments); if ($trans_no == 0) { diff --git a/sales/includes/sales_db.inc b/sales/includes/sales_db.inc index a537894b..ab35dc81 100644 --- a/sales/includes/sales_db.inc +++ b/sales/includes/sales_db.inc @@ -76,7 +76,9 @@ function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=nu if ($factor == 0) return false; // auto price calculations off $base_id = get_base_sales_type(); - $home_curr = get_company_currency(); + if ($base_id <= 0) return 0; // auto price calculations off + + $home_curr = get_company_currency(); // get all prices which we can use to guess the price. // alternative is make up to 2 additional sql queries diff --git a/sales/includes/ui/sales_credit_ui.inc b/sales/includes/ui/sales_credit_ui.inc index f4725d3f..303a7e0f 100644 --- a/sales/includes/ui/sales_credit_ui.inc +++ b/sales/includes/ui/sales_credit_ui.inc @@ -122,7 +122,10 @@ function display_credit_header(&$order) date_row(_("Date:"), 'OrderDate', '', null, 0, 0, 0, null, true); if (isset($_POST['_OrderDate_changed'])) { - $change_prices = 1; + if (!is_company_currency($order->customer_currency) + && (get_base_sales_type()>0)) { + $change_prices = 1; + } $Ajax->activate('currency'); } // 2008-11-12 Joe Hunt added dimensions diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 6e380105..a1122708 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -368,7 +368,10 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group date_row($date_text, 'OrderDate', _('Date of order receive'), null, 0, 0, 0, null, true); if (isset($_POST['_OrderDate_changed'])) { - $change_prices = 1; + if (!is_company_currency($order->customer_currency) + && (get_base_sales_type()>0)) { + $change_prices = 1; + } $Ajax->activate('currency'); if ($order->trans_type == 10) { $_POST['delivery_date'] = get_invoice_duedate(get_post('customer_id'), get_post('OrderDate')); diff --git a/sales/view/view_credit.php b/sales/view/view_credit.php index f220fca1..05e73eb0 100644 --- a/sales/view/view_credit.php +++ b/sales/view/view_credit.php @@ -90,7 +90,7 @@ if (db_num_rows($result) > 0) alt_table_row_color($k); - $value = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), + $value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $sub_total += $value; diff --git a/sales/view/view_dispatch.php b/sales/view/view_dispatch.php index 3d7d2e75..9bd01beb 100644 --- a/sales/view/view_dispatch.php +++ b/sales/view/view_dispatch.php @@ -111,7 +111,7 @@ if (db_num_rows($result) > 0) if($myrow2['quantity']==0) continue; alt_table_row_color($k); - $value = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), + $value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $sub_total += $value; diff --git a/sales/view/view_invoice.php b/sales/view/view_invoice.php index 17900ba2..e430b455 100644 --- a/sales/view/view_invoice.php +++ b/sales/view/view_invoice.php @@ -113,7 +113,7 @@ if (db_num_rows($result) > 0) if($myrow2["quantity"]==0) continue; alt_table_row_color($k); - $value = round(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), + $value = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $sub_total += $value; diff --git a/sales/view/view_sales_order.php b/sales/view/view_sales_order.php index 333a1130..782c951d 100644 --- a/sales/view/view_sales_order.php +++ b/sales/view/view_sales_order.php @@ -177,7 +177,7 @@ $k = 0; //row colour counter foreach ($_SESSION['Items']->line_items as $stock_item) { - $line_total = round($stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent), + $line_total = round2($stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent), user_price_dec()); alt_table_row_color($k); diff --git a/taxes/tax_calc.inc b/taxes/tax_calc.inc index 9d1ba576..acc8f0f0 100644 --- a/taxes/tax_calc.inc +++ b/taxes/tax_calc.inc @@ -175,12 +175,14 @@ function get_tax_for_items($items, $prices, $shipping_cost, $tax_group, $tax_inc foreach ($item_taxes as $item_tax) { $index = $item_tax['tax_type_id']; - if($tax_included==1) - $ret_tax_array[$index]['Value'] += round($prices[$i] * $item_tax['rate'] - / ($item_tax['rate'] + 100), user_price_dec()); + 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)); else - $ret_tax_array[$index]['Value'] += - round($prices[$i] * $item_tax['rate'] / 100, user_price_dec()); + //$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); } } } @@ -195,12 +197,14 @@ function get_tax_for_items($items, $prices, $shipping_cost, $tax_group, $tax_inc { $index = $item_tax['tax_type_id']; if(isset($ret_tax_array[$index])) { - if($tax_included==1) - $ret_tax_array[$index]['Value'] += round($shipping_cost * $item_tax['rate'] - / ($item_tax['rate'] + 100), user_price_dec()); + 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)); else - $ret_tax_array[$index]['Value'] += - round($shipping_cost * $item_tax['rate'] / 100, user_price_dec()); + //$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); } } } diff --git a/update.html b/update.html index cc0bb64d..5a87aafd 100644 --- a/update.html +++ b/update.html @@ -38,7 +38,7 @@ these files too.
  • Upload all the new files.
  • Restore the files mentioned in #1. Be careful with - config.db. Look into variances. There might be new variables in + config.php. Look into variances. There might be new variables in the new version. It might be easier to manually change your former values in the new file.
  • @@ -53,7 +53,7 @@ password and choose the update script from the local harddisk. do this, before entering FrontAccounting! Enter the database user and the password and choose the alter.sql script.  Do the same for the alter2.sql script. If you have -already updated release 2.0 Beta, you can just run the alter2.sql script.
    You must also manuelly ensure that you have write permission to the new folder /company/0.
    There are no database changes during a major and minor release. Like from 2.0 to 2.0.1 - 2.0.5 . +already updated release 2.0 Beta, you can just run the alter2.sql script.
    You must also manuelly ensure that you have write permission to the new folder /company .
    There are no database changes during a major and minor release. Like from 2.0 to 2.0.1 - 2.0.5 .

     

    diff --git a/update_db.php b/update_db.php index 26c14ee5..4ebbbc74 100644 --- a/update_db.php +++ b/update_db.php @@ -9,6 +9,8 @@ $js .= get_js_set_focus("user"); $image = $path_to_root."/themes/default/images/logo_frontaccounting.png"; $title = "Update All Company Databases"; +$comp_subdirs = array('images', 'pdf_files', 'backup','js_cache'); + function get_js_png_fix() { $js = "