|
|
@ -11,6 +11,7 @@ using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Auditing; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
@ -55,7 +56,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
_hbpoMng = hbpoMng; |
|
|
|
|
|
|
|
} |
|
|
|
public virtual async Task<bool> SetForwardState(string p_groupBillnum , InvoiceBillState p_State) |
|
|
|
public virtual async Task<bool> SetForwardState(string p_groupBillnum , SettleBillState p_State) |
|
|
|
{ |
|
|
|
var _first=_repository.Where(p => p.InvbillNum == p_groupBillnum).FirstOrDefault(); |
|
|
|
if (_first != null) |
|
|
@ -65,15 +66,178 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private async Task<bool> SetSettleState(INVOICE_GRP p_entiy, SettleBillState p_State,bool IsForward=true) |
|
|
|
{ |
|
|
|
if (p_entiy.BusinessType == EnumBusinessType.BeiJian || |
|
|
|
p_entiy.BusinessType == EnumBusinessType.YingDuJian || |
|
|
|
p_entiy.BusinessType == EnumBusinessType.MaiDanJian || |
|
|
|
p_entiy.BusinessType == EnumBusinessType.ZhiGongJian |
|
|
|
) |
|
|
|
{ |
|
|
|
bool isSucc = false; |
|
|
|
if (IsForward == true) |
|
|
|
{ |
|
|
|
isSucc = await _pubMng.SetForwardState(p_entiy.InvGroupNum, p_State); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
isSucc = await _pubMng.SetBackwardState(p_entiy.InvGroupNum, p_State); |
|
|
|
} |
|
|
|
return isSucc; |
|
|
|
} |
|
|
|
else if (p_entiy.BusinessType == EnumBusinessType.BBAC) |
|
|
|
{ |
|
|
|
bool isSucc = false; |
|
|
|
if (IsForward == true) |
|
|
|
{ |
|
|
|
isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, p_State); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, p_State); |
|
|
|
} |
|
|
|
//switch ((int)p_State)
|
|
|
|
//{
|
|
|
|
// case (int)SettleBillState.财务已审核:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case (int)SettleBillState.商务已审核:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case (int)SettleBillState.已开票:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
|
|
|
|
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case (int)SettleBillState.客户已收票:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case (int)SettleBillState.已扣减:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
//}
|
|
|
|
return isSucc; |
|
|
|
|
|
|
|
} |
|
|
|
else if (p_entiy.BusinessType == EnumBusinessType.HBPO) |
|
|
|
{ |
|
|
|
bool isSucc = false; |
|
|
|
|
|
|
|
public virtual async Task<bool> SetForwardState(INVOICE_GRP p_entiy, InvoiceBillState p_State) |
|
|
|
if (IsForward == true) |
|
|
|
{ |
|
|
|
isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, p_State); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, p_State); |
|
|
|
} |
|
|
|
//switch ((int)p_State)
|
|
|
|
//{
|
|
|
|
// case (int)SettleBillState.财务已审核:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case (int)SettleBillState.商务已审核:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case (int)SettleBillState.已开票:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
|
|
|
|
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case (int)SettleBillState.客户已收票:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case (int)SettleBillState.已扣减:
|
|
|
|
// if (IsForward == true)
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
//}
|
|
|
|
return isSucc; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 向前流程
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_entiy"></param>
|
|
|
|
/// <param name="p_State"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
public virtual async Task<bool> SetForwardState(INVOICE_GRP p_entiy, SettleBillState p_State) |
|
|
|
{ |
|
|
|
var state = p_State; |
|
|
|
switch (p_entiy.State) |
|
|
|
{ |
|
|
|
case InvoiceBillState.财务已审核: |
|
|
|
if (state == InvoiceBillState.商务已审核) |
|
|
|
case SettleBillState.财务已审核: |
|
|
|
if (state == SettleBillState.商务已审核) |
|
|
|
{ |
|
|
|
p_entiy.State = state; |
|
|
|
} |
|
|
@ -82,8 +246,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case InvoiceBillState.商务已审核: |
|
|
|
if (state == InvoiceBillState.已开票) |
|
|
|
case SettleBillState.商务已审核: |
|
|
|
if (state == SettleBillState.已开票) |
|
|
|
{ |
|
|
|
p_entiy.State = state; |
|
|
|
} |
|
|
@ -92,8 +256,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case InvoiceBillState.已扣减: |
|
|
|
if (state == InvoiceBillState.客户已收票) |
|
|
|
case SettleBillState.已扣减: |
|
|
|
if (state == SettleBillState.客户已收票) |
|
|
|
{ |
|
|
|
p_entiy.State = state; |
|
|
|
} |
|
|
@ -103,12 +267,79 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var flag= await SetSettleState(p_entiy, p_State,true); |
|
|
|
if (flag == true) |
|
|
|
{ |
|
|
|
await _repository.UpdateAsync(p_entiy); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 向后流程
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_entiy"></param>
|
|
|
|
/// <param name="p_State"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <exception cref="BusinessException"></exception>
|
|
|
|
public virtual async Task<bool> SetBackwardState(INVOICE_GRP p_entiy, SettleBillState p_State) |
|
|
|
{ |
|
|
|
var state = p_State; |
|
|
|
switch (p_entiy.State) |
|
|
|
{ |
|
|
|
case SettleBillState.商务已审核: |
|
|
|
if (state == SettleBillState.财务已审核) |
|
|
|
{ |
|
|
|
p_entiy.State = state; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case SettleBillState.已开票: |
|
|
|
if (state == SettleBillState.商务已审核) |
|
|
|
{ |
|
|
|
p_entiy.State = state; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case SettleBillState.客户已收票: |
|
|
|
if (state == SettleBillState.已扣减) |
|
|
|
{ |
|
|
|
p_entiy.State = state; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw new BusinessException("8989", "当前状态不是【已扣减】状态,无法设置成【客户已收票】状态"); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var flag = await SetSettleState(p_entiy, p_State,false); |
|
|
|
if (flag == false) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
await _repository.UpdateAsync(p_entiy); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获得发票主表
|
|
|
|
/// </summary>
|
|
|
@ -304,8 +535,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
{ |
|
|
|
foreach (var p_entity in _ls) |
|
|
|
{ |
|
|
|
if (p_entity.State == InvoiceBillState.财务已审核 |
|
|
|
|| p_entity.State == InvoiceBillState.已开票 || p_entity.State == InvoiceBillState.商务已审核) |
|
|
|
if (p_entity.State == SettleBillState.财务已审核 |
|
|
|
|| p_entity.State == SettleBillState.已开票 || p_entity.State == SettleBillState.商务已审核) |
|
|
|
{ |
|
|
|
var entList = _repository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); |
|
|
|
var groupList = _groupRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); |
|
|
@ -325,7 +556,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
if (p_entity.State == InvoiceBillState.已扣减) |
|
|
|
if (p_entity.State == SettleBillState.已扣减) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
@ -349,7 +580,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers |
|
|
|
/// </summary>
|
|
|
|
/// <param name="billNum"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public virtual async Task<bool> Back(string billNum) |
|
|
|
public virtual async Task<bool> BackAsync(string billNum) |
|
|
|
{ |
|
|
|
|
|
|
|
var _ls = await _repository.Where(p => p.InvGroupNum == billNum).ToListAsync(); |
|
|
|