/// <summary>
 /// 新增
 /// </summary>
 /// <param name="realName"></param>
 /// <param name="invoiceApplyInfo"></param>
 /// <param name="details"></param>
 /// <param name="personnelid"></param>
 /// <returns></returns>
 public ResultInfo Insert(Guid personnelid, string realName, InvoiceApplyInfo invoiceApplyInfo, List <InvoiceApplyDetailInfo> details)
 {
     try
     {
         if (invoiceApplyInfo.ApplySourceType == (int)ApplyInvoiceSourceType.League)
         {
             invoiceApplyInfo.Amount = details.Sum(ent => ent.TotalPayAmount);
             if (invoiceApplyInfo.ApplyKind == (int)ApplyInvoiceKindType.Credit)
             {
                 var bindGoods = _storageRecord.GetStorageRecordDetailsByLinkTradeCode(details.Select(ent => ent.Tradecode));
                 foreach (var item in details)
                 {
                     var dataSource = bindGoods.Where(ent => ent.LinkTradeCode == item.Tradecode);
                     if (dataSource.Sum(ent => ent.Quantity * ent.UnitPrice) != item.TotalPayAmount)
                     {
                         return(new ResultInfo(false, string.Format("发票申请插入失败!要货申请{0}和出库总金额不一致", item.Tradecode)));
                     }
                     item.LinkTradeCodes = string.Join(",", dataSource.Select(ent => ent.TradeCode));
                 }
             }
         }
         var result = _invoiceApply.Insert(invoiceApplyInfo, details);
         if (result)
         {
             string remark = string.Format("[发票申请新增:{0} {1}]{2}", realName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), invoiceApplyInfo.ApplyRemark);
             _operationLogManager.Add(personnelid, realName, invoiceApplyInfo.ApplyId,
                                      invoiceApplyInfo.TradeCode, OperationPoint.CurrentReceivedPayment.Remarks.GetBusinessInfo(), 1,
                                      remark);
             return(new ResultInfo(true, string.Empty));
         }
         return(new ResultInfo(false, "发票申请插入失败!"));
     }
     catch (Exception ex)
     {
         return(new ResultInfo(false, ex.Message));
     }
 }
Beispiel #2
0
 /// <summary> 添加操作记录
 /// </summary>
 /// <param name="personnelId">操作人Id</param>
 /// <param name="realName">操作人</param>
 /// <param name="identiykey">关键字</param>
 /// <param name="identifycode"></param>
 /// <param name="state">操作点</param>
 /// <param name="newClew">备注</param>
 public static bool AddOperationLog(Guid personnelId, string realName, Guid identiykey, string identifycode,
                                    EnumPointAttribute state, string newClew)
 {
     return(_operationLogManager.Add(personnelId, realName, identiykey, identifycode, state, 1, newClew));
 }