Commit 6d260e04 by 陶然

优化新增发票删除接口

parent 336d2297
...@@ -55,6 +55,7 @@ namespace Kivii.Finances ...@@ -55,6 +55,7 @@ namespace Kivii.Finances
rtns.AmountSplited = 0; rtns.AmountSplited = 0;
rtns.AmountUsed = amount; rtns.AmountUsed = amount;
rtns.Summary = "收款登记"; rtns.Summary = "收款登记";
rtns.Remark = remark;
rtns.OperateTime = payment.OperateTime; rtns.OperateTime = payment.OperateTime;
//rtns.OperateTime = DateTime.Now; //rtns.OperateTime = DateTime.Now;
rtns.OperatorName = KiviiContext.CurrentMember.FullName; rtns.OperatorName = KiviiContext.CurrentMember.FullName;
...@@ -137,6 +138,11 @@ namespace Kivii.Finances ...@@ -137,6 +138,11 @@ namespace Kivii.Finances
settlement.Metadata["PayedName"] = payment.PayerName; settlement.Metadata["PayedName"] = payment.PayerName;
settlement.Metadata["PayedSerialNumber"] = payment.SerialNumber; settlement.Metadata["PayedSerialNumber"] = payment.SerialNumber;
settlement.AddOnlyProperties(o => o.Metadata); settlement.AddOnlyProperties(o => o.Metadata);
if (!remark.IsNullOrEmpty())
{
settlement.Remark = remark;
settlement.AddOnlyProperties(o => o.Remark);
}
amount -= currentAmount; amount -= currentAmount;
} }
...@@ -273,6 +279,11 @@ namespace Kivii.Finances ...@@ -273,6 +279,11 @@ namespace Kivii.Finances
settlement.Metadata["PayedName"] = accountPayer.Name; settlement.Metadata["PayedName"] = accountPayer.Name;
settlement.Metadata["PayedSerialNumber"] = accountPayer.SerialNumber; settlement.Metadata["PayedSerialNumber"] = accountPayer.SerialNumber;
settlement.AddOnlyProperties(o => o.Metadata); settlement.AddOnlyProperties(o => o.Metadata);
if (!remark.IsNullOrEmpty())
{
settlement.Remark = remark;
settlement.AddOnlyProperties(o => o.Remark);
}
amount -= currentAmount; amount -= currentAmount;
} }
......
...@@ -190,6 +190,53 @@ namespace Kivii.Finances.Transforms ...@@ -190,6 +190,53 @@ namespace Kivii.Finances.Transforms
} }
} }
[Api(Description = "发票删除")]
[RequiresAnyRole(SystemRoles.Everyone)]
public class InvoiceDelete : RestfulExecution<Invoice>
{
public Guid Kvid { get; set; }
public List<Guid> Kvids { get; set; }
public string Remark { get; set; }
public override object OnExecution(IRequest req, IResponse res)
{
if (Kvid == Guid.Empty && Kvids.IsNullOrEmpty()) throw new Exception("请传入要作废的发票Kvid!");
if (Kvids.IsNullOrEmpty()) Kvids = new List<Guid>();
if (Kvid != Guid.Empty) Kvids.Add(Kvid);
var conn = KiviiContext.GetOpenedDbConnection<Invoice>();
var invoices = conn.SelectByIds<Invoice>(Kvids);
if (invoices.IsNullOrEmpty()) throw new Exception("未找到所选发票信息!");
if (invoices.Exists(o => o.OffsetKvid == Guid.Empty)) throw new Exception("存在未作废的发票,请先作废后再删除!");
var offsets = conn.SelectByIds<Invoice>(invoices.ConvertAll(p => p.OffsetKvid));
var rtns = new RestfulUpdateResponse<Invoice>();
rtns.Results = new List<Invoice>();
var trans = conn.OpenTransaction();
try
{
foreach (var item in invoices)
{
conn.DeleteById<Invoice>(item.Kvid);
rtns.Results.Add(item);
}
foreach (var item in offsets)
{
conn.DeleteById<Invoice>(item.Kvid);
rtns.Results.Add(item);
}
trans.Commit();
}
catch (Exception ex)
{
trans.Rollback();
throw ex;
}
return rtns;
}
}
//[Api(Description = "发票红冲")] //[Api(Description = "发票红冲")]
//[RequiresAnyRole(SystemRoles.Everyone)] //[RequiresAnyRole(SystemRoles.Everyone)]
//public class InvoiceDeficit : RestfulExecution<Invoice> //public class InvoiceDeficit : RestfulExecution<Invoice>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment