Browse Source

更新JIT开票

master
学 赵 7 months ago
parent
commit
7e9a5f7692
  1. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  2. 171
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs
  3. 335
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs
  4. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

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

@ -216,7 +216,7 @@ namespace Win.Sfs.SettleAccount.Bases
invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_invGroupNum, string.Empty, businessType, true).ConfigureAwait(false); invlist = await _invmng.MakeInvoice(p_list, p_adjlist, dtos, p_version, p_invGroupNum, string.Empty, businessType, true).ConfigureAwait(false);
break; break;
case EnumBusinessType.ZhiGongJianBBAC: case EnumBusinessType.ZhiGongJianBBAC:
invlist = await _invmng.JITInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType, true).ConfigureAwait(false);//重开可以变多张发票 invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType).ConfigureAwait(false);//重开可以变多张发票
break; break;
case EnumBusinessType.ZhiGongJianHBPO: case EnumBusinessType.ZhiGongJianHBPO:
invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType).ConfigureAwait(false);//重开可以变多张发票 invlist = await _invmng.FirstInvoice(p_list, p_adjlist, dtos, p_notlist, p_version, p_invGroupNum, string.Empty, businessType).ConfigureAwait(false);//重开可以变多张发票

171
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/GenerateJisInvoiceService.cs

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoMapper; using AutoMapper;
using CodeArts.Db.Lts;
using DocumentFormat.OpenXml.Presentation; using DocumentFormat.OpenXml.Presentation;
using EFCore.BulkExtensions; using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -34,7 +35,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
public decimal Amt { set; get; } public decimal Amt { set; get; }
public decimal TaxAmt { set; get; } public decimal TaxAmt { set; get; }
public decimal Tax { set; get;} public decimal Tax { set; get; }
} }
@ -116,7 +117,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
else//二次开票 else//二次开票
{ {
var invs = SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); var query = from b in _dbcontext.Set<BBAC_NOT_SA_DETAIL>()
join a in (from d in _dbcontext.Set<BBAC_CAN_SA_DETAIL>()
where d.BillNum == main.BillNum
select d.GroupNum).Distinct()
on b.GroupNum equals a
group b by new { b.GroupNum, b.LU } into g
select new TEMP_NOT_SA_DETAIL
{
GroupNum = g.Key.GroupNum,
LU = g.Key.LU,
Qty = g.Sum(p => p.Qty),
};
var invs = SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, query.ToList());
if (invs.Count > 0) if (invs.Count > 0)
{ {
main.State = SettleBillState.; main.State = SettleBillState.;
@ -126,7 +139,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
_dbcontext.BulkUpdate(new List<BBAC_CAN_SA>() { main }); _dbcontext.BulkUpdate(new List<BBAC_CAN_SA>() { main });
} }
} }
if(BussinessType== "JisHBPO") if (BussinessType == "JisHBPO")
{ {
var main = _dbcontext.Set<HBPO_CAN_SA>().FirstOrDefault(p => p.InvGroupNum == billNum); var main = _dbcontext.Set<HBPO_CAN_SA>().FirstOrDefault(p => p.InvGroupNum == billNum);
//var main = await _bbacMng.GetMainAsync(invbillNum); //var main = await _bbacMng.GetMainAsync(invbillNum);
@ -155,7 +168,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
Qty = d.Qty, Qty = d.Qty,
GroupNum = d.GroupNum, GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2), Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID ="n", ContractDocID = "n",
BeginDate = p.BeginTime, BeginDate = p.BeginTime,
EndDate = p.EndTime, EndDate = p.EndTime,
PartCode = d.PartCode PartCode = d.PartCode
@ -192,7 +205,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
else//二次开票 else//二次开票
{ {
var invs = SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType); var query = from b in _dbcontext.Set<HBPO_NOT_SA_DETAIL>()
join a in (from d in _dbcontext.Set<HBPO_CAN_SA_DETAIL>()
where d.BillNum == main.BillNum
select d.GroupNum).Distinct()
on b.GroupNum equals a
group b by new { b.GroupNum, b.LU } into g
select new TEMP_NOT_SA_DETAIL
{
GroupNum = g.Key.GroupNum,
LU = g.Key.LU,
Qty = g.Sum(p => p.Qty),
};
var invs = SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType, query.ToList());
if (invs.Count > 0) if (invs.Count > 0)
{ {
main.State = SettleBillState.; main.State = SettleBillState.;
@ -204,7 +231,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
return id.ToString(); return id.ToString();
} }
public List<string> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) public List<string> SecInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_ajdlist, List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType, List<TEMP_NOT_SA_DETAIL> p_notlist = null)
where TDetail : SA_CAN_BASE where TDetail : SA_CAN_BASE
{ {
List<string> _invls = new List<string>(); List<string> _invls = new List<string>();
@ -252,39 +279,45 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
&& group.BeginDate == group1.BeginDate && group.BeginDate == group1.BeginDate
&& group.EndDate == group1.EndDate && group.EndDate == group1.EndDate
&& group1.ContractDocID == group.ContractDocID && group1.ContractDocID == group.ContractDocID
&& group1.Price == group.Price
&& group1.Qty == group.Qty
&& group1.Amt == group.Amt
) )
{ {
tempList.Add(group1); tempList.Add(group1);
partCount++;//符合条件加入到零件中 partCount++;//符合条件加入到零件中
continue; continue;
} }
//partCount++; sum += group1.Amt;
//if (partCount > 30)
//{
// continue;
//}
if (sum > 10000000) if (sum > 10000000)
{ {
break; break;
} }
sum += group1.Amt;
tempList.Add(group1); tempList.Add(group1);
} }
invoiceMap.Add(invoiceBillNum, tempList); invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1 //更新分组 var query = from itm in groups1 //更新分组
join itm1 in tempList join itm1 in tempList
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode } on
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode } into temp new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode, itm.Qty, itm.Price, itm.Amt }
from tm in temp equals
new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode, itm1.Qty, itm1.Price, itm1.Amt }
into temp
from tm in temp.DefaultIfEmpty()
where tm == null where tm == null
select new TMEP_INV select new TMEP_INV
{ {
LU = itm.LU, LU = itm.LU,
Amt = itm.Amt, Amt = itm.Amt,
Qty = itm.Qty, Qty = itm.Qty,
Price = itm.Price,
BeginDate = itm.BeginDate, BeginDate = itm.BeginDate,
ContractDocID = itm.ContractDocID, ContractDocID = itm.ContractDocID,
EndDate = itm.EndDate EndDate = itm.EndDate,
PartCode = itm.PartCode,
}; };
groups1 = query.ToList(); groups1 = query.ToList();
} }
@ -297,6 +330,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
var invlist = new List<INVOICE_GRP>(); var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>(); var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>(); var adjlist = new List<PUB_ADJ_DETAIL>();
int count = invoiceMap.Keys.Count;//计算第几张发票计数器
int i = 1;
foreach (var group in invoiceMap) foreach (var group in invoiceMap)
{ {
var key = group.Key;//发票票号 var key = group.Key;//发票票号
@ -304,9 +339,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
//反向查找结算数据 //反向查找结算数据
var query = from itm in dtos var query = from itm in dtos
join itm1 in ls join itm1 in ls
on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate } on new { itm.LU, itm.PartCode, itm.BeginDate, itm.EndDate, itm.ContractDocID } equals new { itm1.LU, itm1.PartCode, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID }
join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate } join itm2 in p_list on new { itm.PartCode, itm.PN, itm.SettleDate } equals new { itm2.PartCode, itm2.PN, itm2.SettleDate }
select itm2; select itm2;//反向更新可计算数据
foreach (var itm in query) foreach (var itm in query)
{ {
itm.InvbillNum = key; itm.InvbillNum = key;
@ -351,27 +386,66 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
{ {
detailList.AddRange(_entityDetailList); detailList.AddRange(_entityDetailList);
} }
List<tempAmt> amtList = new List<tempAmt>(); #region 发票不能结算的明细
foreach (var itm in detailList) var innotls = new List<INVOICE_NOT_SETTLE>();
var sq = query.GroupBy(p => new { p.LU, p.GroupNum })
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = group.Key, GroupNum = p.Key.GroupNum });
foreach (var sitm in sq)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: sitm.GroupNum,
lU: sitm.LU,
lU1: sitm.LU,
extend1: "可结算",
extend2: string.Empty,
qty: sitm.Qty,
p_invbillnum: group.Key
));
}
if (innotls.Count > 0)
{ {
amtList.Add(new tempAmt() { notDetialList.AddRange(innotls);
Amt=itm.Amt,
Tax=Math.Round(itm.Amt*0.13m,2),
TaxAmt=itm.Amt+ Math.Round(itm.Amt * 0.13m, 2)
});
} }
decimal amt = amtList.Sum(k => k.Amt);//金额 if (p_notlist != null && p_notlist.Count > 0)
decimal txtAmt = amtList.Sum(k => k.TaxAmt) ;//税后金额 {
decimal readAmt = amtList.Sum(k=>k.Tax);//税额 var innotls1 = new List<INVOICE_NOT_SETTLE>();
//decimal amt = detailList.Sum(k => k.Amt); var grouplist = query.Select(p => p.GroupNum).ToList();
//decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
var contractList = ls.Select(p => p.ContractDocID).Distinct(); var notlist = p_notlist.Where(p => grouplist.Contains(p.GroupNum));
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(); foreach (var nitm in notlist)
//var _groupList = dtos.GroupBy(p => new { p.GroupNum }) {
// .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct(); innotls1.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: nitm.LU,
lU1: nitm.LU,
extend1: "不可结算",
extend2: string.Empty,
qty: nitm.Qty,
p_invbillnum: group.Key
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls1);
}
}
#endregion
decimal amt = ls.Sum(k => k.Amt);//金额
decimal txtAmt = Math.Round(amt * 0.13m, 2);//税后金额
decimal readAmt = amt + Math.Round(amt * 0.13m, 2);//税额
//var contractList = ls.Select(p => p.ContractDocID).Distinct();
var _groupList = query.GroupBy(p => new { p.GroupNum })
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => Math.Round(itm.Qty * itm.Price, 2)) }).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) foreach (var en in _groupList)
{ {
@ -390,7 +464,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
{ {
groupList.AddRange(group1); groupList.AddRange(group1);
} }
var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList(); var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList();
string site = lst.FirstOrDefault().Site; string site = lst.FirstOrDefault().Site;
string clientCode = string.Empty; string clientCode = string.Empty;
@ -434,9 +507,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
_dbcontext.BulkInsert(invlist); _dbcontext.BulkInsert(invlist);
_dbcontext.BulkInsert(groupList); _dbcontext.BulkInsert(groupList);
_dbcontext.BulkInsert(detailList); _dbcontext.BulkInsert(detailList);
_dbcontext.BulkInsert(notDetialList);
if (salist.Count > 0) if (salist.Count > 0)
{ {
_dbcontext.BulkUpdate(salist); _dbcontext.BulkUpdate(salist);
} }
if (adjlist.Count > 0) if (adjlist.Count > 0)
{ {
@ -447,7 +522,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
return _invls; return _invls;
} }
public List<string> FirstInvoice<TDetail>( List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType) public List<string> FirstInvoice<TDetail>(List<TDetail> p_list, List<PUB_ADJ_DETAIL> p_adjlist, List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
where TDetail : SA_CAN_BASE where TDetail : SA_CAN_BASE
{ {
List<string> _invls = new List<string>(); List<string> _invls = new List<string>();
@ -552,7 +627,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
lsby.AddRange(grouplist); lsby.AddRange(grouplist);
var nolist = p_notlist.Where(p => !grouplist.Contains(p.GroupNum)).Select(p => p.GroupNum).ToList();//不可结分组 var nolist = p_notlist.Where(p => !grouplist.Contains(p.GroupNum)).Select(p => p.GroupNum).ToList();//不可结分组
int count = invoiceMap.Keys.Count;//计算第几张发票计数器 int count = invoiceMap.Keys.Count;//计算第几张发票计数器
int i = 1; int i = 1;
foreach (var itm in invoiceMap)//分组影响和 foreach (var itm in invoiceMap)//分组影响和
{ {
@ -585,14 +659,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
Price = itm.Key.Price, Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税前 Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税前
Tax = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2),//税 Tax = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2),//税
TaxAmt = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2)+ Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税后进 TaxAmt = Math.Round(Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2) * 0.13m, 2) + Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),//税后进
Qty = itm.Sum(k => k.Qty), Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate, BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate EndDate = itm.Key.EndDate
}).ToList(); }).ToList();
decimal amt = detailDtos.Sum(k => k.Amt);//金额 decimal amt = detailDtos.Sum(k => k.Amt);//金额
decimal txtAmt = detailDtos.Sum(k => k.TaxAmt);//税后金额 decimal txtAmt = detailDtos.Sum(k => k.TaxAmt);//税后金额
decimal realAmt =detailDtos.Sum(k => k.Tax);//税额 decimal realAmt = detailDtos.Sum(k => k.Tax);//税额
var mapList = new List<INVOICE_MAP_GROUP>(); var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls) foreach (var groupnum in ls)
@ -738,14 +813,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
// 执行批量数据操作 // 执行批量数据操作
if (salist.Count > 0) if (salist.Count > 0)
{ {
_dbcontext.BulkUpdate(salist); _dbcontext.BulkUpdate(salist);
} }
_dbcontext.BulkInsert(invlist); _dbcontext.BulkInsert(invlist);
_dbcontext.BulkInsert(groupList); _dbcontext.BulkInsert(groupList);
_dbcontext.BulkInsert(detailList); _dbcontext.BulkInsert(detailList);
if (adjlist.Count > 0) if (adjlist.Count > 0)
{ {
_dbcontext.BulkInsert(adjlist); _dbcontext.BulkInsert(adjlist);
} }
if (notDetialList.Count > 0) if (notDetialList.Count > 0)
{ {

335
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MakeCanSettlementService.cs

@ -183,74 +183,113 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
if (part_group_small.Count > 0) if (part_group_small.Count > 0)
{ {
var partlist = part_group_small.Select(p => p.LU).ToList(); var partlist = part_group_small.Select(p => p.LU).ToList();
var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ; var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList();
decimal sum = 0; var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>(); var bbac_sa = new BBAC_CAN_SA();
bbac_sa.SetId(Guid.NewGuid());
bbac_sa.BillNum = billNum;
bbac_sa.InvGroupNum = billNum;
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa.State = SettleBillState.;
bbac_sa.SettleBillNum = string.Empty;
bbac_sa.Site = "1040";
bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa);
foreach (var itm1 in ls) foreach (var itm1 in ls)
{ {
sum += (itm1.Qty * itm1.Price);
if (sum > 10000000)
{
var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa = new BBAC_CAN_SA();
bbac_sa.SetId(Guid.NewGuid());
bbac_sa.BillNum = billNum;
bbac_sa.InvGroupNum = billNum;
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa.State = SettleBillState.;
bbac_sa.SettleBillNum = string.Empty;
bbac_sa.Site = "1040";
bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa);
foreach (var itm2 in details)
{
itm2.SetBillNum(billNum);
itm2.SetGroupNum(billNum);
billDetails.Add(itm2);
}
details = new List<BBAC_CAN_SA_DETAIL>();
sum = itm1.Qty * itm1.Price;
}
var _detailEntity = new BBAC_CAN_SA_DETAIL( var _detailEntity = new BBAC_CAN_SA_DETAIL(
guid: GuidGenerator.Create(), guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode, keyCode: itm1.KeyCode,
version: itm1.Version, version: itm1.Version,
billNum: string.Empty, billNum: billNum,
settleBillNum: itm1.SettleBillNum, settleBillNum: itm1.SettleBillNum,
lU: itm1.LU, lU: itm1.LU,
pN: itm1.PN, pN: itm1.PN,
site: itm1.Site, site: itm1.Site,
qty: itm1.Qty, qty: itm1.Qty,
price: itm1.Price, price: itm1.Price,
category: itm1.BusinessType, category: itm1.BusinessType,
isReturn: itm1.IsReturn, isReturn: itm1.IsReturn,
settleDate: itm1.SettleDate, settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum, groupNum: itm1.GroupNum,
invGroupNum: string.Empty, invGroupNum: billNum,
contactid: itm1.ContractDocID, contactid: itm1.ContractDocID,
invbillnum: string.Empty, invbillnum: string.Empty,
partcode: itm1.PartCode partcode: itm1.PartCode
); );
_detailEntity.RealPartCode = itm1.RealPartCode; _detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity); billDetails.Add(_detailEntity);
}
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa1 = new BBAC_CAN_SA();
bbac_sa1.SetId(Guid.NewGuid());
bbac_sa1.BillNum = billNum1;
bbac_sa1.InvGroupNum = billNum1;
bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa1.State = SettleBillState.;
bbac_sa1.SettleBillNum = string.Empty;
bbac_sa1.Site = "1040";
bbac_sa1.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa1);
foreach (var detail in details)
{
detail.SetBillNum(billNum1);
detail.SetGroupNum(billNum1);
billDetails.Add(detail);
} }
//var partlist = part_group_small.Select(p => p.LU).ToList();
//var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ;
//decimal sum = 0;
//List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>();
//foreach (var itm1 in ls)
//{
// sum += (itm1.Qty * itm1.Price);
// if (sum > 10000000)
// {
// var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
// var bbac_sa = new BBAC_CAN_SA();
// bbac_sa.SetId(Guid.NewGuid());
// bbac_sa.BillNum = billNum;
// bbac_sa.InvGroupNum = billNum;
// bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
// bbac_sa.State = SettleBillState.未结状态;
// bbac_sa.SettleBillNum = string.Empty;
// bbac_sa.Site = "1040";
// bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
// billList.Add(bbac_sa);
// foreach (var itm2 in details)
// {
// itm2.SetBillNum(billNum);
// itm2.SetGroupNum(billNum);
// billDetails.Add(itm2);
// }
// details = new List<BBAC_CAN_SA_DETAIL>();
// sum = itm1.Qty * itm1.Price;
// }
// var _detailEntity = new BBAC_CAN_SA_DETAIL(
// guid: GuidGenerator.Create(),
// keyCode: itm1.KeyCode,
// version: itm1.Version,
// billNum: string.Empty,
// settleBillNum: itm1.SettleBillNum,
// lU: itm1.LU,
// pN: itm1.PN,
// site: itm1.Site,
// qty: itm1.Qty,
// price: itm1.Price,
// category: itm1.BusinessType,
// isReturn: itm1.IsReturn,
// settleDate: itm1.SettleDate,
// groupNum: itm1.GroupNum,
// invGroupNum: string.Empty,
// contactid: itm1.ContractDocID,
// invbillnum: string.Empty,
// partcode: itm1.PartCode
// );
// _detailEntity.RealPartCode = itm1.RealPartCode;
// details.Add(_detailEntity);
//}
//var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
//var bbac_sa1 = new BBAC_CAN_SA();
//bbac_sa1.SetId(Guid.NewGuid());
//bbac_sa1.BillNum = billNum1;
//bbac_sa1.InvGroupNum = billNum1;
//bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
//bbac_sa1.State = SettleBillState.未结状态;
//bbac_sa1.SettleBillNum = string.Empty;
//bbac_sa1.Site = "1040";
//bbac_sa1.BusinessType = EnumBusinessType.JisBBAC;
//billList.Add(bbac_sa1);
//foreach (var detail in details)
//{
// detail.SetBillNum(billNum1);
// detail.SetGroupNum(billNum1);
// billDetails.Add(detail);
//}
} }
} }
} }
@ -370,79 +409,113 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
if (part_group_small.Count > 0) if (part_group_small.Count > 0)
{ {
var partlist = part_group_small.Select(p => p.LU).ToList(); var partlist = part_group_small.Select(p => p.LU).ToList();
var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ; var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList();
decimal sum = 0; var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>(); var bbac_sa = new BBAC_CAN_SA();
bbac_sa.SetId(Guid.NewGuid());
bbac_sa.BillNum = billNum;
bbac_sa.InvGroupNum = billNum;
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa.State = SettleBillState.;
bbac_sa.SettleBillNum = string.Empty;
bbac_sa.Site = "1046";
bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa);
foreach (var itm1 in ls) foreach (var itm1 in ls)
{ {
sum += (itm1.Qty * itm1.Price);
if (sum > 10000000)
{
var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa = new BBAC_CAN_SA();
bbac_sa.SetId(Guid.NewGuid());
bbac_sa.BillNum = billNum;
bbac_sa.InvGroupNum = billNum;
bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa.State = SettleBillState.;
bbac_sa.SettleBillNum = string.Empty;
bbac_sa.Site = "1046";
bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa);
foreach (var itm2 in details)
{
itm2.SetBillNum(billNum);
itm2.SetGroupNum(billNum);
billDetails.Add(itm2);
}
details = new List<BBAC_CAN_SA_DETAIL>();
sum = itm1.Qty * itm1.Price;
}
var _detailEntity = new BBAC_CAN_SA_DETAIL( var _detailEntity = new BBAC_CAN_SA_DETAIL(
guid: GuidGenerator.Create(), guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode, keyCode: itm1.KeyCode,
version: itm1.Version, version: itm1.Version,
billNum: string.Empty, billNum: billNum,
settleBillNum: itm1.SettleBillNum, settleBillNum: itm1.SettleBillNum,
lU: itm1.LU, lU: itm1.LU,
pN: itm1.PN, pN: itm1.PN,
site: itm1.Site, site: itm1.Site,
qty: itm1.Qty, qty: itm1.Qty,
price: itm1.Price, price: itm1.Price,
category: itm1.BusinessType, category: itm1.BusinessType,
isReturn: itm1.IsReturn, isReturn: itm1.IsReturn,
settleDate: itm1.SettleDate, settleDate: itm1.SettleDate,
groupNum: itm1.GroupNum, groupNum: itm1.GroupNum,
invGroupNum: string.Empty, invGroupNum: billNum,
contactid: itm1.ContractDocID, contactid: itm1.ContractDocID,
invbillnum: string.Empty, invbillnum: string.Empty,
partcode: itm1.PartCode partcode: itm1.PartCode
); );
_detailEntity.RealPartCode = itm1.RealPartCode; _detailEntity.RealPartCode = itm1.RealPartCode;
details.Add(_detailEntity); billDetails.Add(_detailEntity);
}
var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
var bbac_sa1 = new BBAC_CAN_SA();
bbac_sa1.SetId(Guid.NewGuid());
bbac_sa1.BillNum = billNum1;
bbac_sa1.InvGroupNum = billNum1;
bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
bbac_sa1.State = SettleBillState.;
bbac_sa1.SettleBillNum = string.Empty;
bbac_sa1.Site = "1046";
bbac_sa1.BusinessType = EnumBusinessType.JisBBAC;
billList.Add(bbac_sa1);
foreach (var detail in details)
{
detail.SetBillNum(billNum1);
detail.SetGroupNum(billNum1);
billDetails.Add(detail);
} }
//var partlist = part_group_small.Select(p => p.LU).ToList();
//var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ;
//decimal sum = 0;
//List<BBAC_CAN_SA_DETAIL> details = new List<BBAC_CAN_SA_DETAIL>();
//foreach (var itm1 in ls)
//{
// sum += (itm1.Qty * itm1.Price);
// if (sum > 10000000)
// {
// var billNum = OrderNumberGenerator.GenerateOrderNumber("N");
// var bbac_sa = new BBAC_CAN_SA();
// bbac_sa.SetId(Guid.NewGuid());
// bbac_sa.BillNum = billNum;
// bbac_sa.InvGroupNum = billNum;
// bbac_sa.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
// bbac_sa.State = SettleBillState.未结状态;
// bbac_sa.SettleBillNum = string.Empty;
// bbac_sa.Site = "1046";
// bbac_sa.BusinessType = EnumBusinessType.JisBBAC;
// billList.Add(bbac_sa);
// foreach (var itm2 in details)
// {
// itm2.SetBillNum(billNum);
// itm2.SetGroupNum(billNum);
// billDetails.Add(itm2);
// }
// details = new List<BBAC_CAN_SA_DETAIL>();
// sum = itm1.Qty * itm1.Price;
// }
// var _detailEntity = new BBAC_CAN_SA_DETAIL(
// guid: GuidGenerator.Create(),
// keyCode: itm1.KeyCode,
// version: itm1.Version,
// billNum: string.Empty,
// settleBillNum: itm1.SettleBillNum,
// lU: itm1.LU,
// pN: itm1.PN,
// site: itm1.Site,
// qty: itm1.Qty,
// price: itm1.Price,
// category: itm1.BusinessType,
// isReturn: itm1.IsReturn,
// settleDate: itm1.SettleDate,
// groupNum: itm1.GroupNum,
// invGroupNum: string.Empty,
// contactid: itm1.ContractDocID,
// invbillnum: string.Empty,
// partcode: itm1.PartCode
// );
// _detailEntity.RealPartCode = itm1.RealPartCode;
// details.Add(_detailEntity);
//}
//var billNum1 = OrderNumberGenerator.GenerateOrderNumber("N");
//var bbac_sa1 = new BBAC_CAN_SA();
//bbac_sa1.SetId(Guid.NewGuid());
//bbac_sa1.BillNum = billNum1;
//bbac_sa1.InvGroupNum = billNum1;
//bbac_sa1.Version = int.Parse(DateTime.Now.ToString("yyyyMM"));
//bbac_sa1.State = SettleBillState.未结状态;
//bbac_sa1.SettleBillNum = string.Empty;
//bbac_sa1.Site = "1046";
//bbac_sa1.BusinessType = EnumBusinessType.JisBBAC;
//billList.Add(bbac_sa1);
//foreach (var detail in details)
//{
// detail.SetBillNum(billNum1);
// detail.SetGroupNum(billNum1);
// billDetails.Add(detail);
//}
} }
} }
} }
@ -634,7 +707,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
} }
if (part_group_small.Count > 0) if (part_group_small.Count > 0)
{ {
var partlist = part_group_small.Select(p => p.LU).ToList(); var partlist = part_group_small.Select(p => p.LU).ToList();
var ls = hbpo_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ; var ls = hbpo_can_list.Where(p => partlist.Contains(p.LU)).ToList(); ;
decimal sum = 0; decimal sum = 0;
List<HBPO_CAN_SA_DETAIL> details = new List<HBPO_CAN_SA_DETAIL>(); List<HBPO_CAN_SA_DETAIL> details = new List<HBPO_CAN_SA_DETAIL>();

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

@ -1309,7 +1309,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
// List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类 // List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组 if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{ {
if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO || first.BusinessType == EnumBusinessType.ZhiGongJianBBAC)
{ {
foreach (var _itm1 in copyDic) foreach (var _itm1 in copyDic)
{ {

Loading…
Cancel
Save