|
|
@ -9,6 +9,7 @@ using DS.WMS.Core.Code.Entity;
|
|
|
|
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.Dtos;
|
|
|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Invoice.Entity;
|
|
|
|
using DS.WMS.Core.Invoice.Interface;
|
|
|
|
using DS.WMS.Core.Invoice.Interface;
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
@ -222,7 +223,9 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
dbValue = await TenantDb.Queryable<TEntity>().Select(x => new TEntity
|
|
|
|
dbValue = await TenantDb.Queryable<TEntity>().Select(x => new TEntity
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|
|
|
|
|
InvoiceNO = x.InvoiceNO,
|
|
|
|
IsLocked = x.IsLocked,
|
|
|
|
IsLocked = x.IsLocked,
|
|
|
|
|
|
|
|
IsSettled = x.IsSettled,
|
|
|
|
Mode = x.Mode,
|
|
|
|
Mode = x.Mode,
|
|
|
|
}).FirstAsync(x => x.Id == request.Invoice.Id);
|
|
|
|
}).FirstAsync(x => x.Id == request.Invoice.Id);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -362,7 +365,7 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
|
|
|
|
|
|
|
if (app.AmountOther.HasValue)
|
|
|
|
if (app.AmountOther.HasValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result2 = AssignAmount(details2.FindAll(x => x.Currency != FeeCurrency.RMB_CODE && x.OriginalCurrency != FeeCurrency.USD_CODE), app.AmountOther.Value);
|
|
|
|
result2 = AssignAmount(details2.FindAll(x => x.Currency != FeeCurrency.RMB_CODE && x.Currency != FeeCurrency.USD_CODE), app.AmountOther.Value);
|
|
|
|
if (!result2.Succeeded)
|
|
|
|
if (!result2.Succeeded)
|
|
|
|
return DataResult<TEntity>.Failed(result2.Message, result2.MultiCode);
|
|
|
|
return DataResult<TEntity>.Failed(result2.Message, result2.MultiCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -458,8 +461,7 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//补充销方信息
|
|
|
|
//补充销方信息
|
|
|
|
//var org = await Db.Queryable<SysOrg>().Where(x => x.Id == User.OrgId).Select(x => new { x.OrgFullName, x.LicenseCode }).FirstAsync();
|
|
|
|
var orgId = invoice.SaleDeptId.GetValueOrDefault() == 0 ? User.OrgId : invoice.SaleDeptId;
|
|
|
|
var orgId = invoice.SaleDeptId ?? User.OrgId;
|
|
|
|
|
|
|
|
var org = await Db.Queryable<SysOrg>().LeftJoin<SysOrgAuth>((t, a) => t.Id == a.OrgId).Where((t, a) => t.Id == orgId).Select((t, a) => new { t.OrgFullName, t.LicenseCode }).FirstAsync();
|
|
|
|
var org = await Db.Queryable<SysOrg>().LeftJoin<SysOrgAuth>((t, a) => t.Id == a.OrgId).Where((t, a) => t.Id == orgId).Select((t, a) => new { t.OrgFullName, t.LicenseCode }).FirstAsync();
|
|
|
|
if (org != null)
|
|
|
|
if (org != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -477,9 +479,6 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
invoice.Account = orgBank.BankAccountNo;
|
|
|
|
invoice.Account = orgBank.BankAccountNo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//生成默认备注
|
|
|
|
|
|
|
|
//invoice.InvoiceRemark = $"购买方地址电话:" + Environment.NewLine + invoice.CustomerAddressTel + Environment.NewLine
|
|
|
|
|
|
|
|
// + "购买方开户行/账号:" + invoice.CustomerBankName + " " + invoice.CustomerAccount;
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(invRemark))
|
|
|
|
if (!string.IsNullOrEmpty(invRemark))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
invoice.Note += Environment.NewLine + invRemark;
|
|
|
|
invoice.Note += Environment.NewLine + invRemark;
|
|
|
@ -696,6 +695,7 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
ApplicationId = invoice.Id,
|
|
|
|
ApplicationId = invoice.Id,
|
|
|
|
CodeId = code.Id,
|
|
|
|
CodeId = code.Id,
|
|
|
|
Name = code.Name,
|
|
|
|
Name = code.Name,
|
|
|
|
|
|
|
|
Currency = FeeCurrency.RMB_CODE,
|
|
|
|
Quantity = 1,
|
|
|
|
Quantity = 1,
|
|
|
|
TaxUnitPrice = detail.ApplyAmount,
|
|
|
|
TaxUnitPrice = detail.ApplyAmount,
|
|
|
|
TaxRate = code.TaxRate,
|
|
|
|
TaxRate = code.TaxRate,
|
|
|
@ -765,8 +765,17 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
protected virtual DataResult EnsureSettlement(TEntity invoice, TEntity? dbValue)
|
|
|
|
protected virtual DataResult EnsureSettlement(TEntity invoice, TEntity? dbValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (dbValue != null && dbValue.IsLocked)
|
|
|
|
if (dbValue != null)
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsLocked));
|
|
|
|
{
|
|
|
|
|
|
|
|
if (dbValue.IsLocked)
|
|
|
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsLocked));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(dbValue.InvoiceNO))
|
|
|
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsIssued));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dbValue.IsSettled)
|
|
|
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsSettled));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
return DataResult.Success;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -947,11 +956,14 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
if (invoices.Any(x => x.IsLocked))
|
|
|
|
if (invoices.Any(x => x.IsLocked))
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsLocked));
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsLocked));
|
|
|
|
|
|
|
|
|
|
|
|
if (invoices.Any(x => !string.IsNullOrEmpty(x.ApiCode)))
|
|
|
|
if (invoices.Any(x => !string.IsNullOrEmpty(x.InvoiceNO)))
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsIssued));
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsIssued));
|
|
|
|
|
|
|
|
|
|
|
|
var ids = invoices.Select(x => x.Id);
|
|
|
|
//var ids = invoices.Select(x => x.Id);
|
|
|
|
if (TenantDb.Queryable<ApplicationDetail>().Any(x => ids.Contains(x.RefId.Value) && x.Category == DetailCategory.InvoiceSettlement))
|
|
|
|
//if (TenantDb.Queryable<ApplicationDetail>().Any(x => ids.Contains(x.RefId.Value) && x.Category == DetailCategory.InvoiceSettlement))
|
|
|
|
|
|
|
|
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsSettled));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (invoices.Any(x => x.IsSettled))
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsSettled));
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.InvoiceIsSettled));
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
return DataResult.Success;
|
|
|
@ -1038,8 +1050,7 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
LockTime = isLocked ? dt : null,
|
|
|
|
LockTime = isLocked ? dt : null,
|
|
|
|
LockUserId = isLocked ? userId : null
|
|
|
|
LockUserId = isLocked ? userId : null
|
|
|
|
}).ToList();
|
|
|
|
}).ToList();
|
|
|
|
int rows = await TenantDb.Updateable(list)
|
|
|
|
int rows = await TenantDb.Updateable(list).UpdateColumns(x => new { x.IsLocked, x.LockTime, x.LockUserId }).ExecuteCommandAsync();
|
|
|
|
.UpdateColumns(x => new { x.IsLocked, x.LockTime, x.LockUserId }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
}
|
|
|
|
}
|
|
|
|