X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=reporting%2Frep108.php;h=0247f7cc3539ef3ec2e95ff9c0900d7080e138ba;hb=9af96a2e461b905dbb20f2b87ffb5c28f9b3461c;hp=5299c1b20ba494bfa1c17772245204185a59d1de;hpb=bd3023c1b5e64429043358a691b3aae20eb54c09;p=fa-stable.git diff --git a/reporting/rep108.php b/reporting/rep108.php index 5299c1b2..0247f7cc 100644 --- a/reporting/rep108.php +++ b/reporting/rep108.php @@ -1,12 +1,12 @@ . ***********************************************************************/ $page_security = 'SA_CUSTSTATREP'; @@ -30,10 +30,10 @@ print_statements(); //---------------------------------------------------------------------------------------------------- -function getTransactions($debtorno, $date) +function getTransactions($debtorno, $date, $outstanding) { $sql = "SELECT ".TB_PREF."debtor_trans.*, - (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + + (".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) AS TotalAmount, ".TB_PREF."debtor_trans.alloc AS Allocated, ((".TB_PREF."debtor_trans.type = ".ST_SALESINVOICE.") @@ -41,7 +41,12 @@ function getTransactions($debtorno, $date) FROM ".TB_PREF."debtor_trans WHERE ".TB_PREF."debtor_trans.tran_date <= '$date' AND ".TB_PREF."debtor_trans.debtor_no = ".db_escape($debtorno)." AND ".TB_PREF."debtor_trans.type <> ".ST_CUSTDELIVERY." - ORDER BY ".TB_PREF."debtor_trans.tran_date"; + AND (".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"; + if ($outstanding) + $sql .= " 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) - alloc <> 0"; + $sql .= " ORDER BY ".TB_PREF."debtor_trans.tran_date"; return db_query($sql,"No transactions were returned"); } @@ -56,8 +61,9 @@ function print_statements() $customer = $_POST['PARAM_0']; $currency = $_POST['PARAM_1']; - $email = $_POST['PARAM_2']; - $comments = $_POST['PARAM_3']; + $outstanding = $_POST['PARAM_2']; + $email = $_POST['PARAM_3']; + $comments = $_POST['PARAM_4']; $dec = user_price_dec(); @@ -82,7 +88,7 @@ function print_statements() $rep->Info($params, $cols, null, $aligns); } - $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, email, curr_code, curdate() AS tran_date FROM ".TB_PREF."debtors_master"; + $sql = "SELECT debtor_no, name AS DebtorName, address, tax_id, curr_code, curdate() AS tran_date FROM ".TB_PREF."debtors_master"; if ($customer != ALL_NUMERIC) $sql .= " WHERE debtor_no = ".db_escape($customer); else @@ -95,7 +101,7 @@ function print_statements() $myrow['order_'] = ""; - $TransResult = getTransactions($myrow['debtor_no'], $date); + $TransResult = getTransactions($myrow['debtor_no'], $date, $outstanding); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; if (db_num_rows($TransResult) == 0) @@ -133,7 +139,7 @@ function print_statements() $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); if ($myrow2['type'] == ST_SALESINVOICE) $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); - if ($myrow2['type'] == ST_SALESINVOICE) + if ($myrow2['type'] == ST_SALESINVOICE || $myrow2['type'] == ST_BANKPAYMENT) $rep->TextCol(4, 5, $DisplayTotal, -2); else $rep->TextCol(5, 6, $DisplayTotal, -2);