|
|
@ -10,7 +10,6 @@ using DS.WMS.Core.Code.Entity;
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
using DS.WMS.Core.Invoice.Entity;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar;
|
|
|
@ -575,19 +574,18 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
await base.OnSaveAsync(application, fees);
|
|
|
|
await base.OnSaveAsync(application, fees);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//刷新发票明细
|
|
|
|
//刷新发票明细
|
|
|
|
async Task RefreshInvoiceDetailsAsync(InvoiceApplication application)
|
|
|
|
async Task RefreshInvoiceDetailsAsync(InvoiceApplication application)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (application.Details.Count > 0)
|
|
|
|
if (application.Details.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var recordIds = application.Details.Select(x => x.RecordId).ToList();
|
|
|
|
application.InvoiceDetails ??= [];
|
|
|
|
var codeList = await TenantDb.Queryable<FeeRecord>()
|
|
|
|
var currencies = application.Details.Select(x => x.Currency).Distinct();
|
|
|
|
.InnerJoin<FeeCode>((f, c) => f.FeeId == c.Id && recordIds.Contains(f.Id))
|
|
|
|
var codeList = await TenantDb.Queryable<CodeInvoice>()
|
|
|
|
.LeftJoin<CodeInvoice>((f, c, ci) => c.GoodName == ci.Name)
|
|
|
|
.Where(ci => currencies.Contains(ci.DefaultCurrency))
|
|
|
|
.Select((f, c, ci) => new
|
|
|
|
.OrderBy(ci => ci.IsDefault)
|
|
|
|
|
|
|
|
.Select(ci => new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RecordId = f.Id,
|
|
|
|
|
|
|
|
ci.Id,
|
|
|
|
ci.Id,
|
|
|
|
ci.Name,
|
|
|
|
ci.Name,
|
|
|
|
ci.DefaultCurrency,
|
|
|
|
ci.DefaultCurrency,
|
|
|
@ -596,13 +594,15 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
ci.Unit
|
|
|
|
ci.Unit
|
|
|
|
}).ToListAsync();
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
application.InvoiceDetails ??= [];
|
|
|
|
|
|
|
|
foreach (var detail in application.Details)
|
|
|
|
foreach (var detail in application.Details)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var code = codeList.Find(x => x.RecordId == detail.RecordId);
|
|
|
|
var code = codeList.Find(x => x.DefaultCurrency == detail.Currency);
|
|
|
|
if (code == null || string.IsNullOrEmpty(code.Name))
|
|
|
|
if (code == null)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (application.BuildOption == BuildOption.Update && codeList.IndexOf(code) == 0)//取第一条发票代码税率
|
|
|
|
|
|
|
|
application.TaxRate = code.TaxRate;
|
|
|
|
|
|
|
|
|
|
|
|
var invDetail = application.InvoiceDetails.Find(x => x.CodeId == code.Id);
|
|
|
|
var invDetail = application.InvoiceDetails.Find(x => x.CodeId == code.Id);
|
|
|
|
if (invDetail == null)
|
|
|
|
if (invDetail == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -612,9 +612,8 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
CodeId = code.Id,
|
|
|
|
CodeId = code.Id,
|
|
|
|
Name = code.Name,
|
|
|
|
Name = code.Name,
|
|
|
|
Quantity = 1,
|
|
|
|
Quantity = 1,
|
|
|
|
TaxUnitPrice = application.Details.FindAll(x => x.RecordId == code.RecordId).Sum(x => x.ApplyAmount),
|
|
|
|
TaxUnitPrice = application.Details.FindAll(x => x.Currency == code.DefaultCurrency).Sum(x => x.ApplyAmount),
|
|
|
|
TaxRate = application.TaxRate,
|
|
|
|
TaxRate = code.TaxRate,
|
|
|
|
//TaxRate = code.TaxRate,
|
|
|
|
|
|
|
|
Specification = code.Specification,
|
|
|
|
Specification = code.Specification,
|
|
|
|
Unit = code.Unit,
|
|
|
|
Unit = code.Unit,
|
|
|
|
Category = DetailCategory.InvoiceApplication
|
|
|
|
Category = DetailCategory.InvoiceApplication
|
|
|
@ -633,6 +632,7 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override DataResult PreDelete(List<InvoiceApplication> applications)
|
|
|
|
protected override DataResult PreDelete(List<InvoiceApplication> applications)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (applications.Any(x => x.Status != InvoiceApplicationStatus.Pending && x.Status != InvoiceApplicationStatus.AuditRejected))
|
|
|
|
if (applications.Any(x => x.Status != InvoiceApplicationStatus.Pending && x.Status != InvoiceApplicationStatus.AuditRejected))
|
|
|
@ -653,40 +653,6 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
.PublicSetColumns(it => it.OrderInvoiceAmount, "-")
|
|
|
|
.PublicSetColumns(it => it.OrderInvoiceAmount, "-")
|
|
|
|
.UpdateColumns(x => new { x.OrderInvoiceAmount })
|
|
|
|
.UpdateColumns(x => new { x.OrderInvoiceAmount })
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
//if (deleteOption == DeleteOption.DetailOnly)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// //删除明细需要同时变更发票明细
|
|
|
|
|
|
|
|
// var appIds = applications.Select(x => x.Id).ToList();
|
|
|
|
|
|
|
|
// var excludeIds = applications.SelectMany(x => x.Details).Select(x => x.Id).ToList();
|
|
|
|
|
|
|
|
// var details = await TenantDb.Queryable<ApplicationDetail>().Where(x => appIds.Contains(x.ApplicationId) && !excludeIds.Contains(x.Id))
|
|
|
|
|
|
|
|
// .Select(x => new ApplicationDetail
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Id = x.Id,
|
|
|
|
|
|
|
|
// ApplicationId = x.ApplicationId,
|
|
|
|
|
|
|
|
// RecordId = x.RecordId,
|
|
|
|
|
|
|
|
// FeeId = x.FeeId,
|
|
|
|
|
|
|
|
// ApplyAmount = x.ApplyAmount
|
|
|
|
|
|
|
|
// }).ToListAsync();
|
|
|
|
|
|
|
|
// foreach (var item in applications)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// //重新设置申请明细
|
|
|
|
|
|
|
|
// item.Details = details.FindAll(x => x.ApplicationId == item.Id);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// await TenantDb.Deleteable<InvoiceDetail>().Where(x => appIds.Contains(x.ApplicationId)).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// await FillInvoiceDetailsAsync(applications);
|
|
|
|
|
|
|
|
// var invDetails = applications.SelectMany(x => x.InvoiceDetails).ToList();
|
|
|
|
|
|
|
|
// if (invDetails.Count > 0)
|
|
|
|
|
|
|
|
// await TenantDb.Insertable(invDetails).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// await TenantDb.Updateable(applications).UpdateColumns(x => new
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// x.ApplyAmount,
|
|
|
|
|
|
|
|
// x.AmountUppercase
|
|
|
|
|
|
|
|
// }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override DataResult PreSubmitApproval(List<InvoiceApplication> applications)
|
|
|
|
protected override DataResult PreSubmitApproval(List<InvoiceApplication> applications)
|
|
|
|