From: Joe Hunt Date: Wed, 29 Oct 2008 23:48:27 +0000 (+0000) Subject: Added Quick Entries in Bank Payments/Deposits (Banking and General Ledger). X-Git-Tag: v2.4.2~19^2~1818 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=1f0c585ef87e9138499a71ae2954b1a177a6ef97 Added Quick Entries in Bank Payments/Deposits (Banking and General Ledger). --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1e20cc96..fad2f3d0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,21 @@ Legend: ! -> Note $ -> Affected files +30-Oct-2008 Joe Hunt +! Added Quick Entries in Bank Payments/Deposits (Banking and General Ledger). +$ /applications/generalledger.php + /includes/data_checks.inc + /includes/types.inc + /includes/ui/ui_lists.inc + /gl/gl_bank.php + /gl/includes/db/gl_db_bank_accounts.inc + /gl/includes/ui/gl_bank_ui.inc + /sales/manage/customer_branches.php +! New table, 0_quick_entries +$ /sql/alter2.1.sql +! Changed GL Accounts form. The tax_code is now Tax Group instead of Tax Type. +$ /gl/manage/gl_accounts.php + 24-Oct-2008 Janusz Dobrowolski ! Added hotkeys to final menu options. $ /dimensions/dimension_entry.php diff --git a/applications/generalledger.php b/applications/generalledger.php index e3b5d6d7..ecbc6b91 100644 --- a/applications/generalledger.php +++ b/applications/generalledger.php @@ -27,6 +27,7 @@ $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("Bank &Accounts"),"gl/manage/bank_accounts.php?"); $this->add_lapp_function(2, _("Payment, Deposit and Transfer &Types"),"gl/manage/bank_trans_types.php?"); + $this->add_lapp_function(2, _("Quick Entries"),"gl/manage/gl_quick_entries.php?"); $this->add_lapp_function(2, "",""); $this->add_lapp_function(2, _("&Currencies"),"gl/manage/currencies.php?"); $this->add_lapp_function(2, _("&Exchange Rates"),"gl/manage/exchange_rates.php?"); diff --git a/gl/gl_bank.php b/gl/gl_bank.php index 522cdd86..86a909cf 100644 --- a/gl/gl_bank.php +++ b/gl/gl_bank.php @@ -262,6 +262,50 @@ if (isset($_POST['UpdateItem'])) if (isset($_POST['CancelItemChanges'])) line_start_focus(); +if (isset($_POST['go'])) +{ + if (!check_num('totamount', 0)) + { + display_error( _("The amount entered is not a valid number or is less than zero.")); + set_focus('totamount'); + } + elseif (!get_post('person_id')) + { + if ($_SESSION['pay_items']->trans_type==systypes::bank_payment()) + display_error( _("No Quick Entries are defined for Payment.")); + else + display_error( _("No Quick Entries are defined for Deposit.")); + set_focus('totamount'); + } + else + { + $rate = 0; + $totamount = input_num('totamount'); + $qe = get_quick_entry($_POST['person_id']); + $account = get_gl_account($qe['account']); + $tax_group = $account['tax_code']; + $items = get_tax_group_items($tax_group); + while ($item = db_fetch($items)) + $rate += $item['rate']; + if ($rate != 0) + $totamount = $totamount * 100 / ($rate + 100); + $totamount = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? 1:-1) * $totamount; + $_SESSION['pay_items']->clear_items(); + $_SESSION['pay_items']->add_gl_item($qe['account'], 0, 0, $totamount, $qe['description']); + $items = get_tax_group_items($tax_group); + while ($item = db_fetch($items)) + { + if ($item['rate'] != 0) + { + $amount = $totamount * $item['rate'] / 100; + $code = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? $item['purchasing_gl_code'] : + $item['sales_gl_code']); + $_SESSION['pay_items']->add_gl_item($code, 0, 0, $amount, $qe['description']); + } + } + line_start_focus(); + } +} //----------------------------------------------------------------------------------------------- diff --git a/gl/includes/db/gl_db_bank_accounts.inc b/gl/includes/db/gl_db_bank_accounts.inc index 2c405614..506a94c8 100644 --- a/gl/includes/db/gl_db_bank_accounts.inc +++ b/gl/includes/db/gl_db_bank_accounts.inc @@ -48,4 +48,60 @@ function get_bank_account($account_code) //--------------------------------------------------------------------------------------------- +function add_quick_entry($description, $account, $deposit) +{ + $sql = "INSERT INTO ".TB_PREF."quick_entries (description, account, deposit) VALUES + (".db_escape($description).", ".db_escape($account).", $deposit)"; + + db_query($sql, "could not insert quick entry for $description"); +} + +//--------------------------------------------------------------------------------------------- + +function update_quick_entry($selected_id, $description, $account, $deposit) +{ + $sql = "UPDATE ".TB_PREF."quick_entries SET description = ".db_escape($description).", + account=".db_escape($account).", deposit=$deposit + WHERE id = $selected_id"; + + db_query($sql, "could not update quick entry for $selected_id"); +} + +//--------------------------------------------------------------------------------------------- + +function delete_quick_entry($selected_id) +{ + $sql = "DELETE FROM ".TB_PREF."quick_entries WHERE id=$selected_id"; + + db_query($sql,"could not delete quick entry $selected_id"); +} + +//--------------------------------------------------------------------------------------------- + +function get_quick_entries($type=false) +{ + $sql = "SELECT ".TB_PREF."quick_entries.*, ".TB_PREF."chart_master.account_name + FROM ".TB_PREF."quick_entries, ".TB_PREF."chart_master WHERE + ".TB_PREF."quick_entries.account = ".TB_PREF."chart_master.account_code"; + if ($type == "deposit") + $sql .= " AND deposit=1"; + elseif ($type == "payment") + $sql .= " AND deposit=0"; + + return db_query($sql, "could not retreive quick entries"); +} + +//--------------------------------------------------------------------------------------------- + +function get_quick_entry($selected_id) +{ + $sql = "SELECT * FROM ".TB_PREF."quick_entries WHERE id=$selected_id"; + + $result = db_query($sql, "could not retreive quick entry for $selected_id"); + + return db_fetch($result); +} + +//--------------------------------------------------------------------------------------------- + ?> \ No newline at end of file diff --git a/gl/includes/ui/gl_bank_ui.inc b/gl/includes/ui/gl_bank_ui.inc index 61c5250a..a0a1ed7a 100644 --- a/gl/includes/ui/gl_bank_ui.inc +++ b/gl/includes/ui/gl_bank_ui.inc @@ -67,6 +67,10 @@ function display_bank_header(&$order) hidden('PersonDetailID'); } break; + case payment_person_types::QuickEntry() : + quick_entries_list_row(_("Description:"), 'person_id', null, $payment); + amount_row(_("Total Amount"), 'totamount', null, null, "  ".submit('go', _("Go"), false, false, true)); + break; //case payment_person_types::Project() : // dimensions_list_row(_("Dimension:"), 'person_id', $_POST['person_id'], false, null, true); // break; diff --git a/gl/manage/gl_accounts.php b/gl/manage/gl_accounts.php index 55fd9389..2520d355 100644 --- a/gl/manage/gl_accounts.php +++ b/gl/manage/gl_accounts.php @@ -235,7 +235,7 @@ text_row_ex(_("Account Name:"), 'account_name', 60); gl_account_types_list_row(_("Account Group:"), 'account_type', null); -tax_types_list_row(_("Tax Type:"), 'tax_code', null, _('No Tax')); +tax_groups_list_row(_("Tax Group:"), 'tax_code', null, _('No Tax')); end_table(1); diff --git a/includes/data_checks.inc b/includes/data_checks.inc index b79bf3d2..2f33cb53 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -420,6 +420,11 @@ function check_db_has_gl_account_groups($msg) } } +function db_has_quick_entries() +{ + return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."quick_entries"); +} + function check_empty_result($sql) { $result = db_query($sql, "could not do check empty query"); diff --git a/includes/types.inc b/includes/types.inc index c8c5f904..73efbfe1 100644 --- a/includes/types.inc +++ b/includes/types.inc @@ -144,6 +144,7 @@ $payment_person_types_array = array ( 1=> array ('id' => 1, 'name' => _("Work Order")), 2=> array ('id' => 2, 'name' => _("Customer")), 3=> array ('id' => 3, 'name' => _("Supplier")), + 4=> array ('id' => 4, 'name' => _("Quick Entry")) ); class payment_person_types @@ -175,12 +176,15 @@ class payment_person_types return 3; } - function dimension() + function QuickEntry() { return 4; } - //function Project() { return 4; } + function dimension() + { + return 5; + } function type_name($type) { @@ -194,6 +198,9 @@ class payment_person_types { case payment_person_types::misc() : return $person_id; + case payment_person_types::QuickEntry() : + $qe = get_quick_entry($person_id); + return ($full?payment_person_types::type_name($type) . " ":"") . $qe["description"]; case payment_person_types::WorkOrder() : $wo = get_work_order($person_id); return ($full?payment_person_types::type_name($type) . " ":"") . $wo["wo_ref"]; @@ -201,8 +208,6 @@ class payment_person_types return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id); case payment_person_types::supplier() : return ($full?payment_person_types::type_name($type) . " ":"") . get_supplier_name($person_id); - //case payment_person_types::Project() : - // return ($full?payment_person_types::type_name($type) . " ":"") . get_dimension_string($person_id); default : //DisplayDBerror("Invalid type sent to person_name"); //return; @@ -215,8 +220,8 @@ class payment_person_types switch ($type) { case payment_person_types::misc() : + case payment_person_types::QuickEntry() : case payment_person_types::WorkOrder() : - //case payment_person_types::Project() : return get_company_currency(); case payment_person_types::customer() : @@ -236,17 +241,17 @@ class payment_person_types { case payment_person_types::misc() : return true; - case payment_person_types::WorkOrder() : // 070305 changed to open workorders ES + case payment_person_types::QuickEntry() : + return db_has_quick_entries(); + case payment_person_types::WorkOrder() : // 070305 changed to open workorders JH return db_has_open_workorders(); case payment_person_types::customer() : return db_has_customers(); case payment_person_types::supplier() : return db_has_suppliers(); - //case payment_person_types::Project() : - // return db_has_dimensions(); default : display_db_error("Invalid type sent to has_items", ""); - return; + return false; } } } diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index acfe058c..e53d0eb2 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -887,26 +887,26 @@ function tax_groups_list($name, $selected_id=null, array( 'order' => 'id', 'spec_option' => $none_option, - 'spec_id' => 0, + 'spec_id' => reserved_words::get_all_numeric(), 'select_submit'=> $submit_on_change, 'async' => false, ) ); } -function tax_groups_list_cells($label, $name, $selected_id=null, $submit_on_change=false) +function tax_groups_list_cells($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false) { if ($label != null) echo "$label\n"; echo ""; - $str = tax_groups_list($name, $selected_id, false, $submit_on_change); + $str = tax_groups_list($name, $selected_id, $none_option, $submit_on_change); echo "\n"; return $str; } -function tax_groups_list_row($label, $name, $selected_id=null, $submit_on_change=false) +function tax_groups_list_row($label, $name, $selected_id=null, $none_option=false, $submit_on_change=false) { echo "\n"; - $str = tax_groups_list_cells($label, $name, $selected_id, false, $submit_on_change); + $str = tax_groups_list_cells($label, $name, $selected_id, $none_option, $submit_on_change); echo "\n"; return $str; } @@ -1506,6 +1506,33 @@ function payment_person_types_list_row($label, $name, $selected_id=null, $relate return $str; } +//------------------------------------------------------------------------------------------------ + +function quick_entries_list($name, $selected_id=null, $expense=true, $submit_on_change=false) +{ + $sql = "SELECT * FROM ".TB_PREF."quick_entries"; + if ($expense) + $sql .= " WHERE deposit=0"; + else + $sql .= " WHERE deposit=1"; + combo_input($name, $selected_id, $sql, 'id', 'description', + array( + 'spec_id' => '', + 'order' => 'description', + 'select_submit'=> $submit_on_change, + 'async' => false + ) ); + +} + +function quick_entries_list_row($label, $name, $selected_id=null, $expense=true, $submit_on_change=false) +{ + echo "$label\n"; + quick_entries_list($name, $selected_id, $expense, $submit_on_change); + echo "\n"; +} + + //------------------------------------------------------------------------------------------------ function wo_types_list($name, $selected_id=null) diff --git a/sales/manage/customer_branches.php b/sales/manage/customer_branches.php index c4460d69..69ecd9e4 100644 --- a/sales/manage/customer_branches.php +++ b/sales/manage/customer_branches.php @@ -300,7 +300,7 @@ locations_list_row(_("Default Inventory Location:"), 'default_location', null); shippers_list_row(_("Default Shipping Company:"), 'default_ship_via', null); -tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null, 31, 30); +tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null); yesno_list_row(_("Disable this Branch:"), 'disable_trans', null); diff --git a/sql/alter2.1.sql b/sql/alter2.1.sql index d2d381b4..85127db6 100644 --- a/sql/alter2.1.sql +++ b/sql/alter2.1.sql @@ -1,3 +1,18 @@ +DROP TABLE IF EXISTS `0_quick_entries`; + +CREATE TABLE `0_quick_entries` ( + `id` smallint(6) NOT NULL auto_increment, + `description` varchar(60) NOT NULL, + `account` varchar(11) NOT NULL, + `deposit` tinyint(1) NOT NULL default '0', + PRIMARY KEY (`id`), + UNIQUE KEY `description` (`description`) +) ENGINE=MyISAM AUTO_INCREMENT=1; + +INSERT INTO `0_quick_entries` VALUES ('1', 'Maintenance', '6600', '0'); +INSERT INTO `0_quick_entries` VALUES ('2', 'Phone', '6730', '0'); +INSERT INTO `0_quick_entries` VALUES ('3', 'Cash Sales', '3000', '1'); + ALTER TABLE `0_users` ADD `print_profile` VARCHAR(30) DEFAULT '' AFTER `show_hints` ; ALTER TABLE `0_users` ADD `rep_popup` TINYINT(1) DEFAULT '1' AFTER `print_profile` ;