From b8bb268d265a430ebe0516f89b8c997e0f94a2c7 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Sat, 15 Nov 2008 00:53:38 +0000 Subject: [PATCH] Added Tax Inquiry in Banking and General Ledger tab. --- CHANGELOG.txt | 5 ++ applications/generalledger.php | 2 +- gl/inquiry/tax_inquiry.php | 151 +++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 gl/inquiry/tax_inquiry.php diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a60246b8..b1ac91c3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,11 @@ Legend: ! -> Note $ -> Affected files +15-Nov-2008 Joe Hunt ++ Added Tax Inquiry in Banking and General Ledger tab. +$ /applications/generalledger.php + /gl/inquiry/tax_inquiry.php (new file) + 14-Nov-2008 Joe Hunt + Added Sales Groups and Recurrent Invoices. $ /applications/customers.php diff --git a/applications/generalledger.php b/applications/generalledger.php index 9b02b2a5..6e3c48ca 100644 --- a/applications/generalledger.php +++ b/applications/generalledger.php @@ -18,8 +18,8 @@ $this->add_module(_("Inquiries and Reports")); $this->add_lapp_function(1, _("Bank Account &Inquiry"),"gl/inquiry/bank_inquiry.php?"); $this->add_lapp_function(1, _("GL Account &Inquiry"),"gl/inquiry/gl_account_inquiry.php?"); - $this->add_lapp_function(1, "",""); $this->add_lapp_function(1, _("Trial &Balance"),"gl/inquiry/gl_trial_balance.php?"); + $this->add_lapp_function(1, _("Ta&x Inquiry"),"gl/inquiry/tax_inquiry.php?"); $this->add_rapp_function(1, _("Banking &Reports"),"reporting/reports_main.php?Class=5"); $this->add_rapp_function(1, _("General Ledger &Reports"),"reporting/reports_main.php?Class=6"); diff --git a/gl/inquiry/tax_inquiry.php b/gl/inquiry/tax_inquiry.php new file mode 100644 index 00000000..1de48969 --- /dev/null +++ b/gl/inquiry/tax_inquiry.php @@ -0,0 +1,151 @@ +activate('trans_tbl'); +} + +if (get_post('TransFromDate') == "" && get_post('TransToDate') == "") +{ + $date = Today(); + $row = get_company_prefs(); + $edate = add_months($date, -$row['tax_last']); + $edate = end_month($edate); + $bdate = add_months($edate, -$row['tax_prd'] + 1); + $_POST["TransFromDate"] = begin_month($bdate); + $_POST["TransToDate"] = $edate; +} + +//---------------------------------------------------------------------------------------------------- + +function get_tax_types() +{ + $sql = "SELECT * FROM ".TB_PREF."tax_types ORDER BY id"; + return db_query($sql,"No transactions were returned"); +} + +function tax_inquiry_controls() +{ + global $table_style2; + + start_form(); + + //start_table($table_style2); + start_table("class='tablestyle_noborder'"); + start_row(); + + date_cells(_("from:"), 'TransFromDate', '', null, -30); + date_cells(_("to:"), 'TransToDate'); + submit_cells('Show',_("Show"),'','', true); + + end_row(); + + end_table(); + + end_form(); +} + +//---------------------------------------------------------------------------------------------------- + +function show_results() +{ + global $path_to_root, $table_style; + + $taxes = get_tax_types(); + + /*Now get the transactions */ + div_start('trans_tbl'); + start_table($table_style); + + $th = array(_("Type"), _("Description"), _("Amount")); + table_header($th); + $k = 0; + $total = 0; + $bdate = date2sql($_POST['TransFromDate']); + $edate = date2sql($_POST['TransToDate']); + while ($tx = db_fetch($taxes)) + { + if ($tx['sales_gl_code'] == $tx['purchasing_gl_code']) + { + $sql = "SELECT SUM(IF(amount >= 0, amount, 0)) AS payable, SUM(IF(amount < 0, -amount, 0)) AS collectible + FROM ".TB_PREF."gl_trans WHERE account = '".$tx['sales_gl_code']."' AND tran_date >= '$bdate' AND tran_date <= '$edate'"; + $result = db_query($sql, "Error retrieving tax inquiry"); + $row = db_fetch($result); + $payable = -$row['payable']; + $collectible.= -$row['collectible']; + } + else + { + $sql = "SELECT SUM(amount) AS collectible + FROM ".TB_PREF."gl_trans WHERE account = '".$tx['sales_gl_code']."' AND tran_date >= '$bdate' AND tran_date <= '$edate'"; + $result = db_query($sql, "Error retrieving tax inquiry"); + $row = db_fetch($result); + $collectible = -$row['collectible']; + $sql = "SELECT SUM(amount) AS payable + FROM ".TB_PREF."gl_trans WHERE account = '".$tx['purchasing_gl_code']."' AND tran_date >= '$bdate' AND tran_date <= '$edate'"; + $result = db_query($sql, "Error retrieving tax inquiry"); + $row = db_fetch($result); + $payable = -$row['payable']; + } + $net = $collectible + $payable; + $total += $net; + alt_table_row_color($k); + label_cell($tx['name'] . " " . $tx['rate'] . "%"); + label_cell(_("Charged on sales") . " (" . _("Output Tax")."):"); + amount_cell($collectible); + end_row(); + alt_table_row_color($k); + label_cell($tx['name'] . " " . $tx['rate'] . "%"); + label_cell(_("Paid on purchases") . " (" . _("Input Tax")."):"); + amount_cell($payable); + end_row(); + alt_table_row_color($k); + label_cell($tx['name'] . " " . $tx['rate'] . "%"); + label_cell(_("Net payable or collectible") . ":"); + amount_cell($net, true); + end_row(); + } + alt_table_row_color($k); + label_cell(""); + label_cell(""._("Total payable or refund") . ":"); + amount_cell($total, true); + end_row(); + + end_table(2); + div_end(); +} + +//---------------------------------------------------------------------------------------------------- + +tax_inquiry_controls(); + +show_results(); + +//---------------------------------------------------------------------------------------------------- + +end_page(); + +?> -- 2.30.2