Browse Source

更新代码

master
学 赵 1 year ago
parent
commit
42916a5859
  1. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs
  2. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs
  3. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs
  4. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  5. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  6. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  7. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  8. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  9. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  10. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
  11. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  12. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
  13. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs
  14. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_NOT_SA_DETAIL.cs
  15. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs
  16. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_NOT_SA_DETAIL.cs
  17. 27
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs
  18. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs
  19. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
  20. 374
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  21. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs
  22. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs
  23. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs
  24. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_NOT_SA_DETAIL.cs
  25. 1
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs

21
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs

@ -13,6 +13,7 @@ using Win.Sfs.Shared.Filter;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
{
[Display(Name = "发票")]
public class INVOICE_GRP_DTO : EntityDto<Guid>
{
[Display(Name = "期间")]
@ -38,6 +39,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "税后金额")]
public decimal TaxAmt { get; set; }
[Display(Name = "金税发票税后金额")]
public decimal RealAmt { get; set; }
/// <summary>
///发票分组号
/// </summary>
@ -53,10 +57,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "业务类别")]
public EnumBusinessType BusinessType { get; set; }
/// <summary>
/// 发票状态
/// </summary>
public int State { set; get; }
[Display(Name = "状态")]
public SettleBillState State { get; set; }
[Display(Name = "发票状态")]
public InvoiceBillState InvoiceState { get; set; }
[Display(Name = "发票税后尾差")]
public decimal TaxDiff { get; set; }
[Display(Name = "客户代码")]
public string ClientCode { get; set; }
}

6
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_ADJ_DETAIL_DTO.cs

@ -78,6 +78,12 @@ public class PUB_ADJ_DETAIL_IMP_DTO
public DateTime SettleDate { get; set; }
[ImporterHeader(Name = "零件号")]
public string LU { get; set; }
[ImporterHeader(Name = "厂内零件号")]
public string PartCode { get; set; }
[ImporterHeader(Name = "标识号")]
public string PN { get; set; }
[ImporterHeader(Name = "数量")]

6
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/ADJ_SERVICE.cs

@ -129,7 +129,11 @@ public class ADJ_SERVICE : BASE_SERVICE
businessType: itm1.BusinessType,
groupNum: itm.GroupNum,
oldinv: itm.InvBillNum,
inv: string.Empty);
inv: string.Empty,
partcode:itm.PartCode
);
await _repository.DbContext.BulkDeleteAsync(deletels);//删除发票下所有调整明细
await _repository.DbContext.BulkInsertAsync(query.ToList());
return ApplicationConsts.SuccessStr;

15
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs

@ -62,10 +62,6 @@ namespace Win.Sfs.SettleAccount.Bases
protected readonly INV_MNG _invMng;
private readonly TaskJobService _service;
protected BA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
@ -102,10 +98,10 @@ namespace Win.Sfs.SettleAccount.Bases
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public virtual async Task<string> GenerateInvoice(INVOICE_GRP_REQ_DTO input)
public virtual async Task<string> GenerateInvoice(List<string> p_invs)
{
await _invMng.SetForwardState(input.InvGroupNum, SettleBillState.);
await _invMng.SetForwardState(p_invs, SettleBillState.);
return ApplicationConsts.SuccessStr;
}
@ -212,6 +208,7 @@ namespace Win.Sfs.SettleAccount.Bases
[UnitOfWork(false)]
public virtual async Task<string> ReceivedAsync(List<string> p_ins)
{
await _invMng.ReceivedAsync(p_ins);
return ApplicationConsts.SuccessStr;
}
@ -300,7 +297,7 @@ namespace Win.Sfs.SettleAccount.Bases
return true;
}
throw new BusinessException("8989", "生成失败,请检查调整表和旧发票内容");
throw new BusinessException("8989", "生成失败,请检查调发票整表和旧发票内容");
}
@ -317,16 +314,12 @@ namespace Win.Sfs.SettleAccount.Bases
/// <returns></returns>
protected async Task<bool> ReissueFirstInvoice<TDetail>(List<TDetail> p_list,List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_parentInvBillNum) where TDetail : SA_CAN_BASE
{
var flag = await _invMng.ReissueFirstInvoice(p_list,p_adjlist,dtos, p_parentInvBillNum, p_version);
if (flag==true)
{
return true;
}
throw new BusinessException("8989", "生成失败,请检查调整表和旧发票内容");
}

8
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs

@ -51,11 +51,9 @@ namespace Win.Sfs.SettleAccount.Bases
{
protected readonly INormalEfCoreRepository<TEntity, Guid> _repository;
protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService;
private readonly IExcelImportAppService _excelImportService;
protected readonly INV_MNG _invmng;
protected CAN_SA_SERVICE(
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
@ -82,12 +80,10 @@ namespace Win.Sfs.SettleAccount.Bases
//[Route("detailquery")]
public virtual async Task<PagedResultDto<TEntityDetailDto>> DetailQueryAsync(TRequestDetailInput input)
{
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount);
var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters);
var dtos = ObjectMapper.Map<List<TEntityDetail>, List<TEntityDetailDto>>(entitys);
return new PagedResultDto<TEntityDetailDto>(totalCount, dtos);
}
/// <summary>
/// 导出
@ -195,8 +191,6 @@ namespace Win.Sfs.SettleAccount.Bases
return true;
}
throw new BusinessException("8989", "生成失败,请检可结算单明细数据是否结算分组存在");
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs

@ -76,7 +76,7 @@ namespace Win.Sfs.SettleAccount.Bases
//[Route("detailquery")]
public virtual async Task<PagedResultDto<TEntityDetailDto>> DetailQueryAsync(TRequestDetailInput input)
{
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount);
var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters);
var dtos = ObjectMapper.Map<List<TEntityDetail>, List<TEntityDetailDto>>(entitys);
@ -94,10 +94,8 @@ namespace Win.Sfs.SettleAccount.Bases
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var dtoDetails = ObjectMapper.Map<List<TEntityDetail>, List<TEntityDetailExportDto>>(entities);
var classDisplayName = typeof(TEntityDetailExportDto).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(TEntityDetailExportDto).Name;
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx";
byte[] result = null;

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs

@ -110,7 +110,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum:string.Empty
invbillnum:string.Empty,
partcode:itm.PartCode
));
}
}

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs

@ -96,7 +96,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty
invbillnum: string.Empty,
partcode:itm.PartCode
));
}
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -80,10 +80,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public virtual async Task<string> ApprovalPassed(INVOICE_GRP_REQ_DTO input)
public virtual async Task<string> ApprovalPassed(List<string> p_invs)
{
var inv = _repository.Where(p => p.InvGroupNum == input.InvGroupNum).FirstOrDefault();
await _invMng.SetForwardState(inv, SettleBillState.);
await _invMng.SetForwardState(p_invs, SettleBillState.);
return ApplicationConsts.SuccessStr;
}
@ -257,6 +257,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<INVOICE_GRP_IMP_DTO>(files, _excelImportService);
var ls = ObjectMapper.Map<List<INVOICE_GRP_IMP_DTO>, List<INVOICE_GRP>>(result);
var namelist = ls.Select(p => p.InvbillNum).Distinct();
var invlist = _repository.Where(p => namelist.Contains(p.InvbillNum)).ToList();

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs

@ -96,7 +96,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: string.Empty
invbillnum: string.Empty,
partcode:itm.PartCode
));
}

5
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -123,8 +123,6 @@ namespace Win.Sfs.SettleAccount
#endregion
#region 派格
CreateMapInvoice();
CreateMapInvoiceVersion();
@ -137,7 +135,6 @@ namespace Win.Sfs.SettleAccount
CreateMapUnHQSettleAccountVersion();
#endregion
CreateMapPURCHASE_PRICE();
CreateMapTB_RePartsRelationship();
@ -198,8 +195,6 @@ namespace Win.Sfs.SettleAccount
CreateMapPUB_ADJ_DETAIL();
CreateMapBBAC_PD();
CreateMapBBAC_PD_DETAIL();

