更新开票及状态处理
This commit is contained in:
parent
87aff492c0
commit
329be8258a
|
@ -445,5 +445,101 @@ class FinanceInvoice extends ApiController
|
|||
} else {
|
||||
$this->apiError('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//开具发票
|
||||
public function open()
|
||||
{
|
||||
$param = get_params();
|
||||
$this->uid = JWT_UID;
|
||||
$auth = isAuthInvoice($this->uid);
|
||||
if($auth == 0){
|
||||
$this->apiError("你没有开票权限,请联系管理员或者HR");
|
||||
}
|
||||
if (empty($param['id'])) {
|
||||
$this->apiError("id不能为空");
|
||||
}
|
||||
if (empty($param['code'])) {
|
||||
$this->apiError("发票号码不能为空");
|
||||
}
|
||||
if (empty($param['open_time'])) {
|
||||
$this->apiError("开票日期不能为空");
|
||||
}
|
||||
$status = Invoice::where(['id' => $param['id']])->value('check_status');
|
||||
if ($status == 2) {
|
||||
$param['check_status'] = 5;
|
||||
$param['open_admin_id'] = $this->uid;
|
||||
}
|
||||
if(isset($param['open_time'])){
|
||||
$param['open_time'] = strtotime(urldecode($param['open_time']));
|
||||
}
|
||||
$res = Invoice::where('id', $param['id'])->strict(false)->field('code,check_status,open_time,open_admin_id,delivery,other_file_ids')->update($param);
|
||||
if ($res !== false) {
|
||||
add_log('open', $param['id'],$param,'发票');
|
||||
$this->apiSuccess('操作成功');
|
||||
} else {
|
||||
$this->apiError("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
//作废发票
|
||||
public function tovoid()
|
||||
{
|
||||
$param = get_params();
|
||||
$this->uid = JWT_UID;
|
||||
$auth = isAuthInvoice($this->uid);
|
||||
if($auth == 0){
|
||||
$this->apiError("你没有开票权限,请联系管理员或者HR");
|
||||
}
|
||||
if (empty($param['id'])) {
|
||||
$this->apiError("id不能为空");
|
||||
}
|
||||
if (empty($param['check_status'])) {
|
||||
$this->apiError("发票状态不能为空");
|
||||
}
|
||||
if ($param['check_status'] == 10) {
|
||||
$count = InvoiceIncome::where(['inid'=>$param['id'],'status'=>1])->count();
|
||||
if($count>0){
|
||||
$this->apiError("发票已经新增有到账记录,请先反到账后再作废发票");
|
||||
}
|
||||
else{
|
||||
$param['update_time'] = time();
|
||||
}
|
||||
}
|
||||
$res = Invoice::where('id', $param['id'])->strict(false)->field('check_status')->update($param);
|
||||
if ($res !== false) {
|
||||
add_log('tovoid', $param['id'],$param,'发票');
|
||||
$this->apiSuccess('操作成功');
|
||||
} else {
|
||||
$this->apiError("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
//反作废发票
|
||||
public function novoid()
|
||||
{
|
||||
$param = get_params();
|
||||
$this->uid = JWT_UID;
|
||||
$auth = isAuthInvoice($this->uid);
|
||||
if($auth == 0){
|
||||
$this->apiError("你没有开票权限,请联系管理员或者HR");
|
||||
}
|
||||
if (empty($param['id'])) {
|
||||
$this->apiError("id不能为空");
|
||||
}
|
||||
if (empty($param['check_status'])) {
|
||||
$this->apiError("发票状态不能为空");
|
||||
}
|
||||
$param['check_status'] = 5;
|
||||
$param['update_time'] = time();
|
||||
add_log('tovoid', $param['id'],$param,'发票');
|
||||
$res = Invoice::where('id', $param['id'])->strict(false)->field('check_status')->update($param);
|
||||
if ($res !== false) {
|
||||
add_log('novoid', $param['id'],$param,'发票');
|
||||
$this->apiSuccess('操作成功');
|
||||
} else {
|
||||
$this->apiError("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue