Browse Source

修改发票导出问题,反结算修改

master
学 赵 1 year ago
parent
commit
4f94c61fb2
  1. 43
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  2. 27
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  3. 132
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs
  4. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

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

@ -136,23 +136,50 @@ namespace Win.Sfs.SettleAccount.Bases
[UnitOfWork(false)] [UnitOfWork(false)]
public virtual async Task<string> ApprovalPassed(List<string> p_list) public virtual async Task<string> ApprovalPassed(List<string> p_list)
{ {
return await InvokePD(p_list, _service, false); return await InvokePD(p_list, _service);
} }
[HttpPost] [HttpPost]
[UnitOfWork(false)] [UnitOfWork(false)]
public virtual async Task<string> RejectAsync(List<string> p_list) public virtual async Task<string> RejectAsync(List<string> p_list)
{ {
return await InvokePD(p_list, _service, true); return await InvokePD(p_list, _service);
} }
/// <summary>
/// 调用扣减
/// </summary>
/// <param name="p_list"></param>
/// <param name="p_service"></param>
/// <param name="isback"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false) protected async Task<string> InvokePD(List<string> p_list, TaskJobService p_service, bool isback=false)
{ {
var invlist=_repository.Where(p=>p_list.Contains(p.BillNum)).ToList();
var states= invlist.Select(p => p.State).Distinct().ToList();
if (states.Count > 1)
{
throw new UserFriendlyException($"发票不是同一状态", "400");
}
var first = invlist.FirstOrDefault();//发票状态
if(first.State != SettleBillState. && first.State != SettleBillState.)
{
throw new UserFriendlyException($"当前发票状态不是【客户已收票】或【已扣减状态】不能进行出库扣减或撤销扣减操作", "400");
}
if (first.State == SettleBillState.)
{
isback = false;
}
if(first.State==SettleBillState.)
{
isback = true;
}
var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList(); var detailist = _detailRepository.Where(p => p_list.Contains(p.BillNum)).ToList();
var first=detailist.FirstOrDefault(); var first1=detailist.FirstOrDefault();
List<CustomCondition> customConditionList = new List<CustomCondition>(); List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) }); customConditionList.Add(new CustomCondition() { Name = "BillNumList", Value = string.Join(",", p_list) });
customConditionList.Add(new CustomCondition() { Name = "Type", Value =first.BusinessType.ToString() }); customConditionList.Add(new CustomCondition() { Name = "Type", Value =first1.BusinessType.ToString() });
if (isback == false) if (isback == false)
{ {
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" }); customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "out" });
@ -161,7 +188,6 @@ namespace Win.Sfs.SettleAccount.Bases
{ {
customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "in" }); customConditionList.Add(new CustomCondition() { Name = "IsOut", Value = "in" });
} }
var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList(); var ls = _repository.Where(p => p_list.Contains(p.BillNum)).ToList();
var lst=new List<TEntity>(); var lst=new List<TEntity>();
if (isback == false) if (isback == false)
@ -172,8 +198,6 @@ namespace Win.Sfs.SettleAccount.Bases
{ {
lst = ls.Where(p => (p.State == SettleBillState.|| p.State == SettleBillState.)).ToList(); lst = ls.Where(p => (p.State == SettleBillState.|| p.State == SettleBillState.)).ToList();
} }
if (lst.Count() > 0) if (lst.Count() > 0)
{ {
throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400"); throw new UserFriendlyException("当前状态是已提交状态,不能重复已提交", "400");
@ -190,8 +214,7 @@ namespace Win.Sfs.SettleAccount.Bases
} }
} }
await _repository.DbContext.BulkUpdateAsync(ls); await _repository.DbContext.BulkUpdateAsync(ls);
var _taskid = await p_service.ExportEnqueueAsync($"{first1.BusinessType.ToString()}待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
var _taskid = await p_service.ExportEnqueueAsync($"{first.BusinessType.ToString()}待扣减任务", ExportExtentsion.Excel, DateTime.Now.ToString("yyyyMM"), string.Empty, CurrentUser, typeof(PendingDeductionService), customConditionList, (rs) =>
{ {
}); });

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

