X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=purchasing%2Fincludes%2Fdb%2Fsuppalloc_db.inc;h=dc7119db05f739722c2efd5b76c46ad1abe79175;hb=1571869d54be48452fdbe08f25130972ff0a7b5a;hp=c16c97557f015b1a3d3cac1e809fe945279ef727;hpb=264c09696d65efe4532c197f317162daf8c24f32;p=fa-stable.git diff --git a/purchasing/includes/db/suppalloc_db.inc b/purchasing/includes/db/suppalloc_db.inc index c16c9755..dc7119db 100644 --- a/purchasing/includes/db/suppalloc_db.inc +++ b/purchasing/includes/db/suppalloc_db.inc @@ -48,19 +48,24 @@ function get_supp_trans_allocation_balance($trans_type, $trans_no) } //---------------------------------------------------------------------------------------- - -function update_supp_trans_allocation($trans_type, $trans_no, $alloc) +// Update supplier trans alloc field according to current status of supp_allocations +// +function update_supp_trans_allocation($trans_type, $trans_no) { + $sql = "UPDATE `".TB_PREF.($trans_type==ST_PURCHORDER ? 'purch_orders' : 'supp_trans')."` trans, + (SELECT sum(amt) amt from ".TB_PREF."supp_allocations + WHERE (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) + WHERE " . ($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)); - if ($trans_type == ST_PURCHORDER) - $sql = "UPDATE ".TB_PREF."purch_orders SET alloc = alloc + ".db_escape($alloc)." - WHERE order_no = ".db_escape($trans_no); - else - $sql = "UPDATE ".TB_PREF."supp_trans SET alloc = alloc + ".db_escape($alloc)." - WHERE type=".db_escape($trans_type)." AND trans_no = ".db_escape($trans_no); db_query($sql, "The supp transaction record could not be modified for the allocation against it"); } + //------------------------------------------------------------------------------------------------------------- function void_supp_allocations($type, $type_no, $date="")