diff --git a/ds-wms-service/DS.WMS.Core/Application/Entity/InvoiceDetail.cs b/ds-wms-service/DS.WMS.Core/Application/Entity/InvoiceDetail.cs index 8e30a353..f465c4ad 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Entity/InvoiceDetail.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Entity/InvoiceDetail.cs @@ -21,6 +21,18 @@ namespace DS.WMS.Core.Application.Entity [SugarColumn(ColumnDescription = "申请单ID", IsNullable = false)] public long ApplicationId { get; set; } + /// + /// 发票商品编码ID + /// + [SugarColumn(ColumnDescription = "发票商品编码ID", IsNullable = true)] + public long? CodeId { get; set; } + + ///// + ///// 发票商品编码 + ///// + //[Navigate(NavigateType.OneToOne, nameof(CodeId))] + //public CodeInvoice? CodeInvoice { get; set; } + /// /// 明细项名称 /// diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs index 07adac31..6d1cce05 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs @@ -5,6 +5,7 @@ using DS.Module.Core.Extensions; using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Application.Entity; using DS.WMS.Core.Application.Interface; +using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Info.Entity; @@ -511,7 +512,7 @@ namespace DS.WMS.Core.Application.Method await TenantDb.Deleteable().Where(x => x.ApplicationId == application.Id).ExecuteCommandAsync(); //然后根据申请单明细重新生成 - await CreateInvoiceDetailsAsync([application]); + await FillInvoiceDetailsAsync([application]); if (application.InvoiceDetails?.Count > 0) { @@ -528,8 +529,8 @@ namespace DS.WMS.Core.Application.Method await base.OnSaveAsync(application, fees); } - //生成发票明细 - async Task CreateInvoiceDetailsAsync(IEnumerable applications) + //根据费用明细填充发票明细 + async Task FillInvoiceDetailsAsync(IEnumerable applications) { foreach (var application in applications) { @@ -539,7 +540,8 @@ namespace DS.WMS.Core.Application.Method if (application.Details.Count > 0 && (application.InvoiceDetails == null || application.InvoiceDetails.Count == 0)) { var ids = application.Details.Select(x => x.RecordId).ToList(); - var feesCodes = await TenantDb.Queryable().InnerJoin((f, c) => f.FeeId == c.Id && ids.Contains(f.Id)) + var feesCodes = await TenantDb.Queryable() + .InnerJoin((f, c) => f.FeeId == c.Id && ids.Contains(f.Id)) .Select((f, c) => new { FeeId = c.Id, @@ -551,10 +553,24 @@ namespace DS.WMS.Core.Application.Method Name = x.Key, FeeIds = x.Select(y => y.FeeId) }).ToList(); + + var goodsNames = list.Select(x => x.Name); + var invCodes = await TenantDb.Queryable().Where(x => goodsNames.Contains(x.Name)) + .Select(x => new + { + x.Id, + x.Name, + x.DefaultCurrency, + x.TaxRate, + x.Specification, + x.Unit + }).ToListAsync(); + application.InvoiceDetails = new List(list.Count); foreach (var item in list) { - var invDetail = new InvoiceDetail + var invCode = invCodes.Find(x => x.Name == item.Name); + var detail = new InvoiceDetail { ApplicationId = application.Id, Name = item.Name, @@ -563,10 +579,18 @@ namespace DS.WMS.Core.Application.Method TaxUnitPrice = application.Details.FindAll(x => item.FeeIds.Contains(x.FeeId)).Sum(x => x.ApplyAmount), Category = DetailCategory.InvoiceApplication }; - invDetail.TaxAmount = invDetail.TaxUnitPrice * application.TaxRate; - invDetail.UnitPrice = invDetail.TaxUnitPrice - invDetail.TaxAmount; - invDetail.Amount = invDetail.TaxUnitPrice * invDetail.Quantity; - application.InvoiceDetails.Add(invDetail); + + if (invCode != null) + { + detail.TaxRate = invCode.TaxRate; + detail.Specification = invCode.Specification; + detail.Unit = invCode.Unit; + } + + detail.TaxAmount = detail.TaxUnitPrice * application.TaxRate; + detail.UnitPrice = detail.TaxUnitPrice - detail.TaxAmount; + detail.Amount = detail.TaxUnitPrice * detail.Quantity; + application.InvoiceDetails.Add(detail); } } } @@ -615,7 +639,7 @@ namespace DS.WMS.Core.Application.Method await TenantDb.Deleteable().Where(x => appIds.Contains(x.ApplicationId)).ExecuteCommandAsync(); - await CreateInvoiceDetailsAsync(applications); + await FillInvoiceDetailsAsync(applications); var invDetails = applications.SelectMany(x => x.InvoiceDetails).ToList(); if (invDetails.Count > 0) await TenantDb.Insertable(invDetails).ExecuteCommandAsync(); diff --git a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeInvoice.cs b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeInvoice.cs index f75e2467..9a8c65c9 100644 --- a/ds-wms-service/DS.WMS.Core/Code/Entity/CodeInvoice.cs +++ b/ds-wms-service/DS.WMS.Core/Code/Entity/CodeInvoice.cs @@ -40,12 +40,36 @@ namespace DS.WMS.Core.Code.Entity [SugarColumn(ColumnDescription = "零税率标识")] public ZeroTaxRateIdentification Identification { get; set; } + /// + /// 税收分类编码 + /// + [SugarColumn(ColumnDescription = "税收分类编码", Length = 100, IsNullable = true)] + public string? TaxClassificationCode { get; set; } + + /// + /// 税收分类名称 + /// + [SugarColumn(ColumnDescription = "税收分类名称", Length = 100, IsNullable = true)] + public string? TaxClassificationName { get; set; } + /// /// 是否含税 /// [SugarColumn(ColumnDescription = "是否含税")] public bool IsIncludingTax { get; set; } + /// + /// 是否享受优惠政策 + /// + [SugarColumn(ColumnDescription = "是否享受优惠政策")] + public bool HasPreferentialPolicy { get; set; } + + /// + /// 优惠政策说明 + /// + [SugarColumn(ColumnDescription = "优惠政策说明", Length = 200, IsNullable = true)] + public string? PreferentialPolicyDescription { get; set; } + /// /// 是否默认商品名 /// diff --git a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateDetailService.cs b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateDetailService.cs index a3a8a954..da3c8fef 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateDetailService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateDetailService.cs @@ -22,13 +22,6 @@ public interface IFeeCustTemplateDetailService /// /// Task EditAsync(FeeCustTemplateDetailReq model); - - /// - /// 获取详情 - /// - /// - /// - DataResult GetFeeCustTemplateDetailInfo(string id); /// /// 根据ID批量删除 diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailService.cs index b0444d45..3a2bc6cb 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateDetailService.cs @@ -61,20 +61,6 @@ namespace DS.WMS.Core.Fee.Method } } - /// - /// 详情 - /// - /// - /// - public DataResult GetFeeCustTemplateDetailInfo(string id) - { - var data = TenantDb.Queryable() - .Where(x => x.Id == long.Parse(id)) - .Select() - .First(); - return DataResult.Success(data, MultiLanguageConst.DataQuerySuccess); - } - /// /// 根据ID批量删除 /// diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs index 175c13bd..36c030c0 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs @@ -1,6 +1,7 @@ using DS.Module.Core; using DS.WMS.Core.Application.Method; using DS.WMS.Core.Invoice.Dtos; +using DS.WMS.Core.Sys.Entity; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using SqlSugar; @@ -33,6 +34,12 @@ namespace DS.WMS.Core.Invoice.Method { ArgumentNullException.ThrowIfNull(ids, nameof(ids)); + long userId = long.Parse(User.UserId); + var userInfo = await Db.Queryable().Where(x => x.Id == userId).Select(x => new + { + x.Id, + }).FirstAsync(); + //请求参数设置 InvoiceIssuanceRequest request = new() {