supp_account_no, bank_account, credit_limit, dimension_id, dimension2_id, curr_code,
payment_terms, payable_account, purchase_account, payment_discount_account, notes,
tax_group_id, tax_included)
- VALUES (".db_escape($_POST['supp_name']). ", "
+ VALUES (".db_escape($supp_name). ", "
.db_escape($supp_ref). ", "
.db_escape($address) . ", "
.db_escape($supp_address) . ", "
.db_escape($website). ", "
.db_escape($supp_account_no). ", "
.db_escape($bank_account). ", "
- .$credit_limit. ", "
+ .db_escape($credit_limit). ", "
.db_escape($dimension_id). ", "
.db_escape($dimension2_id). ", "
.db_escape($curr_code). ", "
db_query($sql,"check failed");
}
-function get_supplier_details($supplier_id, $to=null)
+function get_supplier_details($supplier_id, $to=null, $all=true)
{
if ($to == null)
$past2 = 2 * $past1;
// removed - supp_trans.alloc from all summations
- $value = "(trans.ov_amount + trans.ov_gst + trans.ov_discount)";
+ if ($all)
+ $value = "(trans.ov_amount + trans.ov_gst + trans.ov_discount)";
+ else
+ $value = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_BANKDEPOSIT.",
+ (trans.ov_amount + trans.ov_gst + trans.ov_discount - trans.alloc),
+ (trans.ov_amount + trans.ov_gst + trans.ov_discount + trans.alloc))";
$due = "IF (trans.type=".ST_SUPPINVOICE." OR trans.type=".ST_SUPPCREDIT.",trans.due_date,trans.tran_date)";
$sql = "SELECT supp.supp_name, supp.curr_code, ".TB_PREF."payment_terms.terms,
WHERE
supp.payment_terms = ".TB_PREF."payment_terms.terms_indicator
- AND supp.supplier_id = $supplier_id
-
- GROUP BY
+ AND supp.supplier_id = $supplier_id ";
+ if (!$all)
+ $sql .= "AND ABS(trans.ov_amount + trans.ov_gst + trans.ov_discount) - trans.alloc > ".FLOAT_COMP_DELTA." ";
+ $sql .= "GROUP BY
supp.supp_name,
".TB_PREF."payment_terms.terms,
".TB_PREF."payment_terms.days_before_due,