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);
break;
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;
case EnumBusinessType.ZhiGongJianHBPO:
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.Threading.Tasks;
using AutoMapper;
using CodeArts.Db.Lts;
using DocumentFormat.OpenXml.Presentation;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Mvc;
@ -34,7 +35,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
public decimal Amt { 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//二次开票
{
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)
{
main.State = SettleBillState.;
@ -126,7 +139,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
_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 = await _bbacMng.GetMainAsync(invbillNum);
@ -155,7 +168,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
Qty = d.Qty,
GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID ="n",
ContractDocID = "n",
BeginDate = p.BeginTime,
EndDate = p.EndTime,
PartCode = d.PartCode
@ -192,7 +205,21 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
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)
{
main.State = SettleBillState.;
@ -204,7 +231,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
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
{
List<string> _invls = new List<string>();
@ -252,39 +279,45 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
&& group.BeginDate == group1.BeginDate
&& group.EndDate == group1.EndDate
&& group1.ContractDocID == group.ContractDocID
&& group1.Price == group.Price
&& group1.Qty == group.Qty
&& group1.Amt == group.Amt
)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
//partCount++;
//if (partCount > 30)
//{
// continue;
//}
sum += group1.Amt;
if (sum > 10000000)
{
break;
}
sum += group1.Amt;
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1 //更新分组
join itm1 in tempList
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode }
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID, itm1.PartCode } into temp
from tm in temp
on
new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID, itm.PartCode, itm.Qty, itm.Price, itm.Amt }
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
select new TMEP_INV
{
LU = itm.LU,
Amt = itm.Amt,
Qty = itm.Qty,
Price = itm.Price,
BeginDate = itm.BeginDate,
ContractDocID = itm.ContractDocID,
EndDate = itm.EndDate
EndDate = itm.EndDate,
PartCode = itm.PartCode,
};
groups1 = query.ToList();
}
@ -297,6 +330,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
int count = invoiceMap.Keys.Count;//计算第几张发票计数器
int i = 1;
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
@ -304,9 +339,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
//反向查找结算数据
var query = from itm in dtos
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 }
select itm2;
select itm2;//反向更新可计算数据
foreach (var itm in query)
{
itm.InvbillNum = key;
@ -351,27 +386,66 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
{
detailList.AddRange(_entityDetailList);
}
List<tempAmt> amtList = new List<tempAmt>();
foreach (var itm in detailList)
#region 发票不能结算的明细
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() {
Amt=itm.Amt,
Tax=Math.Round(itm.Amt*0.13m,2),
TaxAmt=itm.Amt+ Math.Round(itm.Amt * 0.13m, 2)
});
notDetialList.AddRange(innotls);
}
decimal amt = amtList.Sum(k => k.Amt);//金额
decimal txtAmt = amtList.Sum(k => k.TaxAmt) ;//税后金额
decimal readAmt = amtList.Sum(k=>k.Tax);//税额
//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();
if (p_notlist != null && p_notlist.Count > 0)
{
var innotls1 = new List<INVOICE_NOT_SETTLE>();
var grouplist = query.Select(p => p.GroupNum).ToList();
var notlist = p_notlist.Where(p => grouplist.Contains(p.GroupNum));
foreach (var nitm in notlist)
{
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>();
foreach (var en in _groupList)
{
@ -390,7 +464,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
{
groupList.AddRange(group1);
}
var lst = dtos.Where(p => !string.IsNullOrEmpty(p.Site)).ToList();
string site = lst.FirstOrDefault().Site;
string clientCode = string.Empty;
@ -434,9 +507,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
_dbcontext.BulkInsert(invlist);
_dbcontext.BulkInsert(groupList);
_dbcontext.BulkInsert(detailList);
_dbcontext.BulkInsert(notDetialList);
if (salist.Count > 0)
{
_dbcontext.BulkUpdate(salist);
_dbcontext.BulkUpdate(salist);
}
if (adjlist.Count > 0)
{
@ -447,7 +522,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
}
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
{
List<string> _invls = new List<string>();
@ -552,7 +627,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
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 = 1;
foreach (var itm in invoiceMap)//分组影响和
{
@ -585,14 +659,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
Price = itm.Key.Price,
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),//税
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),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
}).ToList();
decimal amt = detailDtos.Sum(k => k.Amt);//金额
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>();
foreach (var groupnum in ls)
@ -738,14 +813,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
// 执行批量数据操作
if (salist.Count > 0)
{
_dbcontext.BulkUpdate(salist);
_dbcontext.BulkUpdate(salist);
}
_dbcontext.BulkInsert(invlist);
_dbcontext.BulkInsert(groupList);
_dbcontext.BulkInsert(detailList);
_dbcontext.BulkInsert(invlist);
_dbcontext.BulkInsert(groupList);
_dbcontext.BulkInsert(detailList);
if (adjlist.Count > 0)
{
_dbcontext.BulkInsert(adjlist);
_dbcontext.BulkInsert(adjlist);
}
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)
{
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>();
var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList();
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 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
);
guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode,
version: itm1.Version,
billNum: billNum,
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: billNum,
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);
billDetails.Add(_detailEntity);
}
//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)
{
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>();
var ls = bbac_can_list.Where(p => partlist.Contains(p.LU)).ToList();
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 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
);
guid: GuidGenerator.Create(),
keyCode: itm1.KeyCode,
version: itm1.Version,
billNum: billNum,
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: billNum,
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);
billDetails.Add(_detailEntity);
}
//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)
{
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(); ;
decimal sum = 0;
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种类
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)
{

Loading…
Cancel
Save