$result = db_query($sql,"calculate the allocation");
$myrow = db_fetch_row($result);
- return $myrow[0];
+ return $myrow ? $myrow[0] : 0;
}
//----------------------------------------------------------------------------------------
//
function update_supp_trans_allocation($trans_type, $trans_no, $person_id)
{
+ $dec = user_price_dec();
$sql = "UPDATE `".TB_PREF.($trans_type==ST_PURCHORDER ? 'purch_orders' : 'supp_trans')."` trans,
(SELECT person_id, sum(amt) amt from ".TB_PREF."supp_allocations
WHERE person_id=".db_escape($person_id)." AND ((trans_type_to=".db_escape($trans_type)." AND trans_no_to=".db_escape($trans_no).")
OR (trans_type_from=".db_escape($trans_type)." AND trans_no_from=".db_escape($trans_no)."))) allocated
SET
- trans.alloc=IFNULL(allocated.amt, 0)
+ trans.alloc=IFNULL(ROUND(allocated.amt, $dec), 0)
WHERE trans.supplier_id=person_id AND " . ($trans_type==ST_PURCHORDER ?
"trans.order_no=".db_escape($trans_no)
: "trans.type=".db_escape($trans_type)." AND trans.trans_no=".db_escape($trans_no));
$sql .= " AND person_id=".db_escape($person_id);
db_query($sql, "could not void supp transactions for type=$type and trans_no=$type_no");
-// is this necessary?
-// if ($date != "")
-// exchange_variation($type, $type_no, $row['trans_type_to'], $row['trans_no_to'], $date,
-// $row['amt'], PT_SUPPLIER, true);
}
//-------------------------------------------------------------------------------------------------------------
-function get_allocatable_from_supp_sql($supplier_id=null, $settled)
+function get_allocatable_from_supp_sql($supplier_id, $settled)
{
$sql = "SELECT
trans.type,
}
else
{
-// FIXME: change to form below when prepayments terms finally can be selected in PO entry form:
-// $sql .= " AND round(prep_amount) > 0 AND ISNULL(grn.purch_order_no)"; // only sales orders with prepayment level set and no yet received
$sql .= " AND ISNULL(grn.purch_order_no)"; // only sales orders no yet received
}
if ($supplier_id)
AND trans.type NOT IN (".implode(',',array(ST_SUPPAYMENT,ST_BANKPAYMENT)).")";
$sql .= " GROUP BY type, trans_no";
}
-//_vd($sql);
return db_query($sql." ORDER BY due_date", "Cannot retreive alloc to transactions");
}
{
$sql .= " AND trans.type = ".ST_SUPPCREDIT." ";
}
+ elseif ($_POST['filterType'] == '6') // Journal
+ {
+ $sql .= " AND trans.type = ".ST_JOURNAL." ";
+ }
if (($_POST['filterType'] == '2') || ($_POST['filterType'] == '5')) // overdude
{