|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; |
|
|
using SettleAccount.Bases; |
|
|
using SettleAccount.Bases; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using Shouldly; |
|
|
using Shouldly; |
|
|
|
|
|
using SqlSugar; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Uow; |
|
|
using Volo.Abp.Uow; |
|
@ -133,8 +134,8 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
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 s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); |
|
|
var first = invs.FirstOrDefault(); |
|
|
var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s); |
|
|
|
|
|
if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) |
|
|
if (invs.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) |
|
|
{ |
|
|
{ |
|
|
var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); |
|
|
var A = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); |
|
@ -146,7 +147,6 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
select |
|
|
select |
|
|
new INVOICE_WAIT_DETAIL_BBAC_DTO() |
|
|
new INVOICE_WAIT_DETAIL_BBAC_DTO() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
PartDesc = tm == null ? string.Empty : itm.PartDesc, |
|
|
PartDesc = tm == null ? string.Empty : itm.PartDesc, |
|
|
InvDate = itm1.CreationTime, |
|
|
InvDate = itm1.CreationTime, |
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
@ -158,72 +158,106 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
PRICE = itm.PRICE, |
|
|
PRICE = itm.PRICE, |
|
|
Qty = itm.Qty, |
|
|
Qty = itm.Qty, |
|
|
Amt = itm.Amt, |
|
|
Amt = itm.Amt, |
|
|
|
|
|
BussiessType = itm.BussiessType, |
|
|
Extend1 = itm.Extend1, |
|
|
Extend1 = itm.Extend1, |
|
|
BeginDate = itm.BeginDate, |
|
|
BeginDate = itm.BeginDate, |
|
|
EndDate = itm.EndDate, |
|
|
EndDate = itm.EndDate, |
|
|
}; |
|
|
}; |
|
|
entity.INVOICE_WAIT_DETAIL_BBAC = wquery.ToList(); |
|
|
entity.INVOICE_WAIT_DETAIL_BBAC = wquery.OrderBy(p => p.LU).ToList(); |
|
|
} |
|
|
} |
|
|
else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) |
|
|
else if (invs.FirstOrDefault().BusinessType == EnumBusinessType.BeiJian) |
|
|
{ |
|
|
{ |
|
|
var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); |
|
|
var B = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); |
|
|
var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
B.OrderBy(p => p.LineCode); |
|
|
|
|
|
|
|
|
|
|
|
List<INVOICE_WAIT_DETAIL_BJ_DTO> BMap = new List<INVOICE_WAIT_DETAIL_BJ_DTO>(); |
|
|
|
|
|
foreach (var itm in B) |
|
|
|
|
|
{ |
|
|
|
|
|
INVOICE_WAIT_DETAIL_BJ_DTO bj = new INVOICE_WAIT_DETAIL_BJ_DTO(); |
|
|
|
|
|
bj.LU = itm.LU; |
|
|
|
|
|
bj.PartCode = itm.PartCode; |
|
|
|
|
|
bj.PRICE = itm.PRICE; |
|
|
|
|
|
|
|
|
|
|
|
bj.InvGroupNum = itm.InvGroupNum; |
|
|
|
|
|
bj.DeliveryNumber = itm.ExtraProperties["DeliveryIndexNumber"].ToSqlValue(); |
|
|
|
|
|
|
|
|
|
|
|
//bj.DeliveryNumber = itm.GetProperty("DeliveryNumber", "");//交货号
|
|
|
|
|
|
//bj.InvbillNum = itm.GetProperty("InvoiceNumber", "");//发票号
|
|
|
|
|
|
//bj.VendorCode = itm.GetProperty("VendorCode", "");//供应商代码
|
|
|
|
|
|
//bj.VendorName = itm.GetProperty("VendorName", "");//供应商名称
|
|
|
|
|
|
//bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号
|
|
|
|
|
|
//bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号
|
|
|
|
|
|
//bj.PartName = itm.GetProperty("PartName", "");//零件名称
|
|
|
|
|
|
|
|
|
|
|
|
BMap.Add(bj); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//var BMap = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_BJ_DTO>>(B);
|
|
|
var wquery = from itm in BMap |
|
|
var wquery = from itm in BMap |
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp |
|
|
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp |
|
|
from tm in temp.DefaultIfEmpty() |
|
|
from tm in temp.DefaultIfEmpty() |
|
|
select |
|
|
select |
|
|
new INVOICE_WAIT_DETAIL_BJ_DTO() |
|
|
new INVOICE_WAIT_DETAIL_BJ_DTO() |
|
|
{ |
|
|
{ |
|
|
PartDesc = tm == null ? string.Empty : itm.PartDesc, |
|
|
PartDesc = tm == null ? string.Empty : itm.PartDesc, |
|
|
InvDate = itm1.CreationTime, |
|
|
InvDate = itm1.CreationTime, |
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
Version = itm.Version, |
|
|
Version = itm.Version, |
|
|
InvbillNum = itm.InvbillNum, |
|
|
InvbillNum = itm.InvbillNum, |
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
LU = itm.LU, |
|
|
LU = itm.LU, |
|
|
PartCode = itm.PartCode, |
|
|
PartCode = itm.PartCode, |
|
|
PRICE = itm.PRICE, |
|
|
PRICE = itm.PRICE, |
|
|
Qty = itm.Qty, |
|
|
Qty = itm.Qty, |
|
|
Amt = itm.Amt, |
|
|
Amt = itm.Amt, |
|
|
|
|
|
DeliveryNumber = itm.DeliveryNumber, |
|
|
Extend1 = itm.Extend1, |
|
|
VendorCode = itm.VendorCode, |
|
|
BeginDate = itm.BeginDate, |
|
|
VendorName = itm.VendorName, |
|
|
EndDate = itm.EndDate, |
|
|
//PurchaseOrderNumber = itm.PurchaseOrderNumber,
|
|
|
}; |
|
|
DeliveryIndexNumber = itm.DeliveryIndexNumber, |
|
|
|
|
|
Extend1 = itm.Extend1, |
|
|
|
|
|
BeginDate = itm.BeginDate, |
|
|
|
|
|
EndDate = itm.EndDate, |
|
|
|
|
|
}; |
|
|
entity.INVOICE_WAIT_DETAIL_BJ = wquery.ToList(); |
|
|
entity.INVOICE_WAIT_DETAIL_BJ = wquery.ToList(); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
var w = await _wRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount); |
|
|
var wdtos = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(w); |
|
|
var wdtos = ObjectMapper.Map<List<INVOICE_WAIT_DETAIL>, List<INVOICE_WAIT_DETAIL_DTO>>(w); |
|
|
var wquery = from itm in wdtos |
|
|
var wquery = from itm in wdtos |
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp |
|
|
join itm2 in materialList on itm.LU equals itm2.SettleMaterialCode into temp |
|
|
from tm in temp.DefaultIfEmpty() |
|
|
from tm in temp.DefaultIfEmpty() |
|
|
select |
|
|
select |
|
|
new INVOICE_WAIT_DETAIL_DTO() |
|
|
new INVOICE_WAIT_DETAIL_DTO() |
|
|
{ |
|
|
{ |
|
|
PartDesc = tm == null ? string.Empty : itm.PartDesc, |
|
|
PartDesc = tm == null ? string.Empty : itm.PartDesc, |
|
|
InvDate = itm1.CreationTime, |
|
|
InvDate = itm1.CreationTime, |
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
RealInvbillNum = string.IsNullOrEmpty(itm1.RealnvBillNum) ? string.Empty : itm1.RealnvBillNum, |
|
|
Version = itm.Version, |
|
|
Version = itm.Version, |
|
|
InvbillNum = itm.InvbillNum, |
|
|
InvbillNum = itm.InvbillNum, |
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
LU = itm.LU, |
|
|
LU = itm.LU, |
|
|
PartCode = itm.PartCode, |
|
|
PartCode = itm.PartCode, |
|
|
PRICE = itm.PRICE, |
|
|
PRICE = itm.PRICE, |
|
|
Qty = itm.Qty, |
|
|
Qty = itm.Qty, |
|
|
Amt = itm.Amt, |
|
|
Amt = itm.Amt, |
|
|
BussiessType = itm.BussiessType, |
|
|
BussiessType = itm.BussiessType, |
|
|
// Extend1 = itm.Extend1,
|
|
|
//Extend1 = itm.Extend1,
|
|
|
BeginDate = itm.BeginDate, |
|
|
BeginDate = itm.BeginDate, |
|
|
EndDate = itm.EndDate, |
|
|
EndDate = itm.EndDate, |
|
|
}; |
|
|
}; |
|
|
entity.INVOICE_WAIT_DETAIL = wdtos; |
|
|
entity.INVOICE_WAIT_DETAIL = wquery.OrderBy(p => p.LU).ToList(); |
|
|
} |
|
|
} |
|
|
|
|
|
var s = await _sRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount).ConfigureAwait(false); |
|
|
|
|
|
var sdtos = ObjectMapper.Map<List<INVOICE_NOT_SETTLE>, List<INVOICE_NOT_SETTLE_DTO>>(s);//不可结
|
|
|
|
|
|
var adjs = await _adjRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);//调整数据
|
|
|
|
|
|
var adjdtos = ObjectMapper.Map<List<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(adjs);//调整数据DTO
|
|
|
|
|
|
|
|
|
var notquery = from itm in sdtos |
|
|
var notquery = from itm in sdtos |
|
|
join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum |
|
|
join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum |
|
|
select |
|
|
select |
|
@ -249,8 +283,7 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
SettleGroupNum = itm.SettleGroupNum |
|
|
SettleGroupNum = itm.SettleGroupNum |
|
|
}; |
|
|
}; |
|
|
var adjs = await _adjRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false); |
|
|
|
|
|
var adjdtos = ObjectMapper.Map<List<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(adjs); |
|
|
|
|
|
var adjQuery = from itm in adjdtos |
|
|
var adjQuery = from itm in adjdtos |
|
|
join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum |
|
|
join itm1 in invs on itm.InvBillNum equals itm1.InvbillNum |
|
|
select |
|
|
select |
|
@ -266,9 +299,68 @@ namespace Win.Sfs.SettleAccount.Bases |
|
|
KeyCode = itm.KeyCode, |
|
|
KeyCode = itm.KeyCode, |
|
|
Price = itm.Price |
|
|
Price = itm.Price |
|
|
}; |
|
|
}; |
|
|
entity.INVOICE_NOT_SETTLE = notquery.ToList(); |
|
|
|
|
|
entity.INVOICE_MAP_GROUP = mquery.ToList(); |
|
|
entity.INVOICE_NOT_SETTLE = notquery.OrderBy(p => p.SettleGroupNum).ThenBy(p => p.LU).ToList(); |
|
|
entity.ADJ_DETAIL = adjQuery.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, |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)//BBAC直供未结
|
|
|
|
|
|
{ |
|
|
|
|
|
//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 = sdtos |
|
|
|
|
|
.GroupBy(p => new { p.LU, p.SettleGroupNum }) |
|
|
|
|
|
.Select(p => new JIT_UNSETTLED_DETAIL_DTO { LU = p.Key.LU, GroupNum = p.Key.SettleGroupNum, Qty = p.Sum(itm => itm.Qty.Value) }); |
|
|
|
|
|
entity.JIT_UNSETTLED_DETAIL = unsettledList.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.JisBBAC) |
|
|
|
|
|
{ |
|
|
|
|
|
entity.INVOICE_MAP_GROUP = lscompare.ToList().OrderBy(p => p.SettleGroupNum).ToList();//包含不可结结算分组号
|
|
|
|
|
|
} |
|
|
|
|
|
if (first.BusinessType == EnumBusinessType.MaiDanJianHBPO) |
|
|
|
|
|
{ |
|
|
|
|
|
//List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO> maidan = new List<MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO>();
|
|
|
|
|
|
|
|
|
|
|
|
var maiquery = from itm in m |
|
|
|
|
|
join itm1 in invs on itm.InvbillNum equals itm1.InvbillNum |
|
|
|
|
|
select |
|
|
|
|
|
new MAIDAN_HBPO_INVOICE_MAP_GROUP_DTO() |
|
|
|
|
|
{ |
|
|
|
|
|
Extend1 = itm.Extend1, |
|
|
|
|
|
InvGroupNum = itm.InvGroupNum, |
|
|
|
|
|
SettleGroupNum = itm.SettleGroupNum, |
|
|
|
|
|
InvbillNum = itm.InvbillNum, |
|
|
|
|
|
RealInvBillNum = itm1.RealnvBillNum |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
entity.MAIDAN_HBPO_INVOICE_MAP_GROUP = maiquery.ToList(); |
|
|
|
|
|
List<MAIDAN_HBPO_UNSETTLED_DETAIL_DTO> unsettle = new List<MAIDAN_HBPO_UNSETTLED_DETAIL_DTO>(); |
|
|
|
|
|
foreach (var itm in notquery.ToList()) |
|
|
|
|
|
{ |
|
|
|
|
|
unsettle.Add(new MAIDAN_HBPO_UNSETTLED_DETAIL_DTO() |
|
|
|
|
|
{ |
|
|
|
|
|
GroupNum = itm.InvGroupNum, |
|
|
|
|
|
LU = itm.LU, |
|
|
|
|
|
PN = itm.Extend1, |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
entity.MAIDAN_HBPO_UNSETTLED_DETAIL = unsettle; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
entity.ADJ_DETAIL = adjQuery.ToList().OrderBy(p => p.GroupNum).ThenBy(p => p.LU).ToList(); |
|
|
return entity; |
|
|
return entity; |
|
|
} |
|
|
} |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|