@ -298,8 +298,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public virtual async Task<INVOICE_GRP_DETAIL_DTO> DetailQueryAsync(INVOICE_GRP_REQ_DTO input) public virtual async Task<INVOICE_GRP_DETAIL_DTO> DetailQueryAsync(INVOICE_GRP_REQ_DTO input)
{ {
INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO(); INVOICE_GRP_DETAIL_DTO entity = new INVOICE_GRP_DETAIL_DTO();
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And));
var condition = input.Filters.FirstOrDefault(p => p.Column == "invbillNum");
if( condition==null )
{
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And));
}
var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false);
var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false);
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m); var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m);
var first = invs.FirstOrDefault(); var first = invs.FirstOrDefault();
@ -552,6 +560,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList();
return entity; return entity;
} }
[HttpPost] [HttpPost]
public virtual async Task<string> ExportAsync(INVOICE_GRP_REQ_DTO input) public virtual async Task<string> ExportAsync(INVOICE_GRP_REQ_DTO input)
{ {
@ -598,8 +612,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
IExporter _csv = new CsvExporter(); IExporter _csv = new CsvExporter();
ExcelExporter _excel = new ExcelExporter(); ExcelExporter _excel = new ExcelExporter();
// var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false); // var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false);
var condition = input.Filters.FirstOrDefault(p => p.Column == "invbillNum");
if (condition == null)
{
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And));
}
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false);
var first = entities.FirstOrDefault(); var first = entities.FirstOrDefault();
var dtoDetails = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_EXP_DTO>>(entities); var dtoDetails = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_EXP_DTO>>(entities);
var invdetail = await DetailQueryAsync(input).ConfigureAwait(false); var invdetail = await DetailQueryAsync(input).ConfigureAwait(false);

132
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/PendingDeductionService.cs

