|
|
|
@ -927,110 +927,33 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取费用核算单打印信息
|
|
|
|
|
/// 获取费用打印信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="providerName"></param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(BusinessType businessType, params long[] idArray)
|
|
|
|
|
public async Task<DataResult<dynamic>> GetPrintInfoAsync(string providerName, BusinessType businessType, params long[] idArray)
|
|
|
|
|
{
|
|
|
|
|
CostAccountingForm form = null;
|
|
|
|
|
switch (businessType)
|
|
|
|
|
{
|
|
|
|
|
case BusinessType.OceanShippingExport:
|
|
|
|
|
form = await GetOceanShippingExportAsync(idArray);
|
|
|
|
|
break;
|
|
|
|
|
case BusinessType.OceanShippingImport:
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return DataResult<CostAccountingForm>.Failed(string.Format(
|
|
|
|
|
MultiLanguageConst.BusinessNotSupported, businessType.GetDescription()));
|
|
|
|
|
}
|
|
|
|
|
Type type = Type.GetType(providerName, false);
|
|
|
|
|
if (type == null)
|
|
|
|
|
return DataResult<dynamic>.Failed("未能找到数据提供程序");
|
|
|
|
|
|
|
|
|
|
if (form != null)
|
|
|
|
|
var provider = Fasterflect.ConstructorExtensions.CreateInstance(type) as IReportProvider;
|
|
|
|
|
var context = new ReportContext
|
|
|
|
|
{
|
|
|
|
|
long UserId = long.Parse(User.UserId);
|
|
|
|
|
form.Creator = Db.Queryable<SysUser>().Where(x => x.Id == UserId).Select(x => x.UserName).First();
|
|
|
|
|
|
|
|
|
|
form.ReceivableRMB = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
|
|
|
|
|
form.PayableRMB = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.RMB_CODE).Sum(x => x.Amount);
|
|
|
|
|
form.ReceivableUSD = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
|
|
|
|
|
form.PayableUSD = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == FeeCurrency.USD_CODE).Sum(x => x.Amount);
|
|
|
|
|
form.ReceivableOther = form.Details.FindAll(x => x.Type == FeeType.Receivable && (x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
|
|
|
|
|
form.PayableOther = form.Details.FindAll(x => x.Type == FeeType.Payable && (x.Currency == FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE)).Sum(x => x.Amount);
|
|
|
|
|
|
|
|
|
|
//获取美元汇率
|
|
|
|
|
var fees = new List<FeeRecord> {
|
|
|
|
|
new FeeRecord { Currency = FeeCurrency.USD_CODE, FeeType = FeeType.Receivable },
|
|
|
|
|
new FeeRecord { Currency = FeeCurrency.USD_CODE, FeeType = FeeType.Payable }
|
|
|
|
|
};
|
|
|
|
|
await FetchExchangeRateAsync(fees);
|
|
|
|
|
form.ExchangeRate = fees[0].ExchangeRate.HasValue ? fees[0].ExchangeRate.Value : 1;
|
|
|
|
|
form.TotalReceivable = Math.Round(form.ReceivableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.ReceivableRMB + form.ReceivableOther;
|
|
|
|
|
form.TotalPayable = Math.Round(form.PayableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.PayableRMB + form.PayableOther;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult<CostAccountingForm>.Success(form);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取海运出口打印数据
|
|
|
|
|
async Task<CostAccountingForm> GetOceanShippingExportAsync(params long[] idArray)
|
|
|
|
|
{
|
|
|
|
|
CostAccountingForm form = null;
|
|
|
|
|
var list = await TenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
|
|
|
|
|
.Where((x, y) => idArray.Contains(x.Id)
|
|
|
|
|
//&& x.FeeStatus == FeeStatus.SettlementCompleted
|
|
|
|
|
).Select((x, y) => new
|
|
|
|
|
{
|
|
|
|
|
x.FeeType,
|
|
|
|
|
x.FeeName,
|
|
|
|
|
x.Currency,
|
|
|
|
|
x.ExchangeRate,
|
|
|
|
|
x.Amount,
|
|
|
|
|
x.CustomerName,
|
|
|
|
|
y.CustomerNo, //业务编号
|
|
|
|
|
y.AccountDate, //会计期间
|
|
|
|
|
y.ETA,
|
|
|
|
|
y.ETD,
|
|
|
|
|
y.Voyno,
|
|
|
|
|
y.MBLNO,
|
|
|
|
|
y.Carrier,
|
|
|
|
|
y.LoadPort,
|
|
|
|
|
y.DischargePort,
|
|
|
|
|
y.CntrTotal, //Volume
|
|
|
|
|
y.IssueType //放单方式
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
|
return form;
|
|
|
|
|
|
|
|
|
|
var item = list[0];
|
|
|
|
|
form = new CostAccountingForm
|
|
|
|
|
{
|
|
|
|
|
BusinessNo = item.CustomerNo,
|
|
|
|
|
AccountingPeriod = item.AccountDate,
|
|
|
|
|
ETA = item.ETA,
|
|
|
|
|
ETD = item.ETD,
|
|
|
|
|
Voy = item.Voyno,
|
|
|
|
|
MBLNo = item.MBLNO,
|
|
|
|
|
Carrier = item.Carrier,
|
|
|
|
|
POL = item.LoadPort,
|
|
|
|
|
POD = item.DischargePort,
|
|
|
|
|
Volume = item.CntrTotal,
|
|
|
|
|
ReleaseType = item.IssueType,
|
|
|
|
|
PrintTime = DateTime.Now,
|
|
|
|
|
Details = list.Select(x => new CostAccountingDetail
|
|
|
|
|
{
|
|
|
|
|
Amount = x.Amount,
|
|
|
|
|
Currency = x.Currency,
|
|
|
|
|
CustomerName = x.CustomerName,
|
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
|
Type = x.FeeType
|
|
|
|
|
}).ToList()
|
|
|
|
|
BusinessType = businessType,
|
|
|
|
|
Ids = idArray,
|
|
|
|
|
Db = Db,
|
|
|
|
|
TenantDb = TenantDb,
|
|
|
|
|
User = User,
|
|
|
|
|
ServiceProvider = ServiceProvider
|
|
|
|
|
};
|
|
|
|
|
var data = provider.GetDataAsync(context);
|
|
|
|
|
if (context.ErrorResult == null)
|
|
|
|
|
return DataResult<dynamic>.Success(data);
|
|
|
|
|
|
|
|
|
|
return form;
|
|
|
|
|
return DataResult<dynamic>.Failed(context.ErrorResult.Message, context.ErrorResult.MultiCode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|