Commit d039a180 by 陶然

账单创建接口优化不可重复建

parent 2a7b2168
...@@ -28,11 +28,23 @@ namespace Kivii.Finances.Transforms ...@@ -28,11 +28,23 @@ namespace Kivii.Finances.Transforms
conn.InitEntityType<Bill>(); conn.InitEntityType<Bill>();
conn.InitEntityType<BillDetail>(); conn.InitEntityType<BillDetail>();
var settlements = conn.SelectByIds<Settlement>(SettlementKvids); var query = conn.From<Settlement>();
query.Where(o => Sql.In(o.Kvid, SettlementKvids));
query.Select(o => new
{
o.SerialNumber,
o.Kvid,
o.Amount,
o.Currency,
o.Type,
o.Summary,
o.Remark
});
var settlements = conn.Select(query);
if (settlements == null) throw new Exception("无对应数据导出!"); if (settlements == null) throw new Exception("无对应数据导出!");
(settlements.Exists(o => o.Currency != Item.Currency)).ThrowIfTrue("存在于账单不一致的货币单位不可制作!"); (settlements.Exists(o => o.Currency != Item.Currency)).ThrowIfTrue("存在于账单不一致的货币单位不可制作!");
if (Item.Amount != settlements.Sum(o => o.Amount)) throw new Exception("账单金额不等于选择的结算金额之和!"); if (Item.Amount != settlements.Sum(o => o.Amount)) throw new Exception("账单金额不等于选择的结算金额之和!");
if (conn.Exists<BillDetail>(o => o.OffsetKvid == Guid.Empty && Sql.In(o.BizKvid, settlements.ConvertAll(p => p.Kvid)))) throw new Exception("此结算已有账单,不可重复制作账单!");
var rtns = new RestfulCreateResponse<Bill>(); var rtns = new RestfulCreateResponse<Bill>();
rtns.Results = new List<Bill>(); rtns.Results = new List<Bill>();
......
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