|
|
@ -85,17 +85,61 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <param name="request"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <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())
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
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)
|
|
|
|
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>()
|
|
|
|
var query1 = TenantDb.Queryable<SeaExport>()
|
|
|
|
.InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
.InnerJoin<FeeRecord>((s, f) => s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport)
|
|
|
|
.Where((s, f) => f.FeeStatus == FeeStatus.AuditPassed)
|
|
|
|
.Where((s, f) => f.FeeStatus == FeeStatus.AuditPassed)
|
|
|
|
.GroupBy((s, f) => s.Id)
|
|
|
|
.GroupBy((s, f) => s.Id)
|
|
|
|
.Select((s, f) => new BizApplication
|
|
|
|
.Select((s, f) => new BizInvoiceApplication
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = s.Id,
|
|
|
|
Id = s.Id,
|
|
|
|
AccountDate = s.AccountDate,
|
|
|
|
AccountDate = s.AccountDate,
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
BusinessType = BusinessType.OceanShippingExport,
|
|
|
|
CntrTotal = s.CntrTotal,
|
|
|
|
CntrTotal = s.CntrTotal,
|
|
|
|
CreateBy = s.CreateBy,
|
|
|
|
CreateBy = s.CreateBy,
|
|
|
|
CustomerId = s.CustomerId,//费用对象
|
|
|
|
CustomerId = f.CustomerId,//费用对象
|
|
|
|
CustomerName = s.CustomerName,
|
|
|
|
CustomerName = f.CustomerName,
|
|
|
|
CustomerNo = s.CustomerNo,
|
|
|
|
CustomerNo = s.CustomerNo,
|
|
|
|
|
|
|
|
ClientName = s.CustomerName, //委托单位
|
|
|
|
DischargePort = s.DischargePort,
|
|
|
|
DischargePort = s.DischargePort,
|
|
|
|
ETD = s.ETD,
|
|
|
|
ETD = s.ETD,
|
|
|
|
HBLNO = s.HBLNO,
|
|
|
|
HBLNO = s.HBLNO,
|
|
|
@ -155,21 +200,23 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
Currency = f.Currency,
|
|
|
|
Currency = f.Currency,
|
|
|
|
IsAdvancedPay = f.IsAdvancedPay,
|
|
|
|
DebitNo = f.DebitNo,
|
|
|
|
IsInvoice = f.IsInvoice,
|
|
|
|
OrderAmount = f.OrderAmount,
|
|
|
|
|
|
|
|
InvoiceAmount = f.InvoiceAmount,
|
|
|
|
|
|
|
|
SettlementAmount = f.SettlementAmount,
|
|
|
|
//未申请开票金额=(金额-开票金额-申请开票金额+申请开票金额已开票
|
|
|
|
//未申请开票金额=(金额-开票金额-申请开票金额+申请开票金额已开票
|
|
|
|
UnBilledRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.Id && f.FeeStatus == FeeStatus.AuditPassed
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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>
|
|
|
|
/// <summary>
|
|
|
@ -193,9 +240,9 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
FeeName = f.FeeName,
|
|
|
|
FeeName = f.FeeName,
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
Amount = f.Amount.GetValueOrDefault(),
|
|
|
|
Amount = f.Amount,
|
|
|
|
Currency = f.Currency,
|
|
|
|
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,
|
|
|
|
Remark = f.Remark,
|
|
|
|
CreateBy = f.CreateBy
|
|
|
|
CreateBy = f.CreateBy
|
|
|
|
}).ToListAsync();
|
|
|
|
}).ToListAsync();
|
|
|
@ -342,7 +389,7 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|
BusinessId = x.BusinessId,
|
|
|
|
BusinessId = x.BusinessId,
|
|
|
|
BusinessType = x.BusinessType,
|
|
|
|
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,
|
|
|
|
ExchangeRate = x.ExchangeRate,
|
|
|
|
OriginalCurrency = x.Currency
|
|
|
|
OriginalCurrency = x.Currency
|
|
|
|
}).ToListAsync();
|
|
|
|
}).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)
|
|
|
|
if (detail.OriginalAmount > 0 && detail.OriginalAmount > restAmount)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sb.Append($"申请单明细【{detail.FeeName}】的申请开票金额不能超出原费用的金额;");
|
|
|
|
sb.Append($"申请单明细【{detail.FeeName}】的申请开票金额不能超出原费用的金额;");
|
|
|
|