X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep709.php;h=471343dc1939ae3a6482776b84ac805f397a17ae;hb=b17df731b4bb055c2fdd568bc4be9e5caa0ee07b;hp=c6ce2c3ddf5c33d5135946557f7c2fd3e14ef810;hpb=74dc09864f66962353e8a1dbb7fa174cc084cbe8;p=fa-stable.git diff --git a/reporting/rep709.php b/reporting/rep709.php index c6ce2c3d..471343dc 100644 --- a/reporting/rep709.php +++ b/reporting/rep709.php @@ -1,5 +1,14 @@ . +***********************************************************************/ $page_security = 2; // ---------------------------------------------------------------- // $ Revision: 2.0 $ @@ -36,8 +45,6 @@ function getCustTransactions($from, $to) $todate = date2sql($to); $netamount = "IF(".TB_PREF."debtor_trans.type=11,-(ov_amount+ov_freight+ov_discount),ov_amount+ov_freight+ov_discount)*".TB_PREF."debtor_trans.rate"; - // IF(".TB_PREF."debtor_trans.type=11,-(ov_amount+ov_freight+ov_discount),ov_amount+ov_freight+ov_discount)*rate AS NetAmount, - // IF(".TB_PREF."debtor_trans.type=11,-(ov_gst+ov_freight_tax),ov_gst+ov_freight_tax)*rate AS Tax $sql = "SELECT ".TB_PREF."debtor_trans.reference, ".TB_PREF."debtor_trans.trans_no, @@ -91,7 +98,7 @@ function getSuppTransactions($from, $to) function getTaxTypes() { - $sql = "SELECT id FROM ".TB_PREF."tax_types ORDER BY id"; + $sql = "SELECT * FROM ".TB_PREF."tax_types ORDER BY id"; return db_query($sql,"No transactions were returned"); } @@ -189,9 +196,9 @@ function print_tax_report() $cols = array(0, 80, 130, 190, 290, 370, 435, 500, 565); $headers = array(_('Trans Type'), _('#'), _('Date'), _('Name'), _('Branch Name'), - _('Net'), _('Tax')); + _('Net'), _('Tax'), ''); - $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right'); + $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right'); $params = array( 0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), @@ -390,6 +397,71 @@ function print_tax_report() } $rep->Line($rep->row - 4); + $rep->row -= 16; + $rep->Font('italic'); + $rep->TextCol(0, 1, _("General Ledger")); + $rep->aligns[1] = 'left'; + $rep->TextCol(1, 3, _("Description")); + $rep->TextCol(3, 4, _("Amount")); + $rep->Font(); + $rep->Line($rep->row - 6); + + $rep->row -= 22; + + $taxes = getTaxTypes(); + $total = 0; + $bdate = date2sql($from); + $edate = date2sql($to); + + 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; + $rep->TextCol(0, 1, $tx['name'] . " " . $tx['rate'] . "%"); + $rep->TextCol(1, 3, _("Charged on sales") . " (" . _("Output Tax")."):"); + $rep->TextCol(3, 4, number_format2($collectible, $dec)); + $rep->NewLine(); + $rep->TextCol(0, 1, $tx['name'] . " " . $tx['rate'] . "%"); + $rep->TextCol(1, 3, _("Paid on purchases") . " (" . _("Input Tax")."):"); + $rep->TextCol(3, 4, number_format2($payable, $dec)); + $rep->NewLine(); + $rep->Font('bold'); + $rep->TextCol(0, 1, $tx['name'] . " " . $tx['rate'] . "%"); + $rep->TextCol(1, 3, _("Net payable or collectible")); + $rep->TextCol(3, 4, number_format2($net, $dec)); + $rep->Font(); + $rep->NewLine(); + } + $rep->Font('bold'); + $rep->TextCol(1, 3, _("Total payable or refund")); + $rep->TextCol(3, 4, number_format2($total, $dec)); + $rep->Font(); + $rep->NewLine(); + + $rep->Line($rep->row - 4); + $locale = $path_to_root . "lang/" . $_SESSION['language']->code . "/locale.inc"; if (file_exists($locale)) {