获取发票申请详情增加费用统计

usertest
嵇文龙 5 months ago
parent 6066533715
commit 9878a5f1c8

@ -120,6 +120,11 @@ namespace DS.WMS.Core.Application.Dtos
/// </summary>
public decimal OriginalAmount { get; set; }
/// <summary>
/// 币别
/// </summary>
public string Currency { get; set; }
/// <summary>
/// 原始币别
/// </summary>

@ -5,7 +5,7 @@ namespace DS.WMS.Core.Application.Dtos
/// <summary>
/// 费用申请单审核明细展示
/// </summary>
public class FeeApplicationSummary
public class ApplicationSummary
{
/// <summary>
/// 费用汇总
@ -21,7 +21,7 @@ namespace DS.WMS.Core.Application.Dtos
/// 初始化
/// </summary>
/// <param name="details">申请单明细</param>
public FeeApplicationSummary(IEnumerable<ApplicationDetailDto> details)
public ApplicationSummary(IEnumerable<ApplicationDetailDto> details)
{
ArgumentNullException.ThrowIfNull(details);

@ -9,6 +9,8 @@ namespace DS.WMS.Core.Application.Dtos
/// </summary>
public class InvoiceApplicationDto : ApplicationDto
{
public List<SummaryItem> SummaryItems { get; set; }
/// <summary>
/// 状态
/// </summary>
@ -146,6 +148,5 @@ namespace DS.WMS.Core.Application.Dtos
/// 是否已审核(仅用于查询)
/// </summary>
public bool? IsAudited { get; set; }
}
}

@ -1,54 +1,5 @@
using DS.Module.Core.Enums;
using DS.Module.Core.PageQuery;
namespace DS.WMS.Core.Application.Dtos
namespace DS.WMS.Core.Application.Dtos
{
/// <summary>
/// 付费申请列表查询条件
/// </summary>
public class PaymentApplicationListQuery : QueryModel
{
/// <summary>
/// 业务编号
/// </summary>
public string? BillNO { get; set; }
/// <summary>
/// 申请单编号
/// </summary>
public string? ApplicaitionNO { get; set; }
/// <summary>
/// 结算单位
/// </summary>
public long? CustomerId { get; set; }
/// <summary>
/// 申请单状态
/// </summary>
public PaymentApplicationStatus? Status { get; set; }
/// <summary>
/// 发票备注
/// </summary>
public string? InvoiceRemark { get; set; }
/// <summary>
/// 付费申请日期(从)
/// </summary>
public DateTime? PaymentDateStart { get; set; }
/// <summary>
/// 付费申请日期(至)
/// </summary>
public DateTime? PaymentDateEnd { get; set; }
/// <summary>
/// 申请人
/// </summary>
public long? CreateBy { get; set; }
}
public enum AuditStatusForQuery
{
/// <summary>

@ -23,7 +23,7 @@ namespace DS.WMS.Core.Application.Interface
/// </summary>
/// <param name="id">申请单ID</param>
/// <returns></returns>
Task<DataResult<FeeApplicationSummary>> GetDetailsAsync(long id);
Task<DataResult<ApplicationSummary>> GetDetailsAsync(long id);
/// <summary>
/// 获取业务费用统计

@ -66,6 +66,9 @@ namespace DS.WMS.Core.Application.Method
List<FeeRecord> fees = [];
if (application.Details.Count > 0)
{
if (application.Details.GroupBy(x => x.CustomerName).Select(x => x.Key).Count() > 1)
return DataResult<TEntity>.Failed("申请单明细的结算对象有且只能有一个");
var ids = application.Details.Select(x => x.RecordId).ToList();
fees = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.Id)).Select(x => new FeeRecord
{

@ -7,6 +7,7 @@ using DS.WMS.Core.Application.Entity;
using DS.WMS.Core.Application.Interface;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using SqlSugar;
@ -275,8 +276,9 @@ namespace DS.WMS.Core.Application.Method
/// <returns></returns>
public async Task<DataResult<InvoiceApplicationDto>> GetAsync(long id)
{
var dto = await TenantDb.Queryable<InvoiceApplication>().Where((a) => a.Id == id).Select(
(a) => new InvoiceApplicationDto
var dto = await TenantDb.Queryable<InvoiceApplication>().Where(a => a.Id == id)
.LeftJoin<InfoClientBank>((a, b) => a.CustomerBankId == b.Id)
.Select((a, b) => new InvoiceApplicationDto
{
Id = a.Id,
ApplicationNO = a.ApplicationNO,
@ -289,8 +291,19 @@ namespace DS.WMS.Core.Application.Method
CreateBy = a.CreateBy,
InvoiceDate = a.InvoiceDate,
InvoiceAmount = a.InvoiceAmount,
InvoiceCurrency = a.InvoiceCurrency,
InvoiceHeader = a.InvoiceHeader,
InvoiceNO = a.InvoiceNO,
InvoiceBillNO = a.InvoiceBillNO,
InvoiceRemark = a.InvoiceRemark,
SaleDeptId = a.SaleDeptId,
Note = a.Note
Note = a.Note,
ApplyAmount = a.ApplyAmount,
OtherCurrencyAmount = a.OtherCurrencyAmount,
Category = a.Category,
CustomerAddTel = a.CustomerAddTel,
CustomerBank = b.BankName,
CustomerAccount = b.Account,
}).FirstAsync();
if (dto != null)
@ -299,23 +312,24 @@ namespace DS.WMS.Core.Application.Method
dto.Details = await TenantDb.Queryable<ApplicationDetail>().LeftJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
.Where(d => d.ApplicationId == id).Select((d, f) => new InvoiceApplicationDetailDto
{
Id = d.Id,
RecordId = f.Id,
FeeType = d.FeeType,
FeeId = d.FeeId,
FeeName = d.FeeName,
Amount = d.Amount,
OriginalAmount = d.OriginalAmount,
//未申请金额=(金额-结算金额-申请金额+申请金额已结算)
RestAmount = f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount,
OriginalCurrency = d.OriginalCurrency,
OriginalRate = f.ExchangeRate,
ExchangeRate = d.ExchangeRate,
AccTaxRate = f.AccTaxRate,
BusinessId = d.BusinessId,
BusinessType = d.BusinessType
}).ToListAsync();
{
Id = d.Id,
RecordId = f.Id,
FeeType = d.FeeType,
FeeId = d.FeeId,
FeeName = d.FeeName,
Amount = d.Amount,
OriginalAmount = d.OriginalAmount,
//未申请金额=(金额-结算金额-申请金额+申请金额已结算)
RestAmount = f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount,
Currency = d.Currency,
OriginalCurrency = d.OriginalCurrency,
OriginalRate = f.ExchangeRate,
ExchangeRate = d.ExchangeRate,
AccTaxRate = f.AccTaxRate,
BusinessId = d.BusinessId,
BusinessType = d.BusinessType
}).ToListAsync();
var gList = dto.Details.GroupBy(x => x.BusinessType).ToList();
foreach (var g in gList)
@ -363,6 +377,14 @@ namespace DS.WMS.Core.Application.Method
break;
}
}
dto.SummaryItems = dto.Details.GroupBy(x => new { x.FeeType, x.Currency }).Select(x => new SummaryItem
{
FeeType = x.Key.FeeType,
Currency = x.Key.Currency,
Amount = x.Sum(y => y.Amount),
OriginalAmount = x.Sum(y => y.OriginalAmount)
}).ToList();
}
return DataResult<InvoiceApplicationDto>.Success(dto);

@ -145,7 +145,7 @@ namespace DS.WMS.Core.Application.Method
/// </summary>
/// <param name="id">申请单ID</param>
/// <returns></returns>
public async Task<DataResult<FeeApplicationSummary>> GetDetailsAsync(long id)
public async Task<DataResult<ApplicationSummary>> GetDetailsAsync(long id)
{
var details = await TenantDb.Queryable<ApplicationDetail>()
.LeftJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
@ -221,10 +221,10 @@ namespace DS.WMS.Core.Application.Method
}
}
var model = new FeeApplicationSummary(details);
var model = new ApplicationSummary(details);
var customerId = details.GroupBy(x => x.CustomerId).Select(x => x.Key).FirstOrDefault();
return DataResult<FeeApplicationSummary>.Success(model);
return DataResult<ApplicationSummary>.Success(model);
}
/// <summary>

@ -24,6 +24,12 @@ namespace DS.WMS.Core.Fee.Entity
[SugarColumn(ColumnDescription = "业务类型")]
public BusinessType BusinessType { get; set; }
/// <summary>
/// 费用状态
/// </summary>
[SugarColumn(ColumnDescription = "费用状态", DefaultValue = "1")]
public FeeStatus FeeStatus { get; set; } = FeeStatus.Entering;
/// <summary>
/// 收付类型(收、付) 1应收 2 应付
/// </summary>
@ -207,12 +213,6 @@ namespace DS.WMS.Core.Fee.Entity
[SugarColumn(ColumnDescription = "是否销售订舱", DefaultValue = "0")]
public bool? IsCrmOrderFee { get; set; } = false;
/// <summary>
/// 费用状态
/// </summary>
[SugarColumn(ColumnDescription = "费用状态", DefaultValue = "1")]
public FeeStatus FeeStatus { get; set; } = FeeStatus.Entering;
/// <summary>
/// 发票号
/// </summary>

@ -21,7 +21,7 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
public class FeeAuditService : FeeServiceBase, IFeeAuditService
{
const string Audit_Only = "AuditOnly=1";
const string Audit_Only = "AuditOnly";
/// <summary>
/// 待审核的状态值
@ -172,7 +172,7 @@ namespace DS.WMS.Core.Fee.Method
//查询:运输类型 (枚举值,暂未建立)
//查询:是否费用提交
//查询:利润减少
});
}).MergeTable();
//海运进口
//var ids2 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingImport).Select(x => x.BusinessId).ToArray();

@ -36,7 +36,7 @@ namespace DS.WMS.FeeApi.Controllers
}
/// <summary>
/// 按申请单审核
/// 发票申请审核
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
@ -49,21 +49,6 @@ namespace DS.WMS.FeeApi.Controllers
return await _auditService.AuditAsync(request);
}
/// <summary>
///一键审核当前登录用户的所有待审核项
/// </summary>
/// <param name="status">审批结果: 1=通过 2=驳回</param>
/// <param name="remark">审批备注</param>
/// <returns></returns>
[HttpPost, Route("OneClickAudit")]
public async Task<DataResult> OneClickAuditAsync(int status, string remark)
{
if (status != 1 && status != 2)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return await _auditService.AuditAsync(status, remark);
}
/// <summary>
/// 将申请单重置为未打印状态
/// </summary>

@ -42,7 +42,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="id">申请单ID</param>
/// <returns></returns>
[HttpGet, Route("GetDetails")]
public async Task<DataResult<FeeApplicationSummary>> GetDetailsAsync([FromQuery] long id)
public async Task<DataResult<ApplicationSummary>> GetDetailsAsync([FromQuery] long id)
{
return await _auditService.GetDetailsAsync(id);
}

Loading…
Cancel
Save