发票明细金额bug修复

dev
嵇文龙 4 weeks ago
parent 13b017a9e8
commit 41e95fa6c5

@ -202,9 +202,9 @@ namespace DS.WMS.Core.Application.Method
Voyage = s.Voyage,//航次
BookingNo = s.BookingNo,
StlName = s.StlName,
OrderAmount = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId).Sum(f => f.OrderAmount),
InvoiceAmount = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId).Sum(f => f.InvoiceAmount),
SettlementAmount = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId).Sum(f => f.SettlementAmount),
//OrderAmount = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId).Sum(f => f.OrderAmount),
//InvoiceAmount = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId).Sum(f => f.InvoiceAmount),
//SettlementAmount = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId).Sum(f => f.SettlementAmount),
//未申请开票金额=金额-开票金额-申请开票金额+申请开票金额已开票
UnBilledRMB = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == s.BusinessId && f.FeeStatus == FeeStatus.AuditPassed
@ -632,13 +632,15 @@ namespace DS.WMS.Core.Application.Method
else
{
invDetail.Amount += detail.ApplyAmount;
invDetail.UnitPrice = invDetail.TaxUnitPrice = invDetail.Amount;
}
}
foreach (var item in application.InvoiceDetails)
{
item.TaxAmount = item.Amount * (application.TaxRate / 100);
item.UnitPrice += item.Amount - item.TaxAmount;
item.UnitPrice = item.TaxUnitPrice - item.TaxAmount;
item.Amount = item.TaxUnitPrice * item.Quantity;
}
}
}

