提交 66a3d0bf authored 作者: fengzy's avatar fengzy

'费用报销借款抵扣冲销'

上级 450d170e
......@@ -152,4 +152,12 @@ class CommonClassModel extends Model
$data = m('assetm')->getall('state = 0', 'id as value, CONCAT(num, "(",title,")") as name');
return $data;
}
//借款单(已审核)
public function getfingrjkList()
{
$data = m('c_fininfom_jk')->getall('status = 1', 'id as value, CONCAT(docnum, "金额:(",amount,")") as name');
return $data;
}
}
......@@ -12,7 +12,81 @@ class flow_finfybxClassModel extends flowModel
return $arr;
}
//提交时调用
protected function flowsubmit($na, $sm){
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']){
$dk_amount=$fininfom_jk['balance'];
}else{
$dk_amount=$this->rs['money'];
}
$this->rs['money']=$this->rs['money']-$dk_amount;
$deduct_detail = array(
'jk_num' => $jk_num,
'bx_num' => $docnum,
'dk_amount' =>$dk_amount,
'status' =>0,
'create_time' => date("Y-m-d H:i:s"),
);
m('c_deduct_detail')->insert($deduct_detail);
}
}else{
$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']){
$dk_amount=$fininfom_jk['balance'];
}else{
$dk_amount=$this->rs['money'];
}
m('c_fininfom_jk')->update($jkbalance, "`docnum`='$jk_num'");
$deduct_detail = array(
'jk_num' => $jk_num,
'bx_num' => $docnum,
'dk_amount' =>$dk_amount,
'status' =>0,
'create_time' => date("Y-m-d H:i:s"),
);
m('c_deduct_detail')->insert($deduct_detail);
}
}
}
//二级 或一级审批同意之后进行预扣款
protected function flowcheckbefore($zt, $sm){
......@@ -472,6 +546,70 @@ class flow_finfybxClassModel extends flowModel
);
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'],
);
}
$this->rs['money']=$this->rs['money']-$fininfom_jk['balance'];
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,
'update_time' =>date("Y-m-d H:i:s"),
);
m('c_deduct_detail')->update($deduct_status, "`bx_num`='$docnum' and status=0");
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论