|
|
|
@ -11,7 +11,6 @@ using DS.WMS.Core.Settlement.Dtos;
|
|
|
|
|
using DS.WMS.Core.Settlement.Entity;
|
|
|
|
|
using DS.WMS.Core.Settlement.Interface;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
{
|
|
|
|
@ -28,6 +27,75 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取结算单详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">结算单ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<PaymentSettlementDto>> GetAsync(long id)
|
|
|
|
|
{
|
|
|
|
|
var model = await TenantDb.Queryable<ApplicationSettlement>().Select(x => new PaymentSettlementDto
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
ApplicationNO = x.ApplicationNO, //申请编号
|
|
|
|
|
SettlementNO = x.SettlementNO, //结算单号
|
|
|
|
|
CustomerId = x.CustomerId, //结算单位
|
|
|
|
|
CustomerName = x.CustomerName,
|
|
|
|
|
Mode = x.Mode, //结算类型
|
|
|
|
|
SettlementDate = x.SettlementDate, //结算日期
|
|
|
|
|
SettlementTypeId = x.SettlementTypeId, //结算方式
|
|
|
|
|
CustomerBankId = x.CustomerBankId, //客户银行
|
|
|
|
|
Account = x.Account, //客户账户
|
|
|
|
|
Currency = x.Currency, //币别
|
|
|
|
|
Amount = x.Amount, //金额
|
|
|
|
|
ExchangeRate = x.ExchangeRate, //汇率
|
|
|
|
|
IsLocked = x.IsLocked, //锁定状态
|
|
|
|
|
SaleDeptId = x.SaleDeptId, //所属分部
|
|
|
|
|
BillType = x.BillType, //单据类型
|
|
|
|
|
Category = x.Category, //业务类别
|
|
|
|
|
LedgerVoucherNO = x.LedgerVoucherNO, //总账凭证号
|
|
|
|
|
RelativeNO = x.RelativeNO, //相关号码
|
|
|
|
|
InvoiceAmount = x.InvoiceAmount,
|
|
|
|
|
InvoiceDate = x.InvoiceDate,
|
|
|
|
|
InvoiceNO = x.InvoiceNO,
|
|
|
|
|
Note = x.Note, //备注
|
|
|
|
|
|
|
|
|
|
AccountAmount = x.AccountAmount, //记账资料
|
|
|
|
|
AccountCurrency = x.AccountCurrency,
|
|
|
|
|
AccountRate = x.AccountRate,
|
|
|
|
|
PrePayAmount = x.PrePayAmount, //预付支资料
|
|
|
|
|
PrePayCurrency = x.PrePayCurrency,
|
|
|
|
|
PrePayRate = x.PrePayRate,
|
|
|
|
|
AHSRAmount = x.AHSRAmount, //实收支资料
|
|
|
|
|
AHSRCurrency = x.AHSRCurrency,
|
|
|
|
|
AHSRRate = x.AHSRRate,
|
|
|
|
|
FinancialAmount = x.FinancialAmount,//财务费用
|
|
|
|
|
FinancialCurrency = x.FinancialCurrency,
|
|
|
|
|
FinancialRate = x.FinancialRate,
|
|
|
|
|
AdvanceAmount = x.AdvanceAmount, //预收支资料
|
|
|
|
|
AdvanceCurrency = x.AdvanceCurrency,
|
|
|
|
|
AdvanceRate = x.AdvanceRate,
|
|
|
|
|
}, true).FirstAsync(x => x.Id == id && x.Mode == SettlementMode.Payment);
|
|
|
|
|
|
|
|
|
|
if (model != null)
|
|
|
|
|
{
|
|
|
|
|
model.Details = await GetSettlementDetails(id);
|
|
|
|
|
if (model.Details.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//关联用户名称
|
|
|
|
|
var userIds = model.Details.Select(x => x.CreateBy).Distinct();
|
|
|
|
|
var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var item in model.Details)
|
|
|
|
|
{
|
|
|
|
|
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult<PaymentSettlementDto>.Success(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取待结算的发票列表
|
|
|
|
|
/// </summary>
|
|
|
|
@ -134,14 +202,13 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
return DataResult<List<SettlementDocument>>.Success(documents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task<List<SettlementDetailDto>> GetSettlementDetails(long id)
|
|
|
|
|
{
|
|
|
|
|
var list = await TenantDb.Queryable<ApplicationDetail>()
|
|
|
|
|
.InnerJoin<ApplicationDetail>((d, pd) => d.DetailId == pd.Id)
|
|
|
|
|
.InnerJoin<InvoiceApplication>((d, pd, pa) => pd.ApplicationId == pa.Id)
|
|
|
|
|
.InnerJoin<Invoice.Entity.Invoice>((d, pd, i) => pd.ApplicationId == i.Id)
|
|
|
|
|
.Where(d => d.ApplicationId == id)
|
|
|
|
|
.Select((d, pd, pa) => new
|
|
|
|
|
.Select((d, pd, i) => new
|
|
|
|
|
{
|
|
|
|
|
d.Id,
|
|
|
|
|
d.ApplicationId,
|
|
|
|
@ -149,11 +216,12 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
d.Currency,
|
|
|
|
|
d.OriginalCurrency,
|
|
|
|
|
d.OriginalAmount,
|
|
|
|
|
pa.ApplicationNO,
|
|
|
|
|
pa.Status,
|
|
|
|
|
pa.CreateTime,
|
|
|
|
|
pa.CreateBy,
|
|
|
|
|
pa.Note
|
|
|
|
|
i.InvoiceNO,
|
|
|
|
|
i.BillNO,
|
|
|
|
|
i.SN,
|
|
|
|
|
i.CreateTime,
|
|
|
|
|
i.CreateBy,
|
|
|
|
|
i.Note
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var details = new List<SettlementDetailDto>();
|
|
|
|
@ -177,9 +245,8 @@ namespace DS.WMS.Core.Settlement.Method
|
|
|
|
|
//Ids = g.Select(x => x.Id),
|
|
|
|
|
RMBApplyAmount = g.Where(x => x.OriginalCurrency == FeeCurrency.RMB_CODE).Sum(x => x.ApplyAmount),
|
|
|
|
|
USDApplyAmount = g.Where(x => x.OriginalCurrency == FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount),
|
|
|
|
|
ApplicationNO = firstItem.ApplicationNO,
|
|
|
|
|
Status = (int)firstItem.Status,
|
|
|
|
|
StatusText = firstItem.Status.GetDescription(),
|
|
|
|
|
ApplicationNO = firstItem.BillNO,
|
|
|
|
|
InvoiceNO = firstItem.InvoiceNO,
|
|
|
|
|
CreateTime = firstItem?.CreateTime,
|
|
|
|
|
CreateBy = firstItem?.CreateBy,
|
|
|
|
|
CreateByName = users.Find(x => x.Id == firstItem?.CreateBy)?.UserName,
|
|
|
|
|