@ -199,97 +199,109 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
var _first = p_ls.FirstOrDefault(); var _first = p_ls.FirstOrDefault();
bool issucess = true; bool issucess = true;
using (var transaction = _dbcontext.Database.BeginTransaction()) using (var transaction = _dbcontext.Database.BeginTransaction())
{
try
{ {
// 执行批量数据操作 try
if (ls != null && ls.Count > 0)
{ {
var messagelist = new List<VmiMessage>(); // 执行批量数据操作
foreach (var item in ls) if (ls != null && ls.Count > 0)
{ {
var message = new VmiMessage var messagelist = new List<VmiMessage>();
foreach (var item in ls)
{ {
Message = System.Text.Json.JsonSerializer.Serialize(item), var message = new VmiMessage
}; {
messagelist.Add(message); Message = System.Text.Json.JsonSerializer.Serialize(item),
} };
_dbcontext.BulkInsert(messagelist); messagelist.Add(message);
_dbcontext.BulkInsert(ls, new BulkConfig() { }); }
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); _dbcontext.BulkInsert(messagelist);
var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); _dbcontext.BulkInsert(ls, new BulkConfig() { });
if (pdList.Count > 0) var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();//同步数据的发票号
{ var pdList = _dbcontext.Set<PUB_PD>().Where(p => billList.Contains(p.BillNum)).ToList();//扣减单内容
foreach (var item in pdList) var pdinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
if (pdList.Count > 0)
{ {
if (flag == true) if (flag == true)
{ {
item.State = SettleBillState.; foreach (var item in pdList)
{
item.State = SettleBillState.;
}
foreach (var item in pdinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(pdList);
_dbcontext.BulkUpdate(pdinvList);
} }
else else
{ {
item.State = SettleBillState.; _dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
} }
} }
_dbcontext.BulkUpdate(pdList); var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
} var bbacinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
var bbacList = _dbcontext.Set<BBAC_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); if (bbacList.Count > 0)
if (bbacList.Count > 0)
{
foreach (var item in bbacList)
{ {
if (flag == true) if (flag == true)
{ {
item.State = SettleBillState.; foreach (var item in bbacList)
{
item.State = SettleBillState.;
}
foreach (var item in bbacinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(bbacList);
_dbcontext.BulkUpdate(bbacinvList);
} }
else else
{ {
item.State = SettleBillState.; _dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
} }
} }
_dbcontext.BulkUpdate(bbacList); var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList();
} var hbpoinvList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();//发票
var hbpoList = _dbcontext.Set<HBPO_PD>().Where(p => billList.Contains(p.BillNum)).ToList(); if (hbpoList.Count > 0)
if (hbpoList.Count > 0)
{
foreach (var item in hbpoList)
{ {
if (flag == true) if (flag == true)
{ {
item.State = SettleBillState.; foreach (var item in bbacList)
{
item.State = SettleBillState.;
}
foreach (var item in bbacinvList)
{
item.State = SettleBillState.;
}
_dbcontext.BulkUpdate(bbacList);
_dbcontext.BulkUpdate(bbacinvList);
} }
else else
{ {
item.State = SettleBillState.; _dbcontext.BulkDelete(pdList);
_dbcontext.BulkDelete(p_ls);
} }
} }
_dbcontext.BulkUpdate(hbpoList);
}
var invoiceList = _dbcontext.Set<INVOICE_GRP>().Where(p => billList.Contains(p.InvbillNum)).ToList();
if (invoiceList.Count > 0)
{
foreach (var item in invoiceList)
{
if (flag == true)
{
item.State = SettleBillState.;
}
}
_dbcontext.BulkUpdate(invoiceList);
} }
// _emailSender.SendAsync(e)
// 提交事务
transaction.Commit();
}
catch (Exception)
{
issucess = false;
// 回滚事务
transaction.Rollback();
} }
// _emailSender.SendAsync(e)
// 提交事务
transaction.Commit();
}
catch (Exception)
{
issucess = false;
// 回滚事务
transaction.Rollback();
} }
}
if (issucess ==false) if (issucess ==false)
{ {
var billList = p_ls.Select(p => p.BillNum).Distinct().ToList(); var billList = p_ls.Select(p => p.BillNum).Distinct().ToList();

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

@ -1154,10 +1154,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
invoiceBillState: InvoiceBillState., invoiceBillState: InvoiceBillState.,
tax: 0.13m, tax: 0.13m,
parent: p_parentInvBillNum, parent: p_parentInvBillNum,
preTaxDiff: 0, preTaxDiff: 0,
taxDiff: 0, taxDiff: 0,
clientCode: string.Empty, clientCode: string.Empty,
realAmt: readAmt realAmt: readAmt
); );
invbill.ClientCode = clientCode; invbill.ClientCode = clientCode;
invbill.Site = dtos.FirstOrDefault().Site; invbill.Site = dtos.FirstOrDefault().Site;
@ -1393,7 +1393,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState., invoiceBillState: InvoiceBillState.,
tax: 0.13m, tax: 0.13m,
parent: string.Empty, parent: !string.IsNullOrEmpty(p_parentInvBillNum)?p_parentInvBillNum:string.Empty,
preTaxDiff: 0, preTaxDiff: 0,
taxDiff: 0, taxDiff: 0,
clientCode: string.Empty, clientCode: string.Empty,
@ -1963,7 +1963,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState., invoiceBillState: InvoiceBillState.,
tax: 0.13m, tax: 0.13m,
parent: string.Empty, parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
preTaxDiff: 0, preTaxDiff: 0,
taxDiff: 0, taxDiff: 0,
clientCode: string.Empty, clientCode: string.Empty,
@ -2027,7 +2027,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
if (!string.IsNullOrEmpty(p_OldInvBillNum)) if (!string.IsNullOrEmpty(p_OldInvBillNum))
{ {
var inv = await GetInvoiceAsync(p_OldInvBillNum).ConfigureAwait(false); var inv = await GetInvoiceAsync(p_OldInvBillNum).ConfigureAwait(false);//获取旧发票
if (inv == null) if (inv == null)
{ {
@ -2283,7 +2283,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
state: SettleBillState., state: SettleBillState.,
invoiceBillState: InvoiceBillState., invoiceBillState: InvoiceBillState.,
tax: 0.13m, tax: 0.13m,
parent: string.Empty, parent: !string.IsNullOrEmpty(p_parentInvBillNum) ? p_parentInvBillNum : string.Empty,
preTaxDiff: 0, preTaxDiff: 0,
taxDiff: 0, taxDiff: 0,
clientCode: string.Empty, clientCode: string.Empty,

Loading…
Cancel
Save