9
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs

@ -430,6 +430,10 @@ namespace SettleAccount.Bases
public string InvbillNum { get; set; }
[Display(Name = "厂内零件号")]
public string PartCode { get; set; }
//public SA_CAN_BASE(int version, decimal price, string billNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum)
//{
// Version = version;
@ -496,7 +500,10 @@ namespace SettleAccount.Bases
/// 結算分組號
/// </summary>
public string GroupNum { get; set; }
public string PartCode { get; set; }
//public SA_NOT_BASE(decimal price, int version, string settleBillNum, DateTime settleDate, string invGroupNum, string lU, string pN, string keyCode, decimal qty, string groupNum)
//{
// Price = price;

10
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs

@ -113,10 +113,14 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE
public bool IsReturn { get; set; } =false;
[Display(Name="合同号")]
public string ContractDocID { get; set; }
/// <summary>
/// 对应字段PostingDate
/// </summary>
@ -139,11 +143,11 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE
public BBAC_CAN_SA_DETAIL(Guid guid,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn,
DateTime settleDate, string groupNum, string invGroupNum
,string contactid,string invbillnum
,string contactid,string invbillnum,string partcode
):base(guid)
{
InvbillNum = invbillnum;
PartCode=partcode;
KeyCode = keyCode;
Version = version;
BillNum = billNum;

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_NOT_SA_DETAIL.cs

@ -92,7 +92,7 @@ public class BBAC_NOT_SA_DETAIL:SA_NOT_BASE
}
public BBAC_NOT_SA_DETAIL(Guid guid, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn, string invGroupNum, DateTime settleDate, string groupNum,string contractDocID)
public BBAC_NOT_SA_DETAIL(Guid guid, string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, bool isReturn, string invGroupNum, DateTime settleDate, string groupNum,string contractDocID,string partcode)
{
Id = guid;
@ -110,5 +110,6 @@ public class BBAC_NOT_SA_DETAIL:SA_NOT_BASE
SettleDate = settleDate;
GroupNum = groupNum;
ContractDocID = contractDocID;
PartCode = partcode;
}
}

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_CAN_SA.cs

@ -124,7 +124,7 @@ public class HBPO_CAN_SA_DETAIL:SA_CAN_BASE
/// </summary>
public EnumBusinessType BusinessType { get; set; }
public HBPO_CAN_SA_DETAIL(Guid guid ,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType, string invbillnum)
public HBPO_CAN_SA_DETAIL(Guid guid ,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType, string invbillnum,string partcode)
{
InvbillNum=invbillnum;
Id = guid;
@ -141,6 +141,7 @@ public class HBPO_CAN_SA_DETAIL:SA_CAN_BASE
GroupNum = groupNum;
InvGroupNum = invGroupNum;
BusinessType = businessType;
PartCode = partcode;
}
public HBPO_CAN_SA_DETAIL()

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/HBPO_NOT_SA_DETAIL.cs

@ -99,7 +99,7 @@ public class HBPO_NOT_SA_DETAIL :SA_NOT_BASE
public EnumBusinessType BusinessType { get; set; }
public HBPO_NOT_SA_DETAIL(Guid guid ,string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType)
public HBPO_NOT_SA_DETAIL(Guid guid ,string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, DateTime settleDate, string groupNum, string invGroupNum, EnumBusinessType businessType,string partcode)
{
Id = guid;
KeyCode = keyCode;
@ -114,6 +114,7 @@ public class HBPO_NOT_SA_DETAIL :SA_NOT_BASE
GroupNum = groupNum;
InvGroupNum = invGroupNum;
BusinessType = businessType;
PartCode = partcode;
}
public HBPO_NOT_SA_DETAIL()

