|
|
@ -1,6 +1,7 @@ |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Hangfire; |
|
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
|
using SettleAccount.Bases; |
|
|
@ -39,14 +40,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
PUB_CAN_SA_MNG pubMng, |
|
|
|
BBAC_CAN_SA_MNG bbacMng, |
|
|
|
HBPO_CAN_SA_MNG hbpoMng, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INormalEfCoreRepository<INVOICE_GRP, Guid> repository, |
|
|
|
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository, |
|
|
|
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository, |
|
|
|
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository, |
|
|
|
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository |
|
|
|
INormalEfCoreRepository<INVOICE_GRP, Guid> repository, |
|
|
|
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository, |
|
|
|
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository, |
|
|
|
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository, |
|
|
|
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> adjRepository |
|
|
|
) |
|
|
|
{ |
|
|
|
//_canRepository = canRepository;
|
|
|
@ -136,12 +134,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
public virtual async Task<bool> SetForwardState(INVOICE_GRP p_entiy, SettleBillState p_State) |
|
|
|
{ |
|
|
|
if (p_entiy.InvoiceState == InvoiceBillState.报废) |
|
|
|
{ |
|
|
|
throw new BusinessException("8989", "当前发票已报废不能进行操作"); |
|
|
|
} |
|
|
|
|
|
|
|
var state = p_State; |
|
|
|
switch (p_State) |
|
|
|
{ |
|
|
|
case SettleBillState.财务已审核: |
|
|
|
if (p_entiy.State == SettleBillState.商务已审核) |
|
|
|
{ |
|
|
|
|
|
|
|
p_entiy.State = state; |
|
|
|
} |
|
|
|
else |
|
|
@ -170,8 +174,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var flag = await SetSettleState(p_entiy, p_State, true); |
|
|
|
if (flag == true) |
|
|
|
{ |
|
|
@ -434,12 +436,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
/// <returns></returns>
|
|
|
|
public virtual async Task<bool> Reject(string groupbillNum) |
|
|
|
{ |
|
|
|
|
|
|
|
var _ls = await _repository.Where(p => p.InvGroupNum == groupbillNum).ToListAsync(); |
|
|
|
|
|
|
|
if (_ls != null && _ls.Count > 0) |
|
|
|
var ls = await _repository.Where(p => p.InvGroupNum == groupbillNum).ToListAsync(); |
|
|
|
if (ls != null && ls.Count > 0) |
|
|
|
{ |
|
|
|
foreach (var p_entity in _ls) |
|
|
|
var first = ls.FirstOrDefault(); |
|
|
|
if(first.State==SettleBillState.客户已收票 || first.State== SettleBillState.已扣减) |
|
|
|
{ |
|
|
|
throw new BusinessException("8989",$"发票分组{groupbillNum}客户已经是客户已收票或已扣减状态不能退回"); |
|
|
|
} |
|
|
|
foreach (var p_entity in ls) |
|
|
|
{ |
|
|
|
if (p_entity.State == SettleBillState.财务已审核 |
|
|
|
|| p_entity.State == SettleBillState.已开票 || p_entity.State == SettleBillState.商务已审核) |
|
|
@ -448,26 +453,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
var groupList = _groupRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); |
|
|
|
var notList = _notRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); |
|
|
|
var detailList = _detailRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); |
|
|
|
//var canList = _canRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList();
|
|
|
|
//foreach (var itm in canList)
|
|
|
|
//{
|
|
|
|
// itm.State = SettleBillState.未结状态;
|
|
|
|
//}
|
|
|
|
await _repository.DbContext.BulkDeleteAsync(entList); |
|
|
|
await _repository.DbContext.BulkDeleteAsync(groupList); |
|
|
|
await _repository.DbContext.BulkDeleteAsync(notList); |
|
|
|
await _repository.DbContext.BulkDeleteAsync(detailList); |
|
|
|
if (first.BusinessType == EnumBusinessType.JisBBAC) |
|
|
|
{ |
|
|
|
await _bbacMng.SetNewState(groupbillNum); |
|
|
|
} |
|
|
|
else if (first.BusinessType == EnumBusinessType.JisHBPO) |
|
|
|
{ |
|
|
|
await _hbpoMng.SetNewState(groupbillNum); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
await _pubMng.SetNewState(groupbillNum); |
|
|
|
} |
|
|
|
//await _repository.DbContext.BulkUpdateAsync(canList);
|
|
|
|
} |
|
|
|
if (p_entity.State == SettleBillState.已扣减) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
|
throw new BusinessException("8989",$"查询不到发票分组号为{groupbillNum}发票分组"); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
@ -892,7 +901,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dtos"></param>
|
|
|
|
/// <param name="p_OldInvBillNum"></param>
|
|
|
|
/// <param name="p_version"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
public async Task<bool> ReissueFirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, string p_OldInvBillNum, int p_version) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(p_OldInvBillNum)) |
|
|
@ -914,6 +930,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dtos"></param>
|
|
|
|
/// <param name="p_OldInvBillNum"></param>
|
|
|
|
/// <param name="p_version"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
public async Task<bool> ReissueSecInvoice(List<TEMP_CAN_SA_DETAIL> dtos, string p_OldInvBillNum, int p_version) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(p_OldInvBillNum)) |
|
|
|