@ -3,7 +3,6 @@ using DS.Module.Core.Enums;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Application.Entity;
using Masuit.Tools.Systems;
using SqlSugar;
namespace DS.WMS.Core.Invoice.Dtos
{
@ -311,6 +310,11 @@ namespace DS.WMS.Core.Invoice.Dtos
public string? Note { get; set; }
/// <summary>
/// 开票备注
/// </summary>
public string? InvoiceRemark { get; set; }
[IgnoreDataMember]
public List<string>? InvoiceApplicationList { get; set; }

@ -355,6 +355,12 @@ namespace DS.WMS.Core.Invoice.Entity
[SugarColumn(ColumnDescription = "作废时间")]
public DateTime? CancelTime { get; set; }
/// <summary>
/// 发票备注
/// </summary>
[SugarColumn(ColumnDescription = "发票备注", IsNullable = true)]
public string? InvoiceRemark { get; set; }
/// <summary>
/// 费用明细
/// </summary>

@ -5,17 +5,12 @@ using DS.WMS.Core.Application.Method;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Invoice.Interface;
using DS.WMS.Core.QuarztJobs.Dtos;
using DS.WMS.Core.QuarztJobs.Other;
using DS.WMS.Core.Sys.Entity;
using Masuit.Tools;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Org.BouncyCastle.Ocsp;
using SqlSugar;
using static AnyDiff.DifferenceLines;
namespace DS.WMS.Core.Invoice.Method
{
@ -97,10 +92,11 @@ namespace DS.WMS.Core.Invoice.Method
specType = y.Specification,
unit = y.Unit,
num = y.Quantity.ToString(),
taxExcludedAmount = y.UnitPrice,
price = y.TaxUnitPrice.ToString(),
taxExcludedAmount = y.Amount - y.TaxAmount,
taxRate = y.TaxRate.ToString(),
tax = y.TaxAmount,
taxIncludedAmount = y.TaxUnitPrice,
taxIncludedAmount = y.Amount,
goodsCode = z.Code, //商品和服务税收分类合并编码
invoiceLineProperty = "00",
favouredPolicyFlag = z.PreferentialPolicyDescription

@ -249,13 +249,14 @@ namespace DS.WMS.Core.Invoice.Method
y.CustomerId,
y.TaxRate,
y.TaxID,
y.InvoiceHeader,
y.TaxID, //税号
y.InvoiceHeader, //抬头
y.CustomerAddTel,
y.SaleDeptId,
y.PushMode,
y.CellPhoneNO,
y.Email,
y.InvoiceRemark,
z.BankAccountNo,
z.BankName
@ -265,6 +266,7 @@ namespace DS.WMS.Core.Invoice.Method
if (details.GroupBy(x => x.TaxRate).Select(x => x.Key).Count() > 1)
return DataResult<TEntity>.FailedWithDesc(nameof(MultiLanguageConst.InconsistentTaxRates));
invoice.InvoiceRemark = string.Join(" | ", details.Where(x => !string.IsNullOrEmpty(x.InvoiceRemark)).Select(x => x.InvoiceRemark));
invoice.Details ??= new List<ApplicationDetail>(details.Count);
foreach (var item in details)
{
@ -425,6 +427,8 @@ namespace DS.WMS.Core.Invoice.Method
}
if (invoice.Id == 0)
{
if (request.Invoice.Mode == InvoiceMode.Free)
{
//补充购方信息
invoice.CustomerTaxID = await TenantDb.Queryable<InfoClient>().Where(x => x.Id == invoice.CustomerId).Select(x => x.TaxNo).FirstAsync();
@ -446,6 +450,7 @@ namespace DS.WMS.Core.Invoice.Method
invoice.CustomerAccount = clientBank.Account;
invoice.CustomerBankName = clientBank.BankName;
}
}
//补充销方信息
//var org = await Db.Queryable<SysOrg>().Where(x => x.Id == User.OrgId).Select(x => new { x.OrgFullName, x.LicenseCode }).FirstAsync();
@ -527,7 +532,7 @@ namespace DS.WMS.Core.Invoice.Method
await TenantDb.Insertable(invoice.Details).ExecuteCommandAsync();
if (invoice.InvoiceDetails?.Count > 0)
await TenantDb.Storageable(invoice.Details).DefaultAddElseUpdate().ExecuteCommandAsync();
await TenantDb.Storageable(invoice.InvoiceDetails).DefaultAddElseUpdate().ExecuteCommandAsync();
}
if (invoice.Details?.Count > 0)
@ -655,13 +660,15 @@ namespace DS.WMS.Core.Invoice.Method
else
{
invDetail.Amount += detail.ApplyAmount;
invDetail.UnitPrice = invDetail.TaxUnitPrice = invDetail.Amount;
}
}
foreach (var item in invoice.InvoiceDetails)
{
item.TaxAmount = item.Amount * (invoice.TaxRate / 100);
item.UnitPrice += item.Amount - item.TaxAmount;
item.UnitPrice = item.TaxUnitPrice - item.TaxAmount;
item.Amount = item.TaxUnitPrice * item.Quantity;
}
}

@ -13,6 +13,7 @@ using DS.WMS.Core.Settlement.Entity;
using DS.WMS.Core.Settlement.Interface;
using DS.WMS.Core.Sys.Entity;
using SqlSugar;
using static iText.StyledXmlParser.Jsoup.Select.Evaluator;
namespace DS.WMS.Core.Settlement.Method
{
@ -107,6 +108,10 @@ namespace DS.WMS.Core.Settlement.Method
model.SettlementDetails = await GetSettlementDetails(id);
if (model.SettlementDetails.Count > 0)
{
var ids = model.SettlementDetails.Select(x => x.Id);
var appList = await TenantDb.Queryable<PaymentApplication>().Where(x => ids.Contains(x.Id))
.Select(x => new PaymentApplication { Id = x.Id, ApplicationNO = x.ApplicationNO }).ToListAsync();
//关联用户名称
var userIds = model.SettlementDetails.Select(x => x.CreateBy).Distinct();
var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
@ -114,6 +119,7 @@ namespace DS.WMS.Core.Settlement.Method
foreach (var item in model.SettlementDetails)
{
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
item.ApplicationNOList = appList.Where(x => x.Id == item.Id).Select(x => x.ApplicationNO).ToList();
}
}
}
@ -137,83 +143,10 @@ namespace DS.WMS.Core.Settlement.Method
.Select((i, d1, d2) => new SettlementDetailGroup
{
SettlementAmount = SqlFunc.Subqueryable<ApplicationDetail>().Where(d3 => d3.ApplicationId == i.Id).Sum(d3 => d3.ApplyAmount),
ApplicationNOList = SqlFunc.Subqueryable<PaymentApplication>().Where(a => a.Id == d1.RefId).ToList(a => a.ApplicationNO)
//ApplicationNOList = SqlFunc.Subqueryable<PaymentApplication>().Where(a => a.Id == d1.RefId.Value).ToList(a => a.ApplicationNO)
}, true).ToListAsync();
return list;
//var list = await TenantDb.Queryable<ApplicationDetail>()
// .InnerJoin<ApplicationDetail>((d, pd) => d.DetailId == pd.Id)
// .InnerJoin<PaymentApplication>((d, pd, pa) => pd.ApplicationId == pa.Id)
// .Where(d => d.ApplicationId == id)
// .Select((d, pd, pa) => new
// {
// d.Id,
// d.ApplicationId,
// d.ApplyAmount,
// d.Currency,
// d.OriginalCurrency,
// d.OriginalAmount,
// pa.ApplicationNO,
// pa.Status,
// pa.CreateTime,
// pa.CreateBy,
// pa.PaymentDate,
// pa.Note
// }).ToListAsync();
//var details = new List<SettlementDetailDto>();
//if (list.Count == 0)
// return details;
//var gp = list.GroupBy(d => d.ApplicationId);
//var uids = list.Select(x => x.CreateBy).Distinct();
//var users = await Db.Queryable<SysUser>().Where(x => uids.Contains(x.Id)).Select(x => new
//{
// x.Id,
// x.UserName
//}).ToListAsync();
//foreach (var g in gp)
//{
// var firstItem = g.FirstOrDefault();
// var dto = new SettlementDetailDto
// {
// ApplicationId = g.Key,
// //Ids = g.Select(x => x.Id),
// RMBApplyAmount = g.Where(x => x.OriginalCurrency == FeeCurrency.RMB_CODE).Sum(x => x.ApplyAmount),
// USDApplyAmount = g.Where(x => x.OriginalCurrency == FeeCurrency.USD_CODE).Sum(x => x.ApplyAmount),
// ApplicationNO = firstItem.ApplicationNO,
// Status = (int)firstItem.Status,
// StatusText = firstItem.Status.GetDescription(),
// CreateTime = firstItem?.CreateTime,
// CreateBy = firstItem?.CreateBy,
// CreateByName = users.Find(x => x.Id == firstItem?.CreateBy)?.UserName,
// PaymentDate = firstItem?.PaymentDate,
// Note = firstItem?.Note
// };
// //包含多个币别
// if (g.GroupBy(x => x.OriginalCurrency).Select(x => x.Key).Count() > 1)
// {
// //原始币别=不等于结算单币别的首个币别参考DS7
// dto.OriginalCurrency = g.Select(x => x.OriginalCurrency).FirstOrDefault();
// //原始金额=当前结算单的币别合计
// dto.OriginalAmount = g.Sum(x => x.ApplyAmount);
// }
// else
// {
// dto.OriginalCurrency = firstItem?.OriginalCurrency;
// dto.OriginalAmount = g.Where(x => x.OriginalCurrency == dto.OriginalCurrency).Sum(x => x.ApplyAmount);
// }
// //结算金额=原申请的原始币别合计
// dto.SettlementAmount = g.Where(x => x.OriginalCurrency == dto.OriginalCurrency).Sum(x => x.ApplyAmount);
// details.Add(dto);
//}
//return details;
}
/// <summary>

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Publish\DS8\FeeApi</_PublishTargetUrl>
<History>True|2024-11-02T08:26:26.1698304Z||;True|2024-11-02T16:15:20.2872358+08:00||;True|2024-11-02T15:19:14.9663838+08:00||;True|2024-11-02T14:39:47.8808708+08:00||;False|2024-11-02T14:22:04.2841792+08:00||;True|2024-11-02T11:50:48.2452805+08:00||;True|2024-10-29T18:52:12.7978878+08:00||;True|2024-10-29T10:27:49.1623527+08:00||;True|2024-10-25T15:09:27.7029075+08:00||;True|2024-10-25T10:29:26.9218878+08:00||;True|2024-10-22T17:58:39.9582805+08:00||;True|2024-10-21T17:57:21.7047579+08:00||;True|2024-10-21T14:30:54.4520206+08:00||;True|2024-10-21T10:19:05.7405749+08:00||;True|2024-10-18T16:11:05.4049685+08:00||;True|2024-10-18T14:59:49.1162741+08:00||;True|2024-10-16T16:29:15.3185348+08:00||;True|2024-10-16T14:12:58.1754214+08:00||;True|2024-10-16T14:08:06.5805581+08:00||;True|2024-10-16T11:55:29.8273176+08:00||;True|2024-10-15T17:39:40.4090324+08:00||;True|2024-10-15T17:06:43.0181578+08:00||;True|2024-10-15T15:07:38.9601925+08:00||;True|2024-10-12T13:33:32.4412583+08:00||;True|2024-10-11T17:00:54.0916209+08:00||;True|2024-10-11T10:54:50.3307087+08:00||;True|2024-10-11T10:45:07.8181500+08:00||;True|2024-10-11T10:40:44.2066046+08:00||;True|2024-10-11T10:21:25.7226983+08:00||;True|2024-10-11T10:09:05.5257478+08:00||;True|2024-10-10T14:58:29.1228618+08:00||;True|2024-10-10T14:05:59.4501659+08:00||;True|2024-10-10T11:08:58.9765455+08:00||;True|2024-10-08T17:59:07.5583287+08:00||;True|2024-09-27T19:01:59.6945760+08:00||;True|2024-09-27T18:45:48.2812860+08:00||;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||;</History>
<History>True|2024-11-02T10:33:41.0724285Z||;True|2024-11-02T18:21:55.8561639+08:00||;True|2024-11-02T17:36:24.3401782+08:00||;True|2024-11-02T16:38:03.0054105+08:00||;True|2024-11-02T16:26:26.1698304+08:00||;True|2024-11-02T16:15:20.2872358+08:00||;True|2024-11-02T15:19:14.9663838+08:00||;True|2024-11-02T14:39:47.8808708+08:00||;False|2024-11-02T14:22:04.2841792+08:00||;True|2024-11-02T11:50:48.2452805+08:00||;True|2024-10-29T18:52:12.7978878+08:00||;True|2024-10-29T10:27:49.1623527+08:00||;True|2024-10-25T15:09:27.7029075+08:00||;True|2024-10-25T10:29:26.9218878+08:00||;True|2024-10-22T17:58:39.9582805+08:00||;True|2024-10-21T17:57:21.7047579+08:00||;True|2024-10-21T14:30:54.4520206+08:00||;True|2024-10-21T10:19:05.7405749+08:00||;True|2024-10-18T16:11:05.4049685+08:00||;True|2024-10-18T14:59:49.1162741+08:00||;True|2024-10-16T16:29:15.3185348+08:00||;True|2024-10-16T14:12:58.1754214+08:00||;True|2024-10-16T14:08:06.5805581+08:00||;True|2024-10-16T11:55:29.8273176+08:00||;True|2024-10-15T17:39:40.4090324+08:00||;True|2024-10-15T17:06:43.0181578+08:00||;True|2024-10-15T15:07:38.9601925+08:00||;True|2024-10-12T13:33:32.4412583+08:00||;True|2024-10-11T17:00:54.0916209+08:00||;True|2024-10-11T10:54:50.3307087+08:00||;True|2024-10-11T10:45:07.8181500+08:00||;True|2024-10-11T10:40:44.2066046+08:00||;True|2024-10-11T10:21:25.7226983+08:00||;True|2024-10-11T10:09:05.5257478+08:00||;True|2024-10-10T14:58:29.1228618+08:00||;True|2024-10-10T14:05:59.4501659+08:00||;True|2024-10-10T11:08:58.9765455+08:00||;True|2024-10-08T17:59:07.5583287+08:00||;True|2024-09-27T19:01:59.6945760+08:00||;True|2024-09-27T18:45:48.2812860+08:00||;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||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save