From 2a2f64b2e13494eeaefb451a5f5d078fe164d1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Thu, 26 Sep 2024 09:26:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=98=8E=E7=BB=86=E5=B8=81?= =?UTF-8?q?=E5=88=AB=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Settlement/Method/SettlementService`1.cs | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) 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 eaf80921..406dc0ee 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 @@ -121,13 +121,33 @@ namespace DS.WMS.Core.Settlement.Method FeeId = x.FeeId, FeeName = x.FeeName, FeeType = x.FeeType, + ApplyAmount = x.ApplyAmount - x.ProcessedAmount, Currency = x.Currency, - ExchangeRate = x.ExchangeRate, OriginalAmount = x.OriginalAmount - x.OriginalProcessedAmount, + OriginalCurrency = x.OriginalCurrency, + ExchangeRate = x.ExchangeRate }).ToListAsync(); + if (!string.IsNullOrEmpty(settlement.Currency)) //指定结算币别 + { + var details2 = details1.FindAll(x => x.OriginalCurrency != settlement.Currency); + foreach (var detail in details2) + { + detail.Currency = settlement.Currency; + + var doc = request.Documents.Find(x => x.Id == detail.ApplicationId); + if (doc == null) + return DataResult.Failed("结算单据与费用明细不一致"); + var exchange = doc.ExchangeRates?.Find(x => x.Currency == settlement.Currency); + if (exchange == null) + return DataResult.Failed($"未传入结算币别 {settlement.Currency} 与费用原币别 {detail.OriginalCurrency} 之间的汇率信息"); + + detail.ExchangeRate = exchange.ExchangeRate; + detail.ApplyAmount = Math.Round(exchange.ExchangeRate.GetValueOrDefault() * detail.OriginalAmount, 2, MidpointRounding.AwayFromZero); + } + } } //发票结算 else if (settlement.Mode == SettlementMode.InvoiceSettlement || settlement.Mode == SettlementMode.PaymentInvoiceSettlement) @@ -144,12 +164,33 @@ namespace DS.WMS.Core.Settlement.Method FeeId = x.FeeId, FeeName = x.FeeName, FeeType = x.FeeType, + ApplyAmount = x.ApplyAmount - x.ProcessedAmount, Currency = x.Currency, - ExchangeRate = x.ExchangeRate, OriginalAmount = x.OriginalAmount - x.OriginalProcessedAmount, + OriginalCurrency = x.OriginalCurrency, + ExchangeRate = x.ExchangeRate }).ToListAsync(); + if (settlement.Currency == FeeCurrency.RMB_CODE) //指定结算币别 + { + var details2 = details1.FindAll(x => x.OriginalCurrency != settlement.Currency); + foreach (var detail in details2) + { + detail.Currency = settlement.Currency; + + var doc = request.Documents.Find(x => x.Id == detail.ApplicationId); + if (doc == null) + return DataResult.Failed("结算单据与费用明细不一致"); + + var exchange = doc.ExchangeRates?.Find(x => x.Currency == settlement.Currency); + if (exchange == null) + return DataResult.Failed($"未传入结算币别 {settlement.Currency} 与费用原币别 {detail.OriginalCurrency} 之间的汇率信息"); + + detail.ExchangeRate = exchange.ExchangeRate; + detail.ApplyAmount = Math.Round(exchange.ExchangeRate.GetValueOrDefault() * detail.OriginalAmount, 2, MidpointRounding.AwayFromZero); + } + } } }