mahao 1 year ago
parent
commit
561d24e51b
  1. 128
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/bbac-edi-se-compare.js
  2. 26
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/bom.js
  3. 128
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/hbpo-edi-se-compare.js
  4. 101
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/invoice/invoice_grp.js
  5. 12
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/jis-bbac/input/bbac_sa_service.js
  6. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/pub_ba_detail_service.js
  7. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_CAN_SA_DTO.cs
  8. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  9. 230
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  10. 520
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  11. 471
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  12. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  13. 65
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
  14. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs
  15. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SA.cs
  16. 269
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs
  17. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/CAN_SA_MNG.cs
  18. 269
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs
  19. 150
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  20. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/NOT_SA_MNG.cs
  21. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PD_MNG.cs
  22. 269
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs

128
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/bbac-edi-se-compare.js

@ -0,0 +1,128 @@
import version from "./version.js";
const stateName = {
title: "状态",
type: "string",
input: "select",
options: [
{ label: "执行完成(任务成功)", value: "Succeeded" },
{ label: "执行完成(任务失败)", value: "Failed" },
{ label: "执行中", value: "Processing" },
{ label: "等待执行", value: "Enqueued" },
],
};
const schema = {
title: "数据对比",
type: "object",
properties: {
type: {
title: "版本号",
type: "string",
},
taskId: {
title: "单据流水号",
type: "string",
},
email: {
title: "创建人",
type: "string",
},
createdAt: {
title: "创建时间",
type: "DateTime",
},
remark: {
title: "说明",
type: "string",
},
stateName,
},
};
const queryUrl = "settleaccount/Job/list";
const deleteUrl = "settleaccount/Job/delete";
const exportUrl = "settleaccount/pub_sa_detail_service/export";
const compareUrl = "settleaccount/edi-se-compare/bbacedi-se-compare";
const queryMethod = "POST";
const deleteMethod = "POST";
const exportMethod = "POST";
const compareMethod = "POST";
export default function () {
return {
query: {
url: queryUrl,
method: queryMethod,
autoSubmit: true,
disableQueryOnLoad: true,
schema: {
title: "数据对比",
type: "object",
properties: {
type: Object.assign({ defaultSelected: true }, version),
name: {
type: "string",
default: null,
hidden: true,
},
stateName,
filters: {
type: "array",
hidden: true,
items: {
type: "object",
properties: {
logic: {
type: "int",
},
column: {
type: "string",
},
action: {
type: "int",
},
value: {
type: "string",
},
},
},
default: [
// {
// logic: "and",
// column: "year",
// action: "like",
// value: null,
// readOnly: true,
// },
],
},
skipCount: {
hidden: true,
default: 0,
},
maxResultCount: {
hidden: true,
default: 10,
},
sorting: {
hidden: true,
},
},
},
},
table: {
schema: schema,
},
edit: {
deleteUrl,
exportUrl,
compareUrl,
deleteMethod,
exportMethod,
compareMethod,
schema: schema,
},
};
}

26
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/bom.js

@ -18,23 +18,33 @@ const schema = {
title: "组件描述",
type: "string",
},
childItemUom: {
title: "组件计量单位",
type: "string",
},
qty: {
title: "用量",
type: "number",
title: "组件数量",
type: "decimal",
},
bomType: {
title: "结构类型",
type: "string",
},
effectiveTime: {
title: "生效时间",
operateProcess: {
title: "工序",
type: "int",
},
scrapPercent: {
title: "废品率",
type: "string",
input: "date",
},
effectiveTime: {
title: "失效时间",
issuePosition: {
title: "子物品消耗位置",
type: "string",
input: "date",
},
bomLevel: {
title: "结构层级",
type: "int",
},
},
};

128
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/hbpo-edi-se-compare.js

@ -0,0 +1,128 @@
import version from "./version.js";
const stateName = {
title: "状态",
type: "string",
input: "select",
options: [
{ label: "执行完成(任务成功)", value: "Succeeded" },
{ label: "执行完成(任务失败)", value: "Failed" },
{ label: "执行中", value: "Processing" },
{ label: "等待执行", value: "Enqueued" },
],
};
const schema = {
title: "数据对比",
type: "object",
properties: {
type: {
title: "版本号",
type: "string",
},
taskId: {
title: "单据流水号",
type: "string",
},
email: {
title: "创建人",
type: "string",
},
createdAt: {
title: "创建时间",
type: "DateTime",
},
remark: {
title: "说明",
type: "string",
},
stateName,
},
};
const queryUrl = "settleaccount/Job/list";
const deleteUrl = "settleaccount/Job/delete";
const exportUrl = "settleaccount/pub_sa_detail_service/export";
const compareUrl = "settleaccount/edi-se-compare/hbpoedi-se-compare";
const queryMethod = "POST";
const deleteMethod = "POST";
const exportMethod = "POST";
const compareMethod = "POST";
export default function () {
return {
query: {
url: queryUrl,
method: queryMethod,
autoSubmit: true,
disableQueryOnLoad: true,
schema: {
title: "数据对比",
type: "object",
properties: {
type: Object.assign({ defaultSelected: true }, version),
name: {
type: "string",
default: null,
hidden: true,
},
stateName,
filters: {
type: "array",
hidden: true,
items: {
type: "object",
properties: {
logic: {
type: "int",
},
column: {
type: "string",
},
action: {
type: "int",
},
value: {
type: "string",
},
},
},
default: [
// {
// logic: "and",
// column: "year",
// action: "like",
// value: null,
// readOnly: true,
// },
],
},
skipCount: {
hidden: true,
default: 0,
},
maxResultCount: {
hidden: true,
default: 10,
},
sorting: {
hidden: true,
},
},
},
},
table: {
schema: schema,
},
edit: {
deleteUrl,
exportUrl,
compareUrl,
deleteMethod,
exportMethod,
compareMethod,
schema: schema,
},
};
}

101
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/invoice/invoice_grp.js

@ -0,0 +1,101 @@
import version from "../version";
import { state2, state3 } from "../state";
const schema = {
title: "财务审核",
type: "object",
properties: {
version,
realnvBillNum: {
title: "实际纸质发票号",
type: "string",
},
invbillNum: {
title: "系统生成发票号",
type: "string",
},
amt: {
title: "未税金额",
type: "decimal",
},
taxAmt: {
title: "税后金额",
type: "decimal",
},
fileName: {
title: "开票Excel文件",
type: "string",
},
businessType: {
title: "业务类别",
type: "EnumBusinessType",
},
state2,
},
};
const queryUrl = "settleaccount/invoice_service/detail_queryUrl";
const queryMethod = "POST";
export default function () {
return {
query: {
url: queryUrl,
method: queryMethod,
hasFilter: true,
schema: {
title: "财务审核",
type: "object",
properties: {
filters: {
title: "项目",
type: "array",
hidden: true,
items: {
type: "object",
properties: {
logic: {
type: "int",
},
column: {
type: "string",
},
action: {
type: "int",
},
value: {
type: "string",
},
},
},
default: [
{
logic: "and",
column: "version",
action: "equal",
value: null,
readOnly: true,
},
],
},
skipCount: {
hidden: true,
default: 0,
},
maxResultCount: {
hidden: true,
default: 10,
},
sorting: {
hidden: true,
},
},
},
},
table: {
schema: schema,
},
edit: {
schema: schema,
},
};
}

12
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/jis-bbac/input/bbac_sa_service.js

@ -43,17 +43,13 @@ const schema = {
};
const baseUrl = "settleaccount/bbac_sa_service";
const queryUrl = `${baseUrl}/get-list`;
const detailsUrl = `${baseUrl}/get/%s`;
const createUrl = `${baseUrl}/create`;
const updateUrl = `${baseUrl}/update/%s`;
const queryUrl = "settleaccount/bbac_sa_service/get-list";
const createUrl = "settleaccount/bbac_sa_service/create";
const deleteUrl = `${baseUrl}/delete-list`;
const importUrl = `${baseUrl}/code-setting-upload-excel-import`;
const exportUrl = `${baseUrl}/export`;
const queryMethod = "POST";
const detailsMethod = "POST";
const createMethod = "POST";
const updateMethod = "POST";
const deleteMethod = "POST";
const importMethod = "POST";
const exportMethod = "POST";
@ -117,15 +113,11 @@ export default function () {
schema: schema,
},
edit: {
detailsUrl,
createUrl,
updateUrl,
deleteUrl,
importUrl,
exportUrl,
detailsMethod,
createMethod,
updateMethod,
deleteMethod,
importMethod,
exportMethod,

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/pub_ba_detail_service.js

@ -71,7 +71,6 @@ const schema = {
};
const queryUrl = "settleaccount/p-uB_BA_SERVICE/detail-query";
const queryMethod = "POST";
export default function () {

5
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_CAN_SA_DTO.cs

@ -102,6 +102,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public string ContractDocID { set; get; }
}
public class BBAC_CAN_SA_DETAIL_EXP_DTO
{

12
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs

@ -35,9 +35,9 @@ namespace Win.Sfs.SettleAccount.Bases
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository;
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository;
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _mRepository;
private readonly CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> _pubMng;
private readonly CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> _bbacMng;
private readonly CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> _hbpoMng;
private readonly BBAC_CAN_SA_MNG _pubMng;
private readonly HBPO_CAN_SA_MNG _bbacMng;
private readonly PUB_CAN_SA_MNG _hbpoMng;
private readonly INV_MNG _invMng;
@ -51,9 +51,9 @@ namespace Win.Sfs.SettleAccount.Bases
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository,
IExcelImportAppService excelImportService,
CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng,
CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng,
CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng,
BBAC_CAN_SA_MNG pubMng,
HBPO_CAN_SA_MNG bbacMng,
PUB_CAN_SA_MNG hbpoMng,
INV_MNG invMng
//INormalEfCoreRepository<TEntityDetail, Guid> detailRepository

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

@ -3,7 +3,9 @@ using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using Shouldly;
using System;
using System.Collections.Generic;
@ -12,6 +14,7 @@ using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities;
@ -30,7 +33,7 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Bases
{
public abstract class CAN_SA_SERVICE<TEntity, TEntityDto, TEntityDetail, TEntityDetailDto, TRequestMainInput, TRequestDetailInput, TEntityDetailExportDto> : BASE_SERVICE
where TEntity : class, IEntity<Guid>
where TEntity : SA_CAN_BASE_MAIN
where TEntityDetail:SA_CAN_BASE
where TEntityDto : class, IEntityDto<Guid>, new()
where TEntityDetailDto : class, IEntityDto<Guid>, new()
@ -43,14 +46,23 @@ namespace Win.Sfs.SettleAccount.Bases
protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService;
protected readonly INV_MNG _invmng;
//private readonly CAN_SA_MNG<TEntity, TEntityDetail> _bbacMng;
protected CAN_SA_SERVICE(
INormalEfCoreRepository<TEntity, Guid> repository,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository,
INV_MNG invmng
//CAN_SA_MNG<TEntity, TEntityDetail> bbacMng,
INV_MNG invmng
)
{
_invmng= invmng;
_excelImportService = excelImportService;
_repository = repository;
@ -139,7 +151,219 @@ namespace Win.Sfs.SettleAccount.Bases
return new PagedResultDto<TEntityDto>(totalCount, dtos);
}
//public virtual async Task<bool> SetForwardState(TEntity p_entiy, SettleBillState state)
//{
// if (await SetForwardState(p_entiy.InvGroupNum, state) == true)
// {
// return true;
// }
// return false;
//}
///// <summary>
///// 向前流程
///// </summary>
///// <param name="p_billNum"></param>
///// <param name="state"></param>
///// <returns></returns>
///// <exception cref="BusinessException"></exception>
//public virtual async Task<bool> SetForwardState(string p_billNum, SettleBillState state)
//{
// var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
// if (ls != null && ls.Count > 0)
// {
// throw new BusinessException("8989", string.Format("不存在编号为{0}", p_billNum));
// }
// foreach (TEntity p_entiy in ls)
// {
// switch (p_entiy.State)
// {
// case SettleBillState.财务已审核:
// if (state == SettleBillState.商务已审核)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
// }
// break;
// case SettleBillState.商务已审核:
// if (state == SettleBillState.已开票)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】");
// }
// break;
// case SettleBillState.已开票:
// if (state == SettleBillState.未结状态)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【未结状态】状态,无法设置成【已开票】");
// }
// break;
// case SettleBillState.已扣减:
// if (state == SettleBillState.客户已收票)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是[客户收票],无法设置成【财务已审核】状态");
// }
// break;
// case SettleBillState.客户已收票:
// if (state == SettleBillState.财务已审核)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【客户已收票】状态");
// }
// break;
// }
// await _repository.UpdateAsync(p_entiy);
// return true;
// }
// return false;
//}
///// <summary>
///// 向后流程
///// </summary>
///// <param name="p_billNum"></param>
///// <param name="state"></param>
///// <returns></returns>
///// <exception cref="BusinessException"></exception>
//public virtual async Task<bool> SetBackwardState(string p_billNum, SettleBillState state)
//{
// var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
// if (ls != null && ls.Count > 0)
// {
// throw new BusinessException("8989", string.Format("不存在发票分组号为{0}的可结算单", p_billNum));
// }
// foreach (TEntity p_entiy in ls)
// {
// switch (p_entiy.State)
// {
// case SettleBillState.商务已审核:
// if (state == SettleBillState.财务已审核)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
// }
// break;
// case SettleBillState.已开票:
// if (state == SettleBillState.商务已审核)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
// }
// break;
// case SettleBillState.未结状态:
// if (state == SettleBillState.已开票)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【未结状态】");
// }
// break;
// case SettleBillState.客户已收票:
// if (state == SettleBillState.已扣减)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【财务已审核客户收票】状态");
// }
// break;
// case SettleBillState.财务已审核:
// if (state == SettleBillState.客户已收票)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是[客户已收票],无法设置成【财务已审核】状态");
// }
// break;
// }
// await _repository.UpdateAsync(p_entiy);
// return true;
// }
// return false;
//}
//public virtual async Task<bool> SetNewState(TEntity p_entiy)
//{
// return await SetNewState(p_entiy.BillNum);
//}
//public virtual async Task<bool> SetNewState(string billNum)
//{
// var entity = await GetMainAsync(billNum);
// if (entity != null)
// {
// entity.State = SettleBillState.未结状态;
// await _repository.UpdateAsync(entity);
// return true;
// }
// return false;
// ;
//}
///// <summary>
///// 获得所有明细
///// </summary>
///// <param name="billNum"></param>
///// <returns></returns>
//public virtual async Task<List<TEntityDetail>> GetDetalListAsync(string billNum)
//{
// return await _detailRepository.Where(p => p.InvGroupNum == billNum).ToListAsync();
//}
///// <summary>
///// 获得主表信息
///// </summary>
///// <param name="billNum"></param>
///// <returns></returns>
//public virtual async Task<TEntity> GetMainAsync(string billNum)
//{
// return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
//}
}

520
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs

@ -3,8 +3,11 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.Functions;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Finance;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using SettleAccount.Domain.BQ;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -18,9 +21,22 @@ using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.Shared.RepositoryBase;
using System.Text.Json;
using Newtonsoft.Json;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
public class TMEP_INV
{
public string LU { set; get; }
public string ContractDocID { set; get; }
public decimal Amt { set; get; }
public decimal Qty { set; get; }
public decimal Price { set; get; }
}
/// <summary>
/// BBAC-JIS可结算单
@ -39,219 +55,351 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
>
{
private readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
private readonly BBAC_CAN_SA_MNG _bbacMng;
public BBAC_CAN_SA_SERVICE(
INormalEfCoreRepository<BBAC_CAN_SA, Guid> repository,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
INV_MNG invmng) : base(repository, excelImportService, detailRepository, invmng)
BBAC_CAN_SA_MNG bbacMng,
INV_MNG invmng) : base(repository, excelImportService, detailRepository, invmng)
{
_notRepository = notRepository;
_bbacMng = bbacMng;
}
/// <summary>
/// 生成发票
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
//[Route("generateinvoice")]
public async override Task<string> GenerateInvoice(BBAC_CAN_SA_REQ_DTO input)
{
var main=_repository.Where(p => p.InvGroupNum == input.Filters.Where(p => p.Column == "BillNum").FirstOrDefault().Value).FirstOrDefault();
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);//可结算
var groupNumList= entitys.Select(p=>p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
var notList =_notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();//不能结算
var dtos = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
dtos.ForEach(dto =>
var main =await _bbacMng.GetMainAsync(input.BillNum);
if (main != null)
{
dto.Amt = Math.Round(dto.Price * dto.Qty, 2);
});
// dtos = dtos.OrderBy(p => p.SettleDate).ToList();
var _query= dtos.GroupBy(p => new { p.GroupNum }).Select(p =>new {GroupNum=p.Key.GroupNum, Amt=p.Sum(itm=>itm.Amt)});
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap=new Dictionary<string,List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
List<string> luList= dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU+p.ContractDocID ).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key)==true)//是否存在分组
if (await _bbacMng.SetForwardState(main,SettleBillState.))
{
foreach (var _itm1 in copyDic)
var entitys = await _bbacMng.GetDetalListAsync(input.BillNum);//可结算
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
var notList = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();//不能结算
var dtos = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
dtos.ForEach(dto =>
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList();//每项LU种类
luList.AddRange(grouplist);
luList = luList.Distinct().ToList();
if (luList.Count > 20)//累加零件不超过20种
dto.Amt = Math.Round(dto.Price * dto.Qty, 2);
});
if (dtos != null && dtos.Count > 0)
{
if (input.BillNum.Substring(0, 1) != "C")//一次开票
{
continue;
// dtos = dtos.OrderBy(p => p.SettleDate).ToList();
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).OrderBy(p=>p.Amt);
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
//List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList(); //初始LU种类
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除已经开票分组
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
// string str = JsonConvert.SerializeObject(invoiceMap);
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price, p.ContractDocID })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt =itm.Sum(p=>p.Amt),
Qty = itm.Sum(k => k.Qty)
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
//amt = dtos.Where(p => p.GroupNum == groupnum).Sum(p => p.Amt);
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.BBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContactDocID,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
var notls = notList.GroupBy(p => new { p.GroupNum, p.LU })
.Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
var innotls = new List<INVOICE_NOT_SETTLE>();
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: main.Version,
invGroupNum: main.InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.BBAC,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
if (sum > 10000000)
else//二次开票
{
break;
}
sum += _itm1.Value;
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除已经开票分组
{
copyDic.Remove(rem);
}
}
}
if(invoiceMap.Keys.Count>0) {
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos= dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p=>new {p.InvGroupNum, p.LU,p.Price,p.ContractDocID })
.Select(itm=>new {
InvGroupNum=itm.Key.InvGroupNum,
LU=itm.Key.LU,
ContactDocID=itm.Key.ContractDocID,
Price=itm.Key.Price,
Amt=Math.Round(itm.Sum(k=>k.Qty)*itm.Key.Price,2) ,
Qty= itm.Sum(k => k.Qty)
})
.ToList();
decimal amt=detailDtos.Sum(k=>k.Amt);
decimal txtAmt=Math.Round(detailDtos.Sum(k => k.Amt),2);
var mapList= new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
amt=dtos.Where(p => p.GroupNum == groupnum).Sum(p => p.Amt);
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum:groupnum,
amt:amt,
extend1:string.Empty,
extend2:string.Empty
)
);
}
if(mapList.Count > 0)
{
groupList.AddRange(mapList);
var groups1 = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU && p.ContractDocID == group.ContractDocID);
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group1.ContractDocID == group.ContractDocID)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
sum += group1.Amt;
if (sum > 10000000)
{
break;
}
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.ContractDocID } equals new { itm1.LU, itm1.ContractDocID } into temp
from tm in temp
select new TMEP_INV { LU = itm.LU, ContractDocID = itm.ContractDocID, Amt = itm.Amt, Qty = itm.Qty };
groups1 = query.ToList();
}
}
if (invoiceMap.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.BBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContractDocID,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
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();
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
foreach (var en in _groupList)
{
group1.Add(
new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: en.GroupNum,
amt: en.Amt,
extend1: string.Empty,
extend2: string.Empty));
}
if (group1.Count > 0)
{
groupList.AddRange(group1);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.BBAC,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version:main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.BBAC,
amt: detail.Amt,
pRICE:detail.Price,
extend1: detail.ContactDocID,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
var notls= notList.GroupBy(p => new { p.GroupNum, p.LU }).Select(p=>new {GroupNum= p.Key.GroupNum,LU=p.Key.LU,Qty= p.Sum(itm=>itm.Qty) });
var innotls= new List<INVOICE_NOT_SETTLE>();
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: main.Version,
invGroupNum: main.InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt:amt,
taxAmt:txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.BBAC,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
);
invlist.Add( invbill );
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
return ApplicationConsts.SuccessStr;
return ApplicationConsts.SuccessStr;
}
}
}

471
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs

@ -38,16 +38,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
>
{
private INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
private readonly HBPO_CAN_SA_MNG _hbpoMng;
public HBPO_CAN_SA_SERVICE(INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository,
INV_MNG invmng,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
HBPO_CAN_SA_MNG hbpoMng
) : base(repository, excelImportService, detailRepository, invmng)
{
_notRepository = notRepository;
_hbpoMng = hbpoMng;
}
/// <summary>
/// 生成发票
@ -59,187 +62,329 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public async override Task<string> GenerateInvoice(HBPO_CAN_SA_REQ_DTO input)
{
var main = _repository.Where(p => p.InvGroupNum == input.Filters.Where(p => p.Column == "BillNum").FirstOrDefault().Value).FirstOrDefault();
var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);//可结算
var main =await _hbpoMng.GetMainAsync(input.BillNum);
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var notList = _notRepository.Where(p => groupNumList.Contains(p.InvGroupNum)).ToList();//不能结算
var dtos = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
dtos.ForEach(dto =>
if (main != null)
{
dto.Amt = Math.Round(dto.Price * dto.Qty, 2);
});
if (await _hbpoMng.SetForwardState(main, SettleBillState.))
{
var entitys = await _hbpoMng.GetDetalListAsync(input.BillNum);
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
if (await _hbpoMng.SetForwardState(main, SettleBillState.))
{
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
var notList = _notRepository.Where(p => groupNumList.Contains(p.InvGroupNum)).ToList();//不能结算
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
var dtos = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
dtos.ForEach(dto =>
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
luList.AddRange(grouplist);
luList = luList.Distinct().ToList();
if (luList.Count > 20)//累加零件不超过20种
{
continue;
}
if (sum > 10000000)
dto.Amt = Math.Round(dto.Price * dto.Qty, 2);
});
if (dtos != null && dtos.Count > 0)
{
break;
}
sum += _itm1.Value;
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
if (input.BillNum.Substring(0, 1) != "C")//一次开票
{
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
luList.AddRange(grouplist);
luList = luList.Distinct().ToList();
if (luList.Count > 20)//累加零件不超过20种
{
continue;
}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price })
.Select(itm => new {
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty)
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
amt = dtos.Where(p => p.GroupNum == groupnum).Sum(p => p.Amt);
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: groupnum,
amt: amt,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty)
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.HBPO,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
var notls = notList.GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.HBPO,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
var innotls = new List<INVOICE_NOT_SETTLE>();
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: main.Version,
invGroupNum: main.InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.HBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
);
invlist.Add(invbill);
var notls = notList.GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
var innotls = new List<INVOICE_NOT_SETTLE>();
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: main.Version,
invGroupNum: main.InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.HBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
}
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
else//二次开票
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.Price }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU && p.ContractDocID == group.ContractDocID);
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group1.ContractDocID == group.ContractDocID)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
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.ContractDocID } equals new { itm1.LU, itm1.ContractDocID } into temp
from tm in temp
select new TMEP_INV { LU = itm.LU, ContractDocID = itm.ContractDocID, Amt = itm.Amt, Qty = itm.Qty };
groups1 = query.ToList();
}
}
if (invoiceMap.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.BBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContractDocID,
extend2: string.Empty,
extend3: string.Empty,
extend4: string.Empty
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
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.GroupBy(p => new { p.GroupNum })
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
foreach (var en in _groupList)
{
group1.Add(
new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: en.GroupNum,
amt: en.Amt,
extend1: string.Empty,
extend2: string.Empty));
}
if (group1.Count > 0)
{
groupList.AddRange(group1);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.BBAC,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
}
}
}
}
return ApplicationConsts.SuccessStr;
}

8
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -11,6 +11,7 @@ using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.Shared.RepositoryBase;
@ -37,5 +38,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public PUB_CAN_SA_SERVICE(INormalEfCoreRepository<PUB_CAN_SA, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository, INV_MNG invmng) : base(repository, excelImportService, detailRepository, invmng)
{
}
}
[HttpPost]
public async override Task<string> GenerateInvoice(BBAC_CAN_SA_REQ_DTO input)
{
return ApplicationConsts.SuccessStr;
}
}

65
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs

@ -7,6 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Validation;
using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Entities.SettleAccountDomain;
using static System.Runtime.CompilerServices.RuntimeHelpers;
@ -41,6 +42,10 @@ namespace SettleAccount.Bases
public class SA_CAN_BASE_MAIN : FullAuditedAggregateRoot<Guid>
{
public SA_CAN_BASE_MAIN() { }
public SA_CAN_BASE_MAIN(Guid id) : base(id) { }
[Display(Name = "期间")]
public virtual int Version { get; set; }
@ -64,11 +69,15 @@ namespace SettleAccount.Bases
public virtual string Site { get; set; }
}
public class PD_BASE_MAIN : FullAuditedAggregateRoot<Guid>
{
public PD_BASE_MAIN()
{
}
[Display(Name = "期间")]
public virtual int Version { get; set; }
@ -206,6 +215,10 @@ namespace SettleAccount.Bases
public class RE_BASE :FullAuditedAggregateRoot<Guid>, IRE_BASE
{
public RE_BASE()
{
}
/// 发货时间
/// </summary>
public DateTime ShippingDate { set; get; }
@ -316,59 +329,61 @@ namespace SettleAccount.Bases
public class SA_BASE : FullAuditedAggregateRoot<Guid>, ISA_BASE
{
public SA_BASE() { }
public SA_BASE(Guid id) : base(id) { }
/// <summary>
/// 期间
/// </summary>
public int Version { set; get; }
public virtual int Version { set; get; }
/// <summary>
/// 单价
/// </summary>
public decimal Price { set; get; }
public virtual decimal Price { set; get; }
/// <summary>
/// 结算单
/// </summary>
public string BillNum { set; get; }
public virtual string BillNum { set; get; }
/// <summary>
/// 结算日期
/// </summary>
public DateTime SettleDate { set; get; }
public virtual DateTime SettleDate { set; get; }
/// <summary>
/// 零件號
/// </summary>
public string LU { get ; set ; }
public virtual string LU { get ; set ; }
/// <summary>
/// 生產號
/// </summary>
public string PN { get; set ; }
public virtual string PN { get; set ; }
/// <summary>
/// 組合鍵值(LU+PN)
/// </summary>
public string KeyCode { get ; set ; }
public virtual string KeyCode { get ; set ; }
/// <summary>
/// 數量
/// </summary>
public decimal Qty { get ; set ; }
public virtual decimal Qty { get ; set ; }
/// <summary>
/// 結算分組號
/// </summary>
public string GroupNum { get ; set ; }
public virtual string GroupNum { get ; set ; }
//public SA_BASE(int version, decimal price, string billNum, DateTime settleDate, string lU, string pN, string keyCode, decimal qty, string groupNum)
//{
// Version = version;
// Price = price;
// BillNum = billNum;
// SettleDate = settleDate;
// LU = lU;
// PN = pN;
// KeyCode = keyCode;
// Qty = qty;
// GroupNum = groupNum;
//}
}
public class SA_CAN_BASE : FullAuditedAggregateRoot<Guid>, ISA_CAN_BASE
{
protected SA_CAN_BASE() { }
public SA_CAN_BASE(Guid id) : base(id) { }
/// <summary>
/// 期间
/// </summary>
@ -430,6 +445,10 @@ namespace SettleAccount.Bases
}
public class SA_NOT_BASE : FullAuditedAggregateRoot<Guid>, ISA_NOT_BASE
{
public SA_NOT_BASE()
{
}
/// <summary>
/// 单价
/// </summary>
@ -521,6 +540,10 @@ namespace SettleAccount.Bases
}
public class PD_BASE : FullAuditedAggregateRoot<Guid>, ISBASE
{
public PD_BASE()
{
}
/// <summary>
/// 期间
/// </summary>

11
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs

@ -35,9 +35,9 @@ public class BBAC_CAN_SA : SA_CAN_BASE_MAIN
public BBAC_CAN_SA(Guid guid, int version, string billNum, string settleBillNum, SettleBillState state, string invGroupNum,string site)
public BBAC_CAN_SA(Guid guid, int version, string billNum, string settleBillNum, SettleBillState state, string invGroupNum,string site):base(guid)
{
Id = guid;
Version = version;
BillNum = billNum;
SettleBillNum = settleBillNum;
@ -136,15 +136,12 @@ public class BBAC_CAN_SA_DETAIL: SA_CAN_BASE
}
public BBAC_CAN_SA_DETAIL(Guid guid,string keyCode, int version, string billNum, string settleBillNum, string lU, string pN, string site, decimal qty, decimal price, EnumBusinessType category, string isReturn,
DateTime settleDate, string groupNum, string invGroupNum
,string contactid
)
):base(guid)
{
Id = guid;
KeyCode = keyCode;
Version = version;
BillNum = billNum;

15
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_SA.cs

@ -1,4 +1,4 @@
using SettleAccount.Bases;
using SettleAccount.Bases;
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing;
@ -31,16 +31,17 @@ public class BBAC_SA:FullAuditedAggregateRoot<Guid>
[Display(Name = "工厂地点")]
public string Site { get; set; } = null!;
public BBAC_SA(Guid guid, int version, string billNum, string dNBillNum, string state)
public BBAC_SA(Guid guid, int version, string billNum, string dNBillNum, string state):base(guid)
{
Id = guid;
Version = version;
BillNum = billNum;
DNBillNum = dNBillNum;
State = state;
}
public BBAC_SA()
public BBAC_SA() : base()
{
}
@ -125,9 +126,9 @@ public class BBAC_SA_DETAIL:SA_BASE
//[Display(Name = "发票分组号")]
//public string InvGroupNum { get; set; } = null!;
public BBAC_SA_DETAIL(Guid p_guid, string keyCode, int version, string billNum, string lU, string pN, string site, decimal qty, decimal price, string category, string isReturn, DateTime settleDate, string groupNum, string invGroupNum)
public BBAC_SA_DETAIL(Guid p_guid, string keyCode, int version, string billNum, string lU, string pN, string site, decimal qty, decimal price, string category, string isReturn, DateTime settleDate, string groupNum, string invGroupNum):base(p_guid)
{
Id = p_guid;
KeyCode = keyCode;
Version = version;
BillNum = billNum;
@ -143,7 +144,7 @@ public class BBAC_SA_DETAIL:SA_BASE
//InvGroupNum = invGroupNum;
}
public BBAC_SA_DETAIL()
public BBAC_SA_DETAIL():base()
{
}

269
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs

@ -0,0 +1,269 @@
using EFCore.BulkExtensions;
using Hangfire.Annotations;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Win.Sfs.SettleAccount.Bases.DomainServices;
using Win.Sfs.SettleAccount.Boms;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
public class BBAC_CAN_SA_MNG: DomainService
{
private readonly INormalEfCoreRepository<BBAC_CAN_SA, Guid> _repository;
private readonly INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> _detailRepository;
public BBAC_CAN_SA_MNG
(
INormalEfCoreRepository<BBAC_CAN_SA, Guid> repository,
INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> detailRepository
)
{
_repository = repository;
_detailRepository = detailRepository;
}
public BBAC_CAN_SA_MNG()
{
}
public virtual async Task<bool> SetForwardState(BBAC_CAN_SA p_entiy, SettleBillState state)
{
if (await SetForwardState(p_entiy.InvGroupNum, state) == true)
{
return true;
}
return false;
}
/// <summary>
/// 向前流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetForwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls == null && ls.Count ==0)
{
throw new BusinessException("8989", string.Format("不存在编号为{0}",p_billNum));
}
foreach (BBAC_CAN_SA p_entiy in ls)
{
switch (state)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【未结状态】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户收票],无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【客户已收票】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
}
/// <summary>
/// 向后流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetBackwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls == null && ls.Count == 0)
{
throw new BusinessException("8989", string.Format("不存在发票分组号为{0}的可结算单", p_billNum));
}
foreach (BBAC_CAN_SA p_entiy in ls)
{
switch (state)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【未结状态】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【财务已审核客户收票】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户已收票],无法设置成【财务已审核】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
}
public virtual async Task<bool> SetNewState(BBAC_CAN_SA p_entiy)
{
return await SetNewState(p_entiy.BillNum);
}
public virtual async Task<bool> SetNewState(string billNum)
{
var entity= await GetMainAsync(billNum);
if (entity != null )
{
entity.State = SettleBillState.;
await _repository.UpdateAsync(entity);
return true;
}
return false;
;
}
/// <summary>
/// 获得所有明细
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<BBAC_CAN_SA_DETAIL>> GetDetalListAsync(string billNum)
{
return await _detailRepository.Where(p=>p.InvGroupNum==billNum).ToListAsync();
}
/// <summary>
/// 获得主表信息
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<BBAC_CAN_SA> GetMainAsync(string billNum)
{
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
}
}
}

