更新到账管理
This commit is contained in:
parent
dcc2a64222
commit
abcf1dce71
|
@ -52,11 +52,14 @@ class FinanceIncome extends ApiController
|
|||
public function add()
|
||||
{
|
||||
$param = get_params();
|
||||
$this->uid = JWT_UID;
|
||||
$auth = isAuthIncome($this->uid);
|
||||
if (request()->isAjax()) {
|
||||
if($auth == 0){
|
||||
return to_assign(1, "你没有到账管理权限,请联系管理员或者HR");
|
||||
}
|
||||
if($auth == 0){
|
||||
$this->apiError("你没有到账管理权限,请联系管理员或者HR");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$inid = $param['inid'];
|
||||
$admin_id = $this->uid;
|
||||
//计算已到账的金额
|
||||
|
@ -141,39 +144,7 @@ class FinanceIncome extends ApiController
|
|||
return to_assign();
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if($auth == 0){
|
||||
return view('../../base/view/common/roletemplate');
|
||||
}
|
||||
$id = isset($param['id']) ? $param['id']: 0 ;
|
||||
$model = new Invoice();
|
||||
$detail = $model->detail($id);
|
||||
if(empty($detail)){
|
||||
throw new \think\exception\HttpException(406, '找不到记录');
|
||||
}
|
||||
if($detail['file_ids'] !=''){
|
||||
$fileArray = Db::name('File')->where('id','in',$detail['file_ids'])->select();
|
||||
$detail['fileArray'] = $fileArray;
|
||||
}
|
||||
|
||||
if($detail['other_file_ids'] !=''){
|
||||
$fileArrayOther = Db::name('File')->where('id','in',$detail['other_file_ids'])->select();
|
||||
$detail['fileArrayOther'] = $fileArrayOther;
|
||||
}
|
||||
$detail['not_income'] = ($detail['amount']*100 - $detail['enter_amount']*100)/100;
|
||||
//已到账的记录
|
||||
$detail['income'] = InvoiceIncome::field('i.*,a.name as admin')
|
||||
->alias('i')
|
||||
->join('Admin a', 'a.id = i.admin_id', 'LEFT')
|
||||
->where(['i.inid'=>$id,'i.status'=>1])
|
||||
->order('i.enter_time desc')
|
||||
->select();
|
||||
View::assign('uid', $this->uid);
|
||||
View::assign('id', $id);
|
||||
View::assign('detail', $detail);
|
||||
return view();
|
||||
}
|
||||
}
|
||||
//查看
|
||||
public function view()
|
||||
|
@ -210,29 +181,29 @@ class FinanceIncome extends ApiController
|
|||
public function delete()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isAjax()) {
|
||||
//作废初始化发票到账数据
|
||||
$income =InvoiceIncome::where(['id'=>$param['id']])->find();
|
||||
$invoice = Invoice::where(['id'=>$income['inid']])->find();
|
||||
if($income){
|
||||
$res = InvoiceIncome::where(['id'=>$param['id']])->update(['status'=>'6','update_time'=>time()]);
|
||||
if($res!==false){
|
||||
if($income['amount']*100 == $invoice['amount']*100){
|
||||
//发票全部反到账
|
||||
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]);
|
||||
}
|
||||
else if($income['amount']*100 < $invoice['amount']*100){
|
||||
$incomeTotal=InvoiceIncome::where(['inid'=>$income['inid'],'status'=>1])->sum('amount');
|
||||
//发票部分到账
|
||||
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
|
||||
}
|
||||
add_log('enter',$income['inid'],$invoice);
|
||||
return to_assign();
|
||||
$this->uid = JWT_UID;
|
||||
//作废初始化发票到账数据
|
||||
$income =InvoiceIncome::where(['id'=>$param['id']])->find();
|
||||
$invoice = Invoice::where(['id'=>$income['inid']])->find();
|
||||
if($income){
|
||||
$res = InvoiceIncome::where(['id'=>$param['id']])->update(['status'=>'6','update_time'=>time()]);
|
||||
if($res!==false){
|
||||
if($income['amount']*100 == $invoice['amount']*100){
|
||||
//发票全部反到账
|
||||
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>0,'enter_amount'=>0,'enter_time'=>0]);
|
||||
}
|
||||
else{
|
||||
return to_assign(1,'操作失败');
|
||||
else if($income['amount']*100 < $invoice['amount']*100){
|
||||
$incomeTotal=InvoiceIncome::where(['inid'=>$income['inid'],'status'=>1])->sum('amount');
|
||||
//发票部分到账
|
||||
Invoice::where(['id'=>$income['inid']])->update(['is_cash'=>1,'enter_amount'=>$incomeTotal,'enter_time'=>time()]);
|
||||
}
|
||||
add_log('enter',$income['inid'],$invoice);
|
||||
$this->apiSuccess('操作成功');
|
||||
}
|
||||
else{
|
||||
$this->apiError('操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue