|
|
@ -81,7 +81,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
BBAC_CAN_SA_MNG bbacMng, |
|
|
|
HBPO_CAN_SA_MNG hbpoMng, |
|
|
|
INV_MNG invMng |
|
|
|
|
|
|
|
) : base(excelImportService, snowflakeIdGenerator, commonManager) |
|
|
|
{ |
|
|
|
_logger = logger; |
|
|
@ -136,11 +135,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>() |
|
|
|
.Where(t => t.InvbillNum == invbillNum) |
|
|
|
.ToList(); |
|
|
|
|
|
|
|
if (invoiceGrpDetails.Any()) |
|
|
|
{ |
|
|
|
var tedSaInvs = new List<TED_SAS_INVOICE>(); |
|
|
@ -158,7 +155,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
CreateTime = DateTime.Now, |
|
|
|
UpdateTime = DateTime.Now, |
|
|
|
}; |
|
|
|
|
|
|
|
for (var i = 0; i < invoiceGrpDetails.Count; i++) |
|
|
|
{ |
|
|
|
var invoiceGrpDetail = invoiceGrpDetails[i]; |
|
|
@ -186,9 +182,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
LINE = (i + 1).ToString() |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
tedSaInvs.FirstOrDefault().InvoiceTaxAmount += invoiceGrp.TaxDiff; |
|
|
|
|
|
|
|
//红冲发票提交QAD
|
|
|
|
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum)) |
|
|
|
{ |
|
|
@ -317,7 +311,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
{ |
|
|
|
return new JsonResult(new { Code = "400", Message = "有发票没有金税发票号!" }); |
|
|
|
} |
|
|
|
|
|
|
|
var ls = invs.Where(p => p.State != SettleBillState.商务已审核).Distinct(); |
|
|
|
if (ls.Any()) |
|
|
|
{ |
|
|
@ -391,9 +384,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And)); |
|
|
|
} |
|
|
|
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 mdtos = ObjectMapper.Map<List<INVOICE_MAP_GROUP>, List<INVOICE_MAP_GROUP_DTO>>(m); |
|
|
|
var first = invs.FirstOrDefault(); |
|
|
@ -468,7 +458,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
//bj.PurchaseOrderNumber = itm.GetProperty("PurchaseOrderNumber", "");//采购订单号
|
|
|
|
//bj.DeliveryIndexNumber = itm.GetProperty("DeliveryIndexNumber", "");//交付索引号
|
|
|
|
//bj.PartName = itm.GetProperty("PartName", "");//零件名称
|
|
|
|
|
|
|
|
BMap.Add(bj); |
|
|
|
} |
|
|
|
|
|
|
@ -507,9 +496,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
ProductionGroup = itm.ProductionGroup, |
|
|
|
LineCode = itm.LineCode, |
|
|
|
ContractID = itm.ContractID, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
entity.INVOICE_WAIT_DETAIL_BJ = bjquery.OrderBy(p => p.LineCode).ToList(); |
|
|
|
|
|
|
@ -592,7 +578,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
}; |
|
|
|
|
|
|
|
entity.INVOICE_NOT_SETTLE = notquery.OrderBy(p => p.SettleGroupNum).ThenBy(p => p.LU).ToList(); |
|
|
|
|
|
|
|
var lscompare = entity.INVOICE_NOT_SETTLE.GroupBy(x => new { x.InvBillNum, x.SettleGroupNum }).Select(p => |
|
|
|
new INVOICE_MAP_GROUP_DTO() |
|
|
|
{ |
|
|
@ -621,7 +606,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
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 |
|
|
@ -633,7 +617,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
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 sdtos) |
|
|
@ -643,12 +626,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
GroupNum = itm.SettleGroupNum, |
|
|
|
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; |
|
|
|
} |
|
|
@ -678,7 +659,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
// break;
|
|
|
|
//}
|
|
|
|
result.ShouldNotBeNull(); |
|
|
|
|
|
|
|
//保存导出文件到服务器存成二进制
|
|
|
|
await _excelImportService.SaveBlobAsync( |
|
|
|
new SaveExcelImportInputDto |
|
|
@ -701,14 +681,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
IExporter _csv = new CsvExporter(); |
|
|
|
ExcelExporter _excel = new ExcelExporter(); |
|
|
|
// var materialList = await _baseservice.GetMaterialList().ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
var condition = input.Filters.FirstOrDefault(p => p.Column == "invbillNum"); |
|
|
|
if (condition == null) |
|
|
|
{ |
|
|
|
input.Filters.Add(new FilterCondition("InvoiceState", "1", EnumFilterAction.Equal, EnumFilterLogic.And)); |
|
|
|
} |
|
|
|
|
|
|
|
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false); |
|
|
|
var first = entities.FirstOrDefault(); |
|
|
|
var dtoDetails = ObjectMapper.Map<List<INVOICE_GRP>, List<INVOICE_GRP_EXP_DTO>>(entities); |
|
|
@ -723,10 +700,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var hbpom = invdetail.MAIDAN_HBPO_INVOICE_MAP_GROUP;//买单HBPO分组对应
|
|
|
|
var hbpounsettle = invdetail.MAIDAN_HBPO_UNSETTLED_DETAIL;//买单HBPO未结
|
|
|
|
var jitunsettle = invdetail.JIT_UNSETTLED_DETAIL;//买单HBPO未结
|
|
|
|
|
|
|
|
var classDisplayName = typeof(INVOICE_GRP_DTO).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(INVOICE_GRP_DTO).Name; |
|
|
|
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; |
|
|
|
|
|
|
|
#region 发票明细
|
|
|
|
if (entities.FirstOrDefault().BusinessType == EnumBusinessType.JisBBAC) |
|
|
|
{ |
|
|
@ -741,7 +716,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
_excel.Append(detail, "发票明细"); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
// 发票分组
|
|
|
|
if (first.BusinessType == EnumBusinessType.JisBBAC || first.BusinessType == EnumBusinessType.JisHBPO || first.BusinessType == EnumBusinessType.ZhiGongJianHBPO) |
|
|
|
{ |
|
|
@ -810,7 +784,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
p.InvDate, |
|
|
|
p.InvBillNum, |
|
|
|
p.InvGroupNum, |
|
|
|
|
|
|
|
}).Select(p => new INVOICE_NOT_SETTLE_DTO() |
|
|
|
{ |
|
|
|
LU = p.Key.LU, |
|
|
@ -939,7 +912,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
[DisableRequestSizeLimit] |
|
|
|
|
|
|
|
public async Task<string> ExcelImport([FromForm] IFormFileCollection files) |
|
|
|
{ |
|
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
@ -954,22 +926,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var newinv1= result.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); |
|
|
|
var newinv = ls.Where(p => p.InvbillNum == inv.InvbillNum).FirstOrDefault(); |
|
|
|
inv.Tax = 0.13m; |
|
|
|
//inv.RealAmt = Math.Round(inv.Amt * newinv.Tax, 2);
|
|
|
|
//inv.TaxAmt = inv.Amt+ Math.Round(inv.Amt * newinv.Tax, 2);
|
|
|
|
inv.RealnvBillNum = newinv.RealnvBillNum; |
|
|
|
// inv.RealAmt = newinv.RealAmt;
|
|
|
|
inv.TaxDiff = newinv.PreTaxDiff; |
|
|
|
inv.CreationTime = newinv1.InvoiceDate; |
|
|
|
// inv.ClientCode = newinv.ClientCode;
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//foreach (var detail in invdetail)//明细EXTEND1字段BBAC不能占用
|
|
|
|
//{
|
|
|
|
// detail.Extend1 = Math.Round(detail.Amt * first.Tax, 2).ToString();
|
|
|
|
//}
|
|
|
|
await _repository.DbContext.BulkUpdateAsync(invlist).ConfigureAwait(false); |
|
|
|
await _repository.DbContext.BulkUpdateAsync(invdetail).ConfigureAwait(false); |
|
|
|
return ApplicationConsts.SuccessStr; |
|
|
|