15
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/CAN_SA_MNG.cs

@ -8,6 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
using Volo.Abp.Guids;
@ -20,9 +21,9 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
public class CAN_SA_MNG<TEntity, TEntityDetail> : DomainService
where TEntity : SA_CAN_BASE_MAIN
where TEntityDetail : SA_CAN_BASE
public class CAN_SA_MNG<TEntity, TEntityDetail> : DomainService,ITransientDependency
where TEntity : SA_CAN_BASE_MAIN,new()
where TEntityDetail : SA_CAN_BASE,new()
{
private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
@ -35,6 +36,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_repository = repository;
_detailRepository = detailRepository;
}
public CAN_SA_MNG()
{
}
public virtual async Task<bool> SetForwardState(TEntity p_entiy, SettleBillState state)
{
if (await SetForwardState(p_entiy.InvGroupNum, state) == true)
@ -45,6 +51,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
/// <summary>
/// 向前流程
/// </summary>

269
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_CAN_SA_MNG.cs

@ -0,0 +1,269 @@
using EFCore.BulkExtensions;
using Hangfire.Annotations;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Win.Sfs.SettleAccount.Bases.DomainServices;
using Win.Sfs.SettleAccount.Boms;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
public class HBPO_CAN_SA_MNG: DomainService
{
private readonly INormalEfCoreRepository<HBPO_CAN_SA, Guid> _repository;
private readonly INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> _detailRepository;
public HBPO_CAN_SA_MNG
(
INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository,
INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository
)
{
_repository = repository;
_detailRepository = detailRepository;
}
public HBPO_CAN_SA_MNG()
{
}
public virtual async Task<bool> SetForwardState(HBPO_CAN_SA p_entiy, SettleBillState state)
{
if (await SetForwardState(p_entiy.InvGroupNum, state) == true)
{
return true;
}
return false;
}
/// <summary>
/// 向前流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetForwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls == null && ls.Count ==0)
{
throw new BusinessException("8989", string.Format("不存在编号为{0}",p_billNum));
}
foreach (HBPO_CAN_SA p_entiy in ls)
{
switch (state)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【未结状态】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户收票],无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【客户已收票】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
}
/// <summary>
/// 向后流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetBackwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls == null && ls.Count == 0)
{
throw new BusinessException("8989", string.Format("不存在发票分组号为{0}的可结算单", p_billNum));
}
foreach (HBPO_CAN_SA p_entiy in ls)
{
switch (state)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【未结状态】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【财务已审核客户收票】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户已收票],无法设置成【财务已审核】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
}
public virtual async Task<bool> SetNewState(HBPO_CAN_SA p_entiy)
{
return await SetNewState(p_entiy.BillNum);
}
public virtual async Task<bool> SetNewState(string billNum)
{
var entity= await GetMainAsync(billNum);
if (entity != null )
{
entity.State = SettleBillState.;
await _repository.UpdateAsync(entity);
return true;
}
return false;
;
}
/// <summary>
/// 获得所有明细
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<HBPO_CAN_SA_DETAIL>> GetDetalListAsync(string billNum)
{
return await _detailRepository.Where(p=>p.InvGroupNum==billNum).ToListAsync();
}
/// <summary>
/// 获得主表信息
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<HBPO_CAN_SA> GetMainAsync(string billNum)
{
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
}
}
}

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

@ -22,17 +22,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
//private readonly INormalEfCoreRepository<TCAN_SA, Guid> _canRepository;
private readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository;
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _groupRepository;
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _detailRepository;
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _notRepository;
private readonly CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> _pubMng;
private readonly CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> _bbacMng;
private readonly CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> _hbpoMng;
public INV_MNG
(
CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng,
@ -43,7 +38,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> notRepository
)
{
//_canRepository = canRepository;
@ -54,8 +48,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_pubMng = pubMng;
_bbacMng = bbacMng;
_hbpoMng = hbpoMng;
}
public INV_MNG()
{
}
public virtual async Task<bool> SetForwardState(string p_groupBillnum , SettleBillState p_State)
{
var _first=_repository.Where(p => p.InvbillNum == p_groupBillnum).FirstOrDefault();
@ -97,60 +95,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, p_State);
}
//switch ((int)p_State)
//{
// case (int)SettleBillState.财务已审核:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
// }
// else
// {
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
// }
// break;
// case (int)SettleBillState.商务已审核:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
// }
// else
// {
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
// }
// break;
// case (int)SettleBillState.已开票:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
// }
// else
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
// }
// break;
// case (int)SettleBillState.客户已收票:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
// }
// else
// {
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
// }
// break;
// case (int)SettleBillState.已扣减:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
// }
// else
// {
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
// }
// break;
//}
return isSucc;
}
@ -166,60 +110,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, p_State);
}
//switch ((int)p_State)
//{
// case (int)SettleBillState.财务已审核:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
// }
// else
// {
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
// }
// break;
// case (int)SettleBillState.商务已审核:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
// }
// else
// {
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
// }
// break;
// case (int)SettleBillState.已开票:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
// }
// else
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
// }
// break;
// case (int)SettleBillState.客户已收票:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
// }
// else
// {
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
// }
// break;
// case (int)SettleBillState.已扣减:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
// }
// else
// {
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
// }
// break;
//}
return isSucc;
}
return false;
@ -234,10 +125,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
public virtual async Task<bool> SetForwardState(INVOICE_GRP p_entiy, SettleBillState p_State)
{
var state = p_State;
switch (p_entiy.State)
switch (p_State)
{
case SettleBillState.:
if (state == SettleBillState.)
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
@ -247,7 +138,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
break;
case SettleBillState.:
if (state == SettleBillState.)
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
@ -257,7 +148,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
break;
case SettleBillState.:
if (state == SettleBillState.)
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
@ -289,10 +180,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
public virtual async Task<bool> SetBackwardState(INVOICE_GRP p_entiy, SettleBillState p_State)
{
var state = p_State;
switch (p_entiy.State)
switch (state)
{
case SettleBillState.:
if (state == SettleBillState.)
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
@ -302,7 +193,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
break;
case SettleBillState.:
if (state == SettleBillState.)
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
@ -312,7 +203,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
break;
case SettleBillState.:
if (state == SettleBillState.)
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
@ -374,6 +265,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
site: entity.Site
);
var bbacDetail = new List<BBAC_PD_DETAIL>();
foreach (var itm in entityDetail)
{
bbacDetail.Add(
@ -397,6 +293,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
extend3: string.Empty,
extend4: string.Empty
));
await _repository.DbContext.BulkInsertAsync(new List<BBAC_PD>() { bbac });
await _repository.DbContext.BulkInsertAsync(bbacDetail);
return true;
@ -502,14 +400,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
}
}
return false;
}
public virtual async Task<bool> Reject(INVOICE_GRP p_entity)
{

10
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/NOT_SA_MNG.cs

@ -1,4 +1,4 @@
using SettleAccount.Bases;
using SettleAccount.Bases;
using System;
using System.Collections.Generic;
using System.Linq;
@ -26,6 +26,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly INormalEfCoreRepository<TNOTDetail, Guid> _notRepository;
public NOT_SA_MNG()
{
}
public NOT_SA_MNG
(
INormalEfCoreRepository<TEntity, Guid> repository,
@ -37,6 +42,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_detailRepository = detailRepository;
_notRepository = notRepository;
}
public virtual async Task<bool> GenerateSettlementOrder(List<TNOTDetail> p_list, Action<List<TEntityDetail>> p_action = null)
{

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PD_MNG.cs

@ -36,6 +36,9 @@ public class PD_MNG<TEntity,TEntityDetail>:DomainService
}
public PD_MNG()
{
}
public virtual async Task<TEntity> GetMainAsync(string billNum)
{

269
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_CAN_SA_MNG.cs

@ -0,0 +1,269 @@
using EFCore.BulkExtensions;
using Hangfire.Annotations;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Win.Sfs.SettleAccount.Bases.DomainServices;
using Win.Sfs.SettleAccount.Boms;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
public class PUB_CAN_SA_MNG: DomainService
{
private readonly INormalEfCoreRepository<PUB_CAN_SA, Guid> _repository;
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _detailRepository;
public PUB_CAN_SA_MNG
(
INormalEfCoreRepository<PUB_CAN_SA, Guid> repository,
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository
)
{
_repository = repository;
_detailRepository = detailRepository;
}
public PUB_CAN_SA_MNG()
{
}
public virtual async Task<bool> SetForwardState(PUB_CAN_SA p_entiy, SettleBillState state)
{
if (await SetForwardState(p_entiy.InvGroupNum, state) == true)
{
return true;
}
return false;
}
/// <summary>
/// 向前流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetForwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls == null && ls.Count ==0)
{
throw new BusinessException("8989", string.Format("不存在编号为{0}",p_billNum));
}
foreach (PUB_CAN_SA p_entiy in ls)
{
switch (state)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【未结状态】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户收票],无法设置成【财务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【客户已收票】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
}
/// <summary>
/// 向后流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetBackwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls == null && ls.Count == 0)
{
throw new BusinessException("8989", string.Format("不存在发票分组号为{0}的可结算单", p_billNum));
}
foreach (PUB_CAN_SA p_entiy in ls)
{
switch (state)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【未结状态】");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【财务已审核客户收票】状态");
}
break;
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户已收票],无法设置成【财务已审核】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
}
public virtual async Task<bool> SetNewState(PUB_CAN_SA p_entiy)
{
return await SetNewState(p_entiy.BillNum);
}
public virtual async Task<bool> SetNewState(string billNum)
{
var entity= await GetMainAsync(billNum);
if (entity != null )
{
entity.State = SettleBillState.;
await _repository.UpdateAsync(entity);
return true;
}
return false;
;
}
/// <summary>
/// 获得所有明细
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<List<PUB_CAN_SA_DETAIL>> GetDetalListAsync(string billNum)
{
return await _detailRepository.Where(p=>p.InvGroupNum==billNum).ToListAsync();
}
/// <summary>
/// 获得主表信息
/// </summary>
/// <param name="billNum"></param>
/// <returns></returns>
public virtual async Task<PUB_CAN_SA> GetMainAsync(string billNum)
{
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
}
}
}
Loading…
Cancel
Save