27
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs

@ -45,9 +45,28 @@ public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
[Display(Name = "发票状态")]
public InvoiceBillState InvoiceState { get; set; }
[Display(Name = "发票未税尾差")]
public decimal PreTaxDiff { get; set; }
[Display(Name = "发票税后尾差")]
public decimal TaxDiff { get; set; }
[Display(Name = "客户代码")]
public string ClientCode { get; set; }
[Display(Name = "实际发票金额")]
public decimal RealAmt { get; set; }
public INVOICE_GRP(Guid guid, string realnvBillNum, string invbillNum, decimal amt, decimal taxAmt, string invGroupNum, string fileName, EnumBusinessType businessType, SettleBillState state,InvoiceBillState invoiceBillState,decimal tax,string parent)
public INVOICE_GRP(Guid guid, string realnvBillNum, string invbillNum, decimal amt, decimal taxAmt,
string invGroupNum,
string fileName,
EnumBusinessType businessType,
SettleBillState state,
InvoiceBillState invoiceBillState,
decimal tax,
string parent, decimal preTaxDiff, decimal taxDiff, string clientCode,decimal realAmt
)
{
Id= guid;
RealnvBillNum = realnvBillNum;
@ -61,7 +80,11 @@ public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
InvoiceState = invoiceBillState;
ParentInvbillNum = parent;
Tax = tax;
PreTaxDiff= preTaxDiff;
TaxDiff= taxDiff;
ClientCode = clientCode;
RealAmt = realAmt;
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs

@ -70,7 +70,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
groupNum: itm.GroupNum,
invGroupNum: billNumber,
contactid: itm.ContractDocID,
invbillnum: string.Empty
invbillnum: string.Empty,
partcode:itm.PartCode
);
_entityList.Add(_detailEntity);

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs

@ -73,7 +73,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
qty: itm.Qty,
settleDate: itm.SettleDate,
site: itm.Site,
invbillnum: string.Empty
invbillnum: string.Empty,
partcode:itm.PartCode
);
_entityList.Add(_detailEntity);
}

374
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

