Browse Source

更新版本

master
学 赵 1 year ago
parent
commit
9e594a87e1
  1. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs
  2. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  3. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  4. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  5. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  6. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  7. 177
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  8. 32
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  9. 120
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

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

@ -263,6 +263,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public List<PUB_ADJ_DETAIL_DTO> ADJ_DETAIL { get; set; }
/// <summary>
/// 全部未结明细
/// </summary>
public List<UNSETTLED_DETAIL_DTO> UNSETTLED_DETAIL { get; set; }
}
public class UNSETTLED_DETAIL_DTO
{
public string GroupNum { set; get; }
public string LU { set; get; }
public decimal Qty { set; get; }
}
@ -279,8 +296,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public int Version { get; set; }
[Display(Name = "金税发票号")]
public string RealInvbillNum { get; set; }
[Display(Name = "发票日期")]
public DateTime? InvDate { set; get; }
@ -556,8 +571,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
[Display(Name = "发票日期")]
public DateTime? InvDate { set; get; }
/// <summary>
///发票号
/// </summary>

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

@ -89,6 +89,11 @@ namespace Win.Sfs.SettleAccount.Bases
return new PagedResultDto<TEntityDetailDto>(totalCount, dtos);
}
/// <summary>
/// 导出
/// </summary>
@ -227,13 +232,13 @@ namespace Win.Sfs.SettleAccount.Bases
invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_invGroupNum, string.Empty, businessType, true);
break;
case EnumBusinessType.ZhiGongJianBBAC:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
case EnumBusinessType.ZhiGongJianHBPO:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
case EnumBusinessType.BeiJian:
invlist = await _invmng.BJInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType, true);
invlist = await _invmng.BJInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true);
break;
case EnumBusinessType.JisBBAC:
invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos,p_notlist , p_version, p_invGroupNum, string.Empty, businessType);//重开可以变多张发票
@ -242,7 +247,7 @@ namespace Win.Sfs.SettleAccount.Bases
invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos,p_notlist, p_version, p_invGroupNum, string.Empty, businessType);//重开可以变多张发票
break;
case EnumBusinessType.YinDuJian:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true);//重开可以变多张发票
break;
}
if (invlist.Count > 0)

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

@ -43,10 +43,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly ADJ_SERVICE _adjservice;
public BBAC_BA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
@ -64,8 +61,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BaseDomainService baseservice,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
ADJ_SERVICE adjservice
) : base(
excelImportService,
snowflakeIdGenerator,
@ -95,11 +90,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <returns></returns>
public override async Task<IActionResult> ReissueInvoice([FromBody] string p_invbillnum)
{
//var mappingList= await GetMapGroupAsync(p_invbillnum);//发票对应结算分组
//if (mappingList != null && mappingList.Count() > 0)
//{
var version = int.Parse(DateTime.Now.ToString("yyyymm"));
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(p_invbillnum);
var settle = await _bbacMng.GetMainAsync(inv.InvGroupNum);
@ -107,7 +100,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (settle == null)
{
throw new UserFriendlyException($"选择发票:{p_invbillnum}对应的可结算单不在请检查!","400");
}
version = settle.Version;
if (inv != null)
@ -126,7 +118,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
foreach (var itm in adjlist)
{
var entity = new BBAC_CAN_SA_DETAIL(
guid: itm.Id,
keyCode: itm.KeyCode,
@ -153,6 +144,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
var priceList = _priceRepository.Where(p=>p.IsCancel==false).ToList();//价格单
@ -162,9 +155,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode,Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList) });
}
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s
@ -478,8 +469,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
var als= invBilllist.Where(p => string.IsNullOrEmpty(p.PartCode)).ToList();
var invlist=invBilllist.OrderBy(p => p.PartCode).ToList();
return new JsonResult(new { Code = 200, Data= invlist });

8
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs

@ -32,6 +32,7 @@ using Volo.Abp;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Bases.DomainServices;
using LinqToDB;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
@ -106,8 +107,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (await _bbacMng.SetForwardState(main, SettleBillState.))
{
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
var notQuery = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();//不能结算
var notQuery =await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync();
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s
join p in priceList on d.LU equals p.LU

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

@ -48,13 +48,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_priceRepository= priceRepository;
_adjservice = adjservice;
}
/// <summary>
/// 发票重开
/// </summary>
@ -118,10 +111,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var errorList = await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
if (errorList.Count() > 0)
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList) });
;
}
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in entitys
@ -195,8 +185,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
var first = p_list.FirstOrDefault();
var invbillnum = first.InvBillNum;
//var mappingList = await GetMapGroupAsync(p_invbillnum);//发票对应结算分组
//if (mappingList != null && mappingList.Count() > 0)
//{
@ -314,7 +302,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <returns></returns>
public virtual async Task<IActionResult> ReissueInvoiceList(List<PUB_ADJ_DETAIL_DTO> p_list)
{
var result = await _adjservice.CheckImport(p_list);
if (result != "OK")
{
@ -329,15 +316,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var first = p_list.FirstOrDefault();
var invbillnum = first.InvBillNum;
//var mappingList = await GetMapGroupAsync(invbillnum);//发票对应结算分组
//if (mappingList != null && mappingList.Count() > 0)
//{
var version = int.Parse(DateTime.Now.ToString("yyyymm"));
//var gList = mappingList.Select(p => p.SettleGroupNum).ToList();//获取发票所有结算分组
var inv = await GetInvoiceGroupByInvBillNum(invbillnum);
var inv = await GetInvoiceGroupByInvBillNum(invbillnum);
var settle = await _hbpoMng.GetMainAsync(inv.InvGroupNum);
if (settle == null)
{
throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!", "400");
@ -353,9 +335,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!", "400");
}
var bbaclist = await _hbpoMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件
//var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
var bbaclist = await _hbpoMng.GetContainsAsync(inv.InvbillNum);//结算分组对应结算零件 //var adjlist = await _adjRepository.Where(p => p.OldInvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)

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

@ -96,12 +96,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList) });
}
if (await _hbpoMng.SetForwardState(main, SettleBillState.))
{
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var notQuery = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();
var notQuery = _notRepository.Where(p =>p.SettleBillNum==main.SettleBillNum).ToList();
var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var q = from d in dto1s
join p in priceList on d.LU equals p.LU

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

@ -1,6 +1,7 @@
using CodeArts.Db;
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Drawing.Diagrams;
using DocumentFormat.OpenXml.Office.Drawing;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Wordprocessing;
using EFCore.BulkExtensions;
@ -13,6 +14,7 @@ using Microsoft.AspNetCore.Mvc;
using NPOI.HPSF;
using SettleAccount.Domain.BQ;
using Shouldly;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -161,6 +163,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var invs = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
var m = await _mRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
var mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m);
var first = invs.FirstOrDefault();
if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC)
{
var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
@ -249,17 +255,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BeginDate = itm.BeginDate,
EndDate = itm.EndDate,
};
entity.INVOICE_WAIT_DETAIL = wquery.OrderBy(p => p.LU).ToList();
}
var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s);
var adjs =await _adjRepository.GetListByFilterAsync(input.Filters);
var adjdtos = ObjectMapper.Map<List<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(adjs);
var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s);//不可结
var adjs = await _adjRepository.GetListByFilterAsync(input.Filters);//调整数据
var adjdtos = ObjectMapper.Map<List<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(adjs);//调整数据DTO
var notquery = from itm in sdtos
join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum
select
@ -274,8 +276,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
Qty = itm.Qty,
Extend1 = itm.Extend1,
};
var mquery = from itm in mdtos
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum
select
@ -304,12 +304,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
Price = itm.Price
};
entity.INVOICE_NOT_SETTLE = notquery.ToList();
entity.INVOICE_MAP_GROUP = mquery.ToList();
entity.ADJ_DETAIL = adjQuery.ToList();
return entity;
entity.INVOICE_NOT_SETTLE = notquery.OrderBy(p=>p.SettleGroupNum).ThenBy(p=>p.LU).ToList();
var lscompare = entity.INVOICE_NOT_SETTLE.GroupBy(x => new { x.InvBillNum, x.SettleGroupNum }).Select(p =>
new INVOICE_MAP_GROUP_DTO()
{
InvbillNum = p.FirstOrDefault().InvBillNum,
InvGroupNum = p.FirstOrDefault().InvGroupNum,
RealInvBillNum = p.FirstOrDefault().RealInvBillNum,
InvDate = p.FirstOrDefault().InvDate,
SettleGroupNum = p.FirstOrDefault().SettleGroupNum,
}
);
var all= entity.INVOICE_NOT_SETTLE.Select(p => p.SettleGroupNum).Distinct().ToList();//全部分组号
var part = mquery.ToList().Select(p => p.SettleGroupNum).Distinct().ToList();//发票对应分组号
var unsettled= all.Where(p => !part.Contains(p));//排除发票对应分组号,都为不可结
var unsettledList= entity.INVOICE_NOT_SETTLE.Where(p => unsettled.Contains(p.SettleGroupNum))
.GroupBy(p => new { p.LU, p.SettleGroupNum })
.Select(p => new UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) });
entity.UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList();
entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号
entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p=>p.GroupNum).ThenBy(p=>p.LU).ToList();
return entity;
}
[HttpPost]
public virtual async Task<string> ExportAsync(INVOICE_GRP_REQ_DTO input)
@ -350,9 +370,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
return _fileName;
}
/// <summary>
/// 导出发票组明细
/// </summary>
@ -363,26 +380,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
IExporter _csv = new CsvExporter();
ExcelExporter _excel = new ExcelExporter();
var materialList = await _baseservice.GetMaterialList();
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var first=entities.FirstOrDefault();
var dtoDetails = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_EXP_DTO>>(entities);
var invdetail= await DetailQueryAsync(input);
var m = invdetail.INVOICE_MAP_GROUP;
var not=invdetail.INVOICE_NOT_SETTLE;
var detail =invdetail.INVOICE_WAIT_DETAIL;
var adj = invdetail.ADJ_DETAIL;
var bbac = invdetail.INVOICE_WAIT_DETAIL_BBAC;
var bj = invdetail.INVOICE_WAIT_DETAIL_BJ;
var not=invdetail.INVOICE_NOT_SETTLE;//零件结算对应关系
var detail =invdetail.INVOICE_WAIT_DETAIL;//常规明细
var adj = invdetail.ADJ_DETAIL;//调整表
var bbac = invdetail.INVOICE_WAIT_DETAIL_BBAC;//BBACJIS明细
var bj = invdetail.INVOICE_WAIT_DETAIL_BJ;//备件明细
var unsettle = invdetail.UNSETTLED_DETAIL;//未结明细
var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name;
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx";
//发票明细
if (entities.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC)
{
_excel.Append(bbac, "发票明细");
}
else if (entities.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian)
@ -393,6 +410,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
_excel.Append(detail, "发票明细");
}
_excel.Append(m, "发票结算分组对应");//发票分组对应结算号
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO)
{
_excel.Append(unsettle, "未结零件分组汇总");
}
foreach (var itm in entities)
{
var mgroup =m.Where(p => p.InvbillNum == itm.InvbillNum).ToList();
@ -412,11 +434,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
RealInvBillNum =p.Key.RealInvBillNum,
InvDate =p.Key.InvDate,
InvBillNum =p.Key.InvBillNum,
InvGroupNum =p.Key.InvGroupNum,
Qty=p.Sum(itm=>itm.Qty)
}).ToList();
var lsN = nolist.Where(p => p.Extend1 == "不可结算").ToList()
.GroupBy(p => new
{
@ -435,8 +457,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
InvGroupNum = p.Key.InvGroupNum,
Qty = p.Sum(itm => itm.Qty)
}).ToList();
var lineC = lsC.Count;
var lineN = lsN.Count;
List<INVOICE_NOT_SETTLE_EXT_DTO> ls = new List<INVOICE_NOT_SETTLE_EXT_DTO>();
@ -457,9 +477,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
var entity= nolist.FirstOrDefault();
var disList = mgroup.Select(p => p.SettleGroupNum).Distinct().ToList();
for (int i = 0; i < lineC; i++)
for (int i = 0; i < lineC; i++)//更新可结信息
{
ls[i].RealInvBillNum = entity.RealInvBillNum;
ls[i].InvDate = entity.InvDate;
@ -469,7 +487,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
ls[i].SettleLU = lsC[i].LU;
ls[i].SettleQty = lsC[i].Qty == null ? string.Empty : lsC[i].Qty.ToString();
}
for (int i = 0; i < lineN; i++)
for (int i = 0; i < lineN; i++)//更新不可结信息
{
ls[i].RealInvBillNum = entity.RealInvBillNum;
ls[i].InvDate = entity.InvDate;
@ -479,98 +497,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
ls[i].NotSettleLU = lsN[i].LU;
ls[i].Qty = lsN[i].Qty == null ? string.Empty : lsN[i].Qty.ToString();
}
for (int i = 0; i < disList.Count; i++)
for (int i = 0; i < disList.Count; i++)//更新结算分组
{
ls[i].SettleGroupNum = disList[i];
}
if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO)
{
_excel.Append(ls, "结算分组零件" + itm.InvbillNum);
}
//if (lineC > lineN)//可结大于不可结行数时
//{
// for (int number = 0; number < lineC; number++)
// {
// if (number + 1 > lineN)
// {
// INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
// entity.RealInvBillNum = lsC[number].RealInvBillNum;
// entity.InvDate = lsC[number].InvDate;
// entity.InvBillNum = lsC[number].InvBillNum;
// entity.InvGroupNum = lsC[number].InvGroupNum;
// entity.SettleGroupNum = lsC[number].SettleGroupNum;
// entity.SettleLU = lsC[number].LU;
// entity.SettleQty = lsC[number].Qty == null ? string.Empty : lsC[number].Qty.ToString();
// entity.NotSettleLU = string.Empty;
// entity.Qty = string.Empty;
// ls.Add(entity);
// }
// else
// {
// INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
// entity.RealInvBillNum = lsC[number].RealInvBillNum;
// entity.InvDate = lsC[number].InvDate;
// entity.InvBillNum = lsC[number].InvBillNum;
// entity.InvGroupNum = lsC[number].InvGroupNum;
// entity.SettleGroupNum = lsC[number].SettleGroupNum;
// entity.SettleLU = lsC[number].LU;
// entity.SettleQty= lsC[number].Qty==null?string.Empty:lsC[number].Qty.ToString();
// entity.NotSettleLU = lsN[number].LU;
// entity.Qty = lsN[number].Qty == null ? string.Empty : lsC[number].Qty.ToString();
// ls.Add(entity);
// }
// }
//}
//else
//{
// for (int number = 0; number < lineN; number++)
// {
// if (number + 1 > lineC)//不可结大于可结行数时
// {
// INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
// entity.RealInvBillNum = lsN[number].RealInvBillNum;
// entity.InvDate = lsN[number].InvDate;
// entity.InvBillNum = lsN[number].InvBillNum;
// entity.InvGroupNum = lsN[number].InvGroupNum;
// entity.SettleGroupNum = lsN[number].SettleGroupNum;
// entity.SettleLU = string.Empty;
// entity.SettleQty = string.Empty;
// entity.NotSettleLU = lsN[number].LU;
// entity.Qty = lsN[number].Qty == null ? string.Empty : lsN[number].Qty.ToString();
// ls.Add(entity);
// }
// else
// {
// INVOICE_NOT_SETTLE_EXT_DTO entity = new INVOICE_NOT_SETTLE_EXT_DTO();
// entity.RealInvBillNum = lsN[number].RealInvBillNum;
// entity.InvDate = lsN[number].InvDate;
// entity.InvBillNum = lsN[number].InvBillNum;
// entity.InvGroupNum = lsN[number].InvGroupNum;
// entity.SettleGroupNum = lsN[number].SettleGroupNum;
// entity.SettleLU = lsC[number].LU;
// entity.NotSettleLU = lsN[number].LU;
// entity.Qty = lsN[number].Qty == null ? string.Empty : lsN[number].Qty.ToString(); ;
// entity.SettleQty = lsC[number].Qty == null ? string.Empty : lsC[number].Qty.ToString(); ;
// ls.Add(entity);
// }
// }
//}
//var disList= ls.Select(p => p.SettleGroupNum).Distinct().ToList();
//foreach (var de in ls)
//{
// de.SettleGroupNum = string.Empty;
//}
//for (int i = 0; i < disList.Count; i++)
//{
// ls[i].SettleGroupNum = disList[i];
//}
_excel.Append(ls, "结算分组零件" + itm.InvbillNum);
_excel.Append(mgroup, "发票结算分组对应" + itm.InvbillNum).SeparateBySheet();
_excel.Append(adjp, "发票调整数据" + itm.InvbillNum).SeparateBySheet();
}
var result = _excel.ExportAppendDataAsByteArray();

32
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.LinqAsync;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
@ -50,6 +51,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
private readonly PUB_CAN_SA_MNG _pubMng;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _pricebjRepository;
private readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
public PUB_CAN_SA_SERVICE
(IExcelImportAppService excelImportService,
@ -61,13 +63,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INormalEfCoreRepository<PriceList, Guid> priceRepository,
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository,
PUB_CAN_SA_MNG pubMng,
BaseDomainService baseservice
BaseDomainService baseservice,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng,baseservice)
{
_pubMng = pubMng;
_priceRepository = priceRepository;
_pricebjRepository = pricebjRepository;
_notRepository = notRepository;
}
[HttpPost]
[UnitOfWork(false)]
@ -132,7 +136,31 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
if (billnum.Substring(0, 1) == "C")//一次开票
{
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
var notQuery = await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync();
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
{
KeyCode = p.KeyCode,
Version = p.Version,
SettleBillNum = p.SettleBillNum,
LU = p.LU,
PN = p.PN,
Site = p.Site,
Qty = p.Qty,
Price = p.Price,
BusinessType = p.BusinessType,
IsReturn = "",
InvGroupNum = p.InvGroupNum,
SettleDate = p.SettleDate,
GroupNum = p.GroupNum,
ContractDocID = string.Empty,
PartCode = p.PartCode
}).ToList();//不能结算
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
else//二次开票
{

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

@ -743,10 +743,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
await _repository.DbContext.BulkUpdateAsync(invList);
return true;
}
else
{
var pdlist = _pdpubRepository.Where(p => p_invs.Contains(p.BillNum)).ToList();//包含发票号的代扣减单
@ -1238,9 +1234,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
groupList.AddRange(group1);
}
string site = dtos.FirstOrDefault().Site;
var lst=dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList();
string site = lst.FirstOrDefault().Site;
string clientCode = string.Empty;
switch (site)
{
case "1040":
@ -1255,7 +1251,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
@ -1358,6 +1353,16 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
List<string> lsby = new List<string>();
var grouplist = p_list.Select(p => p.GroupNum).Distinct().ToList();//可结分组
lsby.AddRange(grouplist);
var nolist = p_notlist.Where(p => !grouplist.Contains(p.GroupNum)).Select(p => p.GroupNum).ToList();//不可结分组
int count = invoiceMap.Keys.Count;//计算第几张发票计数器
int i = 0;
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
@ -1379,7 +1384,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
adjlist.Add(detail);
}
}
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID, p.LU })//明细
.Select(itm => new
{
PartCode = itm.Key.PartCode,
@ -1396,8 +1401,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
decimal txtAmt =detailDtos.Sum(k => k.Amt) + Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);//税后金额
decimal realAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);//税额
//decimal amt = detailDtos.Sum(k => k.Amt);
//decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
@ -1469,6 +1473,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
var innotls1 = new List<INVOICE_NOT_SETTLE>();
var groupnum = itm.Value;
if (count == i)//最后一张发票追加
{
groupnum.AddRange(nolist);//追加完全不可结
}
var notls = p_notlist.Where(p => groupnum.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU })
.Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = itm.Key });
foreach (var nitm in notls)
@ -1510,7 +1518,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
realAmt: realAmt
);
string site = dtos.FirstOrDefault().Site;
string site = dtos.Where(p=>!string.IsNullOrEmpty(p.Site)).FirstOrDefault().Site;
string clientCode = string.Empty;
switch(site)
@ -1524,14 +1532,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
default:
clientCode = "C004";
break;
}
invbill.ClientCode = clientCode;
invbill.Site= dtos.FirstOrDefault().Site;
invbill.CreationTime = DateTime.Now;
invlist.Add(invbill);
i++;
}
//using (var transaction = _repository.DbContext.Database.BeginTransaction())
//{
@ -1568,11 +1574,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
return _invls;
}
@ -1752,34 +1753,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
decimal realAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额
//decimal amt = detailList.Sum(k => k.Amt);
//decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
//var contractList = ls.Select(p => p.ContractDocID).Distinct();
//var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum })
// .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
//var _groupList = dtos.GroupBy(p => new { p.GroupNum })
// .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
//List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
//foreach (var en in _groupList)
//{
// group1.Add(
// new INVOICE_MAP_GROUP(
// guid: GuidGenerator.Create(),
// version: p_version,
// invbillNum: key,
// invGroupNum: p_InvGroupNum,
// settleGroupNum: en.GroupNum,
// amt: en.Amt,
// extend1: string.Empty,
// extend2: string.Empty));
//}
//if (group1.Count > 0)
//{
// groupList.AddRange(group1);
//}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
@ -1920,7 +1893,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
adjlist.Add(detail);
}
}
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
.Select(itm => new
{
@ -1938,7 +1910,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
decimal amt = detailDtos.Sum(k => k.Amt);//金额
decimal txtAmt = detailDtos.Sum(k => k.Amt)+ Math.Round(detailDtos.Sum(k => k.Amt)*0.13m, 2);//税后金额
decimal realAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);//税额
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
@ -1983,31 +1954,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
detailList.AddRange(_entityDetailList);
}
var innotls = new List<INVOICE_NOT_SETTLE>();
if (p_notlist != null && p_notlist.Count > 0)
{
var notls = p_notlist.Where(p=>ls.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty,
p_invbillnum:key
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
}
string site = dtos.FirstOrDefault().Site;
string clientCode = string.Empty;
@ -2022,11 +1969,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
default:
clientCode = "C004";
break;
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
@ -2063,9 +2006,28 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
await _repository.DbContext.BulkUpdateAsync(adjlist);
}
if (notDetialList.Count > 0)
if (p_notlist.Count > 0)
{
await _repository.DbContext.BulkInsertAsync(notDetialList);
var innotls = new List<INVOICE_NOT_SETTLE>();
var notls = p_notlist.GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty,
p_invbillnum: string.Empty
));
}
await _repository.DbContext.BulkInsertAsync(innotls);
}
_invls = invlist.Select(p => p.InvbillNum).ToList();
}

Loading…
Cancel
Save