|
|
|
@ -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);
|
|
|
|
|