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)
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();
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;
}
echo "</table>";
}
--
--
--//---------------------------------------------------------------------------------
--
--?>
--- /dev/null
- if (!is_date_in_fiscalyears($date, false))
+<?php
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU General Public License, GPL,
+ as published by the Free Software Foundation, either version 3
+ of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+
+$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($_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 <br>
+ and disable edition of already entered transactions up to specified date.<br>
+ 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();
+
+?>
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;
+ }
+}
-
$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_);
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");
}
}
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.
*/
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)\r
- FROM ".TB_PREF."stock_moves\r
- WHERE stock_id=".db_escape($stock_id)\r
- ." AND trans_id ='$from'";\r
- $result = db_query($sql, "The deliveries could not be updated");\r
+ $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\r
++
+ $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);
display_db_error("could not retreive the location name for $loc_code", $sql, true);
}
--
--//--------------------------------------------------------------------------------------------------
--
--
--?>
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 '<noscript>';
echo display_heading(_('This page is usable only with javascript enabled browsers.'));
echo '</noscript>';
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);
}
}
}
-
+//
+// 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)
{
((!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'";
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)
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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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."
"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 ""
"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 ""
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 ""
msgid "Comments"
msgstr ""
- #: ../includes/system_tests.inc:435
+ #: includes/system_tests.inc:435
msgid "Ok"
msgstr ""
-#: includes/packages.inc:295
+
+ #: includes/packages.inc:190
+ #, php-format
+ msgid "No key field '%s' in file '%s'"
+ msgstr ""
+
-#: includes/packages.inc:311
++#: 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:325
++#: includes/packages.inc:316
+ msgid "Repository version does not match application version."
+ msgstr ""
+
-#: includes/packages.inc:358
++#: 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:613 includes/packages.inc:664
++#: 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:621 includes/packages.inc:672
+ #, php-format
+ msgid "Package '%s' not found."
+ msgstr ""
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');
$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;
- add_gl_trans_std_cost(ST_COSTUPDATE, $update_no, $date_, $stock_gl_code["inventory_account"], 0, 0, $memo_,
- $value_of_change);
+ $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));
+
- }
+ $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_);
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."));
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();
$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");
if (!isset($_POST['stock_id']))
$_POST['stock_id'] = get_global_stock_item();
- echo "<center> " . _("Item:"). " ";
- echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
-if (!@$_GET['popup'])
++if (!$page_nested)
+ {
+ echo "<center> " . _("Item:"). " ";
+ echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
-}
++}
echo "<br>";
echo "<hr></center>";
$page_security = 'SA_ITEM';
$path_to_root = "../..";
include($path_to_root . "/includes/session.inc");
- page(_($help_context = "Items"), @$_REQUEST['popup']);
+
-page(_($help_context = "Items"), 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 = "Items"), @$_REQUEST['popup'], false, "", $js);
++
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
$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 .= "<img id='item_img' alt = '[".$_POST['NewStockID'].".jpg".
+ "]' src='".company_path().'/images/'.item_img_name($_POST['NewStockID']).
+ ".jpg?nocache=".rand()."'"." height='$pic_height' border='0'>";
+ $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 .= "<img id='item_img' alt = '[".$_POST['NewStockID'].".jpg".
- "]' src='".company_path().'/images/'.item_img_name($_POST['NewStockID']).
- ".jpg?nocache=".rand()."'"." height='$pic_height' border='0'>";
- $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();
$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;
}
{
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();
}
// -------------------------------------------------------------------------
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,
{
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"]);
- $ivaccount = $issue["cogs_account"];
-
++
+ //Chaitanya : Compatibility for Service Items
+ if (!is_service($issue["mb_flag"]))
+ $ivaccount = $issue["inventory_account"];
+ else
- }
-
++ $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);
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();
}
$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
$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);
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'];
}
//------------------- update average material cost ------------------------------------------ Joe Hunt Mar-03-2008
function update_average_material_cost($supplier, $stock_id, $price, $qty, $date, $adj_only=false)
{
- //8-OCT-2011 : Skip negative inventory adjustment for case of adjust_only\r
- if (is_inventory_item($stock_id) && !$adj_only) \r
+ //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)
+ 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()
}
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\r
- if (!$adj_only && $myrow['mb_flag'] == 'M') \r
++ //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)
$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");
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);\r
- update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price,\r
++ $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)
{
/* 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));\r
++ $po->supplier_id, 1, $order_line->taxfree_charge_price($po));
} /*quantity received is != 0 */
} /*end of order_line loop */
'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)
$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;
$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);
$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");
++ }
}
}
$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)
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;
+}
-
- ?>
.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");
}
$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);
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']);
".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;
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");
+}
-
- ?>
$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'];
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,
***********************************************************************/
$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'];
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)
***********************************************************************/
$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'];
}
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');
global $systypes_array;
return $systypes_array[$type];
}
++div_end();
function trans_view($trans)
{
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=".
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();
$cols[_("Supplier")] = 'skip';
$cols[_("Currency")] = 'skip';
}
--//------------------------------------------------------------------------------------------------
--
/*show a table of the transactions returned by the sql */
$table =& new_db_pager('trans_tbl', $sql, $cols);
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)
{
hidden('dimension_id', 0);
if ($dim < 2)
hidden('dimension2_id', 0);
++ table_section(2);
table_section_title(_("Addresses"));
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');
set_focus('supplier_id');
return false;
}
--
++
if (!is_date($_POST['OrderDate']))
{
display_error(_("The entered order date is invalid."));
set_focus('due_date');
return false;
}
--
++
if (!$_SESSION['PO']->order_no)
{
if (!$Refs->is_valid(get_post('ref')))
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."));
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."));
$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,
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']))
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;
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."));
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));
$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");
$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);
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);
}
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
- 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;
}
- }
-
--?>
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);
$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))
$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
$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))
{
if ($myrow2["quantity"] == 0)
continue;
--
++
$Net = round2(((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]),
user_price_dec());
$SubTotal += $Net;
$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))
$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))
$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 != "")
{
$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']);
$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);
{
$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();
}
$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,
{
$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)
{
$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);
{
$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();
{
$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");
}
$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 != '')
{
$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);
//----------------------------------------------------------------------------------------------------
- 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))
//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();
$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))
$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();
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();
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'];
$trans['net_amount'] *= -1;
$trans['amount'] *= -1;
}
--
++
if (!$summaryOnly)
{
$rep->TextCol(0, 1, $systypes_array[$trans['trans_type']]);
$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)
_('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',
$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',
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()) {
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');
}
//----------------------------------------------------------------------------------------------
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();
//-------------------------------------------------------------------------
//
// $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 = "";
" . 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");
}
$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");
}
}
$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();
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,
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'];
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);
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):'';
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)
display_db_pager($table);
-if (!@$_GET['popup'])
-{
- end_form();
- end_page(@$_GET['popup'], false, false);
-}
+end_form();
+end_page();
-
?>
$_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']))
{
function edit_link($row)
{
- if (@$_GET['popup'])\r
- return '';\r
++ global $page_nested;
++
++ if ($page_nested)
++ return '';
global $trans_type;
$modify = ($trans_type == ST_SALESORDER ? "ModifyOrderNumber" : "ModifyQuotationNumber");
return pager_link( _("Edit"),
function tmpl_checkbox($row)
{
-- global $trans_type;
++ global $trans_type, $page_nested;
if ($trans_type == ST_SALESQUOTE)
return '';
- if (@$_GET['popup'])\r
- return '';\r
++
++ if ($page_nested)
++ return '';
$name = "chgtpl" .$row['order_no'];
$value = $row['type'] ? 1:0;
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'])\r
- customer_list_cells(_("Select a customer: "), 'customer_id', null, true);\r
++if (!@$_GET['popup'])
++ customer_list_cells(_("Select a customer: "), 'customer_id', null, true);
if ($trans_type == ST_SALESQUOTE)
check_cells(_("Show All:"), 'show_all');
//---------------------------------------------------------------------------------------------
// 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']);\r
++ @$selected_stock_item, @$_POST['OrdersAfterDate'], @$_POST['OrdersToDate'], @$_POST['OrderReference'], $_POST['StockLocation'], $_POST['customer_id']);
if ($trans_type == ST_SALESORDER)
$cols = array(
'Type' => 'skip',
_("Currency") => array('align'=>'center')
);
-if ($_POST['order_view_mode'] == 'OutstandingOnly') {\r
- //array_substitute($cols, 3, 1, _("Cust Order Ref"));\r
- array_append($cols, array(\r
- array('insert'=>true, 'fun'=>'dispatch_link'),\r
- array('insert'=>true, 'fun'=>'edit_link')));\r
+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"));
$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");
$contacts = new contacts('contacts', $selected_id, 'customer');
$contacts->show();
break;
- $_GET['popup'] = 1;
+ case 'transactions':
+ $_GET['customer_id'] = $selected_id;
+ include_once($path_to_root."/sales/inquiry/customer_inquiry.php");
+ break;
case 'orders':
- $_GET['popup'] = 1;
+ $_GET['customer_id'] = $selected_id;
+ include_once($path_to_root."/sales/inquiry/sales_orders_view.php");
+ break;
};
br();
tabbed_content_end();
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 "<tr valign=top><td>";
- display_heading2(_("Order Information"));
+
if ($_GET['trans_type'] != ST_SALESQUOTE)
{
+ echo "<tr valign=top><td>";
+ display_heading2(_("Order Information"));
echo "</td><td>";
display_heading2(_("Deliveries"));
echo "</td><td>";
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"
//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;
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)
{
{
$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;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html><head>\r
- <meta http-equiv="CONTENT-TYPE" content="text/html; charset=iso-8859-2">\r
- \r
- <title>FrontAccounting Update</title><meta name="GENERATOR" content="OpenOffice.org 2.4 (Linux)">\r
- <meta name="CREATED" content="0;0">\r
- <meta name="CHANGED" content="20100902;19041400"></head>\r
-<body dir="ltr" lang="en-US">\r
-<p style="margin-bottom: 0cm;"><strong><font color="#cc6600"><font style="font-size: 20pt;" size="5"><i>Front</i></font></font></strong><strong><font style="font-size: 20pt;" size="5">Accounting\r
-Update</font></strong></p>\r
-<h2>Important Notes for release 2.3.5.</h2>Change in the behaviour of <span style="font-weight: bold; font-style: italic;">Recurrent Invoices</span>.<br><ul><li>Now\r
-the Last Sent day is stamped with the former Last Sent (or Begin date\r
-the first time) + months + days. Before the Last Sent day was stamped\r
-with tthe creation date (today). The Invoice date is still todays date.\r
-</li><li>If you for some reason want to make a pause in the recurrent\r
-invoices, you can now edit the Last Sent day in the Management section\r
-of Sales tab.</li><li>Before the days value, together with a month\r
-value, decided which day in the month the invoice was due.. This\r
-does not work now. You can change the day in the month you\r
-want the recurrency to happen by setting the Last Sent day with the new\r
-day in the Management section. </li><li>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.</li></ul>\r
-<h2>Important Notes</h2>\r
-<p>Upgrade process can be done only by administrator of the first\r
-company created during FrontAccounting installation. This person is\r
-considered as a site admin who have granted access to potentially\r
-dangerous setup options, like Setup/Software Upgrade.</p>\r
-<p>In the following description sections related to older FA versions are\r
-prefixed with <span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[color tags]</span><span style="background: transparent none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">\r
-. Y</span>ou can skip tagged fragment safely if currently FA\r
-application is newer than the version in tag.</p>\r
-<p>Upgrade process consists of up to four stages, some of them are\r
-optional:</p>\r
-<ol>\r
- <li><p>Application source files update \r
- </p>\r
- </li><li><p>Database upgrade – this step is needed only during\r
- upgrade which involves change in major application version number\r
- (e.g. from 2.2.x to 2.3.x), and sometimes during upgrade from beta\r
- release to stable version. Otherwise this step can be skipped.</p>\r
- </li><li><p>Final cleanup – is needed when some old source files,\r
- obsoleted by new release should be removed.</p>\r
- </li><li><p>New features configuration – this is optional step\r
- needed for most major releases and some minor ones. \r
- </p>\r
-</li></ol>\r
-<p style="margin-bottom: 0cm;">Before starting upgrade ensure nobody\r
-is using the application and make database backup for all companies.\r
-To be on safe side backup also old source files, especially those\r
-locally customized (if any).</p>\r
-<p>Log into admin account of first company.<strong> </strong><strong><span style="">If\r
-you use a theme other than the standard 3 (aqua, cool or default),\r
-switch to one of these before going further.</span></strong></p>\r
-<h2><strong><b>1. Application files update</b></strong></h2>\r
-<p style="margin-top: 0.42cm; page-break-after: avoid;"><font face="Liberation Sans, sans-serif"><font size="4"><strong><span style="">a. Source\r
-files update</span></strong></font></font></p>\r
-<p><strong><span style="">Extract distribution\r
-zip/tar.gz file in empty directory, and copy all the files to your\r
-FrontAccounting directory overwriting old files. If it is major\r
-release upgrade you can skip next step and go directly to cleanup.</span></strong></p>\r
-<p style="margin-top: 0.42cm; page-break-after: avoid;"><strong><font face="Liberation Sans, sans-serif"><font size="4"><span style="">b. Configuration\r
-files update</span></font></font></strong></p>\r
-<p><strong><span style="">Compare new\r
-</span></strong><strong><i><b>config.default.php</b></i></strong><strong>\r
-</strong><strong><span style="">file with the old\r
-</span></strong><strong><i><b>config.php </b></i></strong><strong><span style="font-style: normal;"><span style="">and\r
-add all n</span></span></strong><strong><span style="">ew\r
-settings (if any). </span></strong>\r
-</p>\r
-<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA\r
-2.2beta]</span></span></strong></p>\r
-<p><strong> <span style="">$show_users_online = 0;</span></strong></p>\r
-<p><strong> <span style="">$def_print_destination\r
-= 0;</span></strong></p>\r
-<p><strong><span style="">$dflt_date_fmt=0;</span></strong></p>\r
-<p><strong><span style="">$dflt_date_sep=0;</span></strong></p>\r
-<p><strong><span style="">$table_style,table_style2\r
-changed</span></strong></p>\r
-<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA\r
-2.3beta]</span></span></strong></p>\r
-<p><strong> <span style="">$alternative_tax_include_on_doc=0;</span></strong></p>\r
-<p><strong><span style="">$suppress_tax_rates = 0;</span></strong></p>\r
-<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA\r
-2.3RC1]</span></span></strong><strong> </strong>\r
-</p>\r
-<p><strong><span style="">Application version\r
-information and a couple of other private FA variables are stored in\r
-</span></strong><strong><i><b>version.php</b></i></strong><strong>\r
-</strong><strong><span style="">file. The\r
-application version displayed in footer is defined in $version\r
-variable unless this is set in config.php file. If you want current\r
-release version to be displayed on every FA update just remove or\r
-comment out $version variable in </span></strong><strong><span style="font-style: normal;"><span style="">config.php</span></span></strong><strong><span style="">.</span></strong></p>\r
-<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA\r
-2.3RC2]</span></span></strong></p>\r
-<p><strong> <span style="">$save_report_selections = 0; // A value > 0 means days to save the report selections.</span></strong></p><p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA\r
-2.3]</span></span></strong></p><p><strong> <span style="">$save_po_item_codes = 0; // show item codes on purchase order </span></strong></p><p><strong><span style="">$def_print_destination = 0; // default print destination. 0 = PDF/Printer, 1 = Excel</span></strong></p><p><strong><span style="">$alternative_tax_include_on_docs = 0; // 1 = print Subtotal tax excluded, tax and Total tax included</span></strong></p><p><strong><span style="">$suppress_tax_rates = 0; // suppress tax rates on documents. 0 = no, 1 = yes.</span></strong></p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;"></span></span></strong>\r
-\r
-<strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;"></span></span></strong><h2><strong><b>2. Database upgrade</b></strong></h2>\r
-<p><strong><span style="">This step can be skipped\r
-for small version updates i.e. when you have already installed\r
-FrontAccounting version 2.3.1 or later. Before database upgrade is\r
-done on all company databases backup file is created automatically to\r
-enable database restore after failure.</span></strong></p>\r
-<p><strong><span style="">After major version\r
-upgrade overwriting files in first step makes the system unaccessible\r
-for all users but site admin, who have to run upgrade procedures to\r
-update all company databases to the new version provided with the\r
-release. After logging to administrator account of first installed\r
-company go directly to Setup/Software Upgrade screen, mark all\r
-subsequent 'Install' checkboxes and press 'Upgrade System'.</span></strong></p>\r
-<p style="">If something goes wrong during\r
-upgrade, you can eventually try forced upgrade option. Forced upgrade\r
-ignores some smaller errors which can arise during upgrade due to\r
-some exotic database configuration. This is depreciated option, so\r
-first read error messages if any, try to fix signalized problems,\r
-restore databases from backup and retry normal installation. To run\r
-upgrade in forced mode check box 'Force Upgrade', and press 'Upgrade\r
-System' again.</p>\r
-<h2>3. Final cleanup</h2>\r
-<p>Remove or rename install folder in main FrontAccounting directory.\r
-</p>\r
-<p>After upgrade is installed you can remove files obsoleted by new\r
-FrontAccounting version. Also old, unused settings <span style="font-style: normal;"><span style="">can\r
-be removed from </span></span><i><b>config.php</b></i><span style="font-style: normal;"><span style="">\r
-file.</span></span></p>\r
-<p style="margin-top: 0.42cm; page-break-after: avoid;"><font face="Liberation Sans, sans-serif"><font size="4">a.\r
-Source files cleanup</font></font></p>\r
-<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA\r
-2.2beta]</span></span></strong></p>\r
-<p><strong><span style=""><span style="background: transparent none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">/includes/reserved.inc\r
-– removed.</span></span></strong></p>\r
-<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA\r
-2.1]</span></span></strong><strong> </strong>\r
-</p>\r
-<p><strong><span style="">/admin/db/v_banktrans.inc\r
-- removed</span></strong></p>\r
-<p style="margin-top: 0.42cm; page-break-after: avoid;"><font face="Liberation Sans, sans-serif"><font size="4"><span style="font-style: normal;"><span style="">b.\r
-Config.php cleanup </span></span></font></font>\r
-</p>\r
-<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA\r
-2.2RC1]</span></span></strong><strong> </strong>\r
-</p>\r
-<p><strong><span style="">$security_headings,\r
-$security_groups arrays – moved to database (see Access Setup) \r
-</span></strong>\r
-</p>\r
-<p><strong><span style="">$def_app – moved\r
-to user configuration in database.</span></strong></p>\r
-<p><strong><span style="font-style: normal;"><span style="">$version\r
-– moved to </span></span></strong><strong><i><b>version.php</b></i></strong><strong><span style="font-style: normal;"><span style="">\r
-file. Remove</span></span></strong></p>\r
-<h2>4. New features configuration</h2>\r
-<p>During upgrade process new features are initialized to default\r
-status, and sometimes old settings are also changed to conform with\r
-new security policy. This automatic process is designed to be as\r
-neutral for end users as possible, however sometimes site or company\r
-admin intervention can be necessary to set thing after changes to\r
-their best state. Below you will find description of new settings\r
-available after upgrade.</p>\r
-<p><br><br>\r
-</p>\r
-<p>----------------------</p>\r
-<ul></ul>\r
+<html><head>
+ <meta http-equiv="CONTENT-TYPE" content="text/html; charset=iso-8859-2">
+
+ <title>FrontAccounting Update</title><meta name="GENERATOR" content="OpenOffice.org 2.4 (Linux)">
+ <meta name="CREATED" content="0;0">
+ <meta name="CHANGED" content="20100902;19041400"></head>
+<body dir="ltr" lang="en-US">
+<p style="margin-bottom: 0cm;"><strong><font color="#cc6600"><font style="font-size: 20pt;" size="5"><i>Front</i></font></font></strong><strong><font style="font-size: 20pt;" size="5">Accounting
+Update</font></strong></p>
++<h2>Important Notes for release 2.3.5.</h2>Change in the behaviour of <span style="font-weight: bold; font-style: italic;">Recurrent Invoices</span>.<br><ul><li>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.
++</li><li>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.</li><li>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. </li><li>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.</li></ul>
+<h2>Important Notes</h2>
+<p>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.</p>
+<p>In the following description sections related to older FA versions are
+prefixed with <span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[color tags]</span><span style="background: transparent none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">
+. Y</span>ou can skip tagged fragment safely if currently FA
+application is newer than the version in tag.</p>
+<p>Upgrade process consists of up to four stages, some of them are
+optional:</p>
+<ol>
+ <li><p>Application source files update
+ </p>
+ </li><li><p>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.</p>
+ </li><li><p>Final cleanup – is needed when some old source files,
+ obsoleted by new release should be removed.</p>
+ </li><li><p>New features configuration – this is optional step
+ needed for most major releases and some minor ones.
+ </p>
+</li></ol>
+<p style="margin-bottom: 0cm;">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).</p>
+<p>Log into admin account of first company.<strong> </strong><strong><span style="">If
+you use a theme other than the standard 3 (aqua, cool or default),
+switch to one of these before going further.</span></strong></p>
+<h2><strong><b>1. Application files update</b></strong></h2>
+<p style="margin-top: 0.42cm; page-break-after: avoid;"><font face="Liberation Sans, sans-serif"><font size="4"><strong><span style="">a. Source
+files update</span></strong></font></font></p>
+<p><strong><span style="">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.</span></strong></p>
+<p style="margin-top: 0.42cm; page-break-after: avoid;"><strong><font face="Liberation Sans, sans-serif"><font size="4"><span style="">b. Configuration
+files update</span></font></font></strong></p>
+<p><strong><span style="">Compare new
+</span></strong><strong><i><b>config.default.php</b></i></strong><strong>
+</strong><strong><span style="">file with the old
+</span></strong><strong><i><b>config.php </b></i></strong><strong><span style="font-style: normal;"><span style="">and
+add all n</span></span></strong><strong><span style="">ew
+settings (if any). </span></strong>
+</p>
+<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA
+2.2beta]</span></span></strong></p>
+<p><strong> <span style="">$show_users_online = 0;</span></strong></p>
+<p><strong> <span style="">$def_print_destination
+= 0;</span></strong></p>
+<p><strong><span style="">$dflt_date_fmt=0;</span></strong></p>
+<p><strong><span style="">$dflt_date_sep=0;</span></strong></p>
+<p><strong><span style="">$table_style,table_style2
+changed</span></strong></p>
+<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA
+2.3beta]</span></span></strong></p>
+<p><strong> <span style="">$alternative_tax_include_on_doc=0;</span></strong></p>
+<p><strong><span style="">$suppress_tax_rates = 0;</span></strong></p>
+<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA
+2.3RC1]</span></span></strong><strong> </strong>
+</p>
+<p><strong><span style="">Application version
+information and a couple of other private FA variables are stored in
+</span></strong><strong><i><b>version.php</b></i></strong><strong>
+</strong><strong><span style="">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 </span></strong><strong><span style="font-style: normal;"><span style="">config.php</span></span></strong><strong><span style="">.</span></strong></p>
+<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA
+2.3RC2]</span></span></strong></p>
- <p><strong> <span style="">$save_report_selections = 0; // A value > 0 means days to save the report selections</span></strong></p>
++<p><strong> <span style="">$save_report_selections = 0; // A value > 0 means days to save the report selections.</span></strong></p><p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA
++2.3]</span></span></strong></p><p><strong> <span style="">$save_po_item_codes = 0; // show item codes on purchase order </span></strong></p><p><strong><span style="">$def_print_destination = 0; // default print destination. 0 = PDF/Printer, 1 = Excel</span></strong></p><p><strong><span style="">$alternative_tax_include_on_docs = 0; // 1 = print Subtotal tax excluded, tax and Total tax included</span></strong></p><p><strong><span style="">$suppress_tax_rates = 0; // suppress tax rates on documents. 0 = no, 1 = yes.</span></strong></p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;"></span></span></strong>
+
+<strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;"></span></span></strong><h2><strong><b>2. Database upgrade</b></strong></h2>
+<p><strong><span style="">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.</span></strong></p>
+<p><strong><span style="">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'.</span></strong></p>
+<p style="">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.</p>
+<h2>3. Final cleanup</h2>
+<p>Remove or rename install folder in main FrontAccounting directory.
+</p>
+<p>After upgrade is installed you can remove files obsoleted by new
+FrontAccounting version. Also old, unused settings <span style="font-style: normal;"><span style="">can
+be removed from </span></span><i><b>config.php</b></i><span style="font-style: normal;"><span style="">
+file.</span></span></p>
+<p style="margin-top: 0.42cm; page-break-after: avoid;"><font face="Liberation Sans, sans-serif"><font size="4">a.
+Source files cleanup</font></font></p>
+<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA
+2.2beta]</span></span></strong></p>
+<p><strong><span style=""><span style="background: transparent none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">/includes/reserved.inc
+– removed.</span></span></strong></p>
+<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA
+2.1]</span></span></strong><strong> </strong>
+</p>
+<p><strong><span style="">/admin/db/v_banktrans.inc
+- removed</span></strong></p>
+<p style="margin-top: 0.42cm; page-break-after: avoid;"><font face="Liberation Sans, sans-serif"><font size="4"><span style="font-style: normal;"><span style="">b.
+Config.php cleanup </span></span></font></font>
+</p>
+<p><strong><span style=""><span style="background: rgb(235, 97, 61) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">[<FA
+2.2RC1]</span></span></strong><strong> </strong>
+</p>
+<p><strong><span style="">$security_headings,
+$security_groups arrays – moved to database (see Access Setup)
+</span></strong>
+</p>
+<p><strong><span style="">$def_app – moved
+to user configuration in database.</span></strong></p>
+<p><strong><span style="font-style: normal;"><span style="">$version
+– moved to </span></span></strong><strong><i><b>version.php</b></i></strong><strong><span style="font-style: normal;"><span style="">
+file. Remove</span></span></strong></p>
+<h2>4. New features configuration</h2>
+<p>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.</p>
+<p><br><br>
+</p>
+<p>----------------------</p>
+<ul></ul>
</body></html>
// 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