获取申请单详情增加统计项

dev
嵇文龙 2 months ago
parent 8c988914d8
commit fb79594ba9

@ -301,6 +301,7 @@ namespace DS.WMS.Core.Application.Method
CustomerBankName = b.BankName + " " + b.Account,
SettlementTypeName = c.StlName,
}, true).FirstAsync();
var result = DataResult<PaymentApplicationDto>.Success(dto);
if (dto != null)
{
@ -384,9 +385,23 @@ namespace DS.WMS.Core.Application.Method
dto.RestAmountRMB = dto.Details.FindAll(x => x.OriginalCurrency == FeeCurrency.RMB_CODE).Sum(x => x.RestAmount);
dto.RestAmountUSD = dto.Details.FindAll(x => x.OriginalCurrency == FeeCurrency.USD_CODE).Sum(x => x.RestAmount);
dto.AmountOther = dto.Details.FindAll(x => x.OriginalCurrency != FeeCurrency.RMB_CODE && x.OriginalCurrency != FeeCurrency.USD_CODE).Sum(x => x.RestAmount);
result.AdditionalData ??= [];
var ids = dto.Details.Select(x => x.RecordId);
var fees = await TenantDb.Queryable<FeeRecord>().Where(f => ids.Contains(f.Id) && f.FeeType == FeeType.Receivable)
.Select(f => new
{
f.Currency,
f.Amount,
UnSettlement = f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount
}).ToListAsync();
result.AdditionalData["ReceivablesRMB"] = fees.Where(x => x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
result.AdditionalData["ReceivablesUSD"] = fees.Where(x => x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
result.AdditionalData["UnSettledRMB"] = fees.Where(x => x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.UnSettlement);
result.AdditionalData["UnSettledUSD"] = fees.Where(x => x.Currency == FeeCurrency.USD_CODE).Sum(x => x.UnSettlement);
}
return DataResult<PaymentApplicationDto>.Success(dto);
return result;
}
protected override async Task<List<ApplicationDetail>> GetDetailsAsync(ApplicationRequest<PaymentApplication> request)
@ -482,37 +497,29 @@ namespace DS.WMS.Core.Application.Method
return sb.Length > 0 ? DataResult.Failed(sb.ToString()) : DataResult.Success;
}
protected override Task PreSaveAsync(PaymentApplication application)
{
application.AmountRMB = application.Details.Where(x => x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.ApplyAmount);
application.AmountUSD = application.Details.Where(x => x.Currency == FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount);
application.AmountOther = application.Details.Where(x => x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount);
return Task.CompletedTask;
}
protected override async Task OnSaveAsync(PaymentApplication application, List<FeeRecord>? fees)
{
var details = application.Details;
if (application.Id > 0)
details = await TenantDb.Queryable<ApplicationDetail>().Where(x => x.ApplicationId == application.Id).ToListAsync();
//更新申请单总金额
application.AmountRMB = details.Where(x => x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.ApplyAmount);
application.AmountUSD = details.Where(x => x.Currency == FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount);
application.AmountOther = details.Where(x => x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount);
await TenantDb.Updateable(application).IgnoreColumns(x => new
{
await TenantDb.Updateable(application).IgnoreColumns(x => new
{
x.ApplicationNO,
x.AmountRMB,
x.AmountUSD,
x.AmountOther,
x.CreateBy,
x.CreateTime,
x.Deleted,
x.DeleteBy,
x.DeleteTime
}).ExecuteCommandAsync();
}
x.ApplicationNO,
x.CreateBy,
x.CreateTime,
x.Deleted,
x.DeleteBy,
x.DeleteTime
}).ExecuteCommandAsync();
if (fees != null && fees.Count > 0)
await TenantDb.Updateable(fees)
.PublicSetColumns(x => x.OrderAmount, "+")
.UpdateColumns(x => new { x.OrderAmount })
.PublicSetColumns(x => x.OrderAmount, "+").UpdateColumns(x => new { x.OrderAmount })
.ExecuteCommandAsync();
}
@ -522,6 +529,7 @@ namespace DS.WMS.Core.Application.Method
return DataResult<PaymentApplication>.Success(app);
}
protected override DataResult PreDelete(List<PaymentApplication> applications)
{
if (applications.Any(x => x.Status != PaymentApplicationStatus.Pending && x.Status != PaymentApplicationStatus.AuditRejected))
@ -577,6 +585,7 @@ namespace DS.WMS.Core.Application.Method
}
protected override DataResult PreSubmitApproval(List<PaymentApplication> applications)
{
if (applications.Exists(x => x.Status == PaymentApplicationStatus.AuditSubmittd || x.Status == PaymentApplicationStatus.AuditPassed))

Loading…
Cancel
Save