|
|
|
@ -10,6 +10,7 @@ using DS.WMS.Core.Code.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
|
using DS.WMS.Core.Invoice.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using SqlSugar;
|
|
|
|
@ -452,7 +453,6 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override DataResult CalculateAmount(InvoiceApplication application, List<FeeRecord> fees)
|
|
|
|
|
{
|
|
|
|
|
if (fees == null)
|
|
|
|
@ -517,6 +517,42 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override async Task PreSaveAsync(InvoiceApplication application)
|
|
|
|
|
{
|
|
|
|
|
if (application.Id > 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (application.CustomerBankId == null)
|
|
|
|
|
{
|
|
|
|
|
var bankId = await TenantDb.Queryable<InfoClientBank>().Where(x => x.ClientId == application.CustomerId &&
|
|
|
|
|
x.Currency == FeeCurrency.RMB_CODE).OrderByDescending(x => x.IsInvoiceDefault).Select(x => x.Id).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (bankId > 0)
|
|
|
|
|
application.CustomerBankId = bankId;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (application.USDCustomerBankId == null)
|
|
|
|
|
{
|
|
|
|
|
var bankId = await TenantDb.Queryable<InfoClientBank>().Where(x => x.ClientId == application.CustomerId &&
|
|
|
|
|
x.Currency == FeeCurrency.USD_CODE).OrderByDescending(x => x.IsInvoiceDefault).Select(x => x.Id).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (bankId > 0)
|
|
|
|
|
application.CustomerBankId = bankId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(application.InvoiceHeader))
|
|
|
|
|
{
|
|
|
|
|
application.TaxID = await TenantDb.Queryable<InfoClient>().Where(x => x.Id == application.CustomerId).Select(x => x.TaxNo).FirstAsync();
|
|
|
|
|
var header = await TenantDb.Queryable<InvoiceHeader>().Where(
|
|
|
|
|
x => x.RelativeId == application.CustomerId).OrderByDescending(x => x.Id).FirstAsync();
|
|
|
|
|
if (header != null)
|
|
|
|
|
{
|
|
|
|
|
application.InvoiceHeader = header.Header;
|
|
|
|
|
application.CustomerAddTel = header.AddressTel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//提交事务前
|
|
|
|
|
protected override async Task OnSaveAsync(InvoiceApplication application, List<FeeRecord>? fees)
|
|
|
|
|
{
|
|
|
|
@ -583,16 +619,16 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
|
Unit = code.Unit,
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
invDetail.Amount += detail.ApplyAmount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
invDetail.TaxAmount = invDetail.TaxUnitPrice * application.TaxRate;
|
|
|
|
|
invDetail.UnitPrice = invDetail.TaxUnitPrice - invDetail.TaxAmount;
|
|
|
|
|
invDetail.Amount = invDetail.TaxUnitPrice * invDetail.Quantity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|