From 4c95576cf4cb986ee514b4f1e1622365ccc716e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Wed, 6 Nov 2024 20:39:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=BE=85=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=B4=B9=E7=94=A8=E7=8A=B6=E6=80=81=E7=AD=9B?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.WMS.Core/Fee/Method/FeeAuditService.cs | 2 +- .../Fee/Method/FeeRecordService.cs | 2 +- .../Settlement/Method/SettlementService`1.cs | 62 ++++++++++++++----- 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs index 63c76cee..9360c3b3 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs @@ -395,7 +395,7 @@ namespace DS.WMS.Core.Fee.Method var query1 = TenantDb.Queryable().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType) .InnerJoin((f, s) => f.BusinessId == s.Id) .LeftJoin((f, s, i) => f.CustomerId == i.Id) - .WhereIF(ids1.Length > 0, (f, s, i) => (ids1.Contains(f.Id) || ids2.Contains(f.BusinessId)) && AuditStatusArray.Contains(f.FeeStatus)) + .WhereIF(ids1.Length > 0, (f, s, i) => ids1.Contains(f.Id) || ids2.Contains(f.BusinessId)) .Select((f, s, i) => new FeeAuditItemQuery { Id = f.Id, diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs index 93eabd9f..f980b03b 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs @@ -914,7 +914,7 @@ namespace DS.WMS.Core.Fee.Method } else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT) { - if (entity.BillAuditStatus != BillAuditStatus.PaySubmitted && entity.BillAuditStatus != BillAuditStatus.PayRejected) + if (entity.BillAuditStatus != BillAuditStatus.PaySubmitted || entity.BillAuditStatus != BillAuditStatus.PayRejected) return DataResult.Failed(string.Format( MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription())); } diff --git a/ds-wms-service/DS.WMS.Core/Settlement/Method/SettlementService`1.cs b/ds-wms-service/DS.WMS.Core/Settlement/Method/SettlementService`1.cs index 4f881de0..983d1dfe 100644 --- a/ds-wms-service/DS.WMS.Core/Settlement/Method/SettlementService`1.cs +++ b/ds-wms-service/DS.WMS.Core/Settlement/Method/SettlementService`1.cs @@ -140,11 +140,11 @@ namespace DS.WMS.Core.Settlement.Method { detail.Currency = settlement.Currency; - var doc = request.Documents.Find(x => x.Id == detail.ApplicationId); + var doc = request.Documents.Find(x => x.Id == detail.RefId); if (doc == null) return DataResult.Failed("结算单据与费用明细不一致"); - var exchange = doc.ExchangeRates?.Find(x => x.Currency == settlement.Currency); + var exchange = doc.ExchangeRates?.Find(x => x.Currency == detail.OriginalCurrency); if (exchange == null) return DataResult.Failed($"未传入结算币别 {settlement.Currency} 与费用原币别 {detail.OriginalCurrency} 之间的汇率信息"); @@ -250,14 +250,14 @@ namespace DS.WMS.Core.Settlement.Method details1.Where(x => x.RefId == doc.Id).OrderBy(x => x.ApplyAmount) : details1.Where(x => x.BusinessId == doc.Id && x.BusinessType == doc.BusinessType && x.CustomerName == doc.CustomerName).OrderBy(x => x.ApplyAmount); - var rmbDetails = details2.Where(x => x.Currency == FeeCurrency.RMB_CODE); - var totalRMB = rmbDetails.Sum(x => x.ApplyAmount); + var rmbDetails = details2.Where(x => x.OriginalCurrency == FeeCurrency.RMB_CODE); + var totalRMB = rmbDetails.Sum(x => x.OriginalAmount); doc.SettlementRMB ??= totalRMB; if (doc.SettlementRMB > totalRMB) return DataResult.Failed("人民币结算金额不能大于剩余人民币金额"); - if (totalRMB < doc.SettlementRMB) + if (doc.SettlementRMB < totalRMB) { var rest = totalRMB - doc.SettlementRMB.GetValueOrDefault(); foreach (var detail in rmbDetails) @@ -265,19 +265,29 @@ namespace DS.WMS.Core.Settlement.Method if (rest == 0) break; - detail.ApplyAmount = detail.ApplyAmount - rest; - rest = detail.ApplyAmount - rest; + detail.OriginalAmount = detail.OriginalAmount - rest; + if (detail.OriginalCurrency == settlement.Currency) + { + detail.ApplyAmount = detail.OriginalAmount; + } + else + { + var er = doc.ExchangeRates.Find(x => x.Currency == detail.OriginalCurrency); + detail.ApplyAmount = detail.OriginalAmount * er?.ExchangeRate ?? 1; + } + + rest = detail.OriginalAmount - rest; } } - var usdDetails = details2.Where(x => x.Currency == FeeCurrency.USD_CODE); - var totalUSD = usdDetails.Sum(x => x.ApplyAmount); + var usdDetails = details2.Where(x => x.OriginalCurrency == FeeCurrency.USD_CODE); + var totalUSD = usdDetails.Sum(x => x.OriginalAmount); doc.SettlementUSD ??= totalUSD; if (doc.SettlementUSD > totalUSD) return DataResult.Failed("美元结算金额不能大于剩余美元金额"); - if (totalUSD < doc.SettlementUSD) + if (doc.SettlementUSD < totalUSD) { var rest = totalUSD - doc.SettlementUSD.GetValueOrDefault(); foreach (var detail in usdDetails) @@ -285,19 +295,28 @@ namespace DS.WMS.Core.Settlement.Method if (rest == 0) break; - detail.ApplyAmount = detail.ApplyAmount - rest; - rest = detail.ApplyAmount - rest; + detail.OriginalAmount = detail.OriginalAmount - rest; + if (detail.OriginalCurrency == settlement.Currency) + { + detail.ApplyAmount = detail.OriginalAmount; + } + else + { + var er = doc.ExchangeRates.Find(x => x.Currency == detail.OriginalCurrency); + detail.ApplyAmount = detail.OriginalAmount * er?.ExchangeRate ?? 1; + } + rest = detail.OriginalAmount - rest; } } - var otherDetails = details2.Where(x => x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE); - var total = rmbDetails.Sum(x => x.ApplyAmount); + var otherDetails = details2.Where(x => x.OriginalCurrency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE); + var total = otherDetails.Sum(x => x.OriginalAmount); doc.SettlementOther ??= total; if (doc.SettlementOther > total) return DataResult.Failed("其他结算金额不能大于剩余其他金额"); - if (total < doc.SettlementOther) + if (doc.SettlementOther < total) { var rest = total - doc.SettlementOther.GetValueOrDefault(); foreach (var detail in otherDetails) @@ -305,8 +324,17 @@ namespace DS.WMS.Core.Settlement.Method if (rest == 0) break; - detail.ApplyAmount = detail.ApplyAmount - rest; - rest = detail.ApplyAmount - rest; + detail.OriginalAmount = detail.OriginalAmount - rest; + if (detail.OriginalCurrency == settlement.Currency) + { + detail.ApplyAmount = detail.OriginalAmount; + } + else + { + var er = doc.ExchangeRates.Find(x => x.Currency == detail.OriginalCurrency); + detail.ApplyAmount = detail.OriginalAmount * er?.ExchangeRate ?? 1; + } + rest = detail.OriginalAmount - rest; } } }