提交 138a1795 authored 作者: fengzy's avatar fengzy

'调整费用报销与借款单逻辑'

上级 948ff3ae
...@@ -40,21 +40,16 @@ class flow_finfybxClassModel extends flowModel ...@@ -40,21 +40,16 @@ class flow_finfybxClassModel extends flowModel
$docnum=$this->rs['docnum']; $docnum=$this->rs['docnum'];
if($this->rs['money'] >= $fininfom_jk['balance']){ if($this->rs['money'] >= $fininfom_jk['balance']){
$jkbalance = array(
'balance' => 0,
);
$dk_amount=$fininfom_jk['balance']; $dk_amount=$fininfom_jk['balance'];
}else{ }else{
$jkbalance = array(
'balance' => $fininfom_jk['balance']-$this->rs['money'],
);
$dk_amount=$this->rs['money']; $dk_amount=$this->rs['money'];
} }
$this->rs['money']=$this->rs['money']-$dk_amount; $this->rs['money']=$this->rs['money']-$dk_amount;
m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'");
$deduct_detail = array( $deduct_detail = array(
...@@ -71,24 +66,15 @@ class flow_finfybxClassModel extends flowModel ...@@ -71,24 +66,15 @@ class flow_finfybxClassModel extends flowModel
$jk_num=substr($dikouid,0,strrpos($dikouid,'金')); $jk_num=substr($dikouid,0,strrpos($dikouid,'金'));
$sql = " docnum ='$jk_num' "; $sql = " docnum ='$jk_num' ";
$fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额 $fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额
$docnum=$this->rs['docnum']; $docnum=$this->rs['docnum'];
if($this->rs['money'] >= $fininfom_jk['balance']){ if($this->rs['money'] >= $fininfom_jk['balance']){
$jkbalance = array(
'balance' => 0,
);
$dk_amount=$fininfom_jk['balance']; $dk_amount=$fininfom_jk['balance'];
}else{ }else{
$jkbalance = array(
'balance' => $fininfom_jk['balance']-$this->rs['money'],
);
$dk_amount=$this->rs['money']; $dk_amount=$this->rs['money'];
} }
m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'"); m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'");
...@@ -101,19 +87,6 @@ class flow_finfybxClassModel extends flowModel ...@@ -101,19 +87,6 @@ class flow_finfybxClassModel extends flowModel
); );
m('c_deduct_detail')->insert($deduct_detail); m('c_deduct_detail')->insert($deduct_detail);
} }
//
// if($this->rs['money'] <= $fininfom_jk['amount']) {
// }
// if($this->rs['money'] > $fininfom_jk['amount']){
//
// }
} }
...@@ -528,69 +501,130 @@ class flow_finfybxClassModel extends flowModel ...@@ -528,69 +501,130 @@ class flow_finfybxClassModel extends flowModel
//流程全部完成后调用 //流程全部完成后调用
protected function flowcheckfinsh($zt){ protected function flowcheckfinsh($zt){
// $docnum=$this->rs['docnum']; $docnum=$this->rs['docnum'];
// $withhold_cost = m('c_withhold_fininform')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount'); $withhold_cost = m('c_withhold_fininform')->getall("docnum='$docnum' and status =1", 'id,cost_id,amount');
//
// foreach ($withhold_cost as $key => $vo) { foreach ($withhold_cost as $key => $vo) {
// // 扣除账户余额 c_fund_account account_balance // 扣除账户余额 c_fund_account account_balance
//
// $cbzxid= $vo['cost_id'];
// $model = 'c_fund_account';
// $sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
// $data = m($model)->getone($sql,'id,name,account_balance,freeze_amount');
//
// $zfarr = array(
// 'account_balance' =>$data['account_balance']-$vo['amount'],
// );
// $id=$data['id'];
// m('c_fund_account')->update($zfarr,"`id`='$id'");
//
// $freeze = array(
// 'freeze_amount' => $data['freeze_amount'] - $vo['amount'],
// );
//
// m('c_fund_account')->update($freeze, "`id`='$id'");
//
// // 成本中心 amount 变更
// $cbzx = substr($cbzxid,0,strrpos($cbzxid,"("));
// $cbzxsql = " code ='$cbzx' and status = 1";
//
// $cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount');
// $cbarr = array(
// 'amount' =>$cbzxdata['amount']+$vo['amount'],
// );
// m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
// //账户明细 c_account_detail
// $account_detail=array(
// 'account' => $data['name'],
// 'opt_type' => 2,
// 'amount' =>$vo['amount'],
// 'trans_numb' => $this->rs['docnum'],
// 'account_balance' => $data['account_balance']-$vo['amount'],
// 'create_time' =>date("Y-m-d H:i:s"),
// 'uid' =>$this->rs['uid'],
// );
//
// m('c_account_detail')->insert($account_detail);
//
// // 业务付款8业务预付款10费用报销11 oa_c_fund_detail
//
//
// $fund_detail=array(
// 'trans_numb' =>$this->rs['docnum'],
// 'account' => $data['name'],
// 'toaccount' =>$this->rs['applicant'],
// 'trans_amount' =>$vo['amount'],
// 'business_type' =>11,
// 'opt_type' =>2,
// 'account_balance'=>$data['account_balance']-$vo['amount'],
// 'create_time' =>date("Y-m-d H:i:s"),
// 'uid' =>$this->rs['uid'],
// );
// m('c_fund_detail')->insert($fund_detail);
// }
$cbzxid= $vo['cost_id'];
$model = 'c_fund_account';
$sql = " cost_id ='$cbzxid' and status = 1 and is_default=1";
$data = m($model)->getone($sql,'id,name,account_balance,freeze_amount');
$zfarr = array(
'account_balance' =>$data['account_balance']-$vo['amount'],
);
$id=$data['id'];
m('c_fund_account')->update($zfarr,"`id`='$id'");
$freeze = array(
'freeze_amount' => $data['freeze_amount'] - $vo['amount'],
);
m('c_fund_account')->update($freeze, "`id`='$id'");
// 成本中心 amount 变更
$cbzx = substr($cbzxid,0,strrpos($cbzxid,"("));
$cbzxsql = " code ='$cbzx' and status = 1";
$cbzxdata = m('c_cbzx')->getone($cbzxsql,'id,amount');
$cbarr = array(
'amount' =>$cbzxdata['amount']+$vo['amount'],
);
m('c_cbzx')->update($cbarr,"`code`='$cbzx'");
//账户明细 c_account_detail
$account_detail=array(
'account' => $data['name'],
'opt_type' => 2,
'amount' =>$vo['amount'],
'trans_numb' => $this->rs['docnum'],
'account_balance' => $data['account_balance']-$vo['amount'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_account_detail')->insert($account_detail);
// 业务付款8业务预付款10费用报销11 oa_c_fund_detail
$fund_detail=array(
'trans_numb' =>$this->rs['docnum'],
'account' => $data['name'],
'toaccount' =>$this->rs['applicant'],
'trans_amount' =>$vo['amount'],
'business_type' =>11,
'opt_type' =>2,
'account_balance'=>$data['account_balance']-$vo['amount'],
'create_time' =>date("Y-m-d H:i:s"),
'uid' =>$this->rs['uid'],
);
m('c_fund_detail')->insert($fund_detail);
}
if($this->rs['dikouid']){
$dikouid = $this->rs['dikouid'];
if(strpos($dikouid,',') !== false){
$jk_num=explode(",",$dikouid);
foreach ($jk_num as $key => $value ){
if($this->rs['money'] ==0 ){
break;
}
$jk_num=substr($value,0,strrpos($value,'金'));
$sql = " docnum ='$jk_num' ";
$fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额
$docnum=$this->rs['docnum'];
if($this->rs['money'] >= $fininfom_jk['balance']){
$jkbalance = array(
'balance' => 0,
);
}else{
$jkbalance = array(
'balance' => $fininfom_jk['balance']-$this->rs['money'],
);
}
m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'");
$deduct_status = array(
'status' => 1,
);
m('c_deduct_detail')->update($deduct_status, "`bx_num`='$docnum' and status=0");
}
}else{
$docnum=$this->rs['docnum'];
$jk_num=substr($dikouid,0,strrpos($dikouid,'金'));
$sql = " docnum ='$jk_num' ";
$fininfom_jk = m('c_fininfom_jk')->getone($sql,'balance');//金额
$docnum=$this->rs['docnum'];
if($this->rs['money'] >= $fininfom_jk['balance']){
$jkbalance = array(
'balance' => 0,
);
}else{
$jkbalance = array(
'balance' => $fininfom_jk['balance']-$this->rs['money'],
);
}
m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'");
$deduct_status = array(
'status' => 1,
);
m('c_deduct_detail')->update($deduct_status, "`bx_num`='$docnum' and status=0");
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论