Commit 64a26bb1 by 陶然

优化发票更新接口

parent 190cc324
......@@ -115,12 +115,27 @@ namespace Kivii.Finances.Transforms
exist.ThrowIfNull("未找到要更新的发票信息!");
if (exist.Type.ToLower() == "relation") throw new Exception("不支持的数据类型,无法更新!");
if (Item.OffsetKvid != Guid.Empty) throw new Exception("无法更新已作废发票!");
if (Item.SerialNumber == exist.SerialNumber) Item.RemoveOnlyProperties(o => o.SerialNumber);
if (Item.OnlyPropertiesIsExist(o => o.SerialNumber))
{
var nodes = conn.Select<Invoice>(o => o.RootKvid == Item.Kvid && o.RootKvid != o.Kvid);
if (!nodes.IsNullOrEmpty())
{
foreach (var node in nodes)
{
node.SerialNumber = node.SerialNumber.Replace(exist.SerialNumber, Item.SerialNumber);
node.AddOnlyProperties(o => o.SerialNumber);
conn.UpdateOnly(node);
}
}
}
if (Item.Amount == exist.Amount) Item.RemoveOnlyProperties(o => o.Amount);
if (Item.OnlyPropertiesIsExist(o => o.Amount))
{
if (Item.Amount <= 0) throw new Exception("发票金额不能小于等于0!");
var details = conn.Select<InvoiceDetail>(o => o.InvoiceKvid == Item.Kvid);
if (exist.AmountPayment > 0) throw new Exception("无法更新发票金额!");
if (exist.AmountUsed > 0) throw new Exception("无法更新发票金额!");
Item.AmountUntaxed = Math.Round(Item.Amount / (1 + Item.TaxRate), 2);
Item.AddOnlyProperties(o => o.AmountUntaxed);
Item.AmountTax = Item.Amount - Item.AmountUntaxed;
......
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