! -> Note
$ -> Affected files
+15-Nov-2008 Joe Hunt
++ Added Quick Entries in GL Journal Entry and changed some needed fixes.
+$ /gl/gl_bank.php
+ /gl/gl_journal.php
+ /gl/includes/db/gl_db_bank_accounts.inc
+ /gl/includes/ui/gl_bank_ui.inc
+ /gl/includes/ui/gl_journal_ui.inc
+ /includes/ui/ui_lists.inc
+
15-Nov-2008 Joe Hunt
+ Added Tax Inquiry in Banking and General Ledger tab.
$ /applications/generalledger.php
line_start_focus();
}
-//-----------------------------------------------------------------------------------------------
-$id = find_submit('Delete');
-if ($id != -1)
- handle_delete_item($id);
-
-if (isset($_POST['AddItem']))
- handle_new_item();
-
-if (isset($_POST['UpdateItem']))
- handle_update_item();
-
-if (isset($_POST['CancelItemChanges']))
- line_start_focus();
-
-if (isset($_POST['go']))
+function display_quick_entries(&$cart)
{
if (!check_num('totamount', 0))
{
}
elseif (!get_post('person_id'))
{
- if ($_SESSION['pay_items']->trans_type==systypes::bank_payment())
+ if ($cart->trans_type==systypes::bank_payment())
display_error( _("No Quick Entries are defined for Payment."));
else
display_error( _("No Quick Entries are defined for Deposit."));
{
$rate = 0;
$totamount = input_num('totamount');
- $totamount = ($_SESSION['pay_items']->trans_type==systypes::bank_payment() ? 1:-1) * $totamount;
+ $totamount = ($cart->trans_type==systypes::bank_payment() ? 1:-1) * $totamount;
$qe = get_quick_entry($_POST['person_id']);
$qe_lines = get_quick_entry_lines($_POST['person_id']);
while ($qe_line = db_fetch($qe_lines))
$rate += $item['rate'];
if ($rate != 0)
$totamount = $totamount * 100 / ($rate + 100);
- $_SESSION['pay_items']->clear_items();
+ $cart->clear_items();
- $_SESSION['pay_items']->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'],
+ $cart->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'],
$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'] :
+ $code = ($cart->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']);
+ $cart->add_gl_item($code, 0, 0, $amount, $qe['description']);
}
}
}
$amount = $totamount * $qe_line['amount'] / 100;
else
$amount = $qe_line['amount'];
- $_SESSION['pay_items']->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'],
+ $cart->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'],
$amount, $qe['description']);
}
}
line_start_focus();
}
-}
+}
+//-----------------------------------------------------------------------------------------------
+$id = find_submit('Delete');
+if ($id != -1)
+ handle_delete_item($id);
+
+if (isset($_POST['AddItem']))
+ handle_new_item();
+
+if (isset($_POST['UpdateItem']))
+ handle_update_item();
+
+if (isset($_POST['CancelItemChanges']))
+ line_start_focus();
+
+if (isset($_POST['go']))
+ display_quick_entries($_SESSION['pay_items']);
//-----------------------------------------------------------------------------------------------
line_start_focus();
}
+function display_quick_entries(&$cart)
+{
+ if (!get_post('person_id'))
+ {
+ display_error( _("No Quick Entries are defined."));
+ set_focus('totamount');
+ }
+ else
+ {
+ $rate = 0;
+ $totamount = input_num('totamount');
+ //$totamount = ($cart->trans_type==systypes::bank_payment() ? 1:-1) * $totamount;
+ $qe = get_quick_entry($_POST['person_id']);
+ $qe_lines = get_quick_entry_lines($_POST['person_id']);
+ while ($qe_line = db_fetch($qe_lines))
+ {
+ if ($qe_line['tax_acc'])
+ {
+ $account = get_gl_account($qe_line['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);
+ $cart->clear_items();
+
+ $cart->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'],
+ $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 = ($amount < 0 ? $item['purchasing_gl_code'] :
+ $item['sales_gl_code']);
+ $cart->add_gl_item($code, 0, 0, $amount, $qe['description']);
+ }
+ }
+ }
+ else
+ {
+ if ($qe_line['pct'])
+ $amount = $totamount * $qe_line['amount'] / 100;
+ else
+ $amount = $qe_line['amount'];
+ $cart->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'],
+ $amount, $qe['description']);
+ }
+ }
+ line_start_focus();
+ }
+}
+
//-----------------------------------------------------------------------------------------------
$id = find_submit('Delete');
if ($id != -1)
if (isset($_POST['CancelItemChanges']))
line_start_focus();
+if (isset($_POST['go']))
+ display_quick_entries($_SESSION['journal_items']);
//-----------------------------------------------------------------------------------------------
if (isset($_GET['NewJournal']) || !isset($_SESSION['journal_items']))
}
//---------------------------------------------------------------------------------------------
-function get_quick_entries($deposit=null, $bank_only=null)
+
+function has_quick_entries($deposit=-1, $bank_only=-1)
+{
+ $where = false;
+ $sql = "SELECT id FROM ".TB_PREF."quick_entries";
+ if ($deposit != -1)
+ {
+ $sql .= " WHERE deposit=$deposit";
+ $where = true;
+ }
+ if ($bank_only != -1)
+ {
+ if ($where)
+ $sql .= " AND bank_only=$bank_only";
+ else
+ $sql .= " WHERE bank_only=$bank_only";
+ }
+
+ $result = db_query($sql, "could not retreive quick entries");
+ return db_num_rows($result) > 0;
+}
+
+function get_quick_entries($deposit=-1, $bank_only=-1)
{
$where = false;
$sql = "SELECT * FROM ".TB_PREF."quick_entries";
- if ($deposit != null)
+ if ($deposit != -1)
{
$sql .= " WHERE deposit=$deposit";
$where = true;
}
- if ($bank_only != null)
+ if ($bank_only != -1)
{
if ($where)
$sql .= " AND bank_only=$bank_only";
}
break;
case payment_person_types::QuickEntry() :
- quick_entries_list_row(_("Description:"), 'person_id', null, $payment);
+ quick_entries_list_row(_("Description:"), 'person_id', null, ($payment ? 0 : 1), 1);
amount_row(_("Total Amount"), 'totamount', null, null, " ".submit('go', _("Go"), false, false, true));
break;
//case payment_person_types::Project() :
{
global $table_style2;
+ $qes = has_quick_entries(-1, 0);
start_table("$table_style2 width=90%");
- echo "<tr><td valign=top width=50%>"; // outer table
+ if ($qes)
+ echo "<tr><td valign=top width=30%>"; // outer table
+ else
+ echo "<tr><td valign=top width=50%>"; // outer table
echo "<table>";
start_row();
echo "</table>";
- echo "</td><td width=50%>"; // outer table
+ if ($qes)
+ echo "</td><td width=20%>"; // outer table
+ else
+ echo "</td><td width=50%>"; // outer table
echo "<table>";
-
- check_row(_("Reverse Transaction:"), 'Reverse', null);
-
+ start_row();
+ check_cells(_("Reverse Transaction:"), 'Reverse', null);
+ end_row();
echo "</table>";
+ if ($qes !== false)
+ {
+ echo "</td><td width=50%>"; // outer table
+ echo "<table>";
+ start_row();
+ quick_entries_list_cells(_("Quick Entry:"), 'person_id', null, -1, 0);
+ amount_cells(_("Total Amount"), 'totamount', null, null, " ".submit('go', _("Go"), false, false, true));
+ end_row();
+ echo "</table>";
+ }
+
echo "</td></tr>"; // outer table
end_table(1);
$_POST['code_id'] = $item->code_id;
$_POST['dimension_id'] = $item->dimension_id;
$_POST['dimension2_id'] = $item->dimension2_id;
- $_POST['AmountDebit'] = price_format($item->amount);
- $_POST['AmountCredit'] = price_format(abs($item->amount));
+ if ($item->amount > 0)
+ {
+ $_POST['AmountDebit'] = price_format($item->amount);
+ $_POST['AmountCredit'] = "";
+ }
+ else
+ {
+ $_POST['AmountDebit'] = "";
+ $_POST['AmountCredit'] = price_format(abs($item->amount));
+ }
$_POST['description'] = $item->description;
$_POST['LineMemo'] = $item->reference;
//------------------------------------------------------------------------------------------------
-function quick_entries_list($name, $selected_id=null, $expense=true, $bank_only=true, $submit_on_change=false)
+function quick_entries_list($name, $selected_id=null, $expense=-1, $bank_only=-1, $submit_on_change=false)
{
+ $where = false;
$sql = "SELECT id, description FROM ".TB_PREF."quick_entries";
- if ($expense)
- $sql .= " WHERE deposit=0";
- else
- $sql .= " WHERE deposit=1";
- if ($bank_only)
- $sql .= " AND bank_only=1";
- else
- $sql .= " AND bank_only=0";
+ if ($expense != -1)
+ {
+ $sql .= " WHERE deposit=$expense";
+ $where = true;
+ }
+ if ($bank_only != -1)
+ {
+ if ($where)
+ $sql .= " AND bank_only=$bank_only";
+ else
+ $sql .= " WHERE bank_only=$bank_only";
+ }
combo_input($name, $selected_id, $sql, 'id', 'description',
array(
'spec_id' => '',
}
-function quick_entries_list_row($label, $name, $selected_id=null, $expense=true, $bank_only=true, $submit_on_change=false)
+function quick_entries_list_cells($label, $name, $selected_id=null, $expense=-1, $bank_only=-1, $submit_on_change=false)
{
- echo "<tr><td>$label</td><td>\n";
+ echo "<td>$label</td><td>\n";
quick_entries_list($name, $selected_id, $expense, $bank_only, $submit_on_change);
- echo "</td></tr>\n";
+ echo "</td>";
+}
+
+function quick_entries_list_row($label, $name, $selected_id=null, $expense=-1, $bank_only=-1, $submit_on_change=false)
+{
+ echo "<tr>\n";
+ quick_entries_list_cells($label, $name, $selected_id, $expense, $bank_only, $submit_on_change);
+ echo "</tr>\n";
}