From: Janusz Dobrowolski Date: Sat, 3 Mar 2012 21:35:40 +0000 (+0100) Subject: Stable merged into unstable again (due to failure on binary file during previous... X-Git-Tag: v2.4.2~19^2~363 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=90b3d069d96b99671af51726e2953352738abb75 Stable merged into unstable again (due to failure on binary file during previous merge). --- 90b3d069d96b99671af51726e2953352738abb75 diff --cc admin/db/fiscalyears_db.inc index 8cb84044,c605c064..9ace5d19 --- a/admin/db/fiscalyears_db.inc +++ b/admin/db/fiscalyears_db.inc @@@ -337,29 -337,21 +337,28 @@@ function delete_this_fiscalyear($select db_query($sql, "Could not delete exchange rates"); $sql = "DELETE FROM ".TB_PREF."budget_trans WHERE tran_date <= '$to'"; db_query($sql, "Could not delete exchange rates"); -- - $sql = "SELECT account, SUM(amount) AS amount FROM ".TB_PREF."gl_trans WHERE tran_date <= '$to' GROUP by account"; + $sql = "SELECT account, SUM(amount) AS amount, person_type_id, person_id FROM " + .TB_PREF."gl_trans WHERE tran_date <= '$to' GROUP by account, person_type_id, person_id"; - $sql = "SELECT account, SUM(amount) AS amount FROM ".TB_PREF."gl_trans WHERE tran_date <= '$to' GROUP by account"; $result = db_query($sql, "Could not retrieve gl trans"); $trans_no = get_next_trans_no(ST_JOURNAL); + + $last_account=''; $new = false; while ($row = db_fetch($result)) { - $sql = "DELETE FROM ".TB_PREF."gl_trans WHERE tran_date <= '$to' AND account = '{$row['account']}'"; - db_query($sql, "Could not delete gl trans"); - if (is_account_balancesheet($row['account'])) + if ($last_account != $row['account']) // deletes all subledgers postings, so do it once for account + { + $sql = "DELETE FROM ".TB_PREF."gl_trans WHERE tran_date <= '$to' AND account = '{$row['account']}'"; + db_query($sql, "Could not delete gl trans"); + $last_account = $row['account']; + } + if (is_account_balancesheet($row['account']) && $row['amount']) { - $sql = "INSERT INTO ".TB_PREF."gl_trans (type, type_no, tran_date, account, memo_, amount) VALUES - (".ST_JOURNAL.", $trans_no, '$to', '{$row['account']}', '$ref', {$row['amount']})"; + $sql = "INSERT INTO ".TB_PREF."gl_trans (type, type_no, tran_date, account, memo_, amount, person_type_id, person_id) VALUES + (".ST_JOURNAL.", $trans_no, '$to', '{$row['account']}', '$ref', {$row['amount']}, " + .db_escape($row['person_type_id'], true).", ".db_escape($row['person_id'], true).")"; db_query($sql, "Could not insert gl trans"); + $new = true; } } if ($new) diff --cc admin/gl_setup.php index 1263be92,1ef3e40e..fe494679 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@@ -83,6 -83,11 +83,10 @@@ start_form() start_outer_table(TABLESTYLE2); table_section(1); - + if (get_company_pref('grn_clearing_act') === null) { // available form 2.3.1, can be not defined on pre-2.4 installations + set_company_pref('grn_clearing_act', 'glsetup.purchase', 'varchar', 15, 0); + refresh_sys_prefs(); + } $myrow = get_company_prefs(); diff --cc gl/includes/db/gl_db_banking.inc index 608f4e8c,4a88583a..0650a0c6 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@@ -251,8 -252,8 +251,7 @@@ function add_bank_transfer($from_accoun if ($SysPrefs->auto_currency_revaluation()) { $currency = get_bank_account_currency($to_account); - - if ($exchanged || add_exchange_variation($trans_no1, $date_, $to_account, $to_gl_account, - + if (add_exchange_variation($trans_no1, $date_, $to_account, $to_gl_account, $currency, PT_MISC, $person_id)) $exchanged = true; } diff --cc gl/includes/ui/gl_journal_ui.inc index f9e5585c,8c4aec6a..d68f0914 --- a/gl/includes/ui/gl_journal_ui.inc +++ b/gl/includes/ui/gl_journal_ui.inc @@@ -277,8 -241,8 +277,3 @@@ function gl_options_controls( echo ""; } -- -- --//--------------------------------------------------------------------------------- -- --?> diff --cc gl/manage/close_period.php index fa21d00b,00000000..fc057c25 mode 100644,000000..100644 --- a/gl/manage/close_period.php +++ b/gl/manage/close_period.php @@@ -1,108 -1,0 +1,109 @@@ +. +***********************************************************************/ + +$page_security = 'SA_GLCLOSE'; +$path_to_root = "../.."; +include_once($path_to_root . "/includes/session.inc"); + +include_once($path_to_root . "/includes/date_functions.inc"); +include_once($path_to_root . "/includes/ui.inc"); +include_once($path_to_root . "/includes/banking.inc"); ++include_once($path_to_root . "/admin/db/fiscalyears_db.inc"); + +$js = ""; +if ($use_date_picker) + $js .= get_js_date_picker(); +page(_($help_context = "Closing GL Transactions"), false, false, "", $js); + +//--------------------------------------------------------------------------------------------- +function check_data() +{ + global $Refs, $allow_gl_reopen; + + if (!is_date($_POST['date']) || date1_greater_date2($_POST['date'], Today())) + { + display_error( _("The entered date is invalid.")); + set_focus('date'); + return false; + } - if (!is_date_in_fiscalyears($date, false)) ++ if (!is_date_in_fiscalyears($_POST['date'], false)) + { + display_error(_("Selected date is not in fiscal year or the year is closed.")); + set_focus('date'); + return false; + } + if (date1_greater_date2(sql2date(get_company_pref('gl_closing_date')), $_POST['date'])) + { + if (!$allow_gl_reopen) { + display_error(_("The entered date is earlier than date already selected as closing date.")); + set_focus('date'); + return false; + } elseif (!user_check_access('SA_GLREOPEN')) { + display_error(_("You are not allowed to reopen already closed transactions.")); + set_focus('date'); + return false; + } + } + return true; +} + +//--------------------------------------------------------------------------------------------- + +function handle_submit() +{ + if (!check_data()) + return; + + if (!close_transactions($_POST['date'])) + { + display_notification( + sprintf( _("All transactions resulting in GL accounts changes up to %s has been closed for further edition."), + sql2date(get_company_pref('gl_closing_date'))) ); + } + +} + + +//--------------------------------------------------------------------------------------------- + +function clear_data() +{ + unset($_POST['date_']); +} + +//--------------------------------------------------------------------------------------------- + +if (get_post('submit')) + handle_submit(); +else + display_note(_("Using this feature you can prevent entering new transactions
+ and disable edition of already entered transactions up to specified date.
+ Only transactions which can generate GL postings are subject to the constraint.")); + +//--------------------------------------------------------------------------------------------- + +br(1); +start_form(); +start_table(TABLESTYLE2); +if (!isset($_POST['date'])) { + $cdate = sql2date(get_company_pref('gl_closing_date')); + $_POST['date'] = $cdate ;// ? end_month(add_months($cdate, 1)) : Today(); +} +date_row(_("End date of closing period:"), 'date'); +end_table(1); + +submit_center('submit', _("Close Transactions"), true, false); +end_form(); + +end_page(); + +?> diff --cc includes/data_checks.inc index 543a7d59,798e84c4..f50e9454 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@@ -485,17 -485,5 +485,16 @@@ function check_num($postname, $min=null return 1; } - -?> +function check_is_closed($type, $type_no, $msg=null) +{ + global $systypes_array; + + if (($type_no > 0) && is_closed_trans($type, $type_no)) + { + if (!$msg) + $msg = sprintf(_("%s #%s is closed for further edition."), $systypes_array[$type], $type_no); + display_error($msg, true); + end_page(); + exit; + } +} - diff --cc includes/date_functions.inc index 343e56ad,6f8379e0..d1aacdf8 --- a/includes/date_functions.inc +++ b/includes/date_functions.inc @@@ -348,7 -345,7 +348,6 @@@ and converts to a yyyy/mm/dd format * $date_ = trim($date_); $year = $month = $day = 0; -- // Split up the date by the separator based on "how" to split it if ($how == 0) // MMDDYYYY list($month, $day, $year) = explode($sep, $date_); diff --cc includes/db/audit_trail_db.inc index e19a659e,f9efe9a0..c25fdc51 --- a/includes/db/audit_trail_db.inc +++ b/includes/db/audit_trail_db.inc @@@ -12,22 -12,21 +12,21 @@@ function add_audit_trail($trans_type, $trans_no, $trans_date, $descr='') { + $date = date2sql($trans_date); $sql = "INSERT INTO ".TB_PREF."audit_trail" - . " (type, trans_no, user, fiscal_year, gl_date, description, gl_seq) + . " (type, trans_no, user, gl_date, description) VALUES(".db_escape($trans_type).", ".db_escape($trans_no)."," - . $_SESSION["wa_current_user"]->user. "," - . get_company_pref('f_year') ."," - . "'". date2sql($trans_date) ."'," - . db_escape($descr). ", 0)"; + . $_SESSION["wa_current_user"]->user . "," + . "'$date',". db_escape($descr). ")"; db_query($sql, "Cannot add audit info"); -- - // all audit records beside latest one should have gl_seq set to NULL + // all audit records beside just inserted one should have gl_seq set to NULL // to avoid need for subqueries (not existing in MySQL 3) all over the code - $sql = "UPDATE ".TB_PREF."audit_trail SET gl_seq = NULL" + $sql = "UPDATE ".TB_PREF."audit_trail audit LEFT JOIN ".TB_PREF."fiscal_year year ON year.begin<='$date' AND year.end>='$date' + SET audit.gl_seq = IF(audit.id=".db_insert_id().", 0, NULL)," + ."audit.fiscal_year=year.id" . " WHERE type=".db_escape($trans_type)." AND trans_no=" - .db_escape($trans_no)." AND id!=".db_insert_id(); + . db_escape($trans_no); db_query($sql, "Cannot update audit gl_seq"); } @@@ -83,27 -78,51 +82,28 @@@ function close_transactions($todate) } if ($last_year != $row['fiscal_year']) { $last_year = $row['fiscal_year']; - $counter = 1; // reset counter on fiscal year change - } else - $counter++; - $sql2 = "UPDATE ".TB_PREF."audit_trail SET" - . " gl_seq=$counter" - . " WHERE id=".$row['id']; - - db_query($sql2, "Cannot reindex journal"); + $counter = 0; // reset counter on fiscal year change + } - ++ + $seq = $row['closed'] ? ++$counter : 0; + if ($row['gl_seq'] != $seq) { // update transaction status only when gl_seq has changed + $sql2 = "UPDATE ".TB_PREF."audit_trail SET" + . " gl_seq=$seq" + . " WHERE id=".$row['id']; + db_query($sql2, "Cannot reindex journal"); + } } } - ++ if ($errors) display_warning(_("Some transactions journal GL postings were not indexed due to lack of audit trail record.")); -} - -/* - Reopen all transactions for edition up from date $fromdate -*/ -function open_transactions($fromdate) { - - $sql = "SELECT a.id, a.gl_date, a.fiscal_year" - ." FROM ".TB_PREF."gl_trans gl" - ." LEFT JOIN ". TB_PREF."audit_trail a ON - (gl.type=a.type AND gl.type_no=a.trans_no)" - . " WHERE gl_date>='". date2sql($fromdate) ."'" - . " AND !ISNULL(gl_seq)" - . " ORDER BY a.fiscal_year, a.gl_date, a.id"; - - $result = db_query($sql, "Cannot select transactions for openning"); + else + update_company_prefs(array('gl_closing_date'=> date2sql($todate))); + commit_transaction(); - if (db_num_rows($result)) { - $last_year = 0; - - while ($row = db_fetch($result)) { - if ($row['fiscal_year'] == null) { - continue; - } - $sql2 = "UPDATE ".TB_PREF."audit_trail SET" - . " gl_seq=0" - . " WHERE id=".$row['id']; - - db_query($sql2, "Cannot clear journal order"); - } - } + return $errors; } + /* Closed transactions have gl_seq number assigned. */ diff --cc includes/db/inventory_db.inc index 80f552e9,068c1645..e0ea2ef7 --- a/includes/db/inventory_db.inc +++ b/includes/db/inventory_db.inc @@@ -173,22 -173,22 +173,22 @@@ function get_deliveries_from_trans($sto trans_id>='$from' GROUP BY stock_id"; $result = db_query($sql, "The deliveries could not be updated"); $row = db_fetch_row($result); - + - $sql = "SELECT IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, standard_cost) - FROM ".TB_PREF."stock_moves - WHERE stock_id=".db_escape($stock_id) - ." AND trans_id ='$from'"; - $result = db_query($sql, "The deliveries could not be updated"); + $sql = "SELECT IF(type=".ST_SUPPRECEIVE." OR type=".ST_SUPPCREDIT.", price, standard_cost) + FROM ".TB_PREF."stock_moves + WHERE stock_id=".db_escape($stock_id) + ." AND trans_id ='$from'"; + $result = db_query($sql, "The deliveries could not be updated"); $cost = db_fetch_row($result); - + // Adjusting QOH valuation $sql = "SELECT SUM(qty) FROM ".TB_PREF."stock_moves WHERE stock_id=".db_escape($stock_id)." AND trans_id<'$from' GROUP BY stock_id"; $result = db_query($sql, "The deliveries could not be updated"); $qoh = db_fetch_row($result); -- - $qty = $row[0] - $qoh[0]; //QOH prior to -ve stock is subtracted ++ + $qty = $row[0] - $qoh[0]; //QOH prior to -ve stock is subtracted $final_cost = $row[1] - $qoh[0]*$cost[0]; return array($qty,$final_cost); @@@ -428,8 -430,8 +428,3 @@@ function get_location_name($loc_code display_db_error("could not retreive the location name for $loc_code", $sql, true); } -- --//-------------------------------------------------------------------------------------------------- -- -- --?> diff --cc includes/main.inc index 8f2b3c33,8f2b3c33..98143cf9 --- a/includes/main.inc +++ b/includes/main.inc @@@ -22,21 -22,21 +22,24 @@@ include_once($path_to_root . "/includes include_once($path_to_root . "/admin/db/users_db.inc"); include_once($path_to_root . "/includes/ui/ui_view.inc"); include_once($path_to_root . "/includes/ui/ui_controls.inc"); -- ++ ++$page_nested = -1; ++ function page($title, $no_menu=false, $is_index=false, $onload="", $js="", $script_only=false, $css='') { -- global $path_to_root, $page_security; ++ global $path_to_root, $page_security, $page_nested; ++ if (++$page_nested) return; $hide_menu = $no_menu; -- include($path_to_root . "/includes/page/header.inc"); ++ include_once($path_to_root . "/includes/page/header.inc"); page_header($title, $no_menu, $is_index, $onload, $js, $css); check_page_security($page_security); // error_box(); -- if($script_only) { ++ if($script_only) { echo ''; @@@ -48,13 -48,13 +51,15 @@@ function end_page($no_menu=false, $is_index=false, $final_screen=false, $type_no=0, $trans_no=0) { -- global $path_to_root; ++ global $path_to_root, $page_nested; ++ ++ if ($page_nested-- > 0) return; if (!$is_index && function_exists('hyperlink_back')) hyperlink_back(true, $no_menu, $type_no, $trans_no, $final_screen); div_end(); // end of _page_body section -- include($path_to_root . "/includes/page/footer.inc"); ++ include_once($path_to_root . "/includes/page/footer.inc"); page_footer($no_menu, $is_index); } diff --cc includes/types.inc index ec06fbaa,79ef8be7..94d5c4e0 --- a/includes/types.inc +++ b/includes/types.inc @@@ -137,80 -137,6 +137,79 @@@ function payment_person_name($type, $pe } } +// +// Returns counterparty (supplier/customer) name for selected transaction. +// +function get_counterparty_name($trans_type, $trans_no, $full=true) +{ + switch($trans_type) + { + case ST_SALESORDER: + case ST_SALESQUOTE: + $sql = "SELECT order.customer_id as person_id, debtor.name as name + FROM ".TB_PREF."sales_orders order, ".TB_PREF."debtors_master debtor + WHERE order_no=".db_escape($trans_no)." AND trans_type=".db_escape($trans_type) + ." AND order.debtor_no=debtor.debtor_no"; + break; - + case ST_SALESINVOICE : + case ST_CUSTCREDIT : + case ST_CUSTPAYMENT : + case ST_CUSTDELIVERY : + $sql = "SELECT trans.debtor_no as person_id, debtor.name as name + FROM ".TB_PREF."debtor_trans trans, ".TB_PREF."debtors_master debtor + WHERE trans_no=".db_escape($trans_no)." AND type=".db_escape($trans_type) + ." AND trans.debtor_no=debtor.debtor_no"; + break; + + case ST_PURCHORDER : + $sql = "SELECT order.supplier_id as person_id, supp.supp_name as name + FROM ".TB_PREF."purch_orders order, ".TB_PREF."suppliers supp + WHERE order_no=".db_escape($trans_no) + ." AND order.supplier_id=supp.supplier_id"; + break; + + case ST_SUPPINVOICE : + case ST_SUPPCREDIT : + case ST_SUPPAYMENT : + $sql = "SELECT trans.supplier_id as person_id, supp.supp_name as name + FROM ".TB_PREF."supp_trans trans, ".TB_PREF."suppliers supp + WHERE trans_no=".db_escape($trans_no)." AND type=".db_escape($trans_type) + ." AND trans.supplier_id=supp.supplier_id"; + break; + + case ST_SUPPRECEIVE : + $sql = "SELECT trans.supplier_id as person_id, supp.supp_name as name + FROM ".TB_PREF."grn_batch trans, ".TB_PREF."suppliers supp + WHERE id=".db_escape($trans_no) + ." AND trans.supplier_id=supp.supplier_id"; + break; + + case ST_JOURNAL: // FIXME - this one can have multiply counterparties of various types depending on person_type_id + + default: + /* // internal operations + case ST_WORKORDER : + case ST_INVADJUST : // GRN/DN returns ? + case ST_BANKTRANSFER : + case ST_LOCTRANSFER : + case ST_MANUISSUE : + case ST_MANURECEIVE : + case ST_COSTUPDATE : + case ST_BANKPAYMENT : // generic bank transactions + case ST_BANKDEPOSIT :*/ + return null; + } + + $result = db_query($sql, 'cannot retrieve counterparty name'); + if (db_num_rows($result)) + { + $row = db_fetch($result); + return sprintf("[%05s] %s", $row['person_id'], $row['name']); + } + + return ''; +} + function payment_person_has_items($type) { switch ($type) { diff --cc includes/ui/ui_controls.inc index d2e094ae,bbe4c7f5..0639124a --- a/includes/ui/ui_controls.inc +++ b/includes/ui/ui_controls.inc @@@ -32,10 -32,10 +32,15 @@@ function get_post($name, $dflt='' ((!isset($_POST[$name]) || $_POST[$name] === '') ? $dflt : $_POST[$name]); } //--------------------------------------------------------------------------------- ++$form_nested = -1; function start_form($multi=false, $dummy=false, $action="", $name="") { // $dummy - leaved for compatibility with 2.0 API ++ global $form_nested; ++ ++ if (++$form_nested) return; ++ if ($name != "") $name = "name='$name'"; @@@ -53,7 -53,7 +58,9 @@@ function end_form($breaks=0) { -- global $Ajax; ++ global $Ajax, $form_nested; ++ ++ if ($form_nested-- > 0) return; $_SESSION['csrf_token'] = hash('sha256', uniqid(mt_rand(), true)); if ($breaks) diff --cc install/lang/new_language_template/LC_MESSAGES/empty.po index a874aded,b82bd46a..804d5ae2 --- a/install/lang/new_language_template/LC_MESSAGES/empty.po +++ b/install/lang/new_language_template/LC_MESSAGES/empty.po @@@ -8,60 -8,66 +8,67 @@@ msgid " msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" - "POT-Creation-Date: 2010-08-13 15:12+0200\n" ++"POT-Creation-Date: 2012-02-29 09:49+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" + "Language: \n" "MIME-Version: 1.0\n" - "Content-Type: text/plain; charset=CHARSET\n" + "Content-Type: text/plain; charset=ISO-8859-2\n" "Content-Transfer-Encoding: 8bit\n" - #: ../install/index.php:20 ../install/index.php:40 -#: install/index.php:20 install/index.php:40 ++#: install/index.php:20 install/index.php:41 msgid "FrontAccouting ERP Installation Wizard" msgstr "" - #: ../install/index.php:41 -#: install/index.php:41 ++#: install/index.php:42 #, php-format msgid "Step %d: %s" msgstr "" - #: ../install/index.php:48 -#: install/index.php:48 ++#: install/index.php:49 msgid "Chart of accounts" msgstr "" - #: ../install/index.php:48 ../install/index.php:75 -#: install/index.php:48 install/index.php:75 ++#: install/index.php:49 install/index.php:76 msgid "Encoding" msgstr "" - #: ../install/index.php:48 ../install/index.php:75 -#: install/index.php:48 install/index.php:75 ++#: install/index.php:49 install/index.php:76 msgid "Description" msgstr "" - #: ../install/index.php:48 ../install/index.php:75 -#: install/index.php:48 install/index.php:75 ++#: install/index.php:49 install/index.php:76 msgid "Install" msgstr "" - #: ../install/index.php:65 ../install/index.php:93 -#: install/index.php:65 install/index.php:93 ++#: install/index.php:66 install/index.php:94 msgid "Installed" msgstr "" - #: ../install/index.php:75 -#: install/index.php:75 ++#: install/index.php:76 msgid "Language" msgstr "" - #: ../install/index.php:156 -#: install/index.php:123 ++#: install/index.php:124 + msgid "" + "Cannot connect to database. User or password is invalid or you have no " + "permittions to create database." + msgstr "" + -#: install/index.php:159 ++#: install/index.php:160 msgid "Cannot save system configuration file 'config.php'." msgstr "" - #: ../install/index.php:173 -#: install/index.php:166 ++#: install/index.php:167 msgid "Cannot open 'config_db.php' configuration file." msgstr "" - #: ../install/index.php:176 -#: install/index.php:169 ++#: install/index.php:170 msgid "Cannot write to the 'config_db.php' configuration file." msgstr "" - #: ../install/index.php:179 -#: install/index.php:172 ++#: install/index.php:173 msgid "" "Configuration file 'config_db.php' is not writable. Change its permissions " "so it is, then re-run installation step." @@@ -109,8 -115,8 +116,8 @@@ msgid " "Continue button below." msgstr "" - #: ../install/index.php:330 ../install/index.php:356 ../install/index.php:363 - #: ../install/index.php:370 ../install/index.php:389 + #: install/index.php:325 install/index.php:351 install/index.php:358 -#: install/index.php:365 install/index.php:384 ++#: install/index.php:365 install/index.php:389 msgid "Continue >>" msgstr "" @@@ -177,8 -183,8 +184,8 @@@ msgid " "connection right now. You can install them later." msgstr "" - #: ../install/index.php:355 ../install/index.php:362 ../install/index.php:369 - #: ../install/index.php:388 + #: install/index.php:350 install/index.php:357 install/index.php:364 -#: install/index.php:383 ++#: install/index.php:388 msgid "<< Back" msgstr "" @@@ -190,43 -196,43 +197,43 @@@ msgstr " msgid "Charts of Accounts Selection" msgstr "" - #: ../install/index.php:379 -#: install/index.php:374 ++#: install/index.php:379 msgid "Company Settings" msgstr "" - #: ../install/index.php:381 -#: install/index.php:376 ++#: install/index.php:381 msgid "Company Name:" msgstr "" - #: ../install/index.php:382 -#: install/index.php:377 ++#: install/index.php:382 msgid "Admin Login:" msgstr "" - #: ../install/index.php:383 -#: install/index.php:378 ++#: install/index.php:383 msgid "Admin Password:" msgstr "" - #: ../install/index.php:384 -#: install/index.php:379 ++#: install/index.php:384 msgid "Reenter Password:" msgstr "" - #: ../install/index.php:385 -#: install/index.php:380 ++#: install/index.php:385 msgid "Select Chart of Accounts:" msgstr "" - #: ../install/index.php:386 -#: install/index.php:381 ++#: install/index.php:386 msgid "Select Default Language:" msgstr "" - #: ../install/index.php:393 -#: install/index.php:388 ++#: install/index.php:393 msgid "FrontAccounting ERP has been installed successsfully." msgstr "" - #: ../install/index.php:394 -#: install/index.php:389 ++#: install/index.php:394 msgid "Please do not forget to remove install wizard folder." msgstr "" - #: ../install/index.php:396 -#: install/index.php:392 ++#: install/index.php:397 msgid "Click here to start." msgstr "" @@@ -453,6 -459,38 +460,43 @@@ msgstr " msgid "Comments" msgstr "" - #: ../includes/system_tests.inc:435 + #: includes/system_tests.inc:435 msgid "Ok" msgstr "" + + #: includes/packages.inc:190 + #, php-format + msgid "No key field '%s' in file '%s'" + msgstr "" + -#: includes/packages.inc:295 ++#: includes/packages.inc:295 includes/packages.inc:329 ++#, php-format ++msgid "Cannot delete outdated '%s' file." ++msgstr "" ++ ++#: includes/packages.inc:299 + msgid "Release file in repository is invalid, or public key is outdated." + msgstr "" + -#: includes/packages.inc:311 ++#: includes/packages.inc:316 + msgid "Repository version does not match application version." + msgstr "" + -#: includes/packages.inc:325 ++#: includes/packages.inc:333 + #, php-format + msgid "" + "Security alert: broken index file in repository '%s'. Please inform " + "repository administrator about this issue." + msgstr "" + -#: includes/packages.inc:358 ++#: includes/packages.inc:366 + #, php-format + msgid "" + "Security alert: broken package '%s' in repository. Please inform repository " + "administrator about this issue." + msgstr "" + -#: includes/packages.inc:613 includes/packages.inc:664 ++#: includes/packages.inc:621 includes/packages.inc:672 + #, php-format + msgid "Package '%s' not found." + msgstr "" diff --cc inventory/cost_update.php index 03db733e,b5ee125d..0e39a0c0 --- a/inventory/cost_update.php +++ b/inventory/cost_update.php @@@ -38,8 -38,8 +38,8 @@@ if (isset($_GET['stock_id']) if (isset($_POST['UpdateData'])) { - $old_cost = $_POST['OldMaterialCost'] + $_POST['OldLabourCost'] - + $_POST['OldOverheadCost']; + $old_cost = get_standard_cost($_POST['stock_id']); - ++ $new_cost = input_num('material_cost') + input_num('labour_cost') + input_num('overhead_cost'); diff --cc inventory/includes/db/items_trans_db.inc index 7292814d,78930e81..923d18c4 --- a/inventory/includes/db/items_trans_db.inc +++ b/inventory/includes/db/items_trans_db.inc @@@ -35,25 -44,26 +44,32 @@@ function stock_cost_update($stock_id, $ $qoh = get_qoh_on_date($_POST['stock_id']); $date_ = Today(); + if (!is_date_in_fiscalyear($date_)) + $date_ = end_fiscalyear(); + if ($qoh > 0) { - - $update_no = get_next_trans_no(ST_COSTUPDATE); - if (!is_date_in_fiscalyear($date_)) - $date_ = end_fiscalyear(); - - $stock_gl_code = get_stock_gl_code($stock_id); - $new_cost = $material_cost + $labour_cost + $overhead_cost; + $value_of_change = $qoh * ($new_cost - $last_cost); + + $memo_ = "Cost was " . $last_cost . " changed to " . $new_cost . " x quantity on hand of $qoh"; + add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $date_, $stock_gl_code["adjustment_account"], + $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], $memo_, (-$value_of_change)); + - add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $date_, $stock_gl_code["inventory_account"], 0, 0, $memo_, - $value_of_change); + $value_of_change = round2($qoh * ($new_cost - $last_cost), user_price_dec()); + + if ($value_of_change != 0) + { + $stock_gl_code = get_stock_gl_code($stock_id); + $update_no = get_next_trans_no(ST_COSTUPDATE); + $memo_ = "Cost was " . $last_cost . " changed to " . $new_cost . " x quantity on hand of $qoh"; + add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $date_, $stock_gl_code["adjustment_account"], + $stock_gl_code["dimension_id"], $stock_gl_code["dimension2_id"], $memo_, (-$value_of_change)); + + add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $date_, $stock_gl_code["inventory_account"], 0, 0, $memo_, + $value_of_change); - } ++ } } add_audit_trail(ST_COSTUPDATE, $update_no, $date_); diff --cc inventory/inquiry/stock_movements.php index 1dd13827,2c5aa0e0..417b5df5 --- a/inventory/inquiry/stock_movements.php +++ b/inventory/inquiry/stock_movements.php @@@ -18,13 -18,15 +18,12 @@@ include_once($path_to_root . "/includes include_once($path_to_root . "/sales/includes/sales_db.inc"); include_once($path_to_root . "/includes/ui.inc"); -if (!@$_GET['popup']) -{ - $js = ""; - if ($use_popup_windows) - $js .= get_js_open_window(800, 500); - if ($use_date_picker) - $js .= get_js_date_picker(); - page(_($help_context = "Inventory Item Movement"), @$_GET['popup'], false, "", $js); -} +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(800, 500); +if ($use_date_picker) + $js .= get_js_date_picker(); - - page(_($help_context = "Inventory Item Movement"), false, false, "", $js); ++page(_($help_context = "Inventory Item Movement"), @$_GET['popup'], false, "", $js); //------------------------------------------------------------------------------------------------ check_db_has_stock_items(_("There are no items defined in the system.")); @@@ -46,7 -49,8 +45,8 @@@ if (!isset($_POST['stock_id']) start_table(TABLESTYLE_NOBORDER); start_row(); - stock_items_list_cells(_("Item:"), 'stock_id', $_POST['stock_id']); -if (!@$_GET['popup']) ++if (!$page_nested) + stock_costable_items_list_cells(_("Item:"), 'stock_id', $_POST['stock_id']); end_row(); end_table(); diff --cc inventory/inquiry/stock_status.php index 1ccbca0d,b6965d29..146422fa --- a/inventory/inquiry/stock_status.php +++ b/inventory/inquiry/stock_status.php @@@ -13,13 -13,16 +13,11 @@@ $page_security = 'SA_ITEMSSTATVIEW' $path_to_root = "../.."; include_once($path_to_root . "/includes/session.inc"); - if (isset($_GET['stock_id'])){ -if (!@$_GET['popup']) -{ - if (isset($_GET['stock_id'])){ - page(_($help_context = "Inventory Item Status"), true); - } else { - page(_($help_context = "Inventory Item Status")); - } -} ++page(_($help_context = "Inventory Item Status")); ++ + if (isset($_GET['stock_id'])) $_POST['stock_id'] = $_GET['stock_id']; - page(_($help_context = "Inventory Item Status"), true); - } else { - page(_($help_context = "Inventory Item Status")); - } + include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/includes/manufacturing.inc"); @@@ -38,8 -42,11 +36,11 @@@ start_form() if (!isset($_POST['stock_id'])) $_POST['stock_id'] = get_global_stock_item(); - echo "
" . _("Item:"). " "; - echo stock_items_list('stock_id', $_POST['stock_id'], false, true); -if (!@$_GET['popup']) ++if (!$page_nested) + { + echo "
" . _("Item:"). " "; + echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true); -} ++} echo "
"; echo "
"; diff --cc inventory/manage/items.php index 1391b825,666486f0..70572f59 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@@ -12,8 -12,13 +12,15 @@@ $page_security = 'SA_ITEM'; $path_to_root = "../.."; include($path_to_root . "/includes/session.inc"); + - page(_($help_context = "Items"), @$_REQUEST['popup']); + $js = ""; + if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + if ($use_date_picker) + $js .= get_js_date_picker(); + -page(_($help_context = "Items"), false, false, "", $js); ++page(_($help_context = "Items"), @$_REQUEST['popup'], false, "", $js); ++ include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/ui.inc"); @@@ -239,194 -246,238 +253,237 @@@ if (isset($_POST['delete']) && strlen($ $Ajax->activate('_page_body'); } } - //-------------------------------------------------------------------------------------------- - - start_form(true); - if (db_has_stock_items()) + function item_settings(&$stock_id) { - start_table(TABLESTYLE_NOBORDER); - start_row(); - stock_items_list_cells(_("Select an item:"), 'stock_id', null, - _('New item'), true, check_value('show_inactive')); - $new_item = get_post('stock_id')==''; - check_cells(_("Show inactive:"), 'show_inactive', null, true); - end_row(); - end_table(); + global $SysPrefs, $path_to_root, $new_item, $pic_height; - if (get_post('_show_inactive_update')) { - $Ajax->activate('stock_id'); - set_focus('stock_id'); + start_outer_table(TABLESTYLE2); + + table_section(1); + + table_section_title(_("Item")); + + //------------------------------------------------------------------------------------ + if ($new_item) + { + text_row(_("Item Code:"), 'NewStockID', null, 21, 20); + + $_POST['inactive'] = 0; + } + else + { // Must be modifying an existing item + if (get_post('NewStockID') != get_post('stock_id') || get_post('addupdate')) { // first item display + + $_POST['NewStockID'] = $_POST['stock_id']; + + $myrow = get_item($_POST['NewStockID']); + + $_POST['long_description'] = $myrow["long_description"]; + $_POST['description'] = $myrow["description"]; + $_POST['category_id'] = $myrow["category_id"]; + $_POST['tax_type_id'] = $myrow["tax_type_id"]; + $_POST['units'] = $myrow["units"]; + $_POST['mb_flag'] = $myrow["mb_flag"]; + + $_POST['sales_account'] = $myrow['sales_account']; + $_POST['inventory_account'] = $myrow['inventory_account']; + $_POST['cogs_account'] = $myrow['cogs_account']; + $_POST['adjustment_account'] = $myrow['adjustment_account']; + $_POST['assembly_account'] = $myrow['assembly_account']; + $_POST['dimension_id'] = $myrow['dimension_id']; + $_POST['dimension2_id'] = $myrow['dimension2_id']; + $_POST['no_sale'] = $myrow['no_sale']; + $_POST['del_image'] = 0; + $_POST['inactive'] = $myrow["inactive"]; + $_POST['editable'] = $myrow["editable"]; + } + label_row(_("Item Code:"),$_POST['NewStockID']); + hidden('NewStockID', $_POST['NewStockID']); + set_focus('description'); } - } - div_start('details'); - start_outer_table(TABLESTYLE2); + text_row(_("Name:"), 'description', null, 52, 200); - table_section(1); + textarea_row(_('Description:'), 'long_description', null, 42, 3); - table_section_title(_("Item")); + stock_categories_list_row(_("Category:"), 'category_id', null, false, $new_item); + + if ($new_item && (list_updated('category_id') || !isset($_POST['units']))) { + + $category_record = get_item_category($_POST['category_id']); + + $_POST['tax_type_id'] = $category_record["dflt_tax_type"]; + $_POST['units'] = $category_record["dflt_units"]; + $_POST['mb_flag'] = $category_record["dflt_mb_flag"]; + $_POST['inventory_account'] = $category_record["dflt_inventory_act"]; + $_POST['cogs_account'] = $category_record["dflt_cogs_act"]; + $_POST['sales_account'] = $category_record["dflt_sales_act"]; + $_POST['adjustment_account'] = $category_record["dflt_adjustment_act"]; + $_POST['assembly_account'] = $category_record["dflt_assembly_act"]; + $_POST['dimension_id'] = $category_record["dflt_dim1"]; + $_POST['dimension2_id'] = $category_record["dflt_dim2"]; + $_POST['no_sale'] = $category_record["dflt_no_sale"]; + $_POST['editable'] = 0; - //------------------------------------------------------------------------------------ - if ($new_item) - { - text_row(_("Item Code:"), 'NewStockID', null, 21, 20); - - $_POST['inactive'] = 0; - } - else - { // Must be modifying an existing item - if (get_post('NewStockID') != get_post('stock_id')) { // first item display - - $_POST['NewStockID'] = $_POST['stock_id']; - - $myrow = get_item($_POST['NewStockID']); - - $_POST['long_description'] = $myrow["long_description"]; - $_POST['description'] = $myrow["description"]; - $_POST['category_id'] = $myrow["category_id"]; - $_POST['tax_type_id'] = $myrow["tax_type_id"]; - $_POST['units'] = $myrow["units"]; - $_POST['mb_flag'] = $myrow["mb_flag"]; - - $_POST['sales_account'] = $myrow['sales_account']; - $_POST['inventory_account'] = $myrow['inventory_account']; - $_POST['cogs_account'] = $myrow['cogs_account']; - $_POST['adjustment_account'] = $myrow['adjustment_account']; - $_POST['assembly_account'] = $myrow['assembly_account']; - $_POST['dimension_id'] = $myrow['dimension_id']; - $_POST['dimension2_id'] = $myrow['dimension2_id']; - $_POST['no_sale'] = $myrow['no_sale']; - $_POST['del_image'] = 0; - $_POST['inactive'] = $myrow["inactive"]; - $_POST['editable'] = $myrow["editable"]; } - label_row(_("Item Code:"),$_POST['NewStockID']); - hidden('NewStockID', $_POST['NewStockID']); - set_focus('description'); - } + $fresh_item = !isset($_POST['NewStockID']) || $new_item + || check_usage($_POST['stock_id'],false); - text_row(_("Name:"), 'description', null, 52, 200); + item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null); - textarea_row(_('Description:'), 'long_description', null, 42, 3); + stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item); - stock_categories_list_row(_("Category:"), 'category_id', null, false, $new_item); + stock_units_list_row(_('Units of Measure:'), 'units', null, $fresh_item); - if ($new_item && (list_updated('category_id') || !isset($_POST['units']))) { + check_row(_("Editable description:"), 'editable'); - $category_record = get_item_category($_POST['category_id']); + check_row(_("Exclude from sales:"), 'no_sale'); - $_POST['tax_type_id'] = $category_record["dflt_tax_type"]; - $_POST['units'] = $category_record["dflt_units"]; - $_POST['mb_flag'] = $category_record["dflt_mb_flag"]; - $_POST['inventory_account'] = $category_record["dflt_inventory_act"]; - $_POST['cogs_account'] = $category_record["dflt_cogs_act"]; - $_POST['sales_account'] = $category_record["dflt_sales_act"]; - $_POST['adjustment_account'] = $category_record["dflt_adjustment_act"]; - $_POST['assembly_account'] = $category_record["dflt_assembly_act"]; - $_POST['dimension_id'] = $category_record["dflt_dim1"]; - $_POST['dimension2_id'] = $category_record["dflt_dim2"]; - $_POST['no_sale'] = $category_record["dflt_no_sale"]; - $_POST['editable'] = 0; + table_section(2); - } - $fresh_item = !isset($_POST['NewStockID']) || $new_item - || check_usage($_POST['stock_id'],false); + $dim = get_company_pref('use_dimension'); + if ($dim >= 1) + { + table_section_title(_("Dimensions")); + + dimensions_list_row(_("Dimension")." 1", 'dimension_id', null, true, " ", false, 1); + if ($dim > 1) + dimensions_list_row(_("Dimension")." 2", 'dimension2_id', null, true, " ", false, 2); + } + if ($dim < 1) + hidden('dimension_id', 0); + if ($dim < 2) + hidden('dimension2_id', 0); + + table_section_title(_("GL Accounts")); - item_tax_types_list_row(_("Item Tax Type:"), 'tax_type_id', null); + gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']); - stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, $fresh_item); + if (!is_service($_POST['mb_flag'])) + { + gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']); + gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']); + gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']); + } + else + { + gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']); + hidden('inventory_account', $_POST['inventory_account']); + hidden('adjustment_account', $_POST['adjustment_account']); + } - stock_units_list_row(_('Units of Measure:'), 'units', null, $fresh_item); - check_row(_("Editable description:"), 'editable'); + if (is_manufactured($_POST['mb_flag'])) + gl_all_accounts_list_row(_("Item Assembly Costs Account:"), 'assembly_account', $_POST['assembly_account']); + else + hidden('assembly_account', $_POST['assembly_account']); - check_row(_("Exclude from sales:"), 'no_sale'); + table_section_title(_("Other")); - table_section(2); + // Add image upload for New Item - by Joe + file_row(_("Image File (.jpg)") . ":", 'pic', 'pic'); + // Add Image upload for New Item - by Joe + $stock_img_link = ""; + $check_remove_image = false; + if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/' + .item_img_name($_POST['NewStockID']).".jpg")) + { + // 31/08/08 - rand() call is necessary here to avoid caching problems. Thanks to Peter D. + $stock_img_link .= "[".$_POST["; + $check_remove_image = true; + } + else + { + $stock_img_link .= _("No image"); + } - $dim = get_company_pref('use_dimension'); - if ($dim >= 1) - { - table_section_title(_("Dimensions")); + label_row(" ", $stock_img_link); + if ($check_remove_image) + check_row(_("Delete Image:"), 'del_image'); + + record_status_list_row(_("Item status:"), 'inactive'); + end_outer_table(1); + + div_start('controls'); + if (!isset($_POST['NewStockID']) || $new_item) + { + submit_center('addupdate', _("Insert New Item"), true, '', 'default'); + } + else + { + submit_center_first('addupdate', _("Update Item"), '', + @$_REQUEST['popup'] ? true : 'default'); + submit_return('select', get_post('stock_id'), + _("Select this items and return to document entry."), 'default'); + submit('clone', _("Clone This Item"), true, '', true); + submit('delete', _("Delete This Item"), true, '', true); + submit_center_last('cancel', _("Cancel"), _("Cancel Edition"), 'cancel'); + } - dimensions_list_row(_("Dimension")." 1", 'dimension_id', null, true, " ", false, 1); - if ($dim > 1) - dimensions_list_row(_("Dimension")." 2", 'dimension2_id', null, true, " ", false, 2); + div_end(); } - if ($dim < 1) - hidden('dimension_id', 0); - if ($dim < 2) - hidden('dimension2_id', 0); - table_section_title(_("GL Accounts")); + //-------------------------------------------------------------------------------------------- - gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']); + start_form(true); - if (!is_service($_POST['mb_flag'])) + if (db_has_stock_items()) { - gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']); - gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']); - gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']); + start_table(TABLESTYLE_NOBORDER); + start_row(); + stock_items_list_cells(_("Select an item:"), 'stock_id', null, + _('New item'), true, check_value('show_inactive')); + $new_item = get_post('stock_id')==''; + check_cells(_("Show inactive:"), 'show_inactive', null, true); + end_row(); + end_table(); + + if (get_post('_show_inactive_update')) { + $Ajax->activate('stock_id'); + set_focus('stock_id'); + } } - else + else { - gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']); - hidden('inventory_account', $_POST['inventory_account']); - hidden('adjustment_account', $_POST['adjustment_account']); + hidden('stock_id', get_post('stock_id')); } + div_start('details'); - if (is_manufactured($_POST['mb_flag'])) - gl_all_accounts_list_row(_("Item Assembly Costs Account:"), 'assembly_account', $_POST['assembly_account']); - else - hidden('assembly_account', $_POST['assembly_account']); - - table_section_title(_("Other")); - - // Add image upload for New Item - by Joe - file_row(_("Image File (.jpg)") . ":", 'pic', 'pic'); - // Add Image upload for New Item - by Joe - $stock_img_link = ""; - $check_remove_image = false; - if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/' - .item_img_name($_POST['NewStockID']).".jpg")) - { - // 31/08/08 - rand() call is necessary here to avoid caching problems. Thanks to Peter D. - $stock_img_link .= "[".$_POST["; - $check_remove_image = true; - } - else - { - $stock_img_link .= _("No image"); - } + $stock_id = get_post('stock_id'); + if (!$stock_id) + unset($_POST['_tabs_sel']); // force settings tab for new customer - label_row(" ", $stock_img_link); - if ($check_remove_image) - check_row(_("Delete Image:"), 'del_image'); + tabbed_content_start('tabs', array( + 'settings' => array(_('&General settings'), $stock_id), + 'movement' => array(_('&Transactions'), $stock_id), + 'status' => array(_('&Status'), $stock_id), + )); - record_status_list_row(_("Item status:"), 'inactive'); - end_outer_table(1); - div_end(); - div_start('controls'); - if (!isset($_POST['NewStockID']) || $new_item) - { - submit_center('addupdate', _("Insert New Item"), true, '', 'default'); - } - else - { - submit_center_first('addupdate', _("Update Item"), '', - @$_REQUEST['popup'] ? true : 'default'); - submit_return('select', get_post('stock_id'), - _("Select this items and return to document entry."), 'default'); - submit('clone', _("Clone This Item"), true, '', true); - submit('delete', _("Delete This Item"), true, '', true); - submit_center_last('cancel', _("Cancel"), _("Cancel Edition"), 'cancel'); - } + switch (get_post('_tabs_sel')) { + default: + case 'settings': + item_settings($stock_id); + break; + case 'movement': + $_GET['stock_id'] = $stock_id; + $_GET['popup'] = 1; + include_once($path_to_root."/inventory/inquiry/stock_movements.php"); + break; + case 'status': + $_GET['stock_id'] = $stock_id; + $_GET['popup'] = 1; + include_once($path_to_root."/inventory/inquiry/stock_status.php"); + break; + }; + br(); + tabbed_content_end(); div_end(); + - hidden('popup', @$_REQUEST['popup']); end_form(); diff --cc manufacturing/includes/db/work_order_issues_db.inc index 28167da7,ca2f4a86..8b7f7f7d --- a/manufacturing/includes/db/work_order_issues_db.inc +++ b/manufacturing/includes/db/work_order_issues_db.inc @@@ -68,7 -70,14 +70,14 @@@ function add_work_order_issue($woid, $r $issue_cost = $standard_cost * $item->quantity; $issue = get_stock_gl_code($item->stock_id); $stockitem = get_item($item->stock_id); - $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $issue["inventory_account"], 0, 0, - ++ + //Chaitanya : Compatibility for Service Items + if (!is_service($issue["mb_flag"])) + $ivaccount = $issue["inventory_account"]; + else + $ivaccount = $issue["cogs_account"]; - ++ + $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $ivaccount, 0, 0, $date_.": "._("Issue of")." ".$stockitem["description"], -$issue_cost); $issue_total += $issue_cost; } @@@ -156,18 -166,63 +166,63 @@@ function void_work_order_issue($type_no { begin_transaction(); hook_db_prevoid(ST_MANUISSUE, $type_no); - + + //Chaitanya : Skip processing already voided entry i.e. explicitly voided + $void_entry = get_voided_entry(ST_MANUISSUE, $type_no); + if ($void_entry) + return; + // void the actual issue items and their quantities $sql = "UPDATE ".TB_PREF."wo_issue_items Set qty_issued = 0 WHERE issue_id=" .db_escape($type_no); db_query($sql,"A work order issue item could not be voided"); - // void all related stock moves - void_stock_move(ST_MANUISSUE, $type_no); - // void any related gl trans - void_gl_trans(ST_MANUISSUE, $type_no, true); + //Chaitanya : Nothing happens due to next statement as all gl postings are done against WO + //void_gl_trans(ST_MANUISSUE, $type_no, true); + + //Chaitanya : Reverse the gl posting + $issue = get_work_order_issue($type_no); + $manf_stock_id = $issue["stock_id"]; + $date_ = sql2date($issue["issue_date"]); + $woid = $issue["workorder_id"]; - ++ + $result = get_stock_moves(ST_MANUISSUE, $type_no); + $total_cost = 0; + $issue_total = 0; + while ($myrow = db_fetch($result)) + { + $issue_cost = $myrow["qty"]*$myrow["standard_cost"]; + $issue = get_stock_gl_code($myrow["stock_id"]); + $stockitem = get_item($myrow["stock_id"]); - ++ + //Chaitanya : Compatibility for Service Items + if (!is_service($issue["mb_flag"])) + $ivaccount = $issue["inventory_account"]; + else - $ivaccount = $issue["cogs_account"]; - ++ $ivaccount = $issue["cogs_account"]; ++ + if ($issue_cost != 0) + { + $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $ivaccount, 0, 0, + $date_.": "._("Reversed the issue of")." ".$stockitem["description"], - -$issue_cost); ++ -$issue_cost); + $issue_total += $issue_cost; + } + } + if ($issue_total != 0) + //Chaitanya : Revese cost effect on manfactured stock item as adjustment only + add_issue_cost($manf_stock_id, 0, $date_, $issue_total, true); + $issue = get_stock_gl_code($manf_stock_id); + $stockitem = get_item($manf_stock_id); + if ($total_cost != 0) + add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $issue["inventory_account"], + 0, 0, $date_.": "._("Reversed the issue to")." ".$stockitem["description"], + -$total_cost); - ++ + //Chaitanya : Shifted below void all related stock moves + void_stock_move(ST_MANUISSUE, $type_no); - + commit_transaction(); } diff --cc manufacturing/includes/db/work_order_produce_items_db.inc index 9b2095c0,38af2add..dcac240c --- a/manufacturing/includes/db/work_order_produce_items_db.inc +++ b/manufacturing/includes/db/work_order_produce_items_db.inc @@@ -48,8 -48,18 +48,17 @@@ function work_order_produce($woid, $ref // ------------------------------------------------------------------------- work_order_quick_costs($woid, $details["stock_id"], $quantity, $date_, $id); - - // ------------------------------------------------------------------------- + + // Chaitanya: stamp BOM cost to finished item + $m_cost = 0; + $result = get_bom($details["stock_id"]); + while ($bom_item = db_fetch($result)) + { + $standard_cost = get_standard_cost($bom_item['component']); + $m_cost += ($bom_item['quantity'] * $standard_cost); - } ++ } + // insert a +ve stock move for the item being manufactured // negative means "unproduce" or unassemble add_stock_move(ST_MANURECEIVE, $details["stock_id"], $id, @@@ -109,18 -118,53 +117,52 @@@ function void_work_order_produce($type_ { begin_transaction(); hook_db_prevoid(ST_MANURECEIVE, $type_no); - + + //Chaitanya : Skip processing already voided entry i.e. explicitly voided + $void_entry = get_voided_entry(ST_MANURECEIVE, $type_no); + if ($void_entry) + return; + $row = get_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); + //Chaitanya : skipped this step as BOM may have got changed + //work_order_quick_costs($row['workorder_id'], $row['stock_id'], -$row['quantity'], sql2date($row['date_']), $type_no); + // void any related gl trans + //Chaitanya : Nothing happens due to next statement as all gl postings are done against WO + //void_gl_trans(ST_MANURECEIVE, $type_no, true); + + $woid = $row["workorder_id"]; + $date_ = sql2date($row["date_"]); + + $result = get_stock_moves(ST_MANURECEIVE, $type_no); + while ($myrow = db_fetch($result)) + { + $issue_cost = $myrow["qty"]*$myrow["standard_cost"]; + $issue = get_stock_gl_code($myrow["stock_id"]); + $stockitem = get_item($myrow["stock_id"]); - ++ + //Chaitanya : Compatibility for Service Items + if (!is_service($issue["mb_flag"])) + $ivaccount = $issue["inventory_account"]; + else - $ivaccount = $issue["cogs_account"]; - ++ $ivaccount = $issue["cogs_account"]; ++ + if ($issue_cost != 0) + { + add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $ivaccount, 0, 0, + $date_.": "._("Reversed the production ")." ".$stockitem["description"], + -$issue_cost); + } - } - ++ } // 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"); - + db_query($sql, "Cannot void a wo production"); + + //Chaitanya : Shifted below // void all related stock moves void_stock_move(ST_MANURECEIVE, $type_no); diff --cc manufacturing/includes/db/work_orders_db.inc index e63aae81,2aed7c19..eb310568 --- a/manufacturing/includes/db/work_orders_db.inc +++ b/manufacturing/includes/db/work_orders_db.inc @@@ -173,7 -370,7 +173,7 @@@ function release_work_order($woid, $rel create_wo_requirements($woid, $stock_id); add_comments(ST_WORKORDER, $woid, $releaseDate, $memo_); - add_audit_trail(ST_WORKORDER, $woid, $myrow['date_'], _("Released.")); - add_audit_trail(ST_WORKORDER, $woid, $releaseDate,_("Released.")); ++ add_audit_trail(ST_WORKORDER, $woid, sql2date($myrow['date_']), _("Released.")); commit_transaction(); } diff --cc manufacturing/includes/db/work_orders_quick_db.inc index 5654caeb,9b869d0a..bcf9688f --- a/manufacturing/includes/db/work_orders_quick_db.inc +++ b/manufacturing/includes/db/work_orders_quick_db.inc @@@ -116,15 -134,26 +116,16 @@@ function work_order_quick_costs($woid, $memo = $date_.": ".$memo; update_wo_requirement_issued($woid, $bom_item['component'], $bom_item["quantity"] * $units_reqd); // insert a -ve stock move for each item - // Chaitanya: Updated to record price and cost as std_cost for work order issued item - $UnitCost = get_standard_cost($bom_item["component"]); add_stock_move(ST_MANURECEIVE, $bom_item["component"], $advanced, - $bom_item["loc_code"], $date_, "", -$bom_item["quantity"] * $units_reqd, $UnitCost, 0, 1, $UnitCost); + $bom_item["loc_code"], $date_, "", -$bom_item["quantity"] * $units_reqd, 0); } - - //Chaitanya : Compatibility for Service Items - if (!is_service($bom_accounts["mb_flag"])) - $ivaccount = $bom_accounts["inventory_account"]; - else - $ivaccount = $bom_accounts["cogs_account"]; - $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $ivaccount, 0, 0, + $total_cost += add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $bom_accounts["inventory_account"], 0, 0, $memo, -$bom_cost); - $total_material_cost += $bom_cost; + } ++ $item_accounts = get_stock_gl_code($stock_id); if ($advanced) { - //Chaitanya: Material cost added at time of production as per BOM at the time and in adjustment mode. - add_material_cost($stock_id, $units_reqd, $date_, true); - $wo = get_work_order($woid); // also take the additional issues // moved to work_order_issues_db.inc @@@ -147,22 -176,44 +148,21 @@@ $lcost = get_gl_wo_cost($woid, WO_LABOUR); add_labour_cost($stock_id, $units_reqd, $date_, $lcost * $units_reqd / $wo['units_reqd']); $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 - $item_accounts = get_stock_gl_code($stock_id); - if ($costs != 0.0) - { - add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $cr_acc, - 0, 0, $wo_cost_types[WO_OVERHEAD], -$costs, PT_WORKORDER, WO_OVERHEAD); - $is_bank_to = is_bank_account($cr_acc); - if ($is_bank_to) - { - add_bank_trans(ST_WORKORDER, $woid, $is_bank_to, "", - $date_, -$costs, PT_WORKORDER, WO_OVERHEAD, get_company_currency(), - "Cannot insert a destination bank transaction"); - } - - add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["assembly_account"], - $item_accounts["dimension_id"], $item_accounts["dimension2_id"], $wo_cost_types[WO_OVERHEAD], $costs, - PT_WORKORDER, WO_OVERHEAD); - } - if ($labour != 0.0) - { - add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $cr_lab_acc, - 0, 0, $wo_cost_types[WO_LABOUR], -$labour, PT_WORKORDER, WO_LABOUR); - $is_bank_to = is_bank_account($cr_lab_acc); - if ($is_bank_to) - { - add_bank_trans(ST_WORKORDER, $woid, $is_bank_to, "", - $date_, -$labour, PT_WORKORDER, WO_LABOUR, get_company_currency(), - "Cannot insert a destination bank transaction"); - } - - add_gl_trans_std_cost(ST_WORKORDER, $woid, $date_, $item_accounts["assembly_account"], - $item_accounts["dimension_id"], $item_accounts["dimension2_id"], $wo_cost_types[WO_LABOUR], $labour, - PT_WORKORDER, WO_LABOUR); + add_overhead_cost($stock_id, $units_reqd, $date_, $ocost * $units_reqd / $wo['units_reqd']); + + } else { // only for quick + // credit additional costs - $item_accounts = get_stock_gl_code($stock_id); + + if ($costs != 0.0) + { + add_wo_costs_journal($woid, $costs, WO_OVERHEAD, $cr_acc, $item_accounts["assembly_account"], + $date_, $item_accounts["dimension_id"], $item_accounts["dimension2_id"]); + } + if ($labour != 0.0) // only for quick + { + add_wo_costs_journal($woid, $labour, WO_LABOUR, $cr_lab_acc, $item_accounts["assembly_account"], + $date_, $item_accounts["dimension_id"], $item_accounts["dimension2_id"]); + } } // debit total components $total_cost $stockitem = get_item($stock_id); diff --cc manufacturing/work_order_issue.php index 77863d27,c7d1cd7c..b5d6e4cc --- a/manufacturing/work_order_issue.php +++ b/manufacturing/work_order_issue.php @@@ -64,9 -62,9 +64,7 @@@ function handle_new_order( unset ($_SESSION['issue_items']); } -- Session_register("issue_items"); -- - $_SESSION['issue_items'] = new items_cart(28); + $_SESSION['issue_items'] = new items_cart(ST_MANUISSUE); $_SESSION['issue_items']->order_id = $_GET['trans_no']; } diff --cc purchasing/includes/db/grn_db.inc index d1c35452,a31bc2ec..00e088e0 --- a/purchasing/includes/db/grn_db.inc +++ b/purchasing/includes/db/grn_db.inc @@@ -12,6 -12,11 +12,11 @@@ //------------------- update average material cost ------------------------------------------ Joe Hunt Mar-03-2008 function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $adj_only=false) { + //Handle if inventory will become negative - //8-OCT-2011 : Skip negative inventory adjustment for case of adjust_only - if (is_inventory_item($stock_id) && !$adj_only) ++ //8-OCT-2011 : Skip negative inventory adjustment for case of adjust_only ++ if (is_inventory_item($stock_id) && !$adj_only) + handle_negative_inventory($stock_id, $qty, $price, $date); + // probably this function should be optimized // passing transaction cart as argument. This would // save a couple of db calls like get_supplier() @@@ -36,20 -38,29 +38,30 @@@ } else $price_in_home_currency = $price; - $sql = "SELECT material_cost FROM ".TB_PREF."stock_master WHERE stock_id=".db_escape($stock_id); - ++ + $price_in_home_currency_ = $price_in_home_currency; + + $sql = "SELECT mb_flag, material_cost, labour_cost, overhead_cost FROM ".TB_PREF."stock_master WHERE stock_id=".db_escape($stock_id); $result = db_query($sql); $myrow = db_fetch($result); $material_cost = $myrow['material_cost']; - if ($price > -0.0001 && $price < 0.0001) - return $material_cost; + - //Price adjustment for manufactured item - if (!$adj_only && $myrow['mb_flag'] == 'M') ++ //Price adjustment for manufactured item ++ if (!$adj_only && $myrow['mb_flag'] == 'M') + { + $standard_cost = get_standard_cost($stock_id); + //reduce overhead_cost and labour_cost from price as those will remain as is + $price_in_home_currency = $price_in_home_currency - $myrow['labour_cost'] - $myrow['overhead_cost']; + } - ++ if ($adj_only) $exclude = ST_CUSTDELIVERY; else $exclude = 0; $cost_adjust = false; - //$qoh = get_qoh_on_date($stock_id, null, $date, $exclude); ++ $qoh = get_qoh_on_date($stock_id); - + if ($adj_only) { if ($qoh > 0) @@@ -63,13 -74,13 +75,12 @@@ $cost_adjust = true; $qoh = 0; } - if ($qoh + $qty != 0) + if ($qoh + $qty > 0) - $material_cost -= ($qoh * $material_cost + $qty * $price_in_home_currency) / ($qoh + $qty); - } - + $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 - adjust_deliveries($stock_id, $material_cost, $date); ++ } ++ + if ($cost_adjust) // new 2010-02-10 //Chaitanya : Material_cost replaced with price + adjust_deliveries($stock_id, $price_in_home_currency_, $date); $sql = "UPDATE ".TB_PREF."stock_master SET material_cost=".db_escape($material_cost)." WHERE stock_id=".db_escape($stock_id); db_query($sql,"The cost details for the inventory item could not be updated"); @@@ -106,10 -117,10 +117,10 @@@ function add_grn(&$po if ($clearing_act) $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $grn, $date_, $stock_gl_code["inventory_account"], $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], - $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id); - $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id, '', 0, $order_line->stock_id); - update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price, ++ $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id, '', 0, $order_line->stock_id); + update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price, $order_line->receive_qty, $date_); -- } ++ } //---------------------------------------------------------------------------------------------------------------- if ($order_line->qty_received == 0) { @@@ -132,7 -143,7 +143,7 @@@ /* Update location stock records - NB a po cannot be entered for a service/kit parts done automatically */ add_stock_move(ST_SUPPRECEIVE, $order_line->stock_id, $grn, $po->Location, $date_, "", $order_line->receive_qty, $order_line->standard_cost, - $po->supplier_id, 1, $order_line->price); - $po->supplier_id, 1, $order_line->taxfree_charge_price($po)); ++ $po->supplier_id, 1, $order_line->taxfree_charge_price($po)); } /*quantity received is != 0 */ } /*end of order_line loop */ diff --cc purchasing/includes/db/invoice_db.inc index 33cfd871,3ffc35d3..0f7f9b53 --- a/purchasing/includes/db/invoice_db.inc +++ b/purchasing/includes/db/invoice_db.inc @@@ -50,16 -38,26 +50,19 @@@ function read_supplier_details_to_trans 'description' => $myrow['terms'], 'days_before_due' => $myrow['days_before_due'], 'day_in_following_month' => $myrow['day_in_following_month'] ); -- ++ $supp_trans->credit = $myrow['cur_credit']; $supp_trans->tax_description = $myrow['tax_group_name']; $supp_trans->tax_group_id = $myrow['tax_group_id']; - if ($supp_trans->tran_date == "") - { - $supp_trans->tran_date = Today(); - if (!is_date_in_fiscalyear($supp_trans->tran_date)) - $supp_trans->tran_date = end_fiscalyear(); - } - //if ($supp_trans->due_date=="") { - // get_duedate_from_terms($supp_trans); - //} - get_duedate_from_terms($supp_trans); } --//-------------------------------------------------------------------------------------------------- -- ++//------------------------------------------------------------------------------------------------- ++// Updates invoiced quantity in PO and GRN line, and act_price in PO ++// Returns: ++// if chg_price is set: previous act_price, delivery date and unit_price from PO ++// function update_supp_received_items_for_invoice($id, $po_detail_item, $qty_invoiced, $chg_price=null) { if ($chg_price != null) @@@ -146,10 -138,13 +149,10 @@@ function add_supp_invoice(&$supp_trans $item_added_tax = $tax_total; } else { $item_added_tax = 0; - } - $trans_type = $supp_trans->trans_type; - if ($trans_type == ST_SUPPCREDIT) - { + { // let's negate everything because it's a credit note $invoice_items_total = -$invoice_items_total; $tax_total = -$tax_total; @@@ -256,9 -250,11 +262,11 @@@ $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], $entered_grn->this_quantity_inv * $old_price, $supp_trans->supplier_id, "", $ex_rate); $diff = get_diff_in_home_currency($supp_trans->supplier_id, $old_date, $date_, $old_price, - $entered_grn->chg_price); - + $line_taxfree); - ++ // 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); */ $mat_cost = update_average_material_cost(null, $entered_grn->item_code, $diff, $entered_grn->this_quantity_inv, null, true); @@@ -326,12 -370,12 +382,15 @@@ $taxitem['tax_type_id'], $taxitem['rate'], $supp_trans->tax_included, $taxitem['Value'], $taxitem['Net'], $ex_rate, $date_, $supp_trans->supp_reference); -- if ($trans_type == ST_SUPPCREDIT) -- $taxitem['Value'] = -$taxitem['Value']; -- $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, -- $taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'], -- $supp_trans->supplier_id, -- "A general ledger transaction for the tax amount could not be added"); ++ if (isset($taxitem['purchasing_gl_code'])) ++ { ++ if ($trans_type == ST_SUPPCREDIT) ++ $taxitem['Value'] = -$taxitem['Value']; ++ $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, ++ $taxitem['purchasing_gl_code'], 0, 0, $taxitem['Value'], ++ $supp_trans->supplier_id, ++ "A general ledger transaction for the tax amount could not be added"); ++ } } } @@@ -508,14 -548,18 +568,17 @@@ function void_supp_invoice($type, $type $batch = get_grn_batch_from_item($details_row["grn_item_id"]); $grn = get_grn_batch($batch); if ($type == ST_SUPPCREDIT) // credit note 2009-06-14 Joe Hunt Must restore the po and grn - { + { // We must get the corresponding invoice item to check for price chg. $match = get_matching_invoice_item($details_row["stock_id"], $details_row["po_detail_item_id"]); - if ($match !== false) - + //Chaitanya : Skipped costing block & handle in void_stock_move + // We must get the corresponding invoice item to check for price chg. + /*if ($match !== false) $mat_cost = update_average_material_cost($grn["supplier_id"], $details_row["stock_id"], $match["unit_price"], -$details_row["quantity"], sql2date($match['tran_date']), $match['tran_date'] !== $trans['tran_date']); else $mat_cost = update_average_material_cost($grn["supplier_id"], $details_row["stock_id"], - $details_row["FullUnitPrice"], -$details_row["quantity"], $old_date, $old[1] !== $trans['tran_date']); + $details_row["FullUnitPrice"], -$details_row["quantity"], $old_date, $old[1] !== $trans['tran_date']);*/ - ++ $sql = "UPDATE ".TB_PREF."purch_order_details SET quantity_ordered = quantity_ordered + ".-$details_row["quantity"].", "; if ($match !== false) @@@ -576,62 -652,47 +671,66 @@@ function is_reference_already_there($su function remove_not_invoice_item($id) { - begin_transaction(); + begin_transaction(); - $myrow = get_grn_item_detail($id); + $myrow = get_grn_item_detail($id); - $grn = get_grn_batch($myrow['grn_batch_id']); + $grn = get_grn_batch($myrow['grn_batch_id']); - ++ + $supp = get_supplier($grn["supplier_id"]); - $sql = "UPDATE ".TB_PREF."purch_order_details - SET quantity_received = qty_invoiced, quantity_ordered = qty_invoiced WHERE po_detail_item = ".$myrow["po_detail_item"]; - db_query($sql, "The quantity invoiced of the purchase order line could not be updated"); + $sql = "UPDATE ".TB_PREF."purch_order_details + SET quantity_received = qty_invoiced, quantity_ordered = qty_invoiced WHERE po_detail_item = ".$myrow["po_detail_item"]; + db_query($sql, "The quantity invoiced of the purchase order line could not be updated"); - $sql = "UPDATE ".TB_PREF."grn_items - SET qty_recd = quantity_inv WHERE id = ".$myrow["id"]; - db_query($sql, "The quantity invoiced off the items received record could not be updated"); - - update_average_material_cost($grn["supplier_id"], $myrow["item_code"], - $myrow["unit_price"], -$myrow["QtyOstdg"], Today()); - - add_stock_move(ST_SUPPRECEIVE, $myrow["item_code"], $myrow['grn_batch_id'], $grn['loc_code'], sql2date($grn["delivery_date"]), "", - -$myrow["QtyOstdg"], $myrow['std_cost_unit'], $grn["supplier_id"], 1, $myrow['unit_price']); - + $sql = "UPDATE ".TB_PREF."grn_items + SET qty_recd = quantity_inv WHERE id = ".$myrow["id"]; + db_query($sql, "The quantity invoiced off the items received record could not be updated"); + + update_average_material_cost($grn["supplier_id"], $myrow["item_code"], + $myrow["unit_price"], -$myrow["QtyOstdg"], Today()); + + $price = $myrow['unit_price']; + if ($supp['tax_included']) + $price = get_tax_free_price_for_item($myrow['item_code'], $myrow['unit_price'], $supp['tax_group_id'], $supp['tax_included']); + + add_stock_move(ST_SUPPRECEIVE, $myrow["item_code"], $myrow['grn_batch_id'], $grn['loc_code'], sql2date($grn["delivery_date"]), "", + -$myrow["QtyOstdg"], $myrow['std_cost_unit'], $grn["supplier_id"], 1, $price); + $clearing_act = get_company_pref('grn_clearing_act'); - if ($clearing_act) { // otherwise GRN clearing account is not used - if (is_inventory_item($myrow['item_code'])) - { - $total = 0; - $stock_gl_code = get_stock_gl_code($myrow['item_code']); - $date = sql2date($grn["delivery_date"]); - $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $myrow['grn_batch_id'], $date, $stock_gl_code["inventory_account"], - $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], - -$myrow['QtyOstdg'] * $myrow['unit_price'], $grn["supplier_id"], "", 0, _("GRN Removal")); - $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $myrow['grn_batch_id'], $date, $clearing_act, - 0, 0, -$total, null, "", 0, _("GRN Removal")); - } - } + if ($clearing_act) { // otherwise GRN clearing account is not used + if (is_inventory_item($myrow['item_code'])) + { + $total = 0; + $stock_gl_code = get_stock_gl_code($myrow['item_code']); + $date = sql2date($grn["delivery_date"]); + $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $myrow['grn_batch_id'], $date, $stock_gl_code["inventory_account"], + $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'], + -$myrow['QtyOstdg'] * $price, $grn["supplier_id"], "", 0, _("GRN Removal")); + $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $myrow['grn_batch_id'], $date, $clearing_act, + 0, 0, -$total, null, "", 0, _("GRN Removal")); + } + } - commit_transaction(); + commit_transaction(); } -?> + +function find_src_invoices($cart) +{ + $invoices = $po_ids = array(); + foreach($cart->grn_items as $item) + $po_ids[] = "'$item->po_detail_item'"; // credit item lines + + if (count($po_ids)) { + $sql = "SELECT DISTINCT trans.trans_no, trans.reference, trans.supp_reference + FROM ".TB_PREF."supp_invoice_items items + LEFT JOIN ".TB_PREF."supp_trans trans ON trans.trans_no=items.supp_trans_no AND trans.`type`=items.supp_trans_type + WHERE items.po_detail_item_id IN (" . implode(',', $po_ids). ")"." AND items.supp_trans_type=20"; + $result = db_query($sql, "cannot find source invoice details"); + while ($rec = db_fetch($result)) + { + $invoices[$rec['trans_no']] = $rec['supp_reference']; // array($rec['reference'], $rec['supp_reference']); + } + } + return $invoices; +} - - ?> diff --cc purchasing/includes/db/po_db.inc index fd34fef1,e841d5e8..45810f1d --- a/purchasing/includes/db/po_db.inc +++ b/purchasing/includes/db/po_db.inc @@@ -105,8 -105,9 +105,8 @@@ function update_po(&$po_obj .db_escape($po_line->item_description). ",'" .date2sql($po_line->req_del_date) . "'," .db_escape($po_line->price) . ", " - .db_escape($po_line->quantity) . ")"; - + .db_escape($po_line->quantity) . ", " + .db_escape($po_line->qty_received) . ")"; - db_query($sql, "One of the purchase order detail records could not be updated"); } @@@ -140,9 -140,9 +140,9 @@@ function read_po_header($order_no, &$or $order->trans_type = ST_PURCHORDER; $order->order_no = $order_no; -- ++ $order->set_supplier($myrow["supplier_id"], $myrow["supp_name"], $myrow["curr_code"], - $myrow['tax_group_id'], $myrow["tax_included"]); + $myrow['tax_group_id'], $myrow["tax_included"], @$myrow["tax_algorithm"]); $order->credit = get_current_supp_credit($order->supplier_id); diff --cc purchasing/includes/db/suppalloc_db.inc index f9eed1a8,535e66c5..6091e42e --- a/purchasing/includes/db/suppalloc_db.inc +++ b/purchasing/includes/db/suppalloc_db.inc @@@ -173,9 -169,32 +169,33 @@@ function get_allocatable_to_supp_transa AND trans.supplier_id=".db_escape($supplier_id)); } - return db_query($sql." ORDER BY trans_no", "Cannot retreive alloc to transactions"); + return db_query($sql." ORDER BY due_date", "Cannot retreive alloc to transactions"); + } + + //------------------------------------------------------------------------------------------------------------- + + function get_allocatable_from_supp_transactions($supplier_id, $trans_no=null, $type=null) + { + if ($trans_no != null && $type!= null) + { + $sql = get_alloc_supp_sql("amt, supp_reference", "trans.trans_no = alloc.trans_no_from + AND trans.type = alloc.trans_type_from + AND alloc.trans_no_to=".db_escape($trans_no)." + AND alloc.trans_type_to=".db_escape($type)." + AND trans.supplier_id=".db_escape($supplier_id), + TB_PREF."supp_allocations as alloc"); + } + else + { + $sql = get_alloc_supp_sql(null, "round(ABS(ov_amount+ov_gst+ov_discount)-alloc,6) > 0 + AND trans.type != ".ST_SUPPAYMENT." + AND trans.supplier_id=".db_escape($supplier_id)); + } + + return db_query($sql." ORDER BY due_date", "Cannot retreive alloc to transactions"); } ++ function get_sql_for_supplier_allocation_inquiry() { $date_after = date2sql($_POST['TransAfterDate']); diff --cc purchasing/includes/db/suppliers_db.inc index 04228e9d,dd9e49c9..61cf2bdc --- a/purchasing/includes/db/suppliers_db.inc +++ b/purchasing/includes/db/suppliers_db.inc @@@ -116,8 -120,8 +122,7 @@@ function get_supplier_details($supplier ".TB_PREF."payment_terms.terms, ".TB_PREF."payment_terms.days_before_due, ".TB_PREF."payment_terms.day_in_following_month"; -- - $result = db_query($sql,"The supplier details could not be retrieved"); + $result = db_query($sql,"The customer details could not be retrieved"); $supp = db_fetch($result); return $supp; @@@ -175,12 -179,4 +180,10 @@@ function is_new_supplier($id return !key_in_foreign_table($id, $tables, 'supplier_id'); } -?> + +function update_supp_tax_algorithm($supplier_id, $tax_algorithm) +{ + $sql = "UPDATE ".TB_PREF."suppliers SET tax_algorithm=".db_escape($tax_algorithm) + . " WHERE supplier_id=".db_escape($supplier_id); + return db_query($sql, "cannot update supplier's tax calculation algorithm"); +} - - ?> diff --cc purchasing/includes/po_class.inc index 84056927,b767e9ea..c9ec00df --- a/purchasing/includes/po_class.inc +++ b/purchasing/includes/po_class.inc @@@ -144,7 -141,8 +144,8 @@@ class purch_orde $prices[] = round($ln_itm->price * ($receival ? $ln_itm->receive_qty : $ln_itm->quantity), user_price_dec()); } $taxes = get_tax_for_items($items, $prices, $shipping_cost, - $this->tax_group_id, $this->tax_included, $this->tax_group_array); + $this->tax_group_id, $this->tax_included, $this->tax_group_array, $this->tax_algorithm); + // Adjustment for swiss franken, we always have 5 rappen = 1/20 franken if ($this->curr_code == 'CHF') { $val = $taxes['1']['Value']; diff --cc purchasing/includes/supp_trans_class.inc index 60e5b7ed,130354d7..8178d30d --- a/purchasing/includes/supp_trans_class.inc +++ b/purchasing/includes/supp_trans_class.inc @@@ -42,30 -40,13 +42,31 @@@ class supp_tran var $ov_gst; var $gl_codes_counter=0; var $credit = 0; + var $tax_algorithm; + var $stored_algorithm; + var $currency; - function supp_trans($trans_type) + function supp_trans($trans_type, $trans_no=0) { + $this->trans_type = $trans_type; /*Constructor function initialises a new Supplier Transaction object */ - $this->grn_items = array(); - $this->gl_codes = array(); + $this->read($trans_type, $trans_no); + } + + function read($trans_type, $trans_no) + { + $this->trans_type = $trans_type; + $this->trans_no = $trans_no; + $this->grn_items = array(); + $this->gl_codes = array(); + if ($trans_no) { + read_supp_invoice($trans_no, $trans_type, $this); + if ($trans_type == ST_SUPPCREDIT) + { + $this->src_docs = find_src_invoices($trans_no); + } + read_supplier_details_to_trans($this, $this->supplier_id); + } } function add_grn_to_trans($grn_item_id, $po_detail_item, $item_code, $item_description, diff --cc purchasing/inquiry/po_search_completed.php index ba77bf7a,9925ac63..90d869aa --- a/purchasing/inquiry/po_search_completed.php +++ b/purchasing/inquiry/po_search_completed.php @@@ -11,18 -11,20 +11,18 @@@ ***********************************************************************/ $page_security = 'SA_SUPPTRANSVIEW'; $path_to_root="../.."; - include($path_to_root . "/includes/db_pager.inc"); - include($path_to_root . "/includes/session.inc"); + include_once($path_to_root . "/includes/db_pager.inc"); + include_once($path_to_root . "/includes/session.inc"); - include($path_to_root . "/purchasing/includes/purchasing_ui.inc"); + include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc"); include_once($path_to_root . "/reporting/includes/reporting.inc"); -if (!@$_GET['popup']) -{ - $js = ""; - if ($use_popup_windows) - $js .= get_js_open_window(900, 500); - if ($use_date_picker) - $js .= get_js_date_picker(); - page(_($help_context = "Search Purchase Orders"), false, false, "", $js); -} +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); +if ($use_date_picker) + $js .= get_js_date_picker(); +page(_($help_context = "Search Purchase Orders"), false, false, "", $js); + if (isset($_GET['order_number'])) { $order_number = $_GET['order_number']; @@@ -98,9 -101,11 +98,13 @@@ function trans_view($trans function edit_link($row) { - return pager_link( _("Edit"), - "/purchasing/po_entry_items.php?" . SID - . "ModifyOrderNumber=" . $row["order_no"], ICON_EDIT); - if (@$_GET['popup']) ++ global $page_nested; ++ ++ if ($page_nested) + return ''; + return pager_link( _("Edit"), + "/purchasing/po_entry_items.php?" . SID + . "ModifyOrderNumber=" . $row["order_no"], ICON_EDIT); } function prt_link($row) diff --cc purchasing/inquiry/supplier_inquiry.php index 3a341abe,ffb264b5..af6c2216 --- a/purchasing/inquiry/supplier_inquiry.php +++ b/purchasing/inquiry/supplier_inquiry.php @@@ -11,19 -11,21 +11,19 @@@ ***********************************************************************/ $page_security = 'SA_SUPPTRANSVIEW'; $path_to_root = "../.."; - include($path_to_root . "/includes/db_pager.inc"); - include($path_to_root . "/includes/session.inc"); + include_once($path_to_root . "/includes/db_pager.inc"); + include_once($path_to_root . "/includes/session.inc"); - include($path_to_root . "/purchasing/includes/purchasing_ui.inc"); - include($path_to_root . "/reporting/includes/reporting.inc"); + include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc"); + include_once($path_to_root . "/reporting/includes/reporting.inc"); -if (!@$_GET['popup']) -{ - $js = ""; - if ($use_popup_windows) - $js .= get_js_open_window(900, 500); - if ($use_date_picker) - $js .= get_js_date_picker(); - page(_($help_context = "Supplier Inquiry"), isset($_GET['supplier_id']), false, "", $js); -} +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); +if ($use_date_picker) + $js .= get_js_date_picker(); +page(_($help_context = "Supplier Inquiry"), isset($_GET['supplier_id']), false, "", $js); + if (isset($_GET['supplier_id'])){ $_POST['supplier_id'] = $_GET['supplier_id']; } @@@ -44,7 -47,8 +44,8 @@@ if (!isset($_POST['supplier_id']) start_table(TABLESTYLE_NOBORDER); start_row(); - supplier_list_cells(_("Select a supplier:"), 'supplier_id', null, true); -if (!@$_GET['popup']) - supplier_list_cells(_("Select a supplier:"), 'supplier_id', null, true, false, false, !@$_GET['popup']); ++if (!$page_nested) ++ supplier_list_cells(_("Select a supplier:"), 'supplier_id', null, true, false, false, true); date_cells(_("From:"), 'TransAfterDate', '', null, -30); date_cells(_("To:"), 'TransToDate'); @@@ -105,6 -109,6 +106,7 @@@ function systype_name($dummy, $type global $systypes_array; return $systypes_array[$type]; } ++div_end(); function trans_view($trans) { @@@ -123,6 -127,8 +125,10 @@@ function gl_view($row function credit_link($row) { - if (@$_GET['popup']) ++ global $page_nested; ++ ++ if ($page_nested) + return ''; return $row['type'] == ST_SUPPINVOICE && $row["TotalAmount"] - $row["Allocated"] > 0 ? pager_link(_("Credit This"), "/purchasing/supplier_credit.php?New=1&invoice_no=". @@@ -159,6 -160,6 +160,11 @@@ function check_overdue($row return $row['OverDue'] == 1 && (abs($row["TotalAmount"]) - $row["Allocated"] != 0); } ++ ++function edit_link($row) ++{ ++ return edit_trans_link($row['type'], $row['trans_no']); ++} //------------------------------------------------------------------------------------------------ $sql = get_sql_for_supplier_inquiry(); @@@ -185,8 -185,8 +191,6 @@@ if ($_POST['supplier_id'] != ALL_TEXT $cols[_("Supplier")] = 'skip'; $cols[_("Currency")] = 'skip'; } --//------------------------------------------------------------------------------------------------ -- /*show a table of the transactions returned by the sql */ $table =& new_db_pager('trans_tbl', $sql, $cols); diff --cc purchasing/manage/suppliers.php index ca34975e,edfad13a..287849ff --- a/purchasing/manage/suppliers.php +++ b/purchasing/manage/suppliers.php @@@ -133,8 -124,13 +130,15 @@@ function supplier_settings(&$supplier_i gl_all_accounts_list_row(_("Purchase Account:"), 'purchase_account', $_POST['purchase_account'], false, false, _("Use Item Inventory/COGS Account")); gl_all_accounts_list_row(_("Purchase Discount Account:"), 'payment_discount_account', $_POST['payment_discount_account']); - - if ($supplier_id) table_section(2); + if (!$supplier_id) { + table_section_title(_("Contact Data")); + text_row(_("Phone Number:"), 'phone', null, 32, 30); + text_row(_("Secondary Phone Number:"), 'phone2', null, 32, 30); ++ table_section_title(_("Contact Data")); ++ text_row(_("Fax Number:"), 'fax', null, 32, 30); ++ email_row(_("E-mail:"), 'email', null, 35, 55); ++ languages_list_row(_("Document Language:"), 'rep_lang', null, _('System default')); + } - - table_section(2); $dim = get_company_pref('use_dimension'); if ($dim >= 1) { @@@ -147,6 -143,6 +151,7 @@@ hidden('dimension_id', 0); if ($dim < 2) hidden('dimension2_id', 0); ++ table_section(2); table_section_title(_("Addresses")); @@@ -157,7 -153,13 +162,6 @@@ textarea_row(_("General Notes:"), 'notes', null, 35, 5); if ($supplier_id) record_status_list_row(_("Supplier status:"), 'inactive'); - - else { - table_section_title(_("Contact Data")); - text_row(_("Contact Person:"), 'contact', null, 42, 40); - text_row(_("Fax Number:"), 'fax', null, 32, 30); - email_row(_("E-mail:"), 'email', null, 35, 55); - languages_list_row(_("Document Language:"), 'rep_lang', null, _('System default')); - } end_outer_table(1); div_start('controls'); diff --cc purchasing/po_entry_items.php index 294d4be5,a23b7a07..388eb772 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@@ -330,7 -327,7 +330,7 @@@ function can_commit( set_focus('supplier_id'); return false; } -- ++ if (!is_date($_POST['OrderDate'])) { display_error(_("The entered order date is invalid.")); @@@ -349,7 -348,7 +350,7 @@@ set_focus('due_date'); return false; } -- ++ if (!$_SESSION['PO']->order_no) { if (!$Refs->is_valid(get_post('ref'))) @@@ -358,7 -357,7 +359,7 @@@ set_focus('ref'); return false; } -- ++ if (!is_new_reference(get_post('ref'), $_SESSION['PO']->trans_type)) { display_error(_("The entered reference is already in use.")); @@@ -366,7 -365,7 +367,7 @@@ return false; } } -- ++ if ($_SESSION['PO']->trans_type == ST_SUPPINVOICE && !$Refs->is_valid(get_post('supp_ref'))) { display_error(_("You must enter a supplier's invoice reference.")); @@@ -446,11 -451,11 +455,12 @@@ function handle_commit_order( $inv->reference = $ref; $inv->supp_reference = $cart->supp_ref; $inv->tax_included = $cart->tax_included; + $inv->tax_algorithm = $cart->tax_algorithm; + $inv->stored_algorithm = $cart->stored_algorithm; $supp = get_supplier($cart->supplier_id); $inv->tax_group_id = $supp['tax_group_id']; -// $inv->ov_discount 'this isn't used at all' - $inv->ov_amount = $inv->ov_gst = 0; - + $total = 0; ++ foreach($cart->line_items as $key => $line) { $inv->add_grn_to_trans($line->grn_item_id, $line->po_detail_rec, $line->stock_id, $line->item_description, $line->receive_qty, 0, $line->receive_qty, diff --cc purchasing/supplier_credit.php index 0f75493a,038f5085..e4805768 --- a/purchasing/supplier_credit.php +++ b/purchasing/supplier_credit.php @@@ -30,42 -31,6 +30,42 @@@ if ($use_date_picker check_db_has_suppliers(_("There are no suppliers defined in the system.")); +if (isset($_GET['ModifyCredit'])) + check_is_closed(ST_SUPPINVOICE, $_GET['ModifyCredit']); + +//--------------------------------------------------------------------------------------------------- + +if (isset($_GET['New'])) +{ + if (isset( $_SESSION['supp_trans'])) + { + unset ($_SESSION['supp_trans']->grn_items); + unset ($_SESSION['supp_trans']->gl_codes); + unset ($_SESSION['supp_trans']); + } + + if (isset($_GET['invoice_no'])) + { + $_SESSION['supp_trans'] = new supp_trans(ST_SUPPINVOICE, $_GET['invoice_no']); + $_SESSION['supp_trans']->src_doc = $_GET['invoice_no']; + + + $_SESSION['supp_trans']->trans_type = ST_SUPPCREDIT; + $_SESSION['supp_trans']->trans_no = 0; + $_SESSION['supp_trans']->supp_reference = ''; + // $_SESSION['supp_trans']->supp_reference = $_POST['invoice_no'] = $_GET['invoice_no']; + $help_context = "Supplier Credit Note"; + $_SESSION['page_title'] = _("Supplier Credit Note"); + + $_SESSION['supp_trans'] = new supp_trans(ST_SUPPCREDIT); + } elseif (isset($_GET['ModifyInvoice'])) { + $help_context = 'Modifying Purchase Invoice'; + $_SESSION['page_title'] = sprintf( _("Modifying Supplier Credit # %d"), $_GET['ModifyCredit']); + $_SESSION['supp_trans'] = new supp_trans(ST_SUPPCREDIT, $_GET['ModifyCredit']); + } - ++} +page($_SESSION['page_title'], false, false, "", $js); + //--------------------------------------------------------------------------------------------------------------- if (isset($_GET['AddedID'])) @@@ -82,11 -47,28 +82,10 @@@ hyperlink_params($_SERVER['PHP_SELF'], _("Enter Another Credit Note"), "New=1"); hyperlink_params("$path_to_root/admin/attachments.php", _("Add an Attachment"), "filterType=$trans_type&trans_no=$invoice_no"); -- - display_footer_exit(); -} - -//--------------------------------------------------------------------------------------------------- - -if (isset($_GET['New'])) -{ - if (isset( $_SESSION['supp_trans'])) - { - unset ($_SESSION['supp_trans']->grn_items); - unset ($_SESSION['supp_trans']->gl_codes); - unset ($_SESSION['supp_trans']); - } + - $_SESSION['supp_trans'] = new supp_trans(ST_SUPPCREDIT); - if (isset($_GET['invoice_no'])) - { - $_SESSION['supp_trans']->supp_reference = $_POST['invoice_no'] = $_GET['invoice_no']; - } + display_footer_exit(); } - function clear_fields() { global $Ajax; @@@ -153,8 -135,8 +152,8 @@@ if (isset($_POST['AddGLCodeToTrans'])) function check_data() { - global $total_grn_value, $total_gl_value, $Refs; - + global $total_grn_value, $total_gl_value, $Refs, $SysPrefs; - ++ if (!$_SESSION['supp_trans']->is_valid_trans_to_post()) { display_error(_("The credit note cannot be processed because the there are no items or values on the invoice. Credit notes are expected to have a charge.")); diff --cc purchasing/supplier_payment.php index 7bafd736,ed8f5a08..6d9992a6 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@@ -273,9 -273,14 +273,14 @@@ start_form() supplier_list_row(_("Payment To:"), 'supplier_id', null, false, true); set_global_supplier($_POST['supplier_id']); -- ++ + if (!list_updated('bank_account')) + $_POST['bank_account'] = get_default_supplier_bank_account($_POST['supplier_id']); - ++ bank_accounts_list_row(_("From Bank Account:"), 'bank_account', null, true); - + + bank_balance_row($_POST['bank_account']); + table_section(2); ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_SUPPAYMENT)); diff --cc purchasing/view/view_supp_invoice.php index b13ef416,025e6581..ad7030aa --- a/purchasing/view/view_supp_invoice.php +++ b/purchasing/view/view_supp_invoice.php @@@ -13,6 -13,6 +13,7 @@@ $page_security = 'SA_SUPPTRANSVIEW' $path_to_root = "../.."; include_once($path_to_root . "/purchasing/includes/purchasing_db.inc"); ++include_once($path_to_root . "/includes/ui/items_cart.inc"); include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc"); @@@ -69,7 -69,7 +70,7 @@@ display_supp_trans_tax_details($tax_ite $display_total = number_format2($supp_trans->ov_amount + $supp_trans->ov_gst,user_price_dec()); --label_row(_("TOTAL INVOICE"), $display_total, "colspan=1 align=right", "nowrap align=right"); ++label_row(_("TOTAL INVOICE").' ('.$supplier_curr_code.')', $display_total, "colspan=1 align=right", "nowrap align=right"); end_table(1); diff --cc reporting/includes/class.pdf.inc index 44b62b43,300cd401..9bc222d3 --- a/reporting/includes/class.pdf.inc +++ b/reporting/includes/class.pdf.inc @@@ -175,7 -175,14 +175,14 @@@ class Cpdf extends FPDI default : $fontname = "freesans5"; break; } } - // else use built-in adobe fonts helvetica. + elseif ($this->encoding === "ISO-8859-13") + { + switch ($this->l['a_meta_language']) + { + default : $fontname = "freesans13"; break; + } - } ++ } + // else use built-in adobe fonts helvetica. } $this->SetFont($fontname, $style); } diff --cc reporting/includes/doctext.inc index 4f52bd2c,7044cee4..f279283b --- a/reporting/includes/doctext.inc +++ b/reporting/includes/doctext.inc @@@ -9,175 -9,266 +9,264 @@@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ - if (isset($header2type)) - { - $doc_Cust_no = _("Cust no"); - $doc_Date = _("Date"); - if ($doctype == ST_PURCHORDER || $doctype == ST_SUPPAYMENT) // Purchase Order - { - $doc_Charge_To = _("Order To"); - if ($doctype == ST_PURCHORDER) - $doc_Delivered_To = _("Deliver To"); - else - $doc_Delivered_To = _("Charge To"); - } - else - { - if ($doctype == ST_CUSTPAYMENT) - $doc_Charge_To = _("With thanks from"); - else - $doc_Charge_To = _("Charge To"); - $doc_Delivered_To = _("Delivered To"); - } - $doc_Shipping_Company = _("Shipping Company"); - if ($doctype == ST_SALESQUOTE) - $doc_Due_Date = _("Valid until"); - elseif ($doctype == ST_SALESORDER) - $doc_Due_Date = _("Delivery Date"); - else - $doc_Due_Date = _("Due Date"); - $doc_Your_Ref = _("Your Ref"); - if ($doctype == ST_WORKORDER) - { - $doc_Our_Ref = _("Type"); - $doc_Your_VAT_no = _("Manufactured Item"); - $doc_Payment_Terms = _("Required By"); - $doc_Customers_Ref = _("Reference"); - $doc_Our_Order_No = _("Into Location"); - $doc_Due_Date = _("Quantity"); - } - else - { - if ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) - $doc_Our_Ref = _("Type"); - else - $doc_Our_Ref = _("Sales Person"); - $doc_Your_VAT_no = _("Your VAT no."); - $doc_Payment_Terms = _("Payment Terms"); - $doc_Customers_Ref = _("Customers Reference"); - $doc_Our_Order_No = _("Our Order No"); - } - $doc_Our_VAT_no = _("Our VAT No."); - $doc_Domicile = _("Domicile"); - $doc_Extra = ""; - if($doctype == ST_CUSTDELIVERY || $doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || - $doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) { - if ($doctype == ST_CUSTPAYMENT) - $doc_Extra = _("* Subject to Realisation of the Cheque."); - $doc_Bank_Account = ''; - $doc_Please_Quote = _("All amounts stated in"); - } else { - $doc_Bank_Account = _("Bank Account"); - $doc_Please_Quote = $doctype==ST_SALESINVOICE ? - _("Please quote Invoice no. when paying. All amounts stated in") : - _("Please quote Credit no. when paying. All amounts stated in"); - } - $doc_Address = _("Address"); - $doc_Phone_Fax_Email = _("Phone/Fax/Email"); - $doc_Bank = _("Bank"); - $doc_Payment_Link = _("You can pay through"); - if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || $doctype == ST_SALESINVOICE || - $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT || - $doctype == ST_CUSTPAYMENT) + /***** + * + * Set document type dependent elements of common page layout. + * + */ + $Addr1 = array( + 'title' => _("Charge To"), + 'name' => @$this->formData['br_name'] ? $this->formData['br_name'] : @$this->formData['DebtorName'], + 'address' => @$this->formData['br_address'] ? $this->formData['br_address'] : @$this->formData['address'] + ); + $Addr2 = array( + 'title' => _("Delivered To"), + 'name' => @$this->formData['deliver_to'], + 'address' => @$this->formData['delivery_address'] + ); + + // default item column headers + $this->headers = array(_("Item Code"), _("Item Description"), _("Quantity"), + _("Unit"), _("Price"), _("Discount %"), _("Total")); + + // for links use 'text' => 'url' + $Footer[0] = _("All amounts stated in") . " - " . @$this->formData['curr_code']; + + switch ($this->formData['doctype']) { - if ($doctype == ST_SALESQUOTE) + case ST_SALESQUOTE: $this->title = _("SALES QUOTATION"); - elseif ($doctype == ST_PURCHORDER) - $this->title = _("PURCHASE ORDER"); - elseif ($doctype == ST_CUSTDELIVERY) - $this->title = ($packing_slip==1 ? _("PACKING SLIP") : _("DELIVERY NOTE")); - elseif ($doctype == ST_SALESORDER) + $this->formData['document_name'] =_("Quotation No."); + $this->formData['document_date'] = $this->formData['ord_date']; + $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) + ? $this->formData['reference'] : $this->formData['order_no']; + $aux_info = array( + _("Customers Reference") => $this->formData["customer_ref"], + _("Sales Person") => get_salesman_name($this->formData['salesman']), + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Quotation No") => $this->formData['order_no'], + _("Valid until") => sql2date($this->formData['delivery_date']), + ); + break; + + case ST_SALESORDER: $this->title = ($print_as_quote==1 ? _("QUOTE") : _("SALES ORDER")); - elseif ($doctype == ST_SALESINVOICE) + $this->formData['document_name'] =_("Order No."); + $this->formData['document_date'] = $this->formData['ord_date']; + $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) + ? $this->formData['reference'] : $this->formData['order_no']; + $this->formData['document_amount'] = $this->formData['order_no']; + + $aux_info = array( + _("Customers Reference") => $this->formData["customer_ref"], + _("Sales Person") => get_salesman_name($this->formData['salesman']), + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Order No") => $this->formData['order_no'], + _("Delivery Date") => sql2date($this->formData['delivery_date']), + ); + break; + + case ST_CUSTDELIVERY: + $this->title = ($packing_slip==1 ? _("PACKING SLIP") : _("DELIVERY NOTE")); + $this->formData['document_name'] = _("Delivery Note No."); + if (@$packing_slip) + $Payment_Terms = ''; + $ref = $this->formData['order_']; + if ($print_invoice_no == 0) + { + $ref = get_reference(ST_SALESORDER, $this->formData['order_']); + if (!$ref) + $ref = $this->formData['order_']; + } + $aux_info = array( + _("Customers Reference") => $this->formData["customer_ref"], + _("Sales Person") => get_salesman_name($this->formData['salesman']), + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Order No") => $ref, + _("To Be Invoiced Before") => sql2date($this->formData['due_date']), + ); + break; + + case ST_CUSTCREDIT: + $this->title = _("CREDIT NOTE"); + $this->formData['document_name'] =_("Credit No."); + $Footer[0] = _("Please quote Credit no. when paying. All amounts stated in") . " - " . $this->formData['curr_code']; + + $aux_info = array( + _("Customers Reference") => @$this->formData["customer_ref"], + _("Sales Person") => get_salesman_name($this->formData['salesman']), + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Order No") => $this->formData['order_'], + _("Due Date") => '', + ); + break; + + case ST_SALESINVOICE: $this->title = _("INVOICE"); - elseif ($doctype == ST_WORKORDER) - $this->title = _("WORK ORDER"); - elseif ($doctype == ST_SUPPAYMENT) + $this->formData['document_name'] =_("Invoice No."); + $this->formData['domicile'] = $this->company['domicile']; + $Footer[0] = _("Please quote Invoice no. when paying. All amounts stated in"). " - " . $this->formData['curr_code']; + + $deliveries = get_sales_parent_numbers(ST_SALESINVOICE, $this->formData['trans_no']); + if ($print_invoice_no == 0) + { + foreach($deliveries as $n => $delivery) { + $deliveries[$n] = get_reference(ST_CUSTDELIVERY, $delivery); + } + } + $aux_info = array( + _("Customers Reference") => $this->formData["customer_ref"], + _("Sales Person") => get_salesman_name($this->formData['salesman']), + _("Your VAT no.") => $this->formData['tax_id'], + _("Delivery Note No.") => implode(',', $deliveries), + _("Due Date") => sql2date($this->formData['due_date']), + ); + break; + + case ST_SUPPAYMENT: + global $systypes_array; + $this->title = _("REMITTANCE"); - elseif ($doctype == ST_CUSTPAYMENT) - $this->title = _("RECEIPT"); - else - $this->title = _("CREDIT NOTE"); - if ($doctype == ST_PURCHORDER) + $this->formData['document_name'] =_("Remittance No."); + $Addr1['title'] = _("Order To"); + $Addr1['name'] = $this->formData['supp_name']; + $Addr1['address'] = $this->formData['address']; + $Addr2['title'] = _("Charge To"); + $Addr2['name'] = ''; + $Addr2['address'] = ''; + + $aux_info = array( + _("Customers Reference") => $this->formData['supp_account_no'], + _("Type") =>$systypes_array[$this->formData["type"]], + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Order No") => '', + _("Due Date") => sql2date($this->formData['tran_date']), + ); + $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation")); + break; + + case ST_PURCHORDER: + $this->title = _("PURCHASE ORDER"); + $this->formData['document_name'] =_("Purchase Order No."); + $Addr1['title'] = _("Order To"); + $Addr1['name'] = $this->formData['supp_name']; + $Addr1['address'] = $this->formData['address']; + $Addr2['title'] = _("Deliver To"); + $Addr2['name'] = $this->company['coy_name']; + //$Addr2['address'] = $this->company['postal_address']; No, don't destroy delivery address! + $this->formData['document_date'] = $this->formData['ord_date']; + $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) + ? $this->formData['reference'] : $this->formData['order_no']; + + $aux_info = array( + _("Customers Reference") => $this->formData['supp_account_no'], + _("Sales Person") => '', + _("Your VAT no.") => '', + _("Our Order No") => '', + _("Due Date") => '', + ); + $this->headers = array(_("Item Code"), _("Item Description"), _("Delivery Date"), _("Quantity"), _("Unit"), _("Price"), _("Total")); - elseif ($doctype == ST_WORKORDER) + break; + + case ST_CUSTPAYMENT: + global $systypes_array; + + $this->title = _("RECEIPT"); + $this->formData['document_name'] =_("Receipt No."); + $Addr1['title'] = _("With thanks from"); + $aux_info = array( + _("Customers Reference") => $this->formData["debtor_ref"], + _("Type") =>$systypes_array[$this->formData["type"]], + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Order No") => $this->formData['order_'], + _("Due Date") => sql2date($this->formData['tran_date']), + ); + $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation")); + break; + + case ST_WORKORDER: + global $wo_types_array; + + $this->title = _("WORK ORDER"); + $this->formData['document_name'] =_("Work Order No."); + $this->formData['document_date'] = $this->formData['date_']; + $this->formData['document_number'] = $this->formData['id']; + $Addr1['name'] = $this->formData['location_name']; + $Addr1['address'] = $this->formData['delivery_address']; + $aux_info = array( + _("Reference") => $this->formData['wo_ref'], + _("Type") => $wo_types_array[$this->formData["type"]], + _("Manufactured Item") => $this->formData["StockItemName"], + _("Into Location") => $this->formData["location_name"], + _("Quantity") => $this->formData["units_issued"], + ); + $Payment_Terms = _("Required By").": ".sql2date($this->formData["required_by"]); $this->headers = array(_("Item Code"), _("Item Description"), _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued")); - elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) - $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation")); - else - $this->headers = array(_("Item Code"), _("Item Description"), _("Quantity"), - _("Unit"), _("Price"), _("Discount %"), _("Total")); - } - else if ($doctype == ST_STATEMENT) - { - $this->title = _("STATEMENT"); - $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"), - _("Credits"), _("Allocated"), _("Outstanding")); + unset($Footer[0]); + break; + + + case ST_STATEMENT: + $this->formData['document_name'] = ''; + $this->formData['domicile'] = $this->company['domicile']; + $Payment_Terms = ''; + $this->title = _("STATEMENT"); + $aux_info = array( + _("Customers Reference") => '', + _("Sales Person") => '', + _("Your VAT no.") => $this->formData['tax_id'], + _("Our Order No") => '', + _("Delivery Date") => '', + ); + $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"), + _("Credits"), _("Allocated"), _("Outstanding")); } - } - if (isset($emailtype)) - { - $doc_Dear_Sirs = _("Dear"); - $doc_AttachedFile = _("Attached you will find "); - $doc_Kindest_regards = _("Kindest regards"); - $doc_Payment_Link = _("You can pay through"); - } - 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_PURCHORDER ? _("Purchase Order No.") : - ($doctype == ST_SALESORDER ? _("Order No.") : - ($doctype == ST_SALESQUOTE ? _("Quotation 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."); - } - if (isset($linetype)) - { - - if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || - $doctype == ST_SALESINVOICE || $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY) + + // default values + if (!isset($this->formData['document_date'])) + $this->formData['document_date'] = $this->formData['tran_date']; + + if (!isset($this->formData['document_number'])) + $this->formData['document_number'] = $print_invoice_no == 0 && isset($this->formData['reference']) + ? $this->formData['reference'] : @$this->formData['trans_no']; + + if (!isset($Payment_Terms)) { - $doc_Sub_total = _("Sub-total"); - $doc_Shipping = _("Shipping"); - $doc_Included = _("Included"); - $doc_Amount = _("Amount"); - $doc_TOTAL_INVOICE = $doctype ==ST_SALESINVOICE ? _("TOTAL INVOICE") : _("TOTAL CREDIT"); - $doc_TOTAL_ORDER = _("TOTAL ORDER EX VAT"); - $doc_TOTAL_ORDER2 = _("TOTAL ORDER VAT INCL."); - $doc_TOTAL_PO = _("TOTAL PO"); - $doc_TOTAL_DELIVERY = _("TOTAL DELIVERY INCL. VAT"); + $id = $this->formData['payment_terms']; + $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator=".db_escape($id); + $result = db_query($sql,"could not get paymentterms"); + $row = db_fetch($result); + $Payment_Terms = _("Payment Terms") . ': ' . $row["terms"]; } - elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) + + // footer generic content + if (@$this->formData['bank_name']) + $Footer[] = _("Bank"). ": ".$this->formData['bank_name']. ", " . _("Bank Account") . ": " . $this->formData['bank_account_number']; + + if (@$this->formData['payment_service']) //payment link { - $doc_Towards = _("As advance / full / part / payment towards:"); - $doc_by_Cheque = _("By Cash / Cheque* / Draft No."); - $doc_Dated = _("Dated"); - $doc_Drawn = _("Drawn on Bank"); - $doc_Drawn_Branch = _("Branch"); - $doc_Received = _("Received / Sign"); - $doc_Total_Allocated = _("Total Allocated"); - $doc_Left_To_Allocate = _("Left to Allocate"); - if ($doctype == ST_CUSTPAYMENT) - $doc_Total_Payment = _("TOTAL RECEIPT"); - else - $doc_Total_Payment = _("TOTAL REMITTANCE"); + $amt = number_format($this->formData["ov_freight"] + $this->formData["ov_gst"] + $this->formData["ov_amount"], user_price_dec()); + $service = $this->formData['payment_service']; + $url = payment_link($service, array( + 'company_email' => $this->company['email'], + 'amount' => $amt, + 'currency' => $this->formData['curr_code'], + 'comment' => $this->title . " " . $this->formData['reference'] + )); + $Footer[_("You can pay through"). " $service: "] = "$url"; } - elseif ($doctype == ST_STATEMENT) + + if ($this->formData['doctype'] == ST_CUSTPAYMENT) + $Footer[] = _("* Subject to Realisation of the Cheque."); + + if ($this->params['comments'] != '') + $Footer[] = $this->params['comments']; + + if (($this->formData['doctype'] == ST_SALESINVOICE || $this->formData['doctype'] == ST_STATEMENT) && $this->company['legal_text'] != "") { - $doc_Outstanding = _("Outstanding Transactions"); - $doc_Current = _("Current"); - $doc_Total_Balance = _("Total Balance"); - $doc_Statement = _("Statement"); - $doc_as_of = _("as of"); - $doc_Days = _("Days"); - $doc_Over = _("Over"); + foreach(explode("\n", $this->company['legal_text']) as $line) + $Footer[] = $line; } - } - --?> diff --cc reporting/includes/excel_report.inc index 996d290c,33ac54a5..7d1379b4 --- a/reporting/includes/excel_report.inc +++ b/reporting/includes/excel_report.inc @@@ -693,8 -693,9 +693,8 @@@ class FrontReport extends Spreadsheet_E return ($px / $unit_offset_length); } - function End($email=0, $subject=null, $myrow=null, $doctype = 0) + function End($email=0, $subject='') { - global $path_to_root; ++$this->y; for ($i = 0; $i < $this->numcols; $i++) $this->sheet->writeBlank($this->y, $i, $this->formatFooter); diff --cc reporting/rep107.php index e2a50b33,5e044f28..36acff5a --- a/reporting/rep107.php +++ b/reporting/rep107.php @@@ -135,11 -118,14 +118,14 @@@ function print_invoices( $rep->TextColLines(1, 2, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; - $rep->TextCol(2, 3, $DisplayQty, -2); - $rep->TextCol(3, 4, $myrow2['units'], -2); - $rep->TextCol(4, 5, $DisplayPrice, -2); - $rep->TextCol(5, 6, $DisplayDiscount, -2); - $rep->TextCol(6, 7, $DisplayNet, -2); + if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) + { + $rep->TextCol(2, 3, $DisplayQty, -2); + $rep->TextCol(3, 4, $myrow2['units'], -2); + $rep->TextCol(4, 5, $DisplayPrice, -2); + $rep->TextCol(5, 6, $DisplayDiscount, -2); + $rep->TextCol(6, 7, $DisplayNet, -2); - } ++ } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight)) @@@ -172,10 -155,10 +155,10 @@@ $first = true; while ($tax_item = db_fetch($tax_items)) { - if ($tax_item['amount'] == 0) - continue; + if ($tax_item['amount'] == 0) + continue; $DisplayTax = number_format2($sign*$tax_item['amount'], $dec); -- ++ if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) $tax_type_name = $tax_item['tax_type_name']; else diff --cc reporting/rep109.php index c775bb90,c8b4a1ef..08990e10 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@@ -124,11 -124,14 +124,14 @@@ function print_sales_orders( $rep->TextColLines(1, 2, $myrow2['description'], -2); $newrow = $rep->row; $rep->row = $oldrow; - $rep->TextCol(2, 3, $DisplayQty, -2); - $rep->TextCol(3, 4, $myrow2['units'], -2); - $rep->TextCol(4, 5, $DisplayPrice, -2); - $rep->TextCol(5, 6, $DisplayDiscount, -2); - $rep->TextCol(6, 7, $DisplayNet, -2); + if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) + { + $rep->TextCol(2, 3, $DisplayQty, -2); + $rep->TextCol(3, 4, $myrow2['units'], -2); + $rep->TextCol(4, 5, $DisplayPrice, -2); + $rep->TextCol(5, 6, $DisplayDiscount, -2); + $rep->TextCol(6, 7, $DisplayNet, -2); - } ++ } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight)) diff --cc reporting/rep110.php index 06857a8d,7b9318d0..856da324 --- a/reporting/rep110.php +++ b/reporting/rep110.php @@@ -111,7 -111,7 +111,7 @@@ function print_deliveries( { if ($myrow2["quantity"] == 0) continue; -- ++ $Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; @@@ -127,14 -127,17 +127,17 @@@ $rep->TextColLines(1, 2, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; - $rep->TextCol(2, 3, $DisplayQty, -2); - $rep->TextCol(3, 4, $myrow2['units'], -2); - if ($packing_slip == 0) + if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) - { + { - $rep->TextCol(4, 5, $DisplayPrice, -2); - $rep->TextCol(5, 6, $DisplayDiscount, -2); - $rep->TextCol(6, 7, $DisplayNet, -2); - } + $rep->TextCol(2, 3, $DisplayQty, -2); + $rep->TextCol(3, 4, $myrow2['units'], -2); + if ($packing_slip == 0) + { + $rep->TextCol(4, 5, $DisplayPrice, -2); + $rep->TextCol(5, 6, $DisplayDiscount, -2); + $rep->TextCol(6, 7, $DisplayNet, -2); + } - } ++ } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight)) diff --cc reporting/rep111.php index 02285fca,2662fca5..be0c48c0 --- a/reporting/rep111.php +++ b/reporting/rep111.php @@@ -107,11 -111,14 +111,14 @@@ function print_sales_quotations( $rep->TextColLines(1, 2, $myrow2['description'], -2); $newrow = $rep->row; $rep->row = $oldrow; - $rep->TextCol(2, 3, $DisplayQty, -2); - $rep->TextCol(3, 4, $myrow2['units'], -2); - $rep->TextCol(4, 5, $DisplayPrice, -2); - $rep->TextCol(5, 6, $DisplayDiscount, -2); - $rep->TextCol(6, 7, $DisplayNet, -2); + if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) + { + $rep->TextCol(2, 3, $DisplayQty, -2); + $rep->TextCol(3, 4, $myrow2['units'], -2); + $rep->TextCol(4, 5, $DisplayPrice, -2); + $rep->TextCol(5, 6, $DisplayDiscount, -2); + $rep->TextCol(6, 7, $DisplayNet, -2); - } ++ } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight)) @@@ -125,23 -132,65 +132,64 @@@ $DisplaySubTot = number_format2($SubTotal,$dec); $DisplayFreight = number_format2($myrow["freight_cost"],$dec); -- $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight); - $linetype = true; $doctype = ST_SALESQUOTE; - include($path_to_root . "/reporting/includes/doctext.inc"); - $rep->TextCol(3, 6, $doc_Sub_total, -2); + $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); - $rep->TextCol(3, 6, $doc_Shipping, -2); + $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -2); $rep->NewLine(); + + $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); + if ($myrow['tax_included'] == 0) { + $rep->TextCol(3, 6, _("TOTAL ORDER EX VAT"), - 2); + $rep->TextCol(6, 7, $DisplayTotal, -2); + $rep->NewLine(); + } + + $tax_items = get_tax_for_items($items, $prices, $myrow["freight_cost"], + $myrow['tax_group_id'], $myrow['tax_included'], null); + $first = true; + foreach($tax_items as $tax_item) + { + if ($tax_item['Value'] == 0) + continue; + $DisplayTax = number_format2($tax_item['Value'], $dec); + + $tax_type_name = $tax_item['tax_type_name']; + + if ($myrow['tax_included']) + { + if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) + { + if ($first) + { + $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); + $rep->TextCol(6, 7, number_format2($sign*$tax_item['net_amount'], $dec), -2); + $rep->NewLine(); + } + $rep->TextCol(3, 6, $tax_type_name, -2); + $rep->TextCol(6, 7, $DisplayTax, -2); + $first = false; + } + else + $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . " " . _("Amount") . ": " . $DisplayTax, -2); + } + else + { + $SubTotal += $tax_item['Value']; + $rep->TextCol(3, 6, $tax_type_name, -2); + $rep->TextCol(6, 7, $DisplayTax, -2); + } + $rep->NewLine(); + } + + $rep->NewLine(); + $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); $rep->Font('bold'); - if ($myrow['tax_included'] == 0) - $rep->TextCol(3, 6, $doc_TOTAL_ORDER, - 2); - else - $rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2); + $rep->TextCol(3, 6, _("TOTAL ORDER VAT INCL."), - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow["freight_cost"] + $SubTotal, ST_SALESQUOTE); if ($words != "") diff --cc reporting/rep112.php index b5238a26,ba6c9465..c510160a --- a/reporting/rep112.php +++ b/reporting/rep112.php @@@ -105,9 -105,10 +105,10 @@@ function print_receipts( { $myrow = get_receipt($j, $i); if (!$myrow) -- continue; - $baccount = get_default_bank_account($myrow['curr_code']); - $params['bankaccount'] = $baccount['id']; ++ continue; + $res = get_bank_trans($j, $i); + $baccount = db_fetch($res); + $params['bankaccount'] = $baccount['bank_act']; $rep->title = _('RECEIPT'); $contacts = get_branch_contacts($myrow['branch_code'], 'invoice', $myrow['debtor_no']); @@@ -115,14 -116,12 +116,12 @@@ $rep->NewPage(); $result = get_allocations_for_receipt($myrow['debtor_no'], $myrow['type'], $myrow['trans_no']); - $linetype = true; $doctype = ST_CUSTPAYMENT; - include($path_to_root . "/reporting/includes/doctext.inc"); $total_allocated = 0; - $rep->TextCol(0, 4, $doc_Towards, -2); + $rep->TextCol(0, 4, _("As advance / full / part / payment towards:"), -2); $rep->NewLine(2); -- ++ while ($myrow2=db_fetch($result)) { $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); @@@ -155,22 -161,22 +161,22 @@@ { $rep->NewLine(1); $rep->TextCol(0, 7, $myrow['curr_code'] . ": " . $words, - 2); -- } ++ } $rep->Font(); $rep->NewLine(); - $rep->TextCol(6, 7, $doc_Received, - 2); + $rep->TextCol(6, 7, _("Received / Sign"), - 2); $rep->NewLine(); - $rep->TextCol(0, 2, $doc_by_Cheque, - 2); + $rep->TextCol(0, 2, _("By Cash / Cheque* / Draft No."), - 2); $rep->TextCol(2, 4, "______________________________", - 2); - $rep->TextCol(4, 5, $doc_Dated, - 2); + $rep->TextCol(4, 5, _("Dated"), - 2); $rep->TextCol(5, 6, "__________________", - 2); $rep->NewLine(1); - $rep->TextCol(0, 2, $doc_Drawn, - 2); + $rep->TextCol(0, 2, _("Drawn on Bank"), - 2); $rep->TextCol(2, 4, "______________________________", - 2); - $rep->TextCol(4, 5, $doc_Drawn_Branch, - 2); + $rep->TextCol(4, 5, _("Branch"), - 2); $rep->TextCol(5, 6, "__________________", - 2); $rep->TextCol(6, 7, "__________________"); -- } ++ } } $rep->End(); } diff --cc reporting/rep202.php index 2eb27559,6bbf6d92..59012605 --- a/reporting/rep202.php +++ b/reporting/rep202.php @@@ -36,7 -36,12 +36,12 @@@ function get_invoices($supplier_id, $to $PastDueDays2 = 2 * $PastDueDays1; // Revomed allocated from sql - $value = "(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; + if ($all) + $value = "(".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount)"; - else ++ else + $value = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_BANKDEPOSIT.", + (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount - ".TB_PREF."supp_trans.alloc), + (".TB_PREF."supp_trans.ov_amount + ".TB_PREF."supp_trans.ov_gst + ".TB_PREF."supp_trans.ov_discount + ".TB_PREF."supp_trans.alloc))"; $due = "IF (".TB_PREF."supp_trans.type=".ST_SUPPINVOICE." OR ".TB_PREF."supp_trans.type=".ST_SUPPCREDIT.",".TB_PREF."supp_trans.due_date,".TB_PREF."supp_trans.tran_date)"; $sql = "SELECT ".TB_PREF."supp_trans.type, ".TB_PREF."supp_trans.reference, diff --cc reporting/rep210.php index 7f6b53b6,136f0d2c..9d8b8d7d --- a/reporting/rep210.php +++ b/reporting/rep210.php @@@ -108,9 -108,10 +108,10 @@@ function print_remittances( { $myrow = get_remittance($j, $i); if (!$myrow) -- continue; - $baccount = get_default_bank_account($myrow['curr_code']); - $params['bankaccount'] = $baccount['id']; ++ continue; + $res = get_bank_trans($j, $i); + $baccount = db_fetch($res); + $params['bankaccount'] = $baccount['bank_act']; if ($email == 1) { @@@ -129,14 -130,12 +130,12 @@@ $rep->NewPage(); $result = get_allocations_for_remittance($myrow['supplier_id'], $myrow['type'], $myrow['trans_no']); - $linetype = true; $doctype = ST_SUPPAYMENT; - include($path_to_root . "/reporting/includes/doctext.inc"); $total_allocated = 0; - $rep->TextCol(0, 4, $doc_Towards, -2); + $rep->TextCol(0, 4, _("As advance / full / part / payment towards:"), -2); $rep->NewLine(2); -- ++ while ($myrow2=db_fetch($result)) { $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); @@@ -170,14 -175,14 +175,14 @@@ { $rep->NewLine(2); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); -- } ++ } $rep->Font(); if ($email == 1) { $myrow['DebtorName'] = $myrow['supp_name']; - $rep->End($email, $doc_Order_no . " " . $myrow['reference'], $myrow); + $rep->End($email); } -- } ++ } } if ($email == 0) $rep->End(); diff --cc reporting/rep305.php index 6711d9b7,1471ae66..3fdef19e --- a/reporting/rep305.php +++ b/reporting/rep305.php @@@ -33,20 -33,27 +33,27 @@@ function getTransactions($from, $to { $from = date2sql($from); $to = date2sql($to); -- - $sql = "SELECT DISTINCT ".TB_PREF."grn_batch.supplier_id, ++ + $sql = "SELECT ".TB_PREF."grn_batch.id batch_no, + ".TB_PREF."grn_batch.supplier_id, ".TB_PREF."purch_order_details.*, - ".TB_PREF."stock_master.description, ".TB_PREF."stock_master.inactive + ".TB_PREF."stock_master.description, + ".TB_PREF."grn_items.qty_recd, + ".TB_PREF."grn_items.quantity_inv, + ".TB_PREF."grn_items.id grn_item_id FROM ".TB_PREF."stock_master, ".TB_PREF."purch_order_details, - ".TB_PREF."grn_batch + ".TB_PREF."grn_batch, + ".TB_PREF."grn_items WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."purch_order_details.item_code AND ".TB_PREF."grn_batch.purch_order_no=".TB_PREF."purch_order_details.order_no - AND ".TB_PREF."purch_order_details.quantity_received>0 + AND ".TB_PREF."grn_batch.id = ".TB_PREF."grn_items.grn_batch_id + AND ".TB_PREF."grn_items.po_detail_item = ".TB_PREF."purch_order_details.po_detail_item + AND ".TB_PREF."grn_items.qty_recd>0 AND ".TB_PREF."grn_batch.delivery_date>='$from' AND ".TB_PREF."grn_batch.delivery_date<='$to' ORDER BY ".TB_PREF."stock_master.stock_id, ".TB_PREF."grn_batch.delivery_date"; -- ++ return db_query($sql,"No transactions were returned"); } @@@ -108,17 -131,43 +131,43 @@@ function print_grn_valuation( $rep->NewLine(); $rep->TextCol(0, 1, $trans['item_code']); - $rep->TextCol(1, 2, $trans['description'].($trans['inactive']==1 ? " ("._("Inactive").")" : ""), -1); + $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, $trans['order_no']); $qdec = get_qty_dec($trans['item_code']); - $rep->AmountCol(3, 4, $trans['quantity_received'], $qdec); - $rep->AmountCol(4, 5, $trans['unit_price'], $dec); - $rep->AmountCol(5, 6, $trans['act_price'], $dec); - $amt = round2($trans['quantity_received'] * $trans['act_price'], $dec); - $rep->AmountCol(6, 7, $amt, $dec); - $total += $amt; - $qtotal += $trans['quantity_received']; - $grandtotal += $amt; + $rep->TextCol(3, 4, $trans['batch_no']); - ++ + if ($trans['quantity_inv']) + { + $suppinv = getSuppInvDetails($trans['grn_item_id']); + while ($inv=db_fetch($suppinv)) + { + $inv['inv_price'] *= $rate; + $rep->TextCol(4, 5, $inv['inv_no']); + $rep->AmountCol(5, 6, $inv['inv_qty'], $qdec); + $rep->AmountCol(6, 7, $inv['inv_price'], $dec); + $rep->AmountCol(7, 8, $trans['unit_price'], $dec); + $amt = round2($inv['inv_qty'] * $inv['inv_price'], $dec); + $rep->AmountCol(8, 9, $amt, $dec); + $rep->NewLine(); + $total += $amt; + $qtotal += $inv['inv_qty']; + $grandtotal += $amt; + } + } + + if ($trans['qty_recd'] - $trans['quantity_inv'] !=0 ) + { + $rep->TextCol(4, 5, "--"); + $rep->AmountCol(5, 6, $trans['qty_recd'] - $trans['quantity_inv'], $qdec); + $rep->AmountCol(7, 8, $trans['unit_price'], $dec); + $amt = round2(($trans['qty_recd'] - $trans['quantity_inv']) * $trans['unit_price'], $dec); + $rep->AmountCol(8, 9, $amt, $dec); + $total += $amt; + $qtotal += $trans['qty_recd'] - $trans['quantity_inv']; + $grandtotal += $amt; + } + else + $rep->NewLine(-1); } if ($stock_id != '') { diff --cc reporting/rep601.php index 7ad92bcb,1d47bc78..1cedff0d --- a/reporting/rep601.php +++ b/reporting/rep601.php @@@ -118,7 -118,7 +118,7 @@@ function print_bank_transactions( $rep->TextCol(1, 2, $myrow['trans_no']); $rep->TextCol(2, 3, $myrow['ref']); $rep->DateCol(3, 4, $myrow["trans_date"], true); - $rep->TextCol(4, 5, get_counterparty_name($myrow["type"], $myrow["type_no"], false)); - $rep->TextCol(4, 5, payment_person_name($myrow["person_type_id"],$myrow["person_id"], false)); ++ $rep->TextCol(4, 5, get_counterparty_name($myrow["type"], $myrow["trans_no"], false)); if ($myrow['amount'] > 0.0) { $rep->AmountCol(5, 6, abs($myrow['amount']), $dec); diff --cc reporting/rep701.php index b4f54c96,30e6aa05..2bfffade --- a/reporting/rep701.php +++ b/reporting/rep701.php @@@ -25,10 -25,10 +25,10 @@@ include_once($path_to_root . "/gl/inclu //---------------------------------------------------------------------------------------------------- - function display_type ($type, $typename, &$dec, &$rep, $showbalance) + function display_type ($type, $typename, &$dec, &$rep, $showbalance, $level) { $printtitle = 0; //Flag for printing type name -- ++ //Get Accounts directly under this group/type $result = get_gl_accounts(null, null, $type); while ($account=db_fetch($result)) @@@ -36,12 -36,15 +36,15 @@@ //Print Type Title if it has atleast one non-zero account if (!$printtitle) { + $prefix = ''; + for ($sp=1; $sp<=$level; $sp++) + { + $prefix .= ' '; - } ++ } $printtitle = 1; $rep->row -= 4; - $rep->Font('bold'); $rep->TextCol(0, 1, $type); - $rep->TextCol(1, 4, $typename); - $rep->Font(); + $rep->TextCol(1, 4, $prefix.$typename); $rep->row -= 4; $rep->Line($rep->row); $rep->NewLine(); @@@ -60,7 -63,7 +63,7 @@@ $rep->AmountCol(3, 4, $balance, $dec); $rep->NewLine(); } -- ++ //Get Account groups/types under this group/type $result = get_account_types(false, false, $type); while ($accounttype=db_fetch($result)) diff --cc reporting/rep708.php index 20956029,979ca2e1..9ff9b296 --- a/reporting/rep708.php +++ b/reporting/rep708.php @@@ -109,65 -208,23 +208,23 @@@ function print_trial_balance( $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->NewPage(); - + - $accounts = get_gl_accounts(); - - $pdeb = $pcre = $cdeb = $ccre = $tdeb = $tcre = $pbal = $cbal = $tbal = 0; - $begin = begin_fiscalyear(); - if (date1_greater_date2($begin, $from)) - $begin = $from; - $begin = add_days($begin, -1); - while ($account=db_fetch($accounts)) + $classresult = get_account_classes(false); + while ($class = db_fetch($classresult)) { - $prev = get_balance($account["account_code"], $dimension, $dimension2, $begin, $from, false, false); - $curr = get_balance($account["account_code"], $dimension, $dimension2, $from, $to, true, true); - $tot = get_balance($account["account_code"], $dimension, $dimension2, $begin, $to, false, true); - - if ($zero == 0 && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) - continue; - $rep->TextCol(0, 1, $account['account_code']); - $rep->TextCol(1, 2, $account['account_name']); - if ($balances != 0) - { - if ($prev['balance'] >= 0.0) - $rep->AmountCol(2, 3, $prev['balance'], $dec); - else - $rep->AmountCol(3, 4, abs($prev['balance']), $dec); - if ($curr['balance'] >= 0.0) - $rep->AmountCol(4, 5, $curr['balance'], $dec); - else - $rep->AmountCol(5, 6, abs($curr['balance']), $dec); - if ($tot['balance'] >= 0.0) - $rep->AmountCol(6, 7, $tot['balance'], $dec); - else - $rep->AmountCol(7, 8, abs($tot['balance']), $dec); - } - else - { - $rep->AmountCol(2, 3, $prev['debit'], $dec); - $rep->AmountCol(3, 4, $prev['credit'], $dec); - $rep->AmountCol(4, 5, $curr['debit'], $dec); - $rep->AmountCol(5, 6, $curr['credit'], $dec); - $rep->AmountCol(6, 7, $tot['debit'], $dec); - $rep->AmountCol(7, 8, $tot['credit'], $dec); - $pdeb += $prev['debit']; - $pcre += $prev['credit']; - $cdeb += $curr['debit']; - $ccre += $curr['credit']; - $tdeb += $tot['debit']; - $tcre += $tot['credit']; - - } - $pbal += $prev['balance']; - $cbal += $curr['balance']; - $tbal += $tot['balance']; + $rep->Font('bold'); + $rep->TextCol(0, 1, $class['cid']); + $rep->TextCol(1, 4, $class['class_name']); + $rep->Font(); $rep->NewLine(); - if ($rep->row < $rep->bottomMargin + $rep->lineHeight) + //Get Account groups/types under this group/type with no parents + $typeresult = get_account_types(false, $class['cid'], -1); + while ($accounttype=db_fetch($typeresult)) { - $rep->Line($rep->row - 2); - $rep->NewPage(); + display_type($accounttype["id"], $accounttype["name"], $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2); } + $rep->NewLine(); } $rep->Line($rep->row); $rep->NewLine(); @@@ -203,9 -256,9 +256,9 @@@ else $rep->AmountCol(7, 8, abs($tbal), $dec); $rep->NewLine(); -- - $rep->Line($rep->row); - if (($pbal = round2($pbal, $dec)) != 0.0) ++ + $rep->Line($rep->row + 10); + if (($pbal = round2($pbal, $dec)) != 0.0 && $dimension == 0 && $dimension2 == 0) { $rep->NewLine(2); $rep->Font(); diff --cc reporting/rep709.php index e52f2933,dbe25e5b..c3cd8e19 --- a/reporting/rep709.php +++ b/reporting/rep709.php @@@ -71,8 -73,8 +73,8 @@@ function getTaxInfo($id function print_tax_report() { - global $path_to_root, $trans_dir, $systypes_array; - + global $path_to_root, $trans_dir, $Hooks, $systypes_array; - ++ $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $summaryOnly = $_POST['PARAM_2']; @@@ -124,7 -126,7 +126,7 @@@ $trans['net_amount'] *= -1; $trans['amount'] *= -1; } -- ++ if (!$summaryOnly) { $rep->TextCol(0, 1, $systypes_array[$trans['trans_type']]); @@@ -138,7 -140,9 +140,9 @@@ $rep->AmountCol(5, 6, $trans['net_amount'], $dec); $rep->AmountCol(6, 7, $trans['rate'], $dec); $rep->AmountCol(7, 8, $trans['amount'], $dec); - + + $rep->TextCol(9, 10, $trans['taxname']); + $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) diff --cc reporting/reports_main.php index baeeba36,ca278556..e9135309 --- a/reporting/reports_main.php +++ b/reporting/reports_main.php @@@ -156,7 -165,7 +165,7 @@@ $reports->addReport(RC_SUPPLIER, 209, _ _('Currency Filter') => 'CURRENCY', _('Email Customers') => 'YES_NO', _('Comments') => 'TEXTBOX')); --$reports->addReport(RC_SUPPLIER, 210, _('Print Remittances'), ++$reports->addReport(RC_SUPPLIER, 210, _('Print Remi&ttances'), array( _('From') => 'REMITTANCE', _('To') => 'REMITTANCE', _('Currency Filter') => 'CURRENCY', @@@ -166,7 -175,8 +175,8 @@@ $reports->addReportClass(_('Inventory'), RC_INVENTORY); $reports->addReport(RC_INVENTORY, 301, _('Inventory &Valuation Report'), - array( _('Inventory Category') => 'CATEGORIES', - array( _('End Date') => 'DATE', ++ array( _('End Date') => 'DATE', + _('Inventory Category') => 'CATEGORIES', _('Location') => 'LOCATIONS', _('Summary Only') => 'YES_NO', _('Comments') => 'TEXTBOX', diff --cc sales/customer_delivery.php index 2208a455,30e35919..df8bad06 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@@ -279,24 -269,35 +270,35 @@@ function check_quantities( function check_qoh() { - global $SysPrefs; - - if (!$SysPrefs->allow_negative_stock()) { - foreach ($_SESSION['Items']->line_items as $itm) { - - if ($itm->qty_dispatched && has_stock_holding($itm->mb_flag)) { - $qoh = get_qoh_on_date($itm->stock_id, $_POST['Location'], $_POST['DispatchDate']); - - if ($itm->qty_dispatched > $qoh) { - display_error(_("The delivery cannot be processed because there is an insufficient quantity for item:") . - " " . $itm->stock_id . " - " . $itm->item_description); - return false; - } - } - } - } - return true; + global $SysPrefs; + $dn = &$_SESSION['Items']; + $newdelivery = ($dn->trans_no==0); + if (!$SysPrefs->allow_negative_stock()) { + foreach ($_SESSION['Items']->line_items as $itm) { + + if ($itm->qty_dispatched && has_stock_holding($itm->mb_flag)) { + $qoh_by_date = get_qoh_on_date($itm->stock_id, $_POST['Location'], $_POST['DispatchDate']); + $qoh_abs = get_qoh_on_date($itm->stock_id, $_POST['Location'], null); + //If editing current delivery delivered qty should be added + if (!$newdelivery) + { + $delivered = get_already_delivered($itm->stock_id, $_POST['Location'], key($dn->trans_no)); - ++ + $qoh_abs = $qoh_abs - $delivered; + $qoh_by_date = $qoh_by_date - $delivered; + } + $qoh = ($qoh_by_date < $qoh_abs ? $qoh_by_date : $qoh_abs); + if ($itm->qty_dispatched > $qoh) { + display_error(_("The delivery cannot be processed because there is an insufficient quantity for item:") . + " " . $itm->stock_id . " - " . $itm->item_description); + return false; + } + } + } + } + return true; } + //------------------------------------------------------------------------------ if (isset($_POST['process_delivery']) && check_data() && check_qoh()) { diff --cc sales/customer_payments.php index 1bf8e196,f5d1f011..e268dd22 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@@ -183,8 -236,22 +236,22 @@@ if (isset($_POST['_customer_id_button'] if (isset($_POST['_DateBanked_changed'])) { $Ajax->activate('_ex_rate'); } - if (list_updated('customer_id') || list_updated('bank_account')) { + + //Chaitanya : 13-OCT-2011 - To support Edit feature + if (isset($_POST['ref']) && $_SESSION['alloc']->trans_no == 0) // added by Joe to fix the browser back button + { + $tno = get_customer_trans_from_ref(ST_CUSTPAYMENT, $_POST['ref']); + if ($tno != false) + { + display_error( _("The entered reference is already in use.")); + display_footer_exit(); + } -} ++} + $new = $_SESSION['alloc']->trans_no == 0; + + if (list_updated('customer_id') || ($new && list_updated('bank_account'))) { $_SESSION['alloc']->read(); + $_POST['memo_'] = $_POST['amount'] = $_POST['discount'] = ''; $Ajax->activate('alloc_tbl'); } //---------------------------------------------------------------------------------------------- @@@ -244,60 -365,61 +365,60 @@@ start_form() read_customer_data(); set_global_customer($_POST['customer_id']); - if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) { - end_outer_table(); - display_error(_("This customer account is on hold.")); - } else { - $display_discount_percent = percent_format($_POST['pymt_discount']*100) . "%"; - - table_section(2); + if (isset($_POST['HoldAccount']) && $_POST['HoldAccount'] != 0) + display_warning(_("This customer account is on hold.")); + $display_discount_percent = percent_format($_POST['pymt_discount']*100) . "%"; - bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, true); + table_section(2); + if (!list_updated('bank_account')) + $_POST['bank_account'] = get_default_customer_bank_account($_POST['customer_id']); + //Chaitanya : 13-OCT-2011 - Is AJAX call really needed ??? + //bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, true); + bank_accounts_list_row(_("Into Bank Account:"), 'bank_account', null, false); - + text_row(_("Reference:"), 'ref', null, 20, 40); - text_row(_("Reference:"), 'ref', null, 20, 40); + table_section(3); - table_section(3); + date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true); - date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true); - - - - $comp_currency = get_company_currency(); - $cust_currency = get_customer_currency($_POST['customer_id']); - $bank_currency = get_bank_account_currency($_POST['bank_account']); + $comp_currency = get_company_currency(); + $cust_currency = get_customer_currency($_POST['customer_id']); + $bank_currency = get_bank_account_currency($_POST['bank_account']); - if ($cust_currency != $bank_currency) { - exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], ($bank_currency == $comp_currency)); - } + if ($cust_currency != $bank_currency) { + exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], ($bank_currency == $comp_currency)); + } - amount_row(_("Bank Charge:"), 'charge'); + amount_row(_("Bank Charge:"), 'charge'); - end_outer_table(1); + end_outer_table(1); - if ($cust_currency == $bank_currency) { - div_start('alloc_tbl'); - show_allocatable(false); - div_end(); - } + if ($cust_currency == $bank_currency) { + div_start('alloc_tbl'); + show_allocatable(false); + div_end(); + } - start_table(TABLESTYLE, "width=60%"); + start_table(TABLESTYLE, "width=60%"); - label_row(_("Customer prompt payment discount :"), $display_discount_percent); - amount_row(_("Amount of Discount:"), 'discount'); + label_row(_("Customer prompt payment discount :"), $display_discount_percent); + amount_row(_("Amount of Discount:"), 'discount'); - amount_row(_("Amount:"), 'amount'); + amount_row(_("Amount:"), 'amount'); - textarea_row(_("Memo:"), 'memo_', null, 22, 4); - end_table(1); + textarea_row(_("Memo:"), 'memo_', null, 22, 4); + end_table(1); - if ($cust_currency != $bank_currency) - display_note(_("Amount and discount are in customer's currency.")); + if ($cust_currency != $bank_currency) + display_note(_("Amount and discount are in customer's currency.")); - br(); + br(); + if (isset($_POST['trans_no']) && $_POST['trans_no'] > 0 ) + submit_center('AddPaymentItem', _("Update Payment"), true, '', 'default'); + else submit_center('AddPaymentItem', _("Add Payment"), true, '', 'default'); - } br(); diff --cc sales/includes/cart_class.inc index 46f8d500,cc7d1567..062d9bad --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@@ -77,10 -75,10 +77,10 @@@ class car //------------------------------------------------------------------------- // // $trans_no==0 => open new/direct document - // $trans_no!=0 && $prep_child==false => update with parent constarints for reedition - // $trans_no!=0 && $prep_child==true => prepare for child doc entry + // $trans_no!=0 && $no_edit==false => update with parent constarints for reedition + // $trans_no!=0 && $no_edit==true => read only: for view, or later child doc entry // - function Cart($type, $trans_no=0, $no_edit=false) { + function Cart($type, $trans_no=0, $prep_child=false) { /*Constructor function initialises a new shopping cart */ $this->line_items = array(); $this->sales_type = ""; diff --cc sales/includes/db/customers_db.inc index bd5b8d34,3a67e4ed..21ce5e41 --- a/sales/includes/db/customers_db.inc +++ b/sales/includes/db/customers_db.inc @@@ -24,7 -24,7 +24,6 @@@ function add_customer($CustName, $cust_ " . db_escape($credit_status) . ", ".db_escape($payment_terms) . ", " . $discount . ", " . $pymt_discount . ", " . $credit_limit .", ".db_escape($sales_type).", ".db_escape($notes) . ")"; -- db_query($sql,"The customer could not be added"); } diff --cc sales/includes/db/sales_invoice_db.inc index a13109f0,558b2159..ecaf4466 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@@ -146,9 -146,9 +146,10 @@@ function write_sales_invoice(&$invoice $taxitem['rate'], $invoice->tax_included, $taxitem['Value'], $taxitem['Net'], $ex_rate, $date_, $invoice->reference); -- $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0, -- (-$taxitem['Value']), $invoice->customer_id, -- "A tax GL posting could not be inserted"); ++ if (isset($taxitem['sales_gl_code'])) ++ $total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $taxitem['sales_gl_code'], 0, 0, ++ (-$taxitem['Value']), $invoice->customer_id, ++ "A tax GL posting could not be inserted"); } } diff --cc sales/includes/db/sales_order_db.inc index eb5665ab,e4eaa5c1..386e3b86 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@@ -87,11 -87,13 +87,16 @@@ function add_sales_order(&$order $line->discount_percent)"; db_query($sql, "order Details Cannot be Added"); + // Now mark quotation line as processed + if ($order->trans_type == ST_SALESORDER && $line->src_id) + update_parent_line(ST_SALESORDER, $line->src_id, $line->qty_dispatched); // clear all the quote despite all or the part was ordered } /* inserted line items into sales order details */ + add_audit_trail($order->trans_type, $order_no, $order->document_date); + $Refs->save($order->trans_type, $order_no, $order->reference); + add_audit_trail($order->trans_type, $order_no, $order->document_date); + $Refs->save($order->trans_type, $order_no, $order->reference); + hook_db_postwrite($order, $order->trans_type); commit_transaction(); @@@ -546,17 -552,22 +555,22 @@@ function get_sql_for_sales_orders_view( if ($selected_customer != -1) $sql .= " AND sorder.debtor_no=".db_escape($selected_customer); - if (isset($selected_stock_item)) - $sql .= " AND line.stk_code=".db_escape($selected_stock_item); + if (isset($stock_item)) + $sql .= " AND line.stk_code=".db_escape($stock_item); - if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != ALL_TEXT) - $sql .= " AND sorder.from_stk_loc = ".db_escape($_POST['StockLocation']); + if ($location) + $sql .= " AND sorder.from_stk_loc = ".db_escape($location); - if ($_POST['order_view_mode']=='OutstandingOnly') + if ($filter=='OutstandingOnly') $sql .= " AND line.qty_sent < line.quantity"; - elseif ($_POST['order_view_mode']=='InvoiceTemplates' || $_POST['order_view_mode']=='DeliveryTemplates') + + elseif ($filter=='InvoiceTemplates' || $filter=='DeliveryTemplates') $sql .= " AND sorder.type=1"; - + + //Chaiatanya : New Filter + if ($customer_id != ALL_TEXT) + $sql .= " AND sorder.debtor_no = ".db_escape($customer_id); + $sql .= " GROUP BY sorder.order_no, sorder.debtor_no, sorder.branch_code, diff --cc sales/inquiry/customer_inquiry.php index bcafeecc,3ebc84b5..d8a000c1 --- a/sales/inquiry/customer_inquiry.php +++ b/sales/inquiry/customer_inquiry.php @@@ -18,14 -18,16 +18,13 @@@ include_once($path_to_root . "/sales/in include_once($path_to_root . "/sales/includes/sales_db.inc"); include_once($path_to_root . "/reporting/includes/reporting.inc"); -if (!@$_GET['popup']) -{ - $js = ""; - if ($use_popup_windows) - $js .= get_js_open_window(900, 500); - if ($use_date_picker) - $js .= get_js_date_picker(); - page(_($help_context = "Customer Transactions"), isset($_GET['customer_id']), false, "", $js); -} +$js = ""; +if ($use_popup_windows) + $js .= get_js_open_window(900, 500); +if ($use_date_picker) + $js .= get_js_date_picker(); +page(_($help_context = "Customer Transactions"), isset($_GET['customer_id']), false, "", $js); - if (isset($_GET['customer_id'])) { $_POST['customer_id'] = $_GET['customer_id']; @@@ -41,7 -44,8 +40,8 @@@ if (!isset($_POST['customer_id']) start_table(TABLESTYLE_NOBORDER); start_row(); - customer_list_cells(_("Select a customer: "), 'customer_id', null, true); -if (!@$_GET['popup']) ++if (!$page_nested) + customer_list_cells(_("Select a customer: "), 'customer_id', null, true, false, false, !@$_GET['popup']); date_cells(_("From:"), 'TransAfterDate', '', null, -30); date_cells(_("To:"), 'TransToDate', '', null, 1); @@@ -154,6 -158,8 +154,10 @@@ function fmt_credit($row function credit_link($row) { - if (@$_GET['popup']) ++ global $page_nested; ++ ++ if ($page_nested) + return ''; return $row['type'] == ST_SALESINVOICE && $row["Outstanding"] > 0 ? pager_link(_("Credit This") , "/sales/customer_credit_invoice.php?InvoiceNumber=". $row['trans_no'], ICON_CREDIT):''; @@@ -161,30 -167,36 +165,14 @@@ function edit_link($row) { - /* $str = ''; - - switch($row['type']) { - case ST_SALESINVOICE: - if (get_voided_entry(ST_SALESINVOICE, $row["trans_no"]) === false && $row['Allocated'] == 0) - $str = "/sales/customer_invoice.php?ModifyInvoice=".$row['trans_no']; - break; - case ST_CUSTCREDIT: - if (get_voided_entry(ST_CUSTCREDIT, $row["trans_no"]) === false && $row['Allocated'] == 0) // 2008-11-19 Joe Hunt - { - if ($row['order_']==0) // free-hand credit note - $str = "/sales/credit_note_entry.php?ModifyCredit=".$row['trans_no']; - else // credit invoice - $str = "/sales/customer_credit_invoice.php?ModifyCredit=".$row['trans_no']; - } - break; - case ST_CUSTDELIVERY: - if (get_voided_entry(ST_CUSTDELIVERY, $row["trans_no"]) === false) - $str = "/sales/customer_delivery.php?ModifyDelivery=".$row['trans_no']; - break; - } - if ($str != '') - */ return edit_trans_link($row['type'], $row['trans_no'], $row['type']==ST_CUSTCREDIT && $row['order_']==0 ? - "/sales/credit_note_entry.php?ModifyCredit=%d" : 0); - $str = ''; ++ global $page_nested; + - if (@$_GET['popup']) ++ $str = ''; ++ if ($page_nested) + return ''; - switch($row['type']) { - case ST_SALESINVOICE: - if (get_voided_entry(ST_SALESINVOICE, $row["trans_no"]) === false && $row['Allocated'] == 0) - $str = "/sales/customer_invoice.php?ModifyInvoice=".$row['trans_no']; - break; - case ST_CUSTCREDIT: - if (get_voided_entry(ST_CUSTCREDIT, $row["trans_no"]) === false && $row['Allocated'] == 0) // 2008-11-19 Joe Hunt - { - if ($row['order_']==0) // free-hand credit note - $str = "/sales/credit_note_entry.php?ModifyCredit=".$row['trans_no']; - else // credit invoice - $str = "/sales/customer_credit_invoice.php?ModifyCredit=".$row['trans_no']; - } - break; - case ST_CUSTDELIVERY: - if (get_voided_entry(ST_CUSTDELIVERY, $row["trans_no"]) === false) - $str = "/sales/customer_delivery.php?ModifyDelivery=".$row['trans_no']; - break; - case ST_CUSTPAYMENT: - if (get_voided_entry(ST_CUSTPAYMENT, $row["trans_no"]) === false) - $str = "/sales/customer_payments.php?trans_no=".$row['trans_no']; - break; - } - if ($str != "" && !is_closed_trans($row['type'], $row["trans_no"])) - return pager_link(_('Edit'), $str, ICON_EDIT); - return ''; ++ ++ return edit_trans_link($row['type'], $row['trans_no'], $row['type']==ST_CUSTCREDIT && $row['order_']==0 ? ++ "/sales/credit_note_entry.php?ModifyCredit=%d" : 0); } function prt_link($row) @@@ -242,7 -254,9 +230,6 @@@ $table->width = "85%" display_db_pager($table); -if (!@$_GET['popup']) -{ - end_form(); - end_page(@$_GET['popup'], false, false); -} +end_form(); +end_page(); - ?> diff --cc sales/inquiry/sales_orders_view.php index 53de2699,f59be9c0..281e3a5f --- a/sales/inquiry/sales_orders_view.php +++ b/sales/inquiry/sales_orders_view.php @@@ -66,7 -60,16 +60,13 @@@ els $_POST['order_view_mode'] = "Quotations"; $_SESSION['page_title'] = _($help_context = "Search All Sales Quotations"); } + -if (!@$_GET['popup']) -{ - $js = ""; - if ($use_popup_windows) - $js .= get_js_open_window(900, 600); - if ($use_date_picker) - $js .= get_js_date_picker(); - page($_SESSION['page_title'], false, false, "", $js); -} ++$js = ""; ++if ($use_popup_windows) ++ $js .= get_js_open_window(900, 600); ++if ($use_date_picker) ++ $js .= get_js_date_picker(); +page($_SESSION['page_title'], false, false, "", $js); if (isset($_GET['selected_customer'])) { @@@ -118,6 -121,8 +118,10 @@@ function prt_link($row function edit_link($row) { - if (@$_GET['popup']) - return ''; ++ global $page_nested; ++ ++ if ($page_nested) ++ return ''; global $trans_type; $modify = ($trans_type == ST_SALESORDER ? "ModifyOrderNumber" : "ModifyQuotationNumber"); return pager_link( _("Edit"), @@@ -159,9 -164,11 +163,12 @@@ function order_link($row function tmpl_checkbox($row) { -- global $trans_type; ++ global $trans_type, $page_nested; if ($trans_type == ST_SALESQUOTE) return ''; - if (@$_GET['popup']) - return ''; ++ ++ if ($page_nested) ++ return ''; $name = "chgtpl" .$row['order_no']; $value = $row['type'] ? 1:0; @@@ -230,14 -230,17 +229,17 @@@ if ($show_dates date_cells(_("to:"), 'OrdersToDate', '', null, 1); } locations_list_cells(_("Location:"), 'StockLocation', null, true); - end_row(); - end_table(); - start_table(TABLESTYLE_NOBORDER); - start_row(); + if($show_dates) { + end_row(); + end_table(); + start_table(TABLESTYLE_NOBORDER); + start_row(); + } stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true); - -if (!@$_GET['popup']) - customer_list_cells(_("Select a customer: "), 'customer_id', null, true); ++if (!@$_GET['popup']) ++ customer_list_cells(_("Select a customer: "), 'customer_id', null, true); if ($trans_type == ST_SALESQUOTE) check_cells(_("Show All:"), 'show_all'); @@@ -251,7 -254,8 +253,8 @@@ end_table(1) //--------------------------------------------------------------------------------------------- // Orders inquiry table // - $sql = get_sql_for_sales_orders_view($selected_customer, $trans_type); + $sql = get_sql_for_sales_orders_view($selected_customer, $trans_type, $_POST['OrderNumber'], $_POST['order_view_mode'], - @$selected_stock_item, @$_POST['OrdersAfterDate'], @$_POST['OrdersToDate'], @$_POST['OrderReference'], $_POST['StockLocation'], $_POST['customer_id']); ++ @$selected_stock_item, @$_POST['OrdersAfterDate'], @$_POST['OrdersToDate'], @$_POST['OrderReference'], $_POST['StockLocation'], $_POST['customer_id']); if ($trans_type == ST_SALESORDER) $cols = array( @@@ -281,9 -285,11 +284,11 @@@ els 'Type' => 'skip', _("Currency") => array('align'=>'center') ); -if ($_POST['order_view_mode'] == 'OutstandingOnly') { - //array_substitute($cols, 3, 1, _("Cust Order Ref")); - array_append($cols, array( - array('insert'=>true, 'fun'=>'dispatch_link'), - array('insert'=>true, 'fun'=>'edit_link'))); +if ($_POST['order_view_mode'] == 'OutstandingOnly') { + //array_substitute($cols, 3, 1, _("Cust Order Ref")); - array_append($cols, array(array('insert'=>true, 'fun'=>'dispatch_link'))); ++ array_append($cols, array( ++ array('insert'=>true, 'fun'=>'dispatch_link'), ++ array('insert'=>true, 'fun'=>'edit_link'))); } elseif ($_POST['order_view_mode'] == 'InvoiceTemplates') { array_substitute($cols, 3, 1, _("Description")); diff --cc sales/manage/customers.php index 13350530,41c642ac..af14b9a6 --- a/sales/manage/customers.php +++ b/sales/manage/customers.php @@@ -12,8 -12,15 +12,15 @@@ $page_security = 'SA_CUSTOMER'; $path_to_root = "../.."; -include($path_to_root . "/includes/db_pager.inc"); ++include_once($path_to_root . "/includes/db_pager.inc"); include_once($path_to_root . "/includes/session.inc"); - page(_($help_context = "Customers"), @$_REQUEST['popup']); + $js = ""; + if ($use_popup_windows) + $js .= get_js_open_window(900, 500); + if ($use_date_picker) + $js .= get_js_date_picker(); + + page(_($help_context = "Customers"), @$_REQUEST['popup'], false, "", $js); include_once($path_to_root . "/includes/date_functions.inc"); include_once($path_to_root . "/includes/banking.inc"); @@@ -310,7 -354,16 +354,14 @@@ tabbed_content_start('tabs', array $contacts = new contacts('contacts', $selected_id, 'customer'); $contacts->show(); break; + case 'transactions': + $_GET['customer_id'] = $selected_id; - $_GET['popup'] = 1; + include_once($path_to_root."/sales/inquiry/customer_inquiry.php"); + break; case 'orders': + $_GET['customer_id'] = $selected_id; - $_GET['popup'] = 1; + include_once($path_to_root."/sales/inquiry/sales_orders_view.php"); + break; }; br(); tabbed_content_end(); diff --cc sales/view/view_sales_order.php index ff88393c,405f1d66..712c5470 --- a/sales/view/view_sales_order.php +++ b/sales/view/view_sales_order.php @@@ -39,13 -39,14 +39,14 @@@ if (isset($_SESSION['View']) unset ($_SESSION['View']); } -$_SESSION['View'] = new Cart($_GET['trans_type'], $_GET['trans_no']); +$_SESSION['View'] = new Cart($_GET['trans_type'], $_GET['trans_no'], true); start_table(TABLESTYLE2, "width=95%", 5); - echo ""; - display_heading2(_("Order Information")); + if ($_GET['trans_type'] != ST_SALESQUOTE) { + echo ""; + display_heading2(_("Order Information")); echo ""; display_heading2(_("Deliveries")); echo ""; diff --cc sql/alter2.3.php index c4071f97,2a517deb..7705f261 --- a/sql/alter2.3.php +++ b/sql/alter2.3.php @@@ -34,8 -35,8 +35,8 @@@ class fa2_3 if (!$this->beta) { // all specials below are already done on 2.3beta - $sql = "SELECT debtor_no, payment_terms FROM {$pref}debtors_master"; - + $sql = "SELECT debtor_no, payment_terms FROM ".TB_PREF."debtors_master"; - ++ $result = db_query($sql); if (!$result) { display_error("Cannot read customers" diff --cc taxes/tax_calc.inc index dbb7999e,4c4b9f37..27b1ccfa --- a/taxes/tax_calc.inc +++ b/taxes/tax_calc.inc @@@ -37,6 -36,6 +36,7 @@@ function get_tax_free_price_for_item($s //print_r($ret_tax_array); $tax_array = get_taxes_for_item($stock_id, $ret_tax_array); ++ // if no exemptions or taxgroup is empty, then no included/excluded taxes if ($tax_array == null) return $price; @@@ -150,34 -150,37 +153,49 @@@ function get_tax_for_items($items, $pri else $ret_tax_array = get_tax_group_items_as_array($tax_group); ++ $dec = user_price_dec(); ++ ++ $fully_exempt = true; foreach($ret_tax_array as $k=>$t) ++ { ++ if ($t['rate'] !== null) ++ $fully_exempt = false; $ret_tax_array[$k]['Net'] = 0; ++ } ++ $ret_tax_array['exempt'] = array('Value'=>0, 'Net'=>0, 'rate' => null, 'tax_type_id' => ''); $dec = user_price_dec(); // loop for all items for ($i = 0; $i < count($items); $i++) { $item_taxes = get_taxes_for_item($items[$i], $ret_tax_array); - -- if ($item_taxes != null) ++ if ($item_taxes == null || $fully_exempt) + { ++ $ret_tax_array['exempt']['Value'] += round2(0, $dec); ++ $ret_tax_array['exempt']['Net'] += $prices[$i]; ++ } ++ else + { + $tax_multiplier = 0; + foreach ($item_taxes as $taxitem) + { + $tax_multiplier += $taxitem['rate']; + } foreach ($item_taxes as $item_tax) { if ($item_tax['rate'] !== null) { $index = $item_tax['tax_type_id']; - if($tax_included==1) {// 2008-11-26 Joe Hunt Taxes are stored without roundings - $nprice = get_tax_free_price_for_item($items[$i], $prices[$i], $tax_group, $tax_included, null, $item_tax['tax_type_id']); - $ret_tax_array[$index]['Value'] += $nprice*$item_tax['rate']/100; - $ret_tax_array[$index]['Net'] += $nprice; + if ($tax_included == 1) { + $ret_tax_array[$index]['Value'] += round2($prices[$i]*$item_tax['rate']/(100+$tax_multiplier), $dec); + $ret_tax_array[$index]['Net'] += round2($prices[$i]*100/(100+$tax_multiplier), $dec); } else { -- $ret_tax_array[$index]['Value'] += ($prices[$i] * $item_tax['rate'] / 100); ++ $ret_tax_array[$index]['Value'] += round2($prices[$i] * $item_tax['rate'] / 100, $dec); $ret_tax_array[$index]['Net'] += $prices[$i]; } } } } } - - // add the shipping taxes, only if non-zero, and only if tax group taxes shipping if ($shipping_cost != 0) { @@@ -200,24 -203,18 +218,24 @@@ { $index = $item_tax['tax_type_id']; if ($item_tax['rate'] !== null && $ret_tax_array[$index]['rate'] !== null) { - if($tax_included==1) {// 2008-11-26 Joe Hunt Taxes are stored without roundings - $ret_tax_array[$index]['Value'] += ($shipping_net * $item_tax['rate'] / 100); + if($tax_included==1) { + $ret_tax_array[$index]['Value'] += round2($shipping_cost*$item_tax['rate']/(100+$tax_rate), $dec); $ret_tax_array[$index]['Net'] += $shipping_net; } else { -- $ret_tax_array[$index]['Value'] += ($shipping_cost * $item_tax['rate'] / 100); ++ $ret_tax_array[$index]['Value'] += round2($shipping_cost * $item_tax['rate'] / 100, $dec); $ret_tax_array[$index]['Net'] += $shipping_cost; } } } } } - - //print_r($ret_tax_array); ++ + if ($tax_algorithm == TCA_TOTALS ) { + // update taxes with + foreach($ret_tax_array as $index => $item_tax) { + $ret_tax_array[$index]['Value'] = round2($item_tax['Net'] * $item_tax['rate'] / 100, $dec); + } + } return $ret_tax_array; } diff --cc update.html index 6cdf420b,efa23202..3af13a0e --- a/update.html +++ b/update.html @@@ -1,152 -1,164 +1,164 @@@ - - - - FrontAccounting Update - - - -

FrontAccounting -Update

-

Important Notes for release 2.3.5.

Change in the behaviour of Recurrent Invoices.
  • Now -the Last Sent day is stamped with the former Last Sent (or Begin date -the first time) + months + days. Before the Last Sent day was stamped -with tthe creation date (today). The Invoice date is still todays date. -
  • If you for some reason want to make a pause in the recurrent -invoices, you can now edit the Last Sent day in the Management section -of Sales tab.
  • Before the days value, together with a month -value, decided which day in the month the invoice was due..  This -does not work now. You can change the day in the month you -want the recurrency to happen by setting the Last Sent day with the new -day in the Management section. 
  • If you create a new Recurrent Invoice the Beginning date can be set to the day in the month you want the recurrencies to be due.
-

Important Notes

-

Upgrade process can be done only by administrator of the first -company created during FrontAccounting installation. This person is -considered as a site admin who have granted access to potentially -dangerous setup options, like Setup/Software Upgrade.

-

In the following description sections related to older FA versions are -prefixed with [color tags] -. You can skip tagged fragment safely if currently FA -application is newer than the version in tag.

-

Upgrade process consists of up to four stages, some of them are -optional:

-
    -
  1. Application source files update -

    -
  2. Database upgrade – this step is needed only during - upgrade which involves change in major application version number - (e.g. from 2.2.x to 2.3.x), and sometimes during upgrade from beta - release to stable version. Otherwise this step can be skipped.

    -
  3. Final cleanup – is needed when some old source files, - obsoleted by new release should be removed.

    -
  4. New features configuration – this is optional step - needed for most major releases and some minor ones. -

    -
-

Before starting upgrade ensure nobody -is using the application and make database backup for all companies. -To be on safe side backup also old source files, especially those -locally customized (if any).

-

Log into admin account of first company. If -you use a theme other than the standard 3 (aqua, cool or default), -switch to one of these before going further.

-

1. Application files update

-

a. Source -files update

-

Extract distribution -zip/tar.gz file in empty directory, and copy all the files to your -FrontAccounting directory overwriting old files. If it is major -release upgrade you can skip next step and go directly to cleanup.

-

b. Configuration -files update

-

Compare new -config.default.php -file with the old -config.php and -add all new -settings (if any). -

-

[<FA -2.2beta]

-

$show_users_online = 0;

-

$def_print_destination -= 0;

-

$dflt_date_fmt=0;

-

$dflt_date_sep=0;

-

$table_style,table_style2 -changed

-

[<FA -2.3beta]

-

$alternative_tax_include_on_doc=0;

-

$suppress_tax_rates = 0;

-

[<FA -2.3RC1] -

-

Application version -information and a couple of other private FA variables are stored in -version.php -file. The -application version displayed in footer is defined in $version -variable unless this is set in config.php file. If you want current -release version to be displayed on every FA update just remove or -comment out $version variable in config.php.

-

[<FA -2.3RC2]

-

$save_report_selections  = 0;  // A value > 0 means days to save the report selections.

[<FA -2.3]

$save_po_item_codes  = 0;  //  show item codes on purchase order 

$def_print_destination = 0; //  default print destination. 0 = PDF/Printer, 1 = Excel

$alternative_tax_include_on_docs = 0; //  1 = print Subtotal tax excluded, tax and Total tax included

$suppress_tax_rates = 0; //  suppress tax rates on documents. 0 = no, 1 = yes.

- -

2. Database upgrade

-

This step can be skipped -for small version updates i.e. when you have already installed -FrontAccounting version 2.3.1 or later. Before database upgrade is -done on all company databases backup file is created automatically to -enable database restore after failure.

-

After major version -upgrade overwriting files in first step makes the system unaccessible -for all users but site admin, who have to run upgrade procedures to -update all company databases to the new version provided with the -release. After logging to administrator account of first installed -company go directly to Setup/Software Upgrade screen, mark all -subsequent 'Install' checkboxes and press 'Upgrade System'.

-

If something goes wrong during -upgrade, you can eventually try forced upgrade option. Forced upgrade -ignores some smaller errors which can arise during upgrade due to -some exotic database configuration. This is depreciated option, so -first read error messages if any, try to fix signalized problems, -restore databases from backup and retry normal installation. To run -upgrade in forced mode check box 'Force Upgrade', and press 'Upgrade -System' again.

-

3. Final cleanup

-

Remove or rename install folder in main FrontAccounting directory. -

-

After upgrade is installed you can remove files obsoleted by new -FrontAccounting version. Also old, unused settings can -be removed from config.php -file.

-

a. -Source files cleanup

-

[<FA -2.2beta]

-

/includes/reserved.inc -– removed.

-

[<FA -2.1] -

-

/admin/db/v_banktrans.inc -- removed

-

b. -Config.php cleanup -

-

[<FA -2.2RC1] -

-

$security_headings, -$security_groups arrays – moved to database (see Access Setup) - -

-

$def_app – moved -to user configuration in database.

-

$version -– moved to version.php -file. Remove

-

4. New features configuration

-

During upgrade process new features are initialized to default -status, and sometimes old settings are also changed to conform with -new security policy. This automatic process is designed to be as -neutral for end users as possible, however sometimes site or company -admin intervention can be necessary to set thing after changes to -their best state. Below you will find description of new settings -available after upgrade.

-



-

-

----------------------

-
    + + + + FrontAccounting Update + + + +

    FrontAccounting +Update

    ++

    Important Notes for release 2.3.5.

    Change in the behaviour of Recurrent Invoices.
    • Now ++the Last Sent day is stamped with the former Last Sent (or Begin date ++the first time) + months + days. Before the Last Sent day was stamped ++with tthe creation date (today). The Invoice date is still todays date. ++
    • If you for some reason want to make a pause in the recurrent ++invoices, you can now edit the Last Sent day in the Management section ++of Sales tab.
    • Before the days value, together with a month ++value, decided which day in the month the invoice was due..  This ++does not work now. You can change the day in the month you ++want the recurrency to happen by setting the Last Sent day with the new ++day in the Management section. 
    • If you create a new Recurrent Invoice the Beginning date can be set to the day in the month you want the recurrencies to be due.
    +

    Important Notes

    +

    Upgrade process can be done only by administrator of the first +company created during FrontAccounting installation. This person is +considered as a site admin who have granted access to potentially +dangerous setup options, like Setup/Software Upgrade.

    +

    In the following description sections related to older FA versions are +prefixed with [color tags] +. You can skip tagged fragment safely if currently FA +application is newer than the version in tag.

    +

    Upgrade process consists of up to four stages, some of them are +optional:

    +
      +
    1. Application source files update +

      +
    2. Database upgrade – this step is needed only during + upgrade which involves change in major application version number + (e.g. from 2.2.x to 2.3.x), and sometimes during upgrade from beta + release to stable version. Otherwise this step can be skipped.

      +
    3. Final cleanup – is needed when some old source files, + obsoleted by new release should be removed.

      +
    4. New features configuration – this is optional step + needed for most major releases and some minor ones. +

      +
    +

    Before starting upgrade ensure nobody +is using the application and make database backup for all companies. +To be on safe side backup also old source files, especially those +locally customized (if any).

    +

    Log into admin account of first company. If +you use a theme other than the standard 3 (aqua, cool or default), +switch to one of these before going further.

    +

    1. Application files update

    +

    a. Source +files update

    +

    Extract distribution +zip/tar.gz file in empty directory, and copy all the files to your +FrontAccounting directory overwriting old files. If it is major +release upgrade you can skip next step and go directly to cleanup.

    +

    b. Configuration +files update

    +

    Compare new +config.default.php +file with the old +config.php and +add all new +settings (if any). +

    +

    [<FA +2.2beta]

    +

    $show_users_online = 0;

    +

    $def_print_destination += 0;

    +

    $dflt_date_fmt=0;

    +

    $dflt_date_sep=0;

    +

    $table_style,table_style2 +changed

    +

    [<FA +2.3beta]

    +

    $alternative_tax_include_on_doc=0;

    +

    $suppress_tax_rates = 0;

    +

    [<FA +2.3RC1] +

    +

    Application version +information and a couple of other private FA variables are stored in +version.php +file. The +application version displayed in footer is defined in $version +variable unless this is set in config.php file. If you want current +release version to be displayed on every FA update just remove or +comment out $version variable in config.php.

    +

    [<FA +2.3RC2]

    -

    $save_report_selections  = 0;  // A value > 0 means days to save the report selections

    ++

    $save_report_selections  = 0;  // A value > 0 means days to save the report selections.

    [<FA ++2.3]

    $save_po_item_codes  = 0;  //  show item codes on purchase order 

    $def_print_destination = 0; //  default print destination. 0 = PDF/Printer, 1 = Excel

    $alternative_tax_include_on_docs = 0; //  1 = print Subtotal tax excluded, tax and Total tax included

    $suppress_tax_rates = 0; //  suppress tax rates on documents. 0 = no, 1 = yes.

    + +

    2. Database upgrade

    +

    This step can be skipped +for small version updates i.e. when you have already installed +FrontAccounting version 2.3.1 or later. Before database upgrade is +done on all company databases backup file is created automatically to +enable database restore after failure.

    +

    After major version +upgrade overwriting files in first step makes the system unaccessible +for all users but site admin, who have to run upgrade procedures to +update all company databases to the new version provided with the +release. After logging to administrator account of first installed +company go directly to Setup/Software Upgrade screen, mark all +subsequent 'Install' checkboxes and press 'Upgrade System'.

    +

    If something goes wrong during +upgrade, you can eventually try forced upgrade option. Forced upgrade +ignores some smaller errors which can arise during upgrade due to +some exotic database configuration. This is depreciated option, so +first read error messages if any, try to fix signalized problems, +restore databases from backup and retry normal installation. To run +upgrade in forced mode check box 'Force Upgrade', and press 'Upgrade +System' again.

    +

    3. Final cleanup

    +

    Remove or rename install folder in main FrontAccounting directory. +

    +

    After upgrade is installed you can remove files obsoleted by new +FrontAccounting version. Also old, unused settings can +be removed from config.php +file.

    +

    a. +Source files cleanup

    +

    [<FA +2.2beta]

    +

    /includes/reserved.inc +– removed.

    +

    [<FA +2.1] +

    +

    /admin/db/v_banktrans.inc +- removed

    +

    b. +Config.php cleanup +

    +

    [<FA +2.2RC1] +

    +

    $security_headings, +$security_groups arrays – moved to database (see Access Setup) + +

    +

    $def_app – moved +to user configuration in database.

    +

    $version +– moved to version.php +file. Remove

    +

    4. New features configuration

    +

    During upgrade process new features are initialized to default +status, and sometimes old settings are also changed to conform with +new security policy. This automatic process is designed to be as +neutral for end users as possible, however sometimes site or company +admin intervention can be necessary to set thing after changes to +their best state. Below you will find description of new settings +available after upgrade.

    +



    +

    +

    ----------------------

    +
      diff --cc version.php index 807ff4dc,8c86a3cc..1b3db02e --- a/version.php +++ b/version.php @@@ -9,7 -9,7 +9,7 @@@ $db_version = "2.3rc" // application version - can be overriden in config.php if (!isset($version)) - $version = "2.4 CVS 1"; - $version = "2.3.10"; ++ $version = "2.4 alpha"; //====================================================================== // Extension packages repository settings