Browse Source

调整发票账期

master
赵新宇 1 year ago
parent
commit
a1be614b06
  1. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs
  2. 122
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  3. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  4. 6
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs

19
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/SeSyncExtendManager.cs

@ -225,20 +225,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
var before = p_billtime.Year;
var last = before - 1;
var next = before + 1;
DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间
DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间
//var result = seDetails
// .Select(log =>
// {
string version = null;
if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1))
if (p_billtime >= DateTime.ParseExact(string.Format("{0}-01-01 08:00:00", before), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) && p_billtime <= lastYear.AddMonths(1))
{
version = $"{before.ToString()}01";
}
else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2))
{ version = $"{before.ToString()}02"; }
{
version = $"{before.ToString()}02";
}
else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3))
{ version = $"{before.ToString()}03"; }
else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4))
@ -257,8 +258,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
{ version = $"{before.ToString()}10"; }
else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11))
{ version = $"{before.ToString()}11"; }
else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear)
{ version = $"{before.ToString()}12"; }
else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <=
DateTime.ParseExact(string.Format("{0}-01-{1} 07:59:59", next.ToString(), 01), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
)
{
version = $"{before.ToString()}12";
}
if (string.IsNullOrEmpty(version))

122
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -225,6 +225,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<string> BalanceExport(RequestDto input)
{
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
@ -419,6 +422,24 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<PagedResultDto<VmiLog>> Log(LogRequestDto input)
{
//var accountday = _codeRepository.FirstOrDefault(p => p.Project == "库存账期").Value;
//var begin= input.Filters.FirstOrDefault(p => p.Column == "BillTime" && p.Action == EnumFilterAction.BiggerThanOrEqual);
//if(begin != null){
// var begintime=DateTime.Parse(begin.Value);
// int version=GetVersionByBillTime(begintime, accountday);
// input.Filters.Add(new FilterCondition("Version",version.ToString(), EnumFilterAction.BiggerThanOrEqual,EnumFilterLogic.And));
//}
//var end = input.Filters.FirstOrDefault(p => p.Column == "BillTime" && p.Action == EnumFilterAction.SmallThan);
//if(end != null) {
// var endtime = DateTime.Parse(end.Value);
// int version = GetVersionByBillTime(endtime, accountday);
// input.Filters.Add(new FilterCondition("Version", version.ToString(), EnumFilterAction.SmallThan, EnumFilterLogic.And)); ;
//}
//if (input.UseHistory)
//{
// return await Log2(input).ConfigureAwait(false);
@ -581,35 +602,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
) on new { temp1.VinCode, temp1.RealPartCode } equals new { temp2.VinCode, temp2.RealPartCode }
where temp1.ChangedQty > 0
select temp1).ToList();
//var temp2 = (from a in _logRepository
// where (int)a.LogType == 200
// group a by new { a.VinCode, a.RealPartCode } into g
// let SumChangedQty = g.Sum(log => log.ChangedQty)
// let MinChangedTime = g.Min(log => log.ChangedTime)
// select new
// {
// VinCode = g.Key.VinCode,
// RealPartCode = g.Key.RealPartCode,
// SumChangedQty,
// MinChangedTime
// } into a
// join b in (from log in _logRepository
// where (int)log.LogType == 100
// group log by new { log.VinCode, log.RealPartCode } into g
// let SumChangedQty = g.Sum(log => log.ChangedQty)
// let MinChangedTime = g.Min(log => log.ChangedTime)
// select new
// {
// VinCode = g.Key.VinCode,
// RealPartCode = g.Key.RealPartCode,
// SumChangedQty,
// MinChangedTime
// }) on new { a.VinCode, a.RealPartCode } equals new { b.VinCode, b.RealPartCode }
// where a.MinChangedTime < b.MinChangedTime && a.SumChangedQty <= b.SumChangedQty
// select b);
var entities = result.Where(p => p.BillTime >= DateTime.Parse(beginDate) && p.BillTime <= DateTime.Parse(endDate) && p.LogType == VmiLogType.Type100).ToList();
// IQueryable<VmiLog> query = _logRepository.WhereIf(input.Filters?.Count != 0, input.Filters.ToLambda<VmiLog>());
var fileName = $"补货数据_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx";
var content = this.GetContent(entities, "补货数据_");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
@ -754,26 +750,80 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
log.ChangedBy = this._currentUser.UserName;
}
//private int GetVersionByTimeSpan(DateTime p_begintime,DateTime p_endtime, string p_day)
//{
// var before = p_billtime.Year;
// var last = before - 1;
// DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间
// DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间
// //var result = seDetails
// // .Select(log =>
// // {
// string version = null;
// if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1))
// {
// version = $"{before.ToString()}01";
// }
// else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2))
// { version = $"{before.ToString()}02"; }
// else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3))
// { version = $"{before.ToString()}03"; }
// else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4))
// { version = $"{before.ToString()}04"; }
// else if (p_billtime >= lastYear.AddMonths(4) && p_billtime <= lastYear.AddMonths(5))
// { version = $"{before.ToString()}05"; }
// else if (p_billtime >= lastYear.AddMonths(5) && p_billtime <= lastYear.AddMonths(6))
// { version = $"{before.ToString()}06"; }
// else if (p_billtime >= lastYear.AddMonths(6) && p_billtime <= lastYear.AddMonths(7))
// { version = $"{before.ToString()}07"; }
// else if (p_billtime >= lastYear.AddMonths(7) && p_billtime <= lastYear.AddMonths(8))
// { version = $"{before.ToString()}08"; }
// else if (p_billtime >= lastYear.AddMonths(8) && p_billtime <= lastYear.AddMonths(9))
// { version = $"{before.ToString()}09"; }
// else if (p_billtime >= lastYear.AddMonths(9) && p_billtime <= lastYear.AddMonths(10))
// { version = $"{before.ToString()}10"; }
// else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11))
// { version = $"{before.ToString()}11"; }
// else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear)
// { version = $"{before.ToString()}12"; }
// if (string.IsNullOrEmpty(version))
// {
// return 200802;//找不到的数据默认写到这个区间
// }
// return int.Parse(version);
//}
private int GetVersionByBillTime(DateTime p_billtime, string p_day)
{
var before = p_billtime.Year;
var last = before - 1;
var next = before + 1;
DateTime lastYear = DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//上期时间
DateTime beforeYear = DateTime.ParseExact(string.Format("{0}-12-{1} 07:59:59", before, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);//这期时间
//var result = seDetails
// .Select(log =>
// {
string version = null;
if (p_billtime >= lastYear && p_billtime <= lastYear.AddMonths(1))
if (p_billtime >= DateTime.ParseExact(string.Format("{0}-12-{1} 08:00:00", last, p_day), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) && p_billtime <= lastYear.AddMonths(1))
{
version = $"{before.ToString()}01";
}
else if (p_billtime >= lastYear.AddMonths(1) && p_billtime <= lastYear.AddMonths(2))
{ version = $"{before.ToString()}02"; }
{
version = $"{before.ToString()}02";
}
else if (p_billtime >= lastYear.AddMonths(2) && p_billtime <= lastYear.AddMonths(3))
{ version = $"{before.ToString()}03"; }
else if (p_billtime >= lastYear.AddMonths(3) && p_billtime <= lastYear.AddMonths(4))
@ -792,8 +842,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{ version = $"{before.ToString()}10"; }
else if (p_billtime >= lastYear.AddMonths(10) && p_billtime <= lastYear.AddMonths(11))
{ version = $"{before.ToString()}11"; }
else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <= beforeYear)
{ version = $"{before.ToString()}12"; }
else if (p_billtime >= lastYear.AddMonths(11) && p_billtime <=
DateTime.ParseExact(string.Format("{0}-01-{1} 07:59:59", next.ToString(), 01), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
)
{
version = $"{before.ToString()}12";
}
if (string.IsNullOrEmpty(version))

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

@ -232,7 +232,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetBackwardState(List<string> p_invs, SettleBillState p_State)
{
List<string> errors = new List<string>();
var appls = _repository.Where(p => p_invs.Contains(p.InvbillNum)).ToList();
if (appls.Count > 0)
@ -256,7 +255,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
if (inv.State == SettleBillState.)
{
inv.State = state;
}
else
@ -275,7 +273,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
if (inv.State == SettleBillState.)
{
inv.State = state;
}
else
@ -499,7 +496,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var bbacDetail = new List<BBAC_PD_DETAIL>();
foreach (var itm in entityList)
{
var detail = new BBAC_PD_DETAIL(
guid: itm.Id,
keyCode: itm.KeyCode,
@ -564,7 +560,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var involdList = invList.Where(p => oldinvs.Contains(p.ParentInvbillNum)).ToList();
var involdname = involdList.Select(p => p.InvbillNum);
var adjlist = _adjRepository.Where(p => involdname.Contains(p.InvBillNum));
if (adjlist != null && adjlist.Any())
{
foreach (var itm in adjlist)
@ -2455,16 +2450,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
case EnumBusinessType.YinDuJian:
invlist = await JITInvoice(p_list, p_adjlist, dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType, false).ConfigureAwait(false);//重开可以变多张发票
break;
}
if (invlist.Count == 0)
{
return false;
}
_repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv });
//foreach (var adj in p_adjlist)
//{
// adj.InvBillNum = string.Join(",", invlist);

6
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/BalanceSum/BalanceSumDapperRepository.cs

@ -335,7 +335,7 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
//"drop table #temp_js\n" +
//"drop table #temp_bh\n";
var sql=
"\n" +
"declare @lastyear as varchar(50)\n" +
"declare @lastTime as varchar(50)\n" +
"declare @BeforeYear as varchar(50)\n" +
@ -458,10 +458,6 @@ namespace Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report
}
}
return entities.ToList();
}

Loading…
Cancel
Save