|
|
@ -1518,7 +1518,8 @@ namespace CK.SCP.Controller |
|
|
|
invoice.SubSite = p_entity.SubSite; |
|
|
|
db.TB_INVOICE.AddOrUpdate(invoice); |
|
|
|
|
|
|
|
p_list.ForEach(p => { |
|
|
|
p_list.ForEach(p => |
|
|
|
{ |
|
|
|
|
|
|
|
TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL(); |
|
|
|
invocieDetail.InvcBillNum = invoice.InvcBillNum; |
|
|
@ -1667,7 +1668,8 @@ namespace CK.SCP.Controller |
|
|
|
invoice.BlancePrice = p_entity.BlancePrice; |
|
|
|
invoice.SubSite = p_entity.SubSite; |
|
|
|
db.TB_INVOICE.AddOrUpdate(invoice); |
|
|
|
p_list.ForEach(p => { |
|
|
|
p_list.ForEach(p => |
|
|
|
{ |
|
|
|
TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL(); |
|
|
|
invocieDetail.InvcBillNum = invoice.InvcBillNum; |
|
|
|
invocieDetail.AsnBillNum = p.AsnBillNum; |
|
|
@ -1854,7 +1856,8 @@ namespace CK.SCP.Controller |
|
|
|
invoice.BlancePrice = p_entity.BlancePrice; |
|
|
|
invoice.SubSite = p_entity.SubSite; |
|
|
|
db.TB_INVOICE.AddOrUpdate(invoice); |
|
|
|
p_list.ForEach(p => { |
|
|
|
p_list.ForEach(p => |
|
|
|
{ |
|
|
|
TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL(); |
|
|
|
invocieDetail.InvcBillNum = invoice.InvcBillNum; |
|
|
|
invocieDetail.AsnBillNum = p.AsnBillNum; |
|
|
@ -2139,7 +2142,8 @@ namespace CK.SCP.Controller |
|
|
|
} |
|
|
|
|
|
|
|
var _list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_billno).ToList(); |
|
|
|
_list.ForEach(p => { |
|
|
|
_list.ForEach(p => |
|
|
|
{ |
|
|
|
p.State = (int)p_state; |
|
|
|
|
|
|
|
}); |
|
|
@ -2152,7 +2156,8 @@ namespace CK.SCP.Controller |
|
|
|
_entity.IsDeleted = true; |
|
|
|
|
|
|
|
_list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_billno).ToList(); |
|
|
|
_list.ForEach(p => { |
|
|
|
_list.ForEach(p => |
|
|
|
{ |
|
|
|
p.State = (int)p_state; |
|
|
|
p.IsDeleted = true; |
|
|
|
}); |
|
|
@ -2390,7 +2395,8 @@ namespace CK.SCP.Controller |
|
|
|
} |
|
|
|
|
|
|
|
var _list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == invoice.InvcBillNum).ToList(); |
|
|
|
_list.ForEach(p => { |
|
|
|
_list.ForEach(p => |
|
|
|
{ |
|
|
|
p.State = (int)p_state; |
|
|
|
|
|
|
|
}); |
|
|
@ -2403,7 +2409,8 @@ namespace CK.SCP.Controller |
|
|
|
_entity.IsDeleted = true; |
|
|
|
|
|
|
|
_list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == invoice.InvcBillNum).ToList(); |
|
|
|
_list.ForEach(p => { |
|
|
|
_list.ForEach(p => |
|
|
|
{ |
|
|
|
p.State = (int)p_state; |
|
|
|
p.IsDeleted = true; |
|
|
|
if (!string.IsNullOrEmpty(p_flag)) |
|
|
@ -2606,7 +2613,8 @@ namespace CK.SCP.Controller |
|
|
|
_bill.Remark = p_invoice.Remark; |
|
|
|
_bill.State = (int)p_invoice.State; |
|
|
|
db.TB_INVOICE.AddOrUpdate(p => p.InvcBillNum, _bill); |
|
|
|
p_list.ForEach(p => { |
|
|
|
p_list.ForEach(p => |
|
|
|
{ |
|
|
|
var _detail = db.TB_INVOICE_DETAIL.Where(itm => itm.UID == p.UID).FirstOrDefault(); |
|
|
|
var _qty = _detail.Qty - p.Qty; |
|
|
|
_detail.State = (int)p.State; |
|
|
@ -3500,6 +3508,151 @@ namespace CK.SCP.Controller |
|
|
|
return _ret; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 带发票时间的保存
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_InvcBillNum"></param>
|
|
|
|
/// <param name="p_state"></param>
|
|
|
|
/// <param name="p_CInvoiceCostCenterCode"></param>
|
|
|
|
/// <param name="p_CInvoiceDescription"></param>
|
|
|
|
/// <param name="p_CInvoiceDivisionCode"></param>
|
|
|
|
/// <param name="p_CInvoiceType"></param>
|
|
|
|
/// <param name="p_PostingDate"></param>
|
|
|
|
/// <param name="time"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static ResultObject<bool> SET_INVOICE_STATE_AND_DATE(string p_InvcBillNum, InvoiceState p_state, string p_CInvoiceCostCenterCode, string p_CInvoiceDescription, string p_CInvoiceDivisionCode,string p_CInvoiceType, DateTime? p_PostingDate, DateTime? time) |
|
|
|
{ |
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
|
try |
|
|
|
{ |
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
|
{ |
|
|
|
TB_INVOICE invoice = db.TB_INVOICE.Where(p => p.InvcBillNum == p_InvcBillNum).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
if (invoice != null) |
|
|
|
{ |
|
|
|
invoice.State = (int)p_state; |
|
|
|
|
|
|
|
invoice.CInvoiceCostCenterCode = p_CInvoiceCostCenterCode; |
|
|
|
invoice.CInvoiceDescription = p_CInvoiceDescription; |
|
|
|
invoice.CInvoiceDivisionCode = p_CInvoiceDivisionCode; |
|
|
|
invoice.CInvoiceType = p_CInvoiceType; |
|
|
|
invoice.PostingDate = p_PostingDate; |
|
|
|
invoice.InvoiceDate = time; |
|
|
|
|
|
|
|
db.TB_INVOICE.AddOrUpdate(invoice); |
|
|
|
|
|
|
|
List<TB_INVOICE_DETAIL> invoicedetail = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_InvcBillNum).ToList(); |
|
|
|
|
|
|
|
foreach (TB_INVOICE_DETAIL det in invoicedetail) |
|
|
|
{ |
|
|
|
det.State = (int)p_state; |
|
|
|
} |
|
|
|
|
|
|
|
//财务审核通过,把所有代办信息设为已办状态
|
|
|
|
|
|
|
|
List<TB_PENING_ITEMS> items = db.TB_PENING_ITEMS.Where(p => p.ITEM_NO == p_InvcBillNum).ToList(); |
|
|
|
|
|
|
|
foreach (TB_PENING_ITEMS item in items) |
|
|
|
{ |
|
|
|
item.ITEM_STATE = (int)PENDING_STATE.COMPLETED; |
|
|
|
} |
|
|
|
List<V_TB_INVOICE_DETAIL> _ls = db.V_TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_InvcBillNum).ToList(); |
|
|
|
V_TB_INVOICE _bill = db.V_TB_INVOICE.Where(p => p.InvcBillNum == p_InvcBillNum).FirstOrDefault(); |
|
|
|
|
|
|
|
var _colne = ConvertHelper.GetObjectClone(_bill); |
|
|
|
|
|
|
|
_colne.CInvoiceCostCenterCode = p_CInvoiceCostCenterCode; |
|
|
|
_colne.CInvoiceDescription = p_CInvoiceDescription; |
|
|
|
_colne.CInvoiceDivisionCode = p_CInvoiceDivisionCode; |
|
|
|
_colne.CInvoiceType = p_CInvoiceType; |
|
|
|
_colne.PostingDate = p_PostingDate; |
|
|
|
|
|
|
|
|
|
|
|
foreach (V_TB_INVOICE_DETAIL itm in _ls) |
|
|
|
{ |
|
|
|
TS_UNI_API _api = UniApiController.CreateBy(_colne, itm, UniApiType.Invoice); |
|
|
|
_api.State = 1; |
|
|
|
db.TS_UNI_API.AddOrUpdate(_api); |
|
|
|
itm.State = (int)p_state; |
|
|
|
} |
|
|
|
if (db.SaveChanges() != -1) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
_ret.Result = true; |
|
|
|
_ret.Message = invoice.VendId; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.Message = invoice.VendId; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.Message = invoice.VendId; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{ |
|
|
|
var sb = new StringBuilder(); |
|
|
|
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList()) |
|
|
|
{ |
|
|
|
|
|
|
|
error.ValidationErrors.ToList().ForEach(i => |
|
|
|
{ |
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); |
|
|
|
}); |
|
|
|
} |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(dbEx); |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "SET_INVOICE_STATE_AND_DATE", sb.ToString()); |
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); |
|
|
|
} |
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{ |
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(ex); |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "SET_INVOICE_STATE_AND_DATE", ex.ToString()); |
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); |
|
|
|
} |
|
|
|
catch (ScpException ex) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(ex); |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "SET_INVOICE_STATE_AND_DATE", ex.ToString()); |
|
|
|
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) |
|
|
|
{ |
|
|
|
var inner = (UpdateException)ex.InnerException; |
|
|
|
|
|
|
|
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (ex.InnerException != null) throw ex.InnerException; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
_ret.Result = false; |
|
|
|
_ret.ErrorList.Add(e); |
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INVOICE_CONTROLLER), "SET_INVOICE_STATE", e.Message); throw e; |
|
|
|
} |
|
|
|
return _ret; |
|
|
|
} |
|
|
|
|
|
|
|
public static ResultObject<bool> SET_INVOICE_STATE(string p_InvcBillNum, InvoiceState p_state, |
|
|
|
string p_CInvoiceCostCenterCode, |
|
|
|