@ -112,82 +112,94 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
List < CustomCondition > customConditionList = new List < CustomCondition > ( ) ;
List < CustomCondition > customConditionList = new List < CustomCondition > ( ) ;
customConditionList . Add ( new CustomCondition ( ) { Name = "BillNum" , Value = invbillnum } ) ;
customConditionList . Add ( new CustomCondition ( ) { Name = "BillNum" , Value = invbillnum } ) ;
customConditionList . Add ( new CustomCondition ( ) { Name = "BussinessType" , Value = main . BusinessType . ToString ( ) } ) ;
customConditionList . Add ( new CustomCondition ( ) { Name = "BussinessType" , Value = main . BusinessType . ToString ( ) } ) ;
await _ hbpoMng . SetWaitingState ( invbillnum ) ;
var _ taskid = await _ service . ExportEnqueueAsync ( "生成发票任务" , ExportExtentsion . Excel , string . Empty , string . Empty , CurrentUser , typeof ( GenerateJisInvoiceService ) , customConditionList , ( rs ) = >
if ( main . BusinessType = = EnumBusinessType . MaiDanJianHBPO )
{
var groupNumList = entitys . Select ( p = > p . GroupNum ) . Distinct ( ) . ToList ( ) ;
var notQuery = _ notRepository . Where ( p = > p . SettleBillNum = = main . SettleBillNum ) . ToList ( ) ;
var dto1s = ObjectMapper . Map < List < HBPO_CAN_SA_DETAIL > , List < HBPO_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 = "no" ,
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 ( ) ; //不能结算
var falg = await FirstInvoice ( entitys , new List < PUB_ADJ_DETAIL > ( ) , dtos , notlist , main . Version , main . InvGroupNum , string . Empty , main . BusinessType ) . ConfigureAwait ( false ) ;
}
else //二次开票
{
var flag = await SecInvoice ( entitys , new List < PUB_ADJ_DETAIL > ( ) , dtos , main . Version , main . InvGroupNum , string . Empty , main . BusinessType ) . ConfigureAwait ( false ) ;
}
}
}
else
{
{
} ) . ConfigureAwait ( false ) ;
await _ hbpoMng . SetWaitingState ( invbillnum ) ;
var _ taskid = await _ service . ExportEnqueueAsync ( "生成发票任务" , ExportExtentsion . Excel , string . Empty , string . Empty , CurrentUser , typeof ( GenerateJisInvoiceService ) , customConditionList , ( rs ) = >
{
} ) . ConfigureAwait ( false ) ;
}
return new JsonResult ( new { Code = 2 0 0 , Message = "生成发票任务" } ) ;
return new JsonResult ( new { Code = 2 0 0 , Message = "生成发票任务" } ) ;
//if (await _hbpoMng.SetForwardState(main, SettleBillState.已开票).ConfigureAwait(false))
//{
// var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
// var notQuery = _notRepository.Where(p => p.SettleBillNum == main.SettleBillNum).ToList();
// var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_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 = "no",
// 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();//不能结算
// var falg = await FirstInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
// }
// else//二次开票
// {
// var flag = await SecInvoice(entitys, new List<PUB_ADJ_DETAIL>(), dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType).ConfigureAwait(false);
// }
// }
//}
}
}
else
else
{
{
return new JsonResult ( new { Code = 4 0 0 , Message = "不存在可结算单记录" } ) ;
return new JsonResult ( new { Code = 4 0 0 , Message = "不存在可结算单记录" } ) ;
}
}
}
}
}
}
}
}