|
|
@ -101,79 +101,79 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = await ExportErrorReportAsync(errorList).ConfigureAwait(false) }); |
|
|
|
} |
|
|
|
|
|
|
|
List<CustomCondition> customConditionList = new List<CustomCondition>(); |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillNum }); |
|
|
|
customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() }); |
|
|
|
//List<CustomCondition> customConditionList = new List<CustomCondition>();
|
|
|
|
//customConditionList.Add(new CustomCondition() { Name = "BillNum", Value = invbillNum });
|
|
|
|
//customConditionList.Add(new CustomCondition() { Name = "BussinessType", Value = main.BusinessType.ToString() });
|
|
|
|
|
|
|
|
//main.State = SettleBillState.发票生成中;
|
|
|
|
await _bbacMng.SetWaitingState(invbillNum); |
|
|
|
var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) => |
|
|
|
{ |
|
|
|
}).ConfigureAwait(false); |
|
|
|
|
|
|
|
//await _bbacMng.SetWaitingState(invbillNum);
|
|
|
|
//var _taskid = await _service.ExportEnqueueAsync("生成发票任务", ExportExtentsion.Excel, string.Empty, string.Empty, CurrentUser, typeof(GenerateJisInvoiceService), customConditionList, (rs) =>
|
|
|
|
//{
|
|
|
|
//}).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
//if (await _bbacMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false))
|
|
|
|
//{
|
|
|
|
// var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
|
|
|
|
// var notQuery = await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync().ConfigureAwait(false);
|
|
|
|
// 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 == main.Site
|
|
|
|
// select new TEMP_CAN_SA_DETAIL
|
|
|
|
// {
|
|
|
|
// 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, 1) == "C")//一次开票
|
|
|
|
// {
|
|
|
|
// var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
|
|
|
|
// {
|
|
|
|
// KeyCode = p.KeyCode,
|
|
|
|
// Version = p.Version,
|
|
|
|
// SettleBillNum = p.SettleBillNum,
|
|
|
|
// LU = p.LU,
|
|
|
|
// PN = p.PN,
|
|
|
|
// Site = p.Site,
|
|
|
|
// Qty = p.Qty,
|
|
|
|
// Price = p.Price,
|
|
|
|
// BusinessType = p.BusinessType,
|
|
|
|
// IsReturn = "",
|
|
|
|
// InvGroupNum = p.InvGroupNum,
|
|
|
|
// SettleDate = p.SettleDate,
|
|
|
|
// GroupNum = p.GroupNum,
|
|
|
|
// ContractDocID = string.Empty,
|
|
|
|
// PartCode = p.PartCode
|
|
|
|
|
|
|
|
// }).ToList();//不能结算
|
|
|
|
// await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
|
|
|
|
// }
|
|
|
|
// else//二次开票
|
|
|
|
// {
|
|
|
|
// await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (await _bbacMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false)) |
|
|
|
{ |
|
|
|
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList(); |
|
|
|
var notQuery = await _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToListAsync().ConfigureAwait(false); |
|
|
|
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 == main.Site |
|
|
|
select new TEMP_CAN_SA_DETAIL |
|
|
|
{ |
|
|
|
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, 1) == "C")//一次开票
|
|
|
|
{ |
|
|
|
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL |
|
|
|
{ |
|
|
|
KeyCode = p.KeyCode, |
|
|
|
Version = p.Version, |
|
|
|
SettleBillNum = p.SettleBillNum, |
|
|
|
LU = p.LU, |
|
|
|
PN = p.PN, |
|
|
|
Site = p.Site, |
|
|
|
Qty = p.Qty, |
|
|
|
Price = p.Price, |
|
|
|
BusinessType = p.BusinessType, |
|
|
|
IsReturn = "", |
|
|
|
InvGroupNum = p.InvGroupNum, |
|
|
|
SettleDate = p.SettleDate, |
|
|
|
GroupNum = p.GroupNum, |
|
|
|
ContractDocID = string.Empty, |
|
|
|
PartCode = p.PartCode |
|
|
|
|
|
|
|
}).ToList();//不能结算
|
|
|
|
await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); |
|
|
|
} |
|
|
|
else//二次开票
|
|
|
|
{ |
|
|
|
await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|