mahao 1 year ago
parent
commit
c772729b3e
  1. 28
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  2. 34
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  3. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  4. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  5. 191
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  6. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  7. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  8. 37
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs
  9. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  10. 220
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG_EXT.cs

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

@ -159,6 +159,9 @@ namespace Win.Sfs.SettleAccount.Bases
var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s);
if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC)
{
var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);
var AMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BBAC_DTO>>(A);
var wquery = from itm in AMap
@ -452,7 +455,7 @@ namespace Win.Sfs.SettleAccount.Bases
}
[UnitOfWork(false)]
/// <summary>
/// 第一次开票
/// </summary>
@ -518,18 +521,6 @@ namespace Win.Sfs.SettleAccount.Bases
@ -547,6 +538,10 @@ namespace Win.Sfs.SettleAccount.Bases
/// <returns></returns>
protected async Task<List<ERR_EXP_DTO>> CheckInvoiceGenerationRules<T>(List<T> dto1s, List<PriceList> p_pricelist, EnumBusinessType p_businessType) where T : SA_CAN_BASE
{
var first= dto1s.FirstOrDefault();
var usepriceList = p_pricelist.Where(p => p.ClientCode == first.Site && p.IsCancel == false).ToList();
var errorlist= _baseservice.CheckPriceListContinuity(usepriceList);
var inner = from d in dto1s
join p in p_pricelist on d.LU equals p.LU
where
@ -593,6 +588,13 @@ namespace Win.Sfs.SettleAccount.Bases
keyname = "交付识别号";
break;
}
foreach (var error in errorlist)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU},价格表开始日期:{error.BeginTime}价格表结束日期:{error.EndTime}在用价格时间段有交集或价格时间不连续!" });
}
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU}{keyname}:{error.PN},下线日期:{error.SettleDate}没有对应区间销售价格表!" });

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

@ -26,6 +26,7 @@ using Volo.Abp.TenantManagement.EntityFrameworkCore;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases.DomainServices;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ;
@ -54,15 +55,15 @@ namespace Win.Sfs.SettleAccount.Bases
protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService;
protected readonly INV_MNG _invmng;
private readonly BaseDomainService _baseservice;
protected CAN_SA_SERVICE(
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
INormalEfCoreRepository<TEntity, Guid> repository,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository,
INV_MNG invmng
INV_MNG invmng,
BaseDomainService baseservice
)
: base(excelImportService, snowflakeIdGenerator, commonManager)
{
@ -70,6 +71,7 @@ namespace Win.Sfs.SettleAccount.Bases
_excelImportService = excelImportService;
_repository = repository;
_detailRepository = detailRepository;
_baseservice = baseservice;
}
/// <summary>
@ -261,6 +263,10 @@ namespace Win.Sfs.SettleAccount.Bases
//var maxDate = p_pricelist.Max(p => p.Date);
var first = dto1s.FirstOrDefault();
var usepriceList = p_pricelist.Where(p => p.ClientCode == first.Site && p.IsCancel == false).ToList();
var errorlist = _baseservice.CheckPriceListContinuity(usepriceList);
var prices = p_pricelist.Where(p =>p.ClientCode==p_site && p.IsCancel == false).ToList();
var inner = from d in dto1s
@ -277,24 +283,6 @@ namespace Win.Sfs.SettleAccount.Bases
select d;
//var maxDate = p_pricelist.Max(p => p.Date);
//var left = from a in dto1s
// join b in (from p in p_pricelist
// where p.Date == maxDate
// select p) on a.LU equals b.LU into joinedResult
// from jr in joinedResult.DefaultIfEmpty()
// where a.SettleDate >= jr.BeginTime && a.SettleDate <= jr.EndTime && jr.LU == null
// select a;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO> ();
string name = string.Empty;
string keyname = string.Empty;
@ -329,6 +317,10 @@ namespace Win.Sfs.SettleAccount.Bases
keyname = "交付识别号";
break;
}
foreach (var error in errorlist)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU},价格表开始日期:{error.BeginTime}价格表结束日期:{error.EndTime}在用价格时间段有交集或价格时间不连续!" });
}
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU}{keyname}:{error.PN},下线日期:{error.SettleDate}没有对应区间销售价格表!" });

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

