diff --git a/ds-wms-service/DS.WMS.Core/Application/Dtos/InvoiceApplicationDto.cs b/ds-wms-service/DS.WMS.Core/Application/Dtos/InvoiceApplicationDto.cs index c251cff5..f2cfd816 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Dtos/InvoiceApplicationDto.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Dtos/InvoiceApplicationDto.cs @@ -10,6 +10,21 @@ namespace DS.WMS.Core.Application.Dtos /// public class InvoiceApplicationDto : ApplicationDto { + /// + /// RMB开票金额 + /// + public decimal? AmountRMB { get; set; } + + /// + /// USD开票金额 + /// + public decimal? AmountUSD { get; set; } + + /// + /// 其他币别开票金额 + /// + public decimal? AmountOther { get; set; } + /// /// 汇总统计 /// diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Dtos/RequestItem.cs b/ds-wms-service/DS.WMS.Core/Invoice/Dtos/RequestItem.cs index a5cf1ad9..1eb66b74 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Dtos/RequestItem.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Dtos/RequestItem.cs @@ -15,7 +15,20 @@ /// public string Currency { get; set; } + /// + /// 本次RMB开票金额 + /// + public decimal? AmountRMB { get; set; } + /// + /// 本次USD开票金额 + /// + public decimal? AmountUSD { get; set; } + + /// + /// 本次其他币别开票金额 + /// + public decimal? AmountOther { get; set; } /// /// 汇率信息 diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Method/GeneralInvoiceService.cs b/ds-wms-service/DS.WMS.Core/Invoice/Method/GeneralInvoiceService.cs index 3b5fc093..5415fbbf 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Method/GeneralInvoiceService.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Method/GeneralInvoiceService.cs @@ -3,9 +3,9 @@ using DS.Module.Core.Enums; using DS.Module.Core.Extensions; using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Application.Entity; +using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Invoice.Interface; using DS.WMS.Core.Sys.Entity; -using Org.BouncyCastle.Crypto; using SqlSugar; namespace DS.WMS.Core.Invoice.Method @@ -38,6 +38,9 @@ namespace DS.WMS.Core.Invoice.Method //Currency = SqlFunc.IsNullOrEmpty(a.Currency) ? SqlFunc.Subqueryable().Where( // d => d.ApplicationId == a.Id && d.Category == DetailCategory.InvoiceApplication).SelectStringJoin(d => d.Currency, ",") // : a.Currency, + AmountRMB = SqlFunc.Subqueryable().Where(y => a.Id == y.ApplicationId && y.Currency == FeeCurrency.RMB_CODE).Sum(y => y.ApplyAmount), + AmountUSD = SqlFunc.Subqueryable().Where(y => a.Id == y.ApplicationId && y.Currency == FeeCurrency.USD_CODE).Sum(y => y.ApplyAmount), + AmountOther = SqlFunc.Subqueryable().Where(y => a.Id == y.ApplicationId && y.Currency != FeeCurrency.RMB_CODE && y.Currency != FeeCurrency.USD_CODE).Sum(y => y.ApplyAmount), //原币金额 OriginalAmountList = SqlFunc.Subqueryable().Where(y => a.Id == y.ApplicationId) .GroupBy(y => y.OriginalCurrency).ToList(y => new CurrencyAmount { Currency = y.OriginalCurrency, Amount = SqlFunc.AggregateSum(y.OriginalAmount) }) diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceService`1.cs b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceService`1.cs index e166c48e..5253040d 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceService`1.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceService`1.cs @@ -225,120 +225,118 @@ namespace DS.WMS.Core.Invoice.Method if (invoice.PushModeValues.Length > 0) invoice.PushMode = string.Join(",", invoice.PushModeValues.Select(x => (int)x)); - if (request.Invoice.Mode == InvoiceMode.Applcation && request.Applications != null && request.Applications.Count > 0) //发票申请开出 + if (request.Invoice.Mode == InvoiceMode.Applcation && request.Applications != null && request.Applications.Count > 0) //按发票申请开出 { var ids = request.Applications.Select(x => x.ApplicationId); - if (request.Invoice.Mode == InvoiceMode.Applcation) //按发票申请 - { - var details = await TenantDb.Queryable() - .InnerJoin((x, y) => x.ApplicationId == y.Id) - .LeftJoin((x, y, z) => y.CustomerId == z.ClientId && z.Currency == invoice.Currency && z.IsInvoiceDefault == true) - .Where((x, y, z) => ids.Contains(x.ApplicationId) && x.Category == DetailCategory.InvoiceApplication) - .Select((x, y, z) => new - { - x.Id, - x.ApplicationId, - x.RecordId, - x.CustomerName, - x.FeeId, - x.FeeType, - x.FeeName, - x.ApplyAmount, - x.OriginalAmount, - x.Currency, - x.OriginalCurrency, - x.ProcessedAmount, - x.OriginalProcessedAmount, - - y.CustomerId, - y.TaxRate, - y.TaxID, - y.InvoiceHeader, - y.CustomerAddTel, - y.SaleDeptId, - y.PushMode, - y.CellPhoneNO, - y.Email, - - z.BankAccountNo, - z.BankName - }).ToListAsync(); + var details = await TenantDb.Queryable() + .InnerJoin((x, y) => x.ApplicationId == y.Id) + .LeftJoin((x, y, z) => y.CustomerId == z.ClientId && z.Currency == invoice.Currency && z.IsInvoiceDefault == true) + .Where((x, y, z) => ids.Contains(x.ApplicationId) && x.Category == DetailCategory.InvoiceApplication) + .Select((x, y, z) => new + { + x.Id, + x.ApplicationId, + x.RecordId, + x.CustomerName, + x.FeeId, + x.FeeType, + x.FeeName, + x.ApplyAmount, + x.OriginalAmount, + x.Currency, + x.OriginalCurrency, + x.ProcessedAmount, + x.OriginalProcessedAmount, + + y.CustomerId, + y.TaxRate, + y.TaxID, + y.InvoiceHeader, + y.CustomerAddTel, + y.SaleDeptId, + y.PushMode, + y.CellPhoneNO, + y.Email, + + z.BankAccountNo, + z.BankName + }).ToListAsync(); - //税率不一致 - if (details.GroupBy(x => x.TaxRate).Select(x => x.Key).Count() > 1) + //税率不一致 + if (details.GroupBy(x => x.TaxRate).Select(x => x.Key).Count() > 1) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InconsistentTaxRates)); + + invoice.Details ??= new List(details.Count); + foreach (var item in details) + { + if (invoice.Id == 0) + { + invoice.CustomerId = item.CustomerId; + invoice.CustomerName = item.CustomerName; + invoice.TaxRate = item.TaxRate; + invoice.InvoiceHeader = item.InvoiceHeader; + invoice.CustomerTaxID = item.TaxID; + invoice.CustomerAddressTel = item.CustomerAddTel; + invoice.CustomerAccount = item.BankAccountNo; + invoice.CustomerBankName = item.BankName; + invoice.SaleDeptId = item.SaleDeptId; + invoice.PushMode = item.PushMode; + invoice.CellPhoneNO = item.CellPhoneNO; + invoice.Email = item.Email; + } + else if (invoice.CustomerId != item.CustomerId) //校验开票单位是否一致 + { + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceCustomerOnlyOne)); + } + else if (invoice.TaxRate != item.TaxRate) //校验税率是否一致 + { return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InconsistentTaxRates)); + } - invoice.Details ??= new List(details.Count); - foreach (var item in details) + //需转换为费用明细 + var detail = new ApplicationDetail { - if (invoice.Id == 0) - { - invoice.CustomerId = item.CustomerId; - invoice.CustomerName = item.CustomerName; - invoice.TaxRate = item.TaxRate; - invoice.InvoiceHeader = item.InvoiceHeader; - invoice.CustomerTaxID = item.TaxID; - invoice.CustomerAddressTel = item.CustomerAddTel; - invoice.CustomerAccount = item.BankAccountNo; - invoice.CustomerBankName = item.BankName; - invoice.SaleDeptId = item.SaleDeptId; - invoice.PushMode = item.PushMode; - invoice.CellPhoneNO = item.CellPhoneNO; - invoice.Email = item.Email; - } - else if (invoice.CustomerId != item.CustomerId) //校验开票单位是否一致 + ApplicationId = invoice.Id, + RefId = item.ApplicationId, + DetailId = item.Id, + RecordId = item.RecordId, + Category = DetailCategory.InvoiceIssuance, + CustomerName = item.CustomerName, + FeeId = item.FeeId, + FeeName = item.FeeName, + FeeType = item.FeeType, + Currency = invoice.Currency, + OriginalCurrency = item.Currency, + ApplyAmount = item.ApplyAmount - item.ProcessedAmount, + OriginalAmount = item.OriginalAmount - item.OriginalProcessedAmount + }; + + var app = request.Applications.Find(x => x.ApplicationId == item.ApplicationId); + if (app != null) + { + if (app.Currency == invoice.Currency) { - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceCustomerOnlyOne)); + detail.ExchangeRate = 1m; } - else if (invoice.TaxRate != item.TaxRate) //校验税率是否一致 + else if (string.IsNullOrEmpty(app.Currency)) //原币申请 { - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InconsistentTaxRates)); + detail.ExchangeRate = app.ExchangeRates.FirstOrDefault(x => x.Currency == item.Currency)?.ExchangeRate; } - - //需转换为费用明细 - var detail = new ApplicationDetail - { - ApplicationId = invoice.Id, - RefId = item.ApplicationId, - DetailId = item.Id, - RecordId = item.RecordId, - Category = DetailCategory.InvoiceIssuance, - CustomerName = item.CustomerName, - FeeId = item.FeeId, - FeeName = item.FeeName, - FeeType = item.FeeType, - Currency = invoice.Currency, - OriginalCurrency = item.Currency, - ApplyAmount = item.ApplyAmount - item.ProcessedAmount, - OriginalAmount = item.OriginalAmount - item.OriginalProcessedAmount - }; - - var app = request.Applications.Find(x => x.ApplicationId == item.ApplicationId); - if (app != null) + else { - if (app.Currency == invoice.Currency) - { - detail.ExchangeRate = 1m; - } - else if (string.IsNullOrEmpty(app.Currency)) //原币申请 - { - detail.ExchangeRate = app.ExchangeRates.FirstOrDefault(x => x.Currency == item.Currency)?.ExchangeRate; - } - else - { - detail.ExchangeRate = app.ExchangeRates.FirstOrDefault(x => x.Currency == invoice.Currency)?.ExchangeRate; - } + detail.ExchangeRate = app.ExchangeRates.FirstOrDefault(x => x.Currency == invoice.Currency)?.ExchangeRate; } + } - if (!detail.ExchangeRate.HasValue) - detail.ExchangeRate = 1m; + if (!detail.ExchangeRate.HasValue) + detail.ExchangeRate = 1m; - if (detail.ExchangeRate.HasValue) - detail.ApplyAmount = detail.ApplyAmount * detail.ExchangeRate.Value; + if (detail.ExchangeRate.HasValue) + detail.ApplyAmount = detail.ApplyAmount * detail.ExchangeRate.Value; - invoice.Details.Add(detail); - } + invoice.Details.Add(detail); } + } else if (request.Invoice.Mode == InvoiceMode.Free) //自由开票 { diff --git a/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user b/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user index df278db9..75e2b24a 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user +++ b/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>D:\Publish\DS8\FeeApi - True|2024-09-27T10:10:25.5697467Z||;True|2024-09-27T17:39:06.3169139+08:00||;True|2024-09-27T17:30:14.1043193+08:00||;True|2024-09-27T16:02:09.0703159+08:00||;True|2024-09-27T15:53:05.1789245+08:00||;True|2024-09-27T15:32:52.1934490+08:00||;True|2024-09-27T13:51:24.9197626+08:00||;True|2024-09-27T13:48:17.2817346+08:00||;True|2024-09-27T11:51:46.8193040+08:00||;True|2024-09-27T10:58:33.1059648+08:00||;True|2024-09-27T10:37:35.0336563+08:00||;False|2024-09-27T10:31:52.6302264+08:00||;True|2024-09-26T19:50:15.5513195+08:00||;True|2024-09-26T19:47:14.0781788+08:00||;True|2024-09-26T19:01:26.5428388+08:00||;True|2024-09-26T18:35:28.7455319+08:00||;True|2024-09-26T18:24:30.8084807+08:00||;True|2024-09-26T18:20:47.3005460+08:00||;True|2024-09-26T18:04:39.8012913+08:00||;True|2024-09-26T17:48:13.8526872+08:00||;True|2024-09-26T16:08:20.1746970+08:00||;True|2024-09-26T16:01:01.1501975+08:00||;False|2024-09-26T16:00:34.1516745+08:00||;True|2024-09-26T14:33:03.4007570+08:00||;True|2024-09-25T19:14:27.8906774+08:00||;True|2024-09-25T18:57:40.1435131+08:00||;True|2024-09-25T17:38:44.0915841+08:00||;True|2024-09-25T15:33:58.4630618+08:00||;True|2024-09-25T15:10:31.3022063+08:00||;False|2024-09-25T14:14:40.9640545+08:00||;True|2024-09-25T10:09:32.2558600+08:00||;True|2024-09-25T09:59:17.1525160+08:00||;False|2024-09-25T09:57:58.7265103+08:00||;False|2024-09-25T09:53:36.7732713+08:00||;False|2024-09-24T18:40:10.0166224+08:00||;True|2024-09-24T08:59:56.1995425+08:00||;True|2024-09-23T18:07:54.7222163+08:00||;True|2024-09-23T17:23:57.7568406+08:00||;True|2024-09-23T16:28:49.3169826+08:00||;True|2024-09-23T15:57:31.8052490+08:00||;True|2024-09-23T11:47:21.1445419+08:00||;True|2024-09-23T09:24:36.0732229+08:00||;True|2024-09-21T11:59:19.0549926+08:00||;True|2024-09-21T11:24:32.4451752+08:00||;True|2024-09-21T10:39:11.5297411+08:00||;True|2024-09-20T18:24:31.7827684+08:00||;True|2024-09-19T17:55:53.1666689+08:00||;True|2024-09-19T17:42:47.9061485+08:00||;True|2024-09-19T16:08:21.7225571+08:00||;False|2024-09-19T14:15:42.9318446+08:00||;True|2024-09-19T11:20:03.5567568+08:00||;True|2024-09-18T11:35:18.1509724+08:00||;True|2024-09-18T09:08:59.1152574+08:00||;True|2024-09-14T15:48:22.9374486+08:00||;True|2024-09-14T15:42:19.0503983+08:00||;True|2024-09-14T11:51:53.3339222+08:00||;True|2024-09-14T11:41:38.3542237+08:00||;True|2024-09-14T11:19:13.1037012+08:00||;True|2024-09-13T14:31:12.4598160+08:00||;True|2024-09-13T10:44:56.1241214+08:00||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||; + True|2024-09-27T10:45:48.2812860Z||;True|2024-09-27T18:10:25.5697467+08:00||;True|2024-09-27T17:39:06.3169139+08:00||;True|2024-09-27T17:30:14.1043193+08:00||;True|2024-09-27T16:02:09.0703159+08:00||;True|2024-09-27T15:53:05.1789245+08:00||;True|2024-09-27T15:32:52.1934490+08:00||;True|2024-09-27T13:51:24.9197626+08:00||;True|2024-09-27T13:48:17.2817346+08:00||;True|2024-09-27T11:51:46.8193040+08:00||;True|2024-09-27T10:58:33.1059648+08:00||;True|2024-09-27T10:37:35.0336563+08:00||;False|2024-09-27T10:31:52.6302264+08:00||;True|2024-09-26T19:50:15.5513195+08:00||;True|2024-09-26T19:47:14.0781788+08:00||;True|2024-09-26T19:01:26.5428388+08:00||;True|2024-09-26T18:35:28.7455319+08:00||;True|2024-09-26T18:24:30.8084807+08:00||;True|2024-09-26T18:20:47.3005460+08:00||;True|2024-09-26T18:04:39.8012913+08:00||;True|2024-09-26T17:48:13.8526872+08:00||;True|2024-09-26T16:08:20.1746970+08:00||;True|2024-09-26T16:01:01.1501975+08:00||;False|2024-09-26T16:00:34.1516745+08:00||;True|2024-09-26T14:33:03.4007570+08:00||;True|2024-09-25T19:14:27.8906774+08:00||;True|2024-09-25T18:57:40.1435131+08:00||;True|2024-09-25T17:38:44.0915841+08:00||;True|2024-09-25T15:33:58.4630618+08:00||;True|2024-09-25T15:10:31.3022063+08:00||;False|2024-09-25T14:14:40.9640545+08:00||;True|2024-09-25T10:09:32.2558600+08:00||;True|2024-09-25T09:59:17.1525160+08:00||;False|2024-09-25T09:57:58.7265103+08:00||;False|2024-09-25T09:53:36.7732713+08:00||;False|2024-09-24T18:40:10.0166224+08:00||;True|2024-09-24T08:59:56.1995425+08:00||;True|2024-09-23T18:07:54.7222163+08:00||;True|2024-09-23T17:23:57.7568406+08:00||;True|2024-09-23T16:28:49.3169826+08:00||;True|2024-09-23T15:57:31.8052490+08:00||;True|2024-09-23T11:47:21.1445419+08:00||;True|2024-09-23T09:24:36.0732229+08:00||;True|2024-09-21T11:59:19.0549926+08:00||;True|2024-09-21T11:24:32.4451752+08:00||;True|2024-09-21T10:39:11.5297411+08:00||;True|2024-09-20T18:24:31.7827684+08:00||;True|2024-09-19T17:55:53.1666689+08:00||;True|2024-09-19T17:42:47.9061485+08:00||;True|2024-09-19T16:08:21.7225571+08:00||;False|2024-09-19T14:15:42.9318446+08:00||;True|2024-09-19T11:20:03.5567568+08:00||;True|2024-09-18T11:35:18.1509724+08:00||;True|2024-09-18T09:08:59.1152574+08:00||;True|2024-09-14T15:48:22.9374486+08:00||;True|2024-09-14T15:42:19.0503983+08:00||;True|2024-09-14T11:51:53.3339222+08:00||;True|2024-09-14T11:41:38.3542237+08:00||;True|2024-09-14T11:19:13.1037012+08:00||;True|2024-09-13T14:31:12.4598160+08:00||;True|2024-09-13T10:44:56.1241214+08:00||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||; \ No newline at end of file