@ -76,16 +76,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
}
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)
{
return await SetForwardState(_first, p_State);
}
return false;
//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)
// {
// return await SetForwardState(_first, p_State);
// }
// return false;
}
//}
private async Task<bool> SetSettleState(INVOICE_GRP p_entiy, SettleBillState p_State, bool IsForward = true)
{
@ -140,67 +140,99 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return false;
}
/// <summary>
/// 向前流程
/// 发票向前流程
/// </summary>
/// <param name="p_entiy"></param>
/// <param name="invs"></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)
public virtual async Task<bool> SetForwardState(List<string> p_invs, SettleBillState p_State)
{
if (p_entiy.InvoiceState == InvoiceBillState.)
{
throw new BusinessException("8989", "当前发票已报废不能进行操作");
}
var state = p_State;
switch (p_State)
List<string> errors = new List<string>();
var appls = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();
if (appls.Count > 0)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
var count = appls.Select(p => p.State).Distinct().Count();
if (count > 1)
{
throw new UserFriendlyException($"提交发票状态不一致");
}
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【客户已收票】状态,无法设置成【已扣减】状态");
}
break;
}
var flag = await SetSettleState(p_entiy, p_State, true);
if (flag == true)
{
var invlist = await _repository.Where(p => p.InvGroupNum == p_entiy.InvGroupNum).ToListAsync();//选择审批时只能整组审批
foreach (var itm in invlist)
var nols = appls.Where(p => p.InvoiceState == InvoiceBillState. || p.State == SettleBillState.).ToList();
if (nols.Count > 0)
{
itm.State = p_entiy.State;
var invs = nols.Select(p => p.InvbillNum);
throw new UserFriendlyException($"选择发票{string.Join("", invs)}已报废或者已收票不能进行操作");
}
await _repository.BatchUpdateAsync(invlist);
var state = p_State;
switch (p_State)
{
case SettleBillState.:
foreach (var inv in appls)
{
if (inv.State == SettleBillState.)
{
inv.State = state;
}
else
{
errors.Add(inv.InvbillNum);
}
}
if (errors.Count > 0)
{
throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
foreach (var inv in appls)
{
if (inv.State == SettleBillState.)
{
inv.State = state;
}
else
{
errors.Add(inv.InvbillNum);
}
}
if (errors.Count > 0)
{
throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【已开票】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
foreach (var inv in appls)
{
if (inv.State == SettleBillState.)
{
inv.State = state;
}
else
{
errors.Add(inv.InvbillNum);
}
}
if (errors.Count > 0)
{
throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【客户已收票】,无法设置成【已扣减】状态");
}
break;
}
await _repository.BatchUpdateAsync(appls);
return true;
}
return false;
else
{
throw new UserFriendlyException($"选择发票不存在");
}
}
/// <summary>
@ -210,58 +242,94 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <param name="p_State"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetBackwardState(INVOICE_GRP p_entiy, SettleBillState p_State)
public virtual async Task<bool> SetBackwardState(List<string> p_invs, SettleBillState p_State)
{
var state = p_State;
switch (state)
List<string> errors = new List<string>();
var appls = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();
if (appls.Count > 0)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已扣减】状态,无法设置成【客户已收票】状态");
}
break;
}
//var flag = await SetSettleState(p_entiy, p_State, false);
var count = appls.Select(p => p.State).Distinct().Count();
if (count > 1)
{
throw new UserFriendlyException($"提交发票状态不一致");
}
var nols = appls.Where(p => p.InvoiceState == InvoiceBillState. || p.State == SettleBillState.).ToList();
if (nols.Count > 0)
{
var invs = nols.Select(p => p.InvbillNum);
throw new UserFriendlyException($"选择发票{string.Join("", invs)}已报废或者已收票不能进行操作");
}
var state = p_State;
switch (p_State)
{
case SettleBillState.:
foreach (var inv in appls)
{
if (inv.State == SettleBillState.)
{
inv.State = state;
}
else
{
errors.Add(inv.InvbillNum);
}
}
if (errors.Count > 0)
{
throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
//if (flag == true)
//{
// var invlist = await _repository.Where(p => p.InvGroupNum == p_entiy.InvGroupNum).ToListAsync();//选择审批时只能整组审批
// foreach (var itm in invlist)
// {
// itm.State = p_entiy.State;
// }
foreach (var inv in appls)
{
if (inv.State == SettleBillState.)
{
inv.State = state;
}
else
{
errors.Add(inv.InvbillNum);
}
}
if (errors.Count > 0)
{
throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【商务已审核】,无法设置成【已开票】状态");
}
break;
case SettleBillState.:
foreach (var inv in appls)
{
await _repository.BatchUpdateAsync(p_entiy);
if (inv.State == SettleBillState.)
{
inv.State = state;
}
else
{
errors.Add(inv.InvbillNum);
}
}
if (errors.Count > 0)
{
throw new UserFriendlyException($"发票{string.Join(",", errors)}当前状态不是【已扣减】,无法设置成【客户已收票】状态");
}
break;
}
await _repository.BatchUpdateAsync(appls);
return true;
//}
}
else
{
throw new UserFriendlyException($"选择发票不存在");
}
}
@ -316,16 +384,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
throw new UserFriendlyException($"发票不属于一个发票分组");
}
var lostlist = invList.Where(p => p.InvoiceState == InvoiceBillState.).ToList();
var lostlist = invList.Where(p => p.InvoiceState == InvoiceBillState. || p.State ==SettleBillState.).ToList();
if (lostlist.Count > 0)
{
var invs=lostlist.Select(p => p.InvbillNum).ToList();
throw new UserFriendlyException($"发票{string.Join(",",invs)}");
throw new UserFriendlyException($"发票{string.Join(",",invs)}已经报废或客户已收票!");
}
var inv = invList.FirstOrDefault();
if (inv.BusinessType == EnumBusinessType.JisBBAC)
{
@ -350,8 +414,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
oldlist = pdoldlist.Select(p => p.BillNum).ToList();//已经存在扣减记录,的发票号
}
newlist = p_invs.Where(p => !oldlist.Contains(p)).ToList();//不存在扣减记录的发票号
List<BBAC_CAN_SA_DETAIL> entityList = new List<BBAC_CAN_SA_DETAIL>();//结算明细
var namelist = invList.Select(p => p.InvbillNum).ToList();
if (oldlist.Count > 0)
@ -381,7 +443,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: itm.InvBillNum
invbillnum: itm.InvBillNum,
partcode:itm.PartCode
));
}
@ -413,16 +476,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
contactid: itm.Extend1,//生产号
invbillnum: itm.InvBillNum
invbillnum: itm.InvBillNum,
partcode:itm.PartCode
));
}
}
entityList.AddRange(entityDetail);
}
var bbacmainlist = new List<BBAC_PD>();
foreach (var itm in invList)
{
@ -465,8 +525,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
await _repository.DbContext.BulkInsertAsync(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
foreach (var itm in invList)
{
itm.State = SettleBillState.;
};
await _repository.DbContext.BulkUpdateAsync(invList);
return true;
}
@ -523,7 +587,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
invbillnum: itm.InvBillNum,
partcode:itm.PartCode
));
}
@ -553,14 +619,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
invbillnum: itm.InvBillNum,
partcode: itm.PartCode
));
}
}
entityList.AddRange(entityDetail);
}
var bbacmainlist = new List<HBPO_PD>();
foreach (var itm in invList)
{
@ -603,6 +669,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
await _repository.DbContext.BulkInsertAsync(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
foreach (var itm in invList)
{
itm.State = SettleBillState.;
};
await _repository.DbContext.BulkUpdateAsync(invList);
return true;
}
else
@ -656,7 +728,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
invbillnum: itm.InvBillNum,
partcode:itm.PartCode
));
}
@ -686,7 +760,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: itm.InvGroupNum,
invbillnum: itm.InvBillNum
invbillnum: itm.InvBillNum,
partcode: itm.PartCode
));
}
}
@ -737,10 +812,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
await _repository.DbContext.BulkInsertAsync(bbacmainlist);
await _repository.DbContext.BulkInsertAsync(bbacDetail);
foreach (var itm in invList)
{
itm.State = SettleBillState.;
};
await _repository.DbContext.BulkUpdateAsync(invList);
return true;
}
return false;
}
public virtual async Task<bool> Reject(INVOICE_GRP p_entity)
{
@ -751,19 +833,34 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return false;
}
/// <summary>
/// 退回
/// 同一退回
/// </summary>
/// <param name="billNum">发票分组号</param>
/// <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 count=ls.Select(p => p.State).Distinct().Count();
if (count > 1)
{
throw new UserFriendlyException($"发票分组{groupbillNum}包含发票不是同一状态不能退回");
}
var first = ls.FirstOrDefault();
if (first.State == SettleBillState. || first.State == SettleBillState.)
{
throw new BusinessException("8989", $"发票分组{groupbillNum}客户已经是客户已收票或已扣减状态不能退回");
throw new UserFriendlyException( $"发票分组{groupbillNum}客户已经是客户已收票不能退回");
}
foreach (var p_entity in ls)
{
@ -1043,8 +1140,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
invGroupNum: p_InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: p_parentInvBillNum
tax: 0,
parent: p_parentInvBillNum,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
);
invlist.Add(invbill);
}
@ -1191,7 +1292,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
itm.InvbillNum = key;
salist.Add(itm);
}
if (!string.IsNullOrEmpty(p_parentInvBillNum))
if (!string.IsNullOrEmpty(p_parentInvBillNum))//发票作废开票
{
var query1 = from itm in dtos
join itm1 in ls
@ -1270,7 +1371,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: p_parentInvBillNum
parent: p_parentInvBillNum,
preTaxDiff:0,
taxDiff:0,
clientCode:string.Empty,
realAmt:0
);
invlist.Add(invbill);
}
@ -1480,7 +1586,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
parent: string.Empty,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
);
invlist.Add(invbill);
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs

@ -67,11 +67,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
qty: itm.Qty,
price: itm.Price,
businessType: itm.BusinessType,
settleDate: itm.SettleDate,
groupNum: itm.GroupNum,
invGroupNum: billNumber,
invbillnum: string.Empty
invbillnum: string.Empty,
partcode:itm.PartCode
);
_entityList.Add(_detailEntity);

5
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_ADJ_DETAIL.cs

@ -70,10 +70,10 @@ public class PUB_ADJ_DETAIL : SA_NOT_BASE
[Display(Name = "发票号")]
public string InvBillNum { get; set; }
public PUB_ADJ_DETAIL(Guid id, string keyCode, int version, string settleBillNum, string lU, string pN,
string site, decimal qty, string extend1, decimal price, string invGroupNum, DateTime settleDate,
EnumBusinessType businessType, string groupNum,string oldinv,string inv)
EnumBusinessType businessType, string groupNum,string oldinv,string inv,string partcode)
{
Id= id;
KeyCode = keyCode;
@ -91,6 +91,7 @@ public class PUB_ADJ_DETAIL : SA_NOT_BASE
GroupNum = groupNum;
OldInvBillNum= oldinv;
InvBillNum = inv;
PartCode = partcode;
}
public PUB_ADJ_DETAIL()

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_CAN_SA.cs

@ -118,7 +118,7 @@ public class PUB_CAN_SA_DETAIL : SA_CAN_BASE
//[Display(Name = "结算分组")]
//public string GroupNum { get; set; } = null!;
public PUB_CAN_SA_DETAIL(Guid guid, string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType,
public PUB_CAN_SA_DETAIL(Guid guid, string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType,string partcode,
string groupNum,
string invbillnum
)
@ -138,6 +138,7 @@ public class PUB_CAN_SA_DETAIL : SA_CAN_BASE
SettleDate = settleDate;
BusinessType = businessType;
GroupNum = groupNum;
PartCode = partcode;
}
public PUB_CAN_SA_DETAIL()

5
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_NOT_SA_DETAIL.cs

@ -1,4 +1,4 @@
using SettleAccount.Bases;
using SettleAccount.Bases;
using System;
using System.ComponentModel.DataAnnotations;
using Win.Sfs.SettleAccount;
@ -70,7 +70,7 @@ public class PUB_NOT_SA_DETAIL : SA_NOT_BASE
//[Display(Name = "结算分组")]
//public string GroupNum { get; set; } = null!;
public PUB_NOT_SA_DETAIL(string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, string extend1, string extend2, string extend3, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType, string groupNum)
public PUB_NOT_SA_DETAIL(string keyCode, int version, string settleBillNum, string lU, string pN, string site, decimal qty, string extend1, string extend2, string extend3, decimal price, string invGroupNum, DateTime settleDate, EnumBusinessType businessType, string groupNum,string partcode)
{
KeyCode = keyCode;
Version = version;
@ -87,6 +87,7 @@ public class PUB_NOT_SA_DETAIL : SA_NOT_BASE
SettleDate = settleDate;
BusinessType = businessType;
GroupNum = groupNum;
PartCode = partcode;
}
public PUB_NOT_SA_DETAIL()

1
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContext.cs

@ -15,6 +15,7 @@ namespace Win.Sfs.SettleAccount
: base(options)
{
this.Database.SetCommandTimeout(System.TimeSpan.FromMinutes(30));
}
protected override void OnModelCreating(ModelBuilder builder)

Loading…
Cancel
Save