@ -4,6 +4,7 @@ using DocumentFormat.OpenXml.Spreadsheet;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.EntityFrameworkCore;
using NPOI.HPSF;
using SettleAccount.Domain.BQ;
@ -451,6 +452,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
};
var dtos = q.ToList();
var testls = dtos.Where(p => string.IsNullOrEmpty(p.LU)).ToList();
if (dtos != null && dtos.Count > 0)
{
if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
@ -465,15 +469,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
invBilllist.AddRange(ls);
}
}
else
{
throw new UserFriendlyException($"不存发票号为:{invbillnum}发票");
}
}
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 });
@ -585,7 +591,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
if (ls.Count > 0)
{
var invlist = ls.Select(p => p.InvbillNum).Distinct();
@ -594,7 +599,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var invBill = new INVOICE_REPEAT_DTO();
var invls = ls.Where(p => p.InvbillNum == itm).ToList();
var entitylist = entities.Where(p => p.InvbillNum == itm).ToList();
var tax = inv.Tax;//税率
var tax = inv.Tax==0?0.13m:inv.Tax;//税率
var amt = entitylist.Sum(p => p.Amt);//税前
var taxamt = amt + Math.Round(amt * tax, 2);//税后
var realamt = Math.Round(amt * tax, 2);//税额
@ -619,7 +624,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var invBill = new INVOICE_REPEAT_DTO();
var invls = ls.Where(p => p.InvbillNum == itm).ToList();
var entitylist = entities.Where(p => p.InvbillNum == itm).ToList();
var tax = inv.Tax;//税率
var tax = inv.Tax==0?0.13m:inv.Tax;//税率
var amt = entitylist.Sum(p => p.Amt);//税前
var taxamt = amt + Math.Round(amt * tax, 2);//税后
var realamt = Math.Round(amt * tax, 2);//税额

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

@ -31,6 +31,7 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Volo.Abp;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Bases.DomainServices;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
@ -65,10 +66,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INV_MNG invmng,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
BBAC_CAN_SA_MNG bbacMng
BBAC_CAN_SA_MNG bbacMng,
BaseDomainService baseservice
)
: base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng)
: base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng,baseservice)
{
_notRepository = notRepository;
_bbacMng = bbacMng;
@ -86,6 +87,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[UnitOfWork(false)]
public async Task<IActionResult> GenerateInvoice([FromBody] string invbillNum)
{
var main =await _bbacMng.GetMainAsync(invbillNum);
if (main != null)
{
@ -95,8 +97,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
var entitys = await _bbacMng.GetDetalListAsync(invbillNum);//可结算
var priceList = _priceRepository.Where(p => p.IsCancel == false).ToList();
;//价格单
//价格单
var errorList = await CheckInvoiceGenerationRules(entitys,main.Site,priceList, main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{

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

@ -301,153 +301,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
//[HttpPost]
//[UnitOfWork(false)]
///// <summary>
///// 发票重开列表
///// </summary>
///// <param name="input"></param>
///// <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")
// {
// return new JsonResult(new { Code = 400, Message = "请下载错误模版", fileName = result });
// }
// var invBilllist = new List<INVOICE_WAIT_DETAIL_DTO>();
// var adjlist = ObjectMapper.Map<List<PUB_ADJ_DETAIL_DTO>, List<PUB_ADJ_DETAIL>>(p_list);
// if (adjlist == null && adjlist.Count == 0)
// {
// throw new UserFriendlyException($"调整表无数据!");
// }
// 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 settle = await _bbacMng.GetMainAsync(inv.InvGroupNum);
// if (settle == null)
// {
// throw new UserFriendlyException($"选择发票:{invbillnum}对应的可结算单不在请检查!");
// }
// version = settle.Version;
// if (inv != null)
// {
// if (inv.InvoiceState == InvoiceBillState.报废)
// {
// throw new UserFriendlyException($"选择发票:{invbillnum}状态为报废状态不能重开!");
// }
// if (inv.State == SettleBillState.商务已审核 || inv.State == SettleBillState.已开票)
// {
// throw new UserFriendlyException($"选择发票:{invbillnum}状态在财务审核后可以报废重开,之前请退回重开!");
// }
// var bbaclist = await _bbacMng.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)
// {
// bbaclist.Add(new BBAC_CAN_SA_DETAIL(
// guid: itm.Id,
// keyCode: itm.KeyCode,
// version: itm.Version,
// billNum: itm.InvGroupNum,
// settleBillNum: itm.SettleBillNum,
// lU: itm.LU,
// pN: itm.PN,
// site: itm.Site,
// qty: itm.Qty,
// price: itm.Price,
// category: itm.BusinessType,
// isReturn: itm.Qty > 0 ? false : true,
// settleDate: itm.SettleDate,
// groupNum: itm.GroupNum,
// invGroupNum: itm.InvGroupNum,
// contactid: itm.Extend1,//生产号
// invbillnum: string.Empty,
// partcode: itm.PartCode
// ));
// }
// }
// var entitys = bbaclist;//合并库存调整单和就发票可结算明细数据
// var gNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
// var priceList = _priceRepository.ToList();//价格单
// 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
// where d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime && p.IsCancel == false && p.ClientCode == inv.Site//客户零件号
// select new TEMP_CAN_SA_DETAIL
// {
// Id = d.Id,
// SettleBillNum = d.SettleBillNum,
// Site = d.Site,
// Version = d.Version,
// Price = p.Price,
// BillNum = d.BillNum,
// SettleDate = d.SettleDate,
// InvGroupNum = d.InvGroupNum,
// LU = d.LU,
// MaterialDesc = d.MaterialDesc,
// PN = d.PN,
// Qty = d.Qty,
// GroupNum = d.GroupNum,
// Amt = Math.Round(d.Qty * p.Price, 2),
// ContractDocID = d.ContractDocID,
// BeginDate = p.BeginTime,
// EndDate = p.EndTime,
// PartCode = d.PartCode
// };
// var dtos = q.ToList();
// if (dtos != null && dtos.Count > 0)
// {
// if (invbillnum.Substring(0, 3) == "INV")//一次开票重开
// {
// var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
// var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
// invBilllist.AddRange(ls);
// }
// else//二次开票
// {
// var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
// var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
// invBilllist.AddRange(ls);
// }
// }
// else
// {
// throw new UserFriendlyException($"不存发票号为:{invbillnum}发票");
// }
// }
// var invlist = invBilllist.OrderBy(p => p.PartCode);
// return new JsonResult(new { Code = 200, Data = invlist });
//}
[HttpPost]
/// 发票重开列表
/// </summary>
@ -569,52 +422,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var entities = await ReissueFirstInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
invBilllist.AddRange(ls);
//var invlist = ls.Select(p => p.InvbillNum).Distinct();
//foreach (var itm in invlist)
//{
// var invBill = new INVOICE_REPEAT_DTO();
// var invls = ls.Where(p => p.InvbillNum == itm).ToList();
// var entitylist = entities.Where(p => p.InvbillNum == itm).ToList();
// var tax = inv.Tax;//税率
// var amt = entitylist.Sum(p => p.Amt);//税前
// var taxamt = amt + Math.Round(amt * tax, 2);//税后
// var realamt = Math.Round(amt * tax, 2);//税额
// invBill.Amt = amt;
// invBill.TaxAmt = taxamt;
// invBill.Tax = tax;
// invBill.BusinessType = inv.BusinessType;
// invBill.DETAIL = invls;
// invBill.RealAmt = realamt;
// invBilllist.Add(invBill);
//}
}
else//二次开票
{
var entities = await ReissueSecInvoiceExtend(bbaclist, adjlist, dtos, version, invbillnum);
var ls = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(entities);
invBilllist.AddRange(ls);
//var invlist = ls.Select(p => p.InvbillNum).Distinct();
//foreach (var itm in invlist)
//{
// var invBill = new INVOICE_REPEAT_DTO();
// var invls = ls.Where(p => p.InvbillNum == itm).ToList();
// var entitylist = entities.Where(p => p.InvbillNum == itm).ToList();
// var tax = inv.Tax;//税率
// var amt = entitylist.Sum(p => p.Amt);//税前
// var taxamt = amt + Math.Round(amt * tax, 2);//税后
// var realamt = Math.Round(amt * tax, 2);//税额
// invBill.Amt = amt;
// invBill.TaxAmt = taxamt;
// invBill.Tax = tax;
// invBill.BusinessType = inv.BusinessType;
// invBill.DETAIL = invls;
// invBill.RealAmt = realamt;
// invBilllist.Add(invBill);
//}
}
}
}
@ -762,7 +577,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var invBill = new INVOICE_REPEAT_DTO();
var invls = ls.Where(p => p.InvbillNum == itm).ToList();
var entitylist = entities.Where(p => p.InvbillNum == itm).ToList();
var tax = inv.Tax;//税率
var tax = inv.Tax == 0 ? 0.13m : inv.Tax;//税率
var amt = entitylist.Sum(p => p.Amt);//税前
var taxamt = amt + Math.Round(amt * tax, 2);//税后
var realamt = Math.Round(amt * tax, 2);//税额
@ -785,7 +600,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var invBill = new INVOICE_REPEAT_DTO();
var invls = ls.Where(p => p.InvbillNum == itm).ToList();
var entitylist = entities.Where(p => p.InvbillNum == itm).ToList();
var tax = inv.Tax;//税率
var tax = inv.Tax == 0 ? 0.13m : inv.Tax;//税率
var amt = entitylist.Sum(p => p.Amt);//税前
var taxamt = amt + Math.Round(amt * tax, 2);//税后
var realamt = Math.Round(amt * tax, 2);//税额

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

@ -19,6 +19,7 @@ using Volo.Abp.Uow;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Bases.DomainServices;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
@ -61,8 +62,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INV_MNG invmng,
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> notRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
HBPO_CAN_SA_MNG hbpoMng
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng)
HBPO_CAN_SA_MNG hbpoMng,
BaseDomainService baseservice
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng,baseservice)
{
_priceRepository = priceRepository;

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

@ -15,6 +15,7 @@ using Volo.Abp.Uow;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Bases.DomainServices;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
@ -59,9 +60,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INV_MNG invmng,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
INormalEfCoreRepository<PriceListBJ, Guid> pricebjRepository,
PUB_CAN_SA_MNG pubMng
PUB_CAN_SA_MNG pubMng,
BaseDomainService baseservice
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng)
) : base(excelImportService, snowflakeIdGenerator, commonManager, repository, detailRepository, invmng,baseservice)
{
_pubMng = pubMng;
_priceRepository = priceRepository;

37
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/BaseDomainServices/BaseDomainService.cs

@ -201,13 +201,43 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices
return errorList;
}
/// <summary>
/// 价格表时间是否连续
/// </summary>
/// <param name="priceList"></param>
/// <returns></returns>
public List<PriceList> CheckPriceListContinuity(List<PriceList> priceList)
{
List<PriceList> prices = new List<PriceList>();
if (priceList.Count <= 1)
return prices; // 只有一个或零个价格条目
var sortedList = priceList.OrderBy(item => item.BeginTime).ToList();
for (int i = 1; i < sortedList.Count; i++)
{
if (sortedList[i].LU== sortedList[i - 1].LU && sortedList[i].BeginTime != sortedList[i - 1].EndTime.AddDays(1))
{
prices.Add(sortedList[i]);
}
}
return prices; // 所有价格时间都连续
}
public static bool IsTimeOverlap(PriceList range1, PriceList range2)
{
return range1.BeginTime <= range2.EndTime && range1.EndTime >= range2.BeginTime;
}
public async Task<List<TEntity>> CheckPriceList<TEntity>(List<TEntity> p_list,string p_site,bool isBj=false)
where TEntity : ISA_BASE,new()
{
List<TEntity> errorList = new List<TEntity>();
if (isBj == true)
{
var pricebjlist = _pricebjRepository.ToList();
var pricebjlist = _pricebjRepository.Where(p => p.ClientCode == p_site && p.IsCancel == false).ToList();
var inner = from d in p_list
join p in pricebjlist on d.LU equals p.LU
@ -226,10 +256,11 @@ namespace Win.Sfs.SettleAccount.Bases.DomainServices
}
else
{
var pricebjlist = _priceRepository.Where(p=>p.ClientCode==p_site).ToList();
var pricelist = _priceRepository.Where(p=>p.ClientCode==p_site && p.IsCancel==false).ToList();
var inner = from d in p_list
join p in pricebjlist on d.LU equals p.LU
join p in pricelist on d.LU equals p.LU
where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d;

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

@ -1370,12 +1370,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
}).ToList();
decimal amt = detailDtos.Sum(k => k.Amt);//金额
decimal txtAmt =detailDtos.Sum(k => k.Amt) + Math.Round(detailList.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>();

220
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG_EXT.cs

@ -194,33 +194,33 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
decimal amt = detailList.Sum(k => k.Amt);//金额
decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额
decimal readAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 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>();
//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);
}
//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(),
@ -238,26 +238,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
realAmt: readAmt
);
invlist.Add(invbill);
}
//await _repository.DbContext.BulkInsertAsync(invlist);
//await _repository.DbContext.BulkInsertAsync(groupList);
//await _repository.DbContext.BulkInsertAsync(detailList);
//if(salist.Count>0)
//{
// await _repository.DbContext.BulkUpdateAsync(salist);
//}
//if (adjlist.Count > 0)
//{
// await _repository.DbContext.BulkUpdateAsync(adjlist);
//}
//await _repository.DbContext.BulkInsertAsync(notDetialList);
//_invls = invlist.Select(p => p.InvbillNum).ToList();
}
return detailList;
@ -327,28 +312,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var ls = itm.Value;//结算分组号列表
//反向查找结算数据
var invdetails = p_list.Where(p => ls.Contains(p.GroupNum)).ToList();
//foreach (var detail in invdetails)
//{
// detail.InvbillNum = key;
// salist.Add(detail);
//}
//if (!string.IsNullOrEmpty(p_parentInvBillNum))
//{
// //反向查找调整数据
// var adjdetails = p_adjlist.Where(p => ls.Contains(p.GroupNum)).ToList();
// foreach (var detail in adjdetails)
// {
// detail.InvBillNum = key;
// adjdetails.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 })
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode,p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
.Select(itm => new
{
PartCode = itm.Key.PartCode,
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.PartCode,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
@ -357,27 +327,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
EndDate = itm.Key.EndDate
})
.ToList();
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)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
decimal amt = detailDtos.Sum(k => k.Amt);//金额
decimal txtAmt = detailDtos.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额
decimal realAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);//税额
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
@ -403,31 +356,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);
// }
//}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
@ -444,27 +373,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
realAmt: realAmt
);
invlist.Add(invbill);
}
//await _repository.DbContext.BulkInsertAsync(invlist);
//await _repository.DbContext.BulkInsertAsync(groupList);
//await _repository.DbContext.BulkInsertAsync(detailList);
//if (salist.Count > 0)
//{
// await _repository.DbContext.BulkUpdateAsync(salist);
//}
//if (adjlist.Count > 0)
//{
// await _repository.DbContext.BulkUpdateAsync(adjlist);
//}
//if (notDetialList.Count > 0)
//{
// await _repository.DbContext.BulkInsertAsync(notDetialList);
//}
//_invls = invlist.Select(p => p.InvbillNum).ToList();
}
return detailList;
@ -635,8 +548,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
decimal amt = detailList.Sum(k => k.Amt);//金额
decimal txtAmt = detailList.Sum(k => k.Amt) + Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税后金额
decimal realAmt = Math.Round(detailList.Sum(k => k.Amt) * 0.13m, 2);//税额
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
@ -654,24 +568,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
preTaxDiff:0,
taxDiff:0,
clientCode:string.Empty,
realAmt:0
realAmt:realAmt
);
invlist.Add(invbill);
}
//await _repository.DbContext.BulkInsertAsync(invlist);
////await _repository.DbContext.BulkInsertAsync(groupList);
//await _repository.DbContext.BulkInsertAsync(detailList);
//if (salist.Count > 0)
//{
// await _repository.DbContext.BulkUpdateAsync(salist);
//}
//if (adjlist.Count > 0)
//{
// await _repository.DbContext.BulkUpdateAsync(adjlist);
//}
//await _repository.DbContext.BulkInsertAsync(notDetialList);
//_invls = invlist.Select(p => p.InvbillNum).ToList();
}
return detailList;
}
@ -776,12 +678,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
adjdetails.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 })
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,
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.PartCode,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
@ -790,8 +692,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
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)
{
@ -876,27 +779,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
realAmt: realAmt
);
invlist.Add(invbill);
}
//await _repository.DbContext.BulkInsertAsync(invlist);
//await _repository.DbContext.BulkInsertAsync(groupList);
//await _repository.DbContext.BulkInsertAsync(detailList);
//if(salist.Count>0)
//{
// await _repository.DbContext.BulkUpdateAsync(salist);
//}
//if (adjlist.Count > 0)
//{
// await _repository.DbContext.BulkUpdateAsync(adjlist);
//}
//if (notDetialList.Count > 0)
//{
// await _repository.DbContext.BulkInsertAsync(notDetialList);
//}
//_invls = invlist.Select(p => p.InvbillNum).ToList();
}
return detailList;
@ -1059,12 +946,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
}
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
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,
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.PartCode,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
@ -1097,8 +984,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
PartName = inv1.GetProperty("PartName", ""),//零件名称
};
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
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 readAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);//税额
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
@ -1191,27 +1079,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
realAmt: readAmt
);
invlist.Add(invbill);
}
//await _repository.DbContext.BulkInsertAsync(invlist);
//await _repository.DbContext.BulkInsertAsync(groupList);
//await _repository.DbContext.BulkInsertAsync(detailList);
//if (salist.Count > 0)
//{
// await _repository.DbContext.BulkUpdateAsync(salist);
//}
//if (adjlist.Count > 0)
//{
// await _repository.DbContext.BulkUpdateAsync(adjlist);
//}
//if (notDetialList.Count > 0)
//{
// await _repository.DbContext.BulkInsertAsync(notDetialList);
//}
//_invls = invlist.Select(p => p.InvbillNum).ToList();
}
return detailList;

Loading…
Cancel
Save