|
|
|
@ -85,17 +85,61 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<BizApplication>>> GetBizListAsync(PageRequest request)
|
|
|
|
|
public async Task<DataResult<List<BizInvoiceApplication>>> GetBizListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var queryList = CreateBizQuery();
|
|
|
|
|
var query = CreateBizQuery();
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
int? index = null;
|
|
|
|
|
foreach (var item in whereList)
|
|
|
|
|
{
|
|
|
|
|
ConditionalModel? model = item as ConditionalModel;
|
|
|
|
|
if (model == null)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
//设置了费用范围筛选
|
|
|
|
|
if (string.Equals(model.FieldName, nameof(BizInvoiceApplication.FeeRange)) && int.TryParse(model.FieldValue, out int feeRangeVal))
|
|
|
|
|
{
|
|
|
|
|
FeeRange feeRange = (FeeRange)feeRangeVal;
|
|
|
|
|
switch (feeRange)
|
|
|
|
|
{
|
|
|
|
|
case FeeRange.Unsettled:
|
|
|
|
|
query = query.Where(x => x.SettlementAmount == 0);
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.Settled:
|
|
|
|
|
query = query.Where(x => x.SettlementAmount > 0);
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.PaidNotReceived:
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.ReceivedNotPaid:
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.NotAppliedSettled:
|
|
|
|
|
query = query.Where(x => x.OrderAmount == 0 && x.SettlementAmount == 0);
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.UnreconciledSettled:
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.NotIssuedSettled:
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.ReconciledNotSettled:
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.NotReceivedPaid:
|
|
|
|
|
break;
|
|
|
|
|
case FeeRange.SettledNotIssued:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
index = whereList.IndexOf(item);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (index.HasValue)
|
|
|
|
|
whereList.RemoveAt(index.Value);
|
|
|
|
|
|
|
|
|
|
query = query.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = await queryList.ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
var result = await query.ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
if (result.Data.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//关联用户名称
|
|
|
|
@ -122,23 +166,24 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项业务数据的查询并集
|
|
|
|
|
internal ISugarQueryable<BizApplication> CreateBizQuery()
|
|
|
|
|
internal ISugarQueryable<BizInvoiceApplication> CreateBizQuery()
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var query1 = TenantDb.Queryable<SeaExport>()
|
|
|
|
|
.InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
|
.Where((s, f) => f.FeeStatus == FeeStatus.AuditPassed)
|
|
|
|
|
.GroupBy((s, f) => s.Id)
|
|
|
|
|
.Select((s, f) => new BizApplication
|
|
|
|
|
.Select((s, f) => new BizInvoiceApplication
|
|
|
|
|
{
|
|
|
|
|
Id = s.Id,
|
|
|
|
|
AccountDate = s.AccountDate,
|
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
|
CntrTotal = s.CntrTotal,
|
|
|
|
|
CreateBy = s.CreateBy,
|
|
|
|
|
CustomerId = s.CustomerId,//费用对象
|
|
|
|
|
CustomerName = s.CustomerName,
|
|
|
|
|
CustomerId = f.CustomerId,//费用对象
|
|
|
|
|
CustomerName = f.CustomerName,
|
|
|
|
|
CustomerNo = s.CustomerNo,
|
|
|
|
|
ClientName = s.CustomerName, //委托单位
|
|
|
|
|
DischargePort = s.DischargePort,
|
|
|
|
|
ETD = s.ETD,
|
|
|
|
|
HBLNO = s.HBLNO,
|
|
|
|
@ -155,21 +200,23 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
|
Currency = f.Currency,
|
|
|
|
|
IsAdvancedPay = f.IsAdvancedPay,
|
|
|
|
|
IsInvoice = f.IsInvoice,
|
|
|
|
|
DebitNo = f.DebitNo,
|
|
|
|
|
OrderAmount = f.OrderAmount,
|
|
|
|
|
InvoiceAmount = f.InvoiceAmount,
|
|
|
|
|
SettlementAmount = f.SettlementAmount,
|
|
|
|
|
//未申请开票金额=(金额-开票金额-申请开票金额+申请开票金额已开票
|
|
|
|
|
UnBilledRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency == RMB_CODE).Select(f => SqlFunc.AggregateSum((f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount).GetValueOrDefault())),
|
|
|
|
|
&& f.Currency == RMB_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount)),
|
|
|
|
|
UnBilledUSD = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency == USD_CODE).Select(f => SqlFunc.AggregateSum((f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount).GetValueOrDefault())),
|
|
|
|
|
&& f.Currency == USD_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount)),
|
|
|
|
|
UnBilledOther = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
|
&& f.Currency != RMB_CODE && f.Currency != USD_CODE).Select(f => SqlFunc.AggregateSum((f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount).GetValueOrDefault()))
|
|
|
|
|
&& f.Currency != RMB_CODE && f.Currency != USD_CODE).Select(f => SqlFunc.AggregateSum(f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//海运进口
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<BizApplication>> { query1 });
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<BizInvoiceApplication>> { query1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -193,9 +240,9 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
|
FeeName = f.FeeName,
|
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
|
Amount = f.Amount.GetValueOrDefault(),
|
|
|
|
|
Amount = f.Amount,
|
|
|
|
|
Currency = f.Currency,
|
|
|
|
|
RestAmount = (f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount).GetValueOrDefault(),
|
|
|
|
|
RestAmount = f.Amount - f.InvoiceAmount - f.OrderInvoiceAmount + f.OrderInvSettlementAmount,
|
|
|
|
|
Remark = f.Remark,
|
|
|
|
|
CreateBy = f.CreateBy
|
|
|
|
|
}).ToListAsync();
|
|
|
|
@ -329,7 +376,7 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
// return DataResult<PaymentApplicationDto>.Success(dto);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task<List<ApplicationDetail>> GetDetailsAsync(IEnumerable<BizItem> items)
|
|
|
|
|
{
|
|
|
|
|
var ids1 = items.Select(x => x.Id);
|
|
|
|
@ -342,7 +389,7 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
BusinessId = x.BusinessId,
|
|
|
|
|
BusinessType = x.BusinessType,
|
|
|
|
|
Amount = (x.Amount - x.InvoiceAmount - x.OrderInvoiceAmount + x.OrderInvSettlementAmount).GetValueOrDefault(),
|
|
|
|
|
Amount = x.Amount - x.InvoiceAmount - x.OrderInvoiceAmount + x.OrderInvSettlementAmount,
|
|
|
|
|
ExchangeRate = x.ExchangeRate,
|
|
|
|
|
OriginalCurrency = x.Currency
|
|
|
|
|
}).ToListAsync();
|
|
|
|
@ -395,7 +442,7 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//未申请开票金额=(金额-已开票金额-申请开票金额+申请开票金额已开票
|
|
|
|
|
var restAmount = (fee.Amount - fee.InvoiceAmount- fee.OrderInvoiceAmount + fee.OrderInvSettlementAmount).GetValueOrDefault();
|
|
|
|
|
var restAmount = fee.Amount - fee.InvoiceAmount - fee.OrderInvoiceAmount + fee.OrderInvSettlementAmount;
|
|
|
|
|
if (detail.OriginalAmount > 0 && detail.OriginalAmount > restAmount)
|
|
|
|
|
{
|
|
|
|
|
sb.Append($"申请单明细【{detail.FeeName}】的申请开票金额不能超出原费用的金额;");
|
|
|
|
|