<?php
-
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU Affero General Public License,
+ AGPL, 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/agpl-3.0.html>.
+***********************************************************************/
$page_security = 2;
// ----------------------------------------------------------------
// $ Revision: 2.0 $
// date_: 2005-05-19
// Title: Aged Customer Balances
// ----------------------------------------------------------------
-$path_to_root="../";
+$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/data_checks.inc");
-include_once($path_to_root . "gl/includes/gl_db.inc");
+include_once($path_to_root . "/includes/session.inc");
+include_once($path_to_root . "/includes/date_functions.inc");
+include_once($path_to_root . "/includes/data_checks.inc");
+include_once($path_to_root . "/gl/includes/gl_db.inc");
//----------------------------------------------------------------------------------------------------
$PastDueDays2 = 2 * $PastDueDays1;
// Revomed allocated from sql
+ $value = "(".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + "
+ .TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_freight_tax + "
+ .TB_PREF."debtor_trans.ov_discount)";
+ $due = "IF (".TB_PREF."debtor_trans.type=10,".TB_PREF."debtor_trans.due_date,".TB_PREF."debtor_trans.tran_date)";
$sql = "SELECT ".TB_PREF."sys_types.type_name, ".TB_PREF."debtor_trans.type, ".TB_PREF."debtor_trans.reference,
".TB_PREF."debtor_trans.tran_date,
- (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount) as Balance,
- IF (".TB_PREF."payment_terms.days_before_due > 0,
- CASE WHEN TO_DAYS('$todate') - TO_DAYS(".TB_PREF."debtor_trans.tran_date) >= ".TB_PREF."payment_terms.days_before_due THEN
- ".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount
- ELSE
- 0
- END,
-
- CASE WHEN TO_DAYS('$todate') - TO_DAYS(DATE_ADD(DATE_ADD(".TB_PREF."debtor_trans.tran_date,
- INTERVAL 1 MONTH), INTERVAL (".TB_PREF."payment_terms.day_in_following_month -
- DAYOFMONTH(".TB_PREF."debtor_trans.tran_date)) DAY)) >= 0 THEN
- ".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount
- ELSE
- 0
- END
- ) AS Due,
- IF (".TB_PREF."payment_terms.days_before_due > 0,
- CASE WHEN TO_DAYS('$todate') - TO_DAYS(".TB_PREF."debtor_trans.tran_date) > ".TB_PREF."payment_terms.days_before_due
- AND TO_DAYS('$todate') - TO_DAYS(".TB_PREF."debtor_trans.tran_date) >= (".TB_PREF."payment_terms.days_before_due + $PastDueDays1) THEN
- ".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount
- ELSE
- 0
- END,
-
- CASE WHEN TO_DAYS('$todate') - TO_DAYS(DATE_ADD(DATE_ADD(".TB_PREF."debtor_trans.tran_date,
- INTERVAL 1 MONTH), INTERVAL (".TB_PREF."payment_terms.day_in_following_month -
- DAYOFMONTH(".TB_PREF."debtor_trans.tran_date)) DAY)) >= $PastDueDays1 THEN
- ".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount
- ELSE
- 0
- END
- ) AS Overdue1,
- IF (".TB_PREF."payment_terms.days_before_due > 0,
- CASE WHEN TO_DAYS('$todate') - TO_DAYS(".TB_PREF."debtor_trans.tran_date) > ".TB_PREF."payment_terms.days_before_due
- AND TO_DAYS('$todate') - TO_DAYS(".TB_PREF."debtor_trans.tran_date) >= (".TB_PREF."payment_terms.days_before_due + $PastDueDays2) THEN
- ".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount
- ELSE
- 0
- END,
-
- CASE WHEN TO_DAYS('$todate') - TO_DAYS(DATE_ADD(DATE_ADD(".TB_PREF."debtor_trans.tran_date,
- INTERVAL 1 MONTH), INTERVAL (".TB_PREF."payment_terms.day_in_following_month -
- DAYOFMONTH(".TB_PREF."debtor_trans.tran_date)) DAY)) >= $PastDueDays2 THEN
- ".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount
- ELSE
- 0
- END
- ) AS Overdue2
+ $value as Balance,
+ IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= 0,$value,0) AS Due,
+ IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $PastDueDays1,$value,0) AS Overdue1,
+ IF ((TO_DAYS('$todate') - TO_DAYS($due)) >= $PastDueDays2,$value,0) AS Overdue2
FROM ".TB_PREF."debtors_master,
".TB_PREF."payment_terms,
AND ".TB_PREF."debtors_master.debtor_no = ".TB_PREF."debtor_trans.debtor_no
AND ".TB_PREF."debtor_trans.debtor_no = $costomer_id
AND ".TB_PREF."debtor_trans.tran_date <= '$todate'
- AND ABS(".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_discount) > 0.004
+ AND ABS(".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + ".TB_PREF."debtor_trans.ov_freight_tax + ".TB_PREF."debtor_trans.ov_discount) > 0.004
ORDER BY ".TB_PREF."debtor_trans.tran_date";
-
return db_query($sql, "The customer details could not be retrieved");
}
{
global $comp_path, $path_to_root;
- include_once($path_to_root . "reporting/includes/pdf_report.inc");
+ include_once($path_to_root . "/reporting/includes/pdf_report.inc");
$to = $_POST['PARAM_0'];
$fromcust = $_POST['PARAM_1'];
$comments = $_POST['PARAM_5'];
if ($graphics)
{
- include_once($path_to_root . "reporting/includes/class.graphic.inc");
+ include_once($path_to_root . "/reporting/includes/class.graphic.inc");
$pg = new graph();
}
$rep->Info($params, $cols, $headers, $aligns);
$rep->Header();
- $total = array(0,0,0,0);
+ $total = array(0,0,0,0, 0);
$sql = "SELECT debtor_no, name, curr_code FROM ".TB_PREF."debtors_master ";
if ($fromcust != reserved_words::get_all_numeric())
$pg->type = $graphics;
$pg->skin = $graph_skin;
$pg->built_in = false;
- $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
+ $pg->fontfile = $path_to_root . "/reporting/fonts/Vera.ttf";
$pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
$filename = $comp_path .'/'. user_company(). "/images/test.png";
$pg->display($filename, true);