/// <summary> /// Takes the specified take. /// </summary> /// <param name="bUPlanWithdrawEntity">The b u plan withdraw entity.</param> /// <returns>System.Object[].</returns> private object[] Take(BUPlanWithdrawEntity bUPlanWithdrawEntity) { return(new object[] { "@RefID", bUPlanWithdrawEntity.RefId, "@CashWithDrawType", bUPlanWithdrawEntity.CashWithDrawType, "@RefType", bUPlanWithdrawEntity.RefType, "@RefDate", bUPlanWithdrawEntity.RefDate, "@PostedDate", bUPlanWithdrawEntity.PostedDate, "@RefNo", bUPlanWithdrawEntity.RefNo, "@CurrencyCode", bUPlanWithdrawEntity.CurrencyCode, "@ExchangeRate", bUPlanWithdrawEntity.ExchangeRate, "@ParalellRefNo", bUPlanWithdrawEntity.ParalellRefNo, "@TargetProgramID", bUPlanWithdrawEntity.TargetProgramId, "@BankID", bUPlanWithdrawEntity.BankId, "@AccountingObjectID", bUPlanWithdrawEntity.AccountingObjectId, "@JournalMemo", bUPlanWithdrawEntity.JournalMemo, "@TotalAmount", bUPlanWithdrawEntity.TotalAmount, "@TotalAmountOC", bUPlanWithdrawEntity.TotalAmountOC, "@GeneratedRefID", bUPlanWithdrawEntity.GeneratedRefId, "@Posted", bUPlanWithdrawEntity.Posted, "@BUCommitmentRequestID", bUPlanWithdrawEntity.BUCommitmentRequestId, "@AccountingObjectBankID", bUPlanWithdrawEntity.AccountingObjectBankId }); }
/// <summary> /// Deletes the cash entity. /// </summary> /// <param name="receipt">The receipt.</param> /// <returns>System.String.</returns> public string DeleteBUPlanWithdraw(BUPlanWithdrawEntity receipt) { const string procedures = @"uspDelete_BUPlanWithdraw"; object[] parms = { "@RefID", receipt.RefId }; return(Db.Delete(procedures, true, parms)); }
/// <summary> /// Inserts the ca receipt. /// </summary> /// <param name="receipt">The receipt.</param> /// <returns>System.String.</returns> public string InsertBUPlanWithdraw(BUPlanWithdrawEntity receipt) { const string procedures = @"uspInsert_BUPlanWithdraw"; return(Db.Insert(procedures, true, Take(receipt))); }
public List <BUPlanWithdrawEntity> GetBUPlanWithdraws(string connectionString) { List <BUPlanWithdrawEntity> buplanwithdraws = new List <BUPlanWithdrawEntity>(); using (var context = new MISAEntity(connectionString)) { var querry = context.BUPlanWithdrawDetails.ToList(); var projects = context.Projects.ToList(); var currencys = context.CCies.ToList(); var budgetsource = context.BudgetSources.ToList(); var listitems = context.ListItems.ToList(); var fundstructures = context.FundStructures.ToList(); var budgetproviders = context.BudgetProvidences.ToList(); var accountingobject = context.AccountingObjects.ToList(); banks = context.BankInfoes.ToList(); var resultcontext = context.BUPlanWithdraws.ToList(); foreach (var result in resultcontext) { var newresult = new BUPlanWithdrawEntity(); newresult.RefId = result.RefID.ToString(); newresult.CashWithDrawType = result.CashWithDrawType; newresult.RefType = ConvRefType.ConvRefType(result.RefType); newresult.RefDate = result.RefDate; newresult.PostedDate = result.PostedDate; newresult.RefNo = result.RefNo; newresult.CurrencyCode = result.CCY == null ? null : result.CCY.CurrencyID; newresult.ExchangeRate = result.ExchangeRate; newresult.ParalellRefNo = result.ParalellRefNo; newresult.TargetProgramId = result.Project == null? null: result.Project.ProjectID.ToString(); newresult.BankId = result.BankInfo.BankInfoID.ToString(); newresult.AccountingObjectId = result.AccountingObject == null? null: result.AccountingObject.AccountingObjectID.ToString(); newresult.JournalMemo = result.JournalMemo; newresult.TotalAmount = result.TotalAmount; newresult.TotalAmountOC = result.TotalAmountOC; newresult.GeneratedRefId = result.GeneratedRefID.ToString(); newresult.Posted = result.Posted; newresult.BUCommitmentRequestId = result.BUCommitmentRequestID.ToString(); newresult.AccountingObjectBankId = result.AccountingObjectBankAccount == null ? null : banks.FirstOrDefault(x => x.BankAccount == result.AccountingObjectBankAccount).BankInfoID.ToString(); //newresult.CAReceiptRefId = result.id; //newresult.LinkRefNo = result.l; //newresult.BeneficiaryAccount = result.BeneficiaryAccount; //newresult.BeneficiaryBank = result.BeneficiaryBank; //newresult.BudgetExpenseID = result.BudgetExpenseID; newresult.BUPlanWithdrawDetails = BuPlanWithDrawDetails(result.BUPlanWithdrawDetails.ToList(), newresult.RefId); buplanwithdraws.Add(newresult); } } return(buplanwithdraws); }
/// <summary> /// Updates the ca planWithdraw. /// </summary> /// <param name="planWithdrawEntity">The planWithdraw entity.</param> /// <returns>BUPlanWithdrawResponse.</returns> public BUPlanWithdrawResponse UpdateBUPlanWithdraw(BUPlanWithdrawEntity planWithdrawEntity) { var planWithdrawResponse = new BUPlanWithdrawResponse { Acknowledge = AcknowledgeType.Success }; try { if (planWithdrawEntity != null && !planWithdrawEntity.Validate()) { foreach (var error in planWithdrawEntity.ValidationErrors) { planWithdrawResponse.Message += error + Environment.NewLine; } planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } using (var scope = new TransactionScope()) { // Trừ số tiền khi mà update xử lý Bảng cân đối tài khoản//////////////////////////////////// //accountBalances.Clear(); if (planWithdrawEntity != null) { //accountBalances = GetListAccountBalanceOlder(planWithdrawEntity.RefId); //foreach (var accountBalanceEntity in accountBalances) //{ // var obAccoutBalanceExit = AccountBalanceDao.GetExitsAccountBalance(accountBalanceEntity); // if (obAccoutBalanceExit != null) // { // obAccoutBalanceExit.CurrencyCode = accountBalanceEntity.CurrencyCode; // // cập nhật bên TK nợ // if (accountBalanceEntity.MovementCreditAmountOC == 0) // { // obAccoutBalanceExit.ExchangeRate = accountBalanceEntity.ExchangeRate; // obAccoutBalanceExit.MovementDebitAmountExchange = // obAccoutBalanceExit.MovementDebitAmountExchange - accountBalanceEntity.MovementDebitAmountExchange; // obAccoutBalanceExit.MovementDebitAmountOC = // obAccoutBalanceExit.MovementDebitAmountOC - accountBalanceEntity.MovementDebitAmountOC; // AccountBalanceDao.UpdateAccountBalance(obAccoutBalanceExit); // } // else // { // obAccoutBalanceExit.ExchangeRate = accountBalanceEntity.ExchangeRate; // obAccoutBalanceExit.MovementCreditAmountExchange = // obAccoutBalanceExit.MovementCreditAmountExchange - accountBalanceEntity.MovementCreditAmountExchange; // obAccoutBalanceExit.MovementCreditAmountOC = // obAccoutBalanceExit.MovementCreditAmountOC - accountBalanceEntity.MovementCreditAmountOC; // AccountBalanceDao.UpdateAccountBalance(obAccoutBalanceExit); // } // } //} // Cập nhật lại dữ liệu vào bảng cân đối tài khoản //accountBalances.Clear(); //accountBalances = GetListAccountBalance(planWithdrawEntity); //foreach (var accountBalanceEntity in accountBalances) //{ // var obAccoutBalanceExit = AccountBalanceDao.GetExitsAccountBalance(accountBalanceEntity); // if (obAccoutBalanceExit != null) // { // obAccoutBalanceExit.CurrencyCode = accountBalanceEntity.CurrencyCode; // // cập nhật bên TK nợ // if (accountBalanceEntity.MovementCreditAmountOC == 0) // { // obAccoutBalanceExit.ExchangeRate = accountBalanceEntity.ExchangeRate; // obAccoutBalanceExit.MovementDebitAmountExchange = // obAccoutBalanceExit.MovementDebitAmountExchange + accountBalanceEntity.MovementDebitAmountExchange; // obAccoutBalanceExit.MovementDebitAmountOC = // obAccoutBalanceExit.MovementDebitAmountOC + accountBalanceEntity.MovementDebitAmountOC; // AccountBalanceDao.UpdateAccountBalance(obAccoutBalanceExit); // } // else // { // obAccoutBalanceExit.ExchangeRate = accountBalanceEntity.ExchangeRate; // obAccoutBalanceExit.MovementCreditAmountExchange = // obAccoutBalanceExit.MovementCreditAmountExchange + accountBalanceEntity.MovementCreditAmountExchange; // obAccoutBalanceExit.MovementCreditAmountOC = // obAccoutBalanceExit.MovementCreditAmountOC + accountBalanceEntity.MovementCreditAmountOC; // AccountBalanceDao.UpdateAccountBalance(obAccoutBalanceExit); // } // } // else // { // AccountBalanceDao.InsertAccountBalance(accountBalanceEntity); // } //} // Xóa dữ liệu trống trong bảng Cân đối tài khoản //AccountBalanceDao.DeleteAccountBalance(); //check ma trung var planWithdrawEntityExisted = BUPlanWithdrawDao.GetBUPlanWithdrawByRefNoRefType(planWithdrawEntity.RefNo.Trim(), planWithdrawEntity.RefType, planWithdrawEntity.PostedDate); if (planWithdrawEntityExisted != null && planWithdrawEntityExisted.RefId != planWithdrawEntity.RefId && planWithdrawEntityExisted.PostedDate.Year == planWithdrawEntity.PostedDate.Year) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; planWithdrawResponse.Message = @"Số chứng từ '" + planWithdrawEntity.RefNo + @"' đã tồn tại!"; return(planWithdrawResponse); } planWithdrawResponse.Message = BUPlanWithdrawDetailDao.DeleteBUPlanWithdrawDetailByRefId(planWithdrawEntity.RefId); if (planWithdrawResponse.Message != null) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; scope.Dispose(); return(planWithdrawResponse); } #region Delete OriginalGeneralLedger if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } planWithdrawResponse.Message = OriginalGeneralLedgerDao.DeleteOriginalGeneralLedger(planWithdrawEntity.RefId); #endregion //if (planWithdrawEntity.RefTypeId == 600) //{ // //Update Lại các mục Khoản lương // //Lấy lại số chứng từ cũ thay the số chứng từ mới // var objBUPlanWithdraw = BUPlanWithdrawDao.GetBUPlanWithdraw(planWithdrawEntity.RefId); // planWithdrawResponse.Message = BUPlanWithdrawDao.UpdateEmployeePayroll(objBUPlanWithdraw.RefNo, planWithdrawEntity.RefNo, planWithdrawEntity.PostedDate.Month + "/" + planWithdrawEntity.PostedDate.Day + "/" + planWithdrawEntity.PostedDate.Year); //} planWithdrawResponse.Message = BUPlanWithdrawDao.UpdateBUPlanWithdraw(planWithdrawEntity); if (planWithdrawResponse.Message != null) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; scope.Dispose(); return(planWithdrawResponse); } //var jourentryAccount = journalEntryAccounts[0]; //planWithdrawResponse.Message = JournalEntryAccountDao.DeleteJournalEntryAccount(jourentryAccount); //if (planWithdrawResponse.Message != null) //{ // planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; // scope.Dispose(); // return planWithdrawResponse; //} foreach (var planWithdrawDetail in planWithdrawEntity.BUPlanWithdrawDetails) { planWithdrawDetail.RefId = planWithdrawEntity.RefId; planWithdrawDetail.RefDetailId = Guid.NewGuid().ToString(); if (!planWithdrawDetail.Validate()) { foreach (string error in planWithdrawDetail.ValidationErrors) { planWithdrawResponse.Message += error + Environment.NewLine; } planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } planWithdrawResponse.Message = BUPlanWithdrawDetailDao.InsertBUPlanWithdrawDetail(planWithdrawDetail); if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } #region Insert OriginalGeneralLedger var originalGeneralLedgerEntity = new OriginalGeneralLedgerEntity { OriginalGeneralLedgerId = Guid.NewGuid().ToString(), RefType = planWithdrawEntity.RefType, RefId = planWithdrawEntity.RefId, RefDetailId = planWithdrawDetail.RefDetailId, OrgRefDate = planWithdrawDetail.OrgRefDate, OrgRefNo = planWithdrawDetail.OrgRefNo, RefDate = planWithdrawEntity.RefDate, RefNo = planWithdrawEntity.RefNo, Amount = planWithdrawDetail.Amount, AmountOC = planWithdrawDetail.AmountOC, BudgetChapterCode = planWithdrawDetail.BudgetChapterCode, BudgetDetailItemCode = planWithdrawDetail.BudgetDetailItemCode, BudgetItemCode = planWithdrawDetail.BudgetItemCode, BudgetKindItemCode = planWithdrawDetail.BudgetKindItemCode, BudgetSourceId = planWithdrawDetail.BudgetSourceId, BudgetSubItemCode = planWithdrawDetail.BudgetSubItemCode, BudgetSubKindItemCode = planWithdrawDetail.BudgetSubKindItemCode, CreditAccount = planWithdrawDetail.CreditAccount, Description = planWithdrawDetail.Description, FundStructureId = planWithdrawDetail.FundStructureId, // TaxAmount = planWithdrawDetail.TaxAmount, JournalMemo = planWithdrawEntity.JournalMemo, ProjectId = planWithdrawDetail.ProjectId, PostedDate = planWithdrawEntity.PostedDate, CurrencyCode = planWithdrawEntity.CurrencyCode, ExchangeRate = planWithdrawEntity.ExchangeRate, }; planWithdrawResponse.Message = OriginalGeneralLedgerDao.InsertOriginalGeneralLedger(originalGeneralLedgerEntity); if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } #endregion //// Insert into JourentryAcocunt //jourentryAccount = journalEntryAccounts[i]; //jourentryAccount.RefId = planWithdrawDetail.RefId; //jourentryAccount.RefDetailId = planWithdrawDetail.RefDetailId; //#region " jourentryAccount: thay đổi thông tin theo đối tượng Master" //int accountingObjectType = planWithdrawEntity.AccountingObjectType == null ? 0 : int.Parse(planWithdrawEntity.AccountingObjectType.ToString()); //switch (accountingObjectType) //{ // case 0: // jourentryAccount.VendorId = planWithdrawEntity.VendorId; // break; // case 1: // jourentryAccount.EmployeeId = planWithdrawEntity.EmployeeId; // break; // case 2: // jourentryAccount.AccountingObjectId = planWithdrawEntity.AccountingObjectId; // break; // case 3: // jourentryAccount.CustomerId = planWithdrawEntity.CustomerId; // break; //} //#endregion //if (!jourentryAccount.Validate()) //{ // foreach (string error in jourentryAccount.ValidationErrors) // planWithdrawResponse.Message += error + Environment.NewLine; // planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; // return planWithdrawResponse; //} //JournalEntryAccountDao.InsertDoubleJournalEntryAccount(jourentryAccount); //i = i + 1; } //foreach (var buPlanDrawDetail in planWithdrawEntity.BUPlanWithdrawDetails) //{ // var generalLedgerEntity = new GeneralLedgerEntity // { // RefType = planWithdrawEntity.RefType, // RefNo = planWithdrawEntity.RefNo, // // AccountingObjectId = buPlanReceiptEntity.AccountingObjectId, // //BankId = buPlanReceiptEntity.BankId, // // BudgetChapterCode = buPlanReceiptDetail.BudgetChapterCode, // ProjectId = buPlanDrawDetail.ProjectId, // BudgetSourceId = buPlanDrawDetail.BudgetSourceId, // Description = buPlanDrawDetail.Description, // RefDetailId = buPlanDrawDetail.RefDetailId, // ExchangeRate = planWithdrawEntity.ExchangeRate, // // ActivityId = buPlanReceiptDetail.ActivityId, // BudgetSubKindItemCode = buPlanDrawDetail.BudgetSubKindItemCode, // CurrencyCode = planWithdrawEntity.CurrencyCode, // BudgetKindItemCode = buPlanDrawDetail.BudgetKindItemCode, // RefId = planWithdrawEntity.RefId, // PostedDate = planWithdrawEntity.PostedDate, // //MethodDistributeId = buPlanReceiptDetail.MethodDistributeId, // //OrgRefNo = buPlanReceiptDetail.OrgRefNo, // // OrgRefDate = buPlanReceiptDetail.OrgRefDate, // BudgetItemCode = buPlanDrawDetail.BudgetItemCode, // ListItemId = buPlanDrawDetail.ListItemId, // BudgetSubItemCode = buPlanDrawDetail.BudgetSubItemCode, // BudgetDetailItemCode = buPlanDrawDetail.BudgetDetailItemCode, // //CashWithDrawTypeId = buPlanReceiptDetail.CashWithDrawTypeId, // //AccountNumber = buPlanDrawDetail.DebitAccount, // CorrespondingAccountNumber = buPlanDrawDetail.CreditAccount, // DebitAmount = buPlanDrawDetail.Amount, // DebitAmountOC = buPlanDrawDetail.AmountOC, // CreditAmount = 0, // CreditAmountOC = 0, // FundStructureId = buPlanDrawDetail.FundStructureId, // GeneralLedgerId = Guid.NewGuid().ToString(), // JournalMemo = planWithdrawEntity.JournalMemo, // RefDate = planWithdrawEntity.RefDate // }; // planWithdrawResponse.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity); // if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) // { // planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; // return planWithdrawResponse; // } ////insert lan 2 //generalLedgerEntity.GeneralLedgerId = Guid.NewGuid().ToString(); //generalLedgerEntity.AccountNumber = buPlanDrawDetail.CreditAccount; ////generalLedgerEntity.CorrespondingAccountNumber = buPlanDrawDetail.DebitAccount; //generalLedgerEntity.DebitAmount = 0; //generalLedgerEntity.DebitAmountOC = 0; //generalLedgerEntity.CreditAmount = buPlanDrawDetail.Amount; //generalLedgerEntity.CreditAmountOC = buPlanDrawDetail.AmountOC; //planWithdrawResponse.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity); if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } //} planWithdrawResponse.RefId = planWithdrawEntity.RefId; } if (planWithdrawResponse.Message != null) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; scope.Dispose(); return(planWithdrawResponse); } scope.Complete(); } return(planWithdrawResponse); } catch (Exception ex) { planWithdrawResponse.Message = ex.Message; return(planWithdrawResponse); } }
/// <summary> /// Inserts the ca planWithdraw. /// </summary> /// <param name="planWithdrawEntity">The planWithdraw entity.</param> /// <returns>BUPlanWithdrawResponse.</returns> public BUPlanWithdrawResponse InsertBUPlanWithdraw(BUPlanWithdrawEntity planWithdrawEntity) { var planWithdrawResponse = new BUPlanWithdrawResponse { Acknowledge = AcknowledgeType.Success }; try { if (planWithdrawEntity != null && !planWithdrawEntity.Validate()) { foreach (var error in planWithdrawEntity.ValidationErrors) { planWithdrawResponse.Message += error + Environment.NewLine; } planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } using (var scope = new TransactionScope()) { if (planWithdrawEntity != null) { //check ma trung var planWithdrawEntityExisted = BUPlanWithdrawDao.GetBUPlanWithdrawByRefNoRefType(planWithdrawEntity.RefNo.Trim(), planWithdrawEntity.RefType, planWithdrawEntity.PostedDate); if (planWithdrawEntityExisted != null && planWithdrawEntityExisted.PostedDate.Year == planWithdrawEntity.PostedDate.Year) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; planWithdrawResponse.Message = @"Số chứng từ '" + planWithdrawEntity.RefNo + @"' đã tồn tại!"; return(planWithdrawResponse); } planWithdrawEntity.RefId = Guid.NewGuid().ToString(); planWithdrawResponse.Message = BUPlanWithdrawDao.InsertBUPlanWithdraw(planWithdrawEntity); if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } foreach (var planWithdrawDetail in planWithdrawEntity.BUPlanWithdrawDetails) { planWithdrawDetail.RefId = planWithdrawEntity.RefId; planWithdrawDetail.RefDetailId = Guid.NewGuid().ToString(); if (!planWithdrawDetail.Validate()) { foreach (var error in planWithdrawDetail.ValidationErrors) { planWithdrawResponse.Message += error + Environment.NewLine; } planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } planWithdrawResponse.Message = BUPlanWithdrawDetailDao.InsertBUPlanWithdrawDetail(planWithdrawDetail); if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } #region Insert OriginalGeneralLedger var originalGeneralLedgerEntity = new OriginalGeneralLedgerEntity { OriginalGeneralLedgerId = Guid.NewGuid().ToString(), RefType = planWithdrawEntity.RefType, RefId = planWithdrawEntity.RefId, RefDetailId = planWithdrawDetail.RefDetailId, OrgRefDate = planWithdrawDetail.OrgRefDate, OrgRefNo = planWithdrawDetail.OrgRefNo, RefDate = planWithdrawEntity.RefDate, RefNo = planWithdrawEntity.RefNo, Amount = planWithdrawDetail.Amount, AmountOC = planWithdrawDetail.AmountOC, BudgetChapterCode = planWithdrawDetail.BudgetChapterCode, BudgetDetailItemCode = planWithdrawDetail.BudgetDetailItemCode, BudgetItemCode = planWithdrawDetail.BudgetItemCode, BudgetKindItemCode = planWithdrawDetail.BudgetKindItemCode, BudgetSourceId = planWithdrawDetail.BudgetSourceId, BudgetSubItemCode = planWithdrawDetail.BudgetSubItemCode, BudgetSubKindItemCode = planWithdrawDetail.BudgetSubKindItemCode, CreditAccount = planWithdrawDetail.CreditAccount, Description = planWithdrawDetail.Description, FundStructureId = planWithdrawDetail.FundStructureId, // TaxAmount = planWithdrawDetail.TaxAmount, JournalMemo = planWithdrawEntity.JournalMemo, ProjectId = planWithdrawDetail.ProjectId, PostedDate = planWithdrawEntity.PostedDate, CurrencyCode = planWithdrawEntity.CurrencyCode, ExchangeRate = planWithdrawEntity.ExchangeRate, }; planWithdrawResponse.Message = OriginalGeneralLedgerDao.InsertOriginalGeneralLedger(originalGeneralLedgerEntity); if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; return(planWithdrawResponse); } #endregion //// insert bang JourentryAccount //var jourentryAccount = journalEntryAccounts[i]; //jourentryAccount.RefId = planWithdrawDetail.RefId; //jourentryAccount.RefDetailId = iBUPlanWithdrawDetailId; //#region " jourentryAccount: thay đổi thông tin theo đối tượng Master" //int accountingObjectType = planWithdrawEntity.AccountingObjectType == null ? 0 : int.Parse(planWithdrawEntity.AccountingObjectType.ToString()); //switch (accountingObjectType) //{ // case 0: // jourentryAccount.VendorId = planWithdrawEntity.VendorId; // break; // case 1: // jourentryAccount.EmployeeId = planWithdrawEntity.EmployeeId; // break; // case 2: // jourentryAccount.AccountingObjectId = planWithdrawEntity.AccountingObjectId; // break; // case 3: // jourentryAccount.CustomerId = planWithdrawEntity.CustomerId; // break; //} ////LinhMC bổ sung trường hợp người dùng chọn đối tượng khác ở phần chi tiết mà không chọn ở phần thông tin chung. //if (jourentryAccount.AccountingObjectId == null) //{ // jourentryAccount.AccountingObjectId = planWithdrawDetail.AccountingObjectId; //} //#endregion //if (!jourentryAccount.Validate()) //{ // foreach (string error in jourentryAccount.ValidationErrors) // planWithdrawResponse.Message += error + Environment.NewLine; // planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; // return planWithdrawResponse; //} //JournalEntryAccountDao.InsertDoubleJournalEntryAccount(jourentryAccount); //i = i + 1; } //foreach (var buPlanDrawDetail in planWithdrawEntity.BUPlanWithdrawDetails) //{ // var generalLedgerEntity = new GeneralLedgerEntity // { // RefType = planWithdrawEntity.RefType, // RefNo = planWithdrawEntity.RefNo, // // AccountingObjectId = buPlanReceiptEntity.AccountingObjectId, // //BankId = buPlanReceiptEntity.BankId, // // BudgetChapterCode = buPlanReceiptDetail.BudgetChapterCode, // ProjectId = buPlanDrawDetail.ProjectId, // BudgetSourceId = buPlanDrawDetail.BudgetSourceId, // Description = buPlanDrawDetail.Description, // RefDetailId = buPlanDrawDetail.RefDetailId, // ExchangeRate = planWithdrawEntity.ExchangeRate, // // ActivityId = buPlanReceiptDetail.ActivityId, // BudgetSubKindItemCode = buPlanDrawDetail.BudgetSubKindItemCode, // CurrencyCode = planWithdrawEntity.CurrencyCode, // BudgetKindItemCode = buPlanDrawDetail.BudgetKindItemCode, // RefId = planWithdrawEntity.RefId, // PostedDate = planWithdrawEntity.PostedDate, // //MethodDistributeId = buPlanReceiptDetail.MethodDistributeId, // //OrgRefNo = buPlanReceiptDetail.OrgRefNo, // // OrgRefDate = buPlanReceiptDetail.OrgRefDate, // BudgetItemCode = buPlanDrawDetail.BudgetItemCode, // ListItemId = buPlanDrawDetail.ListItemId, // BudgetSubItemCode = buPlanDrawDetail.BudgetSubItemCode, // BudgetDetailItemCode = buPlanDrawDetail.BudgetDetailItemCode, // //CashWithDrawTypeId = buPlanReceiptDetail.CashWithDrawTypeId, // //AccountNumber = buPlanDrawDetail.DebitAccount, // CorrespondingAccountNumber = buPlanDrawDetail.CreditAccount, // DebitAmount = buPlanDrawDetail.Amount, // DebitAmountOC = buPlanDrawDetail.AmountOC, // CreditAmount = 0, // CreditAmountOC = 0, // FundStructureId = buPlanDrawDetail.FundStructureId, // GeneralLedgerId = Guid.NewGuid().ToString(), // JournalMemo = planWithdrawEntity.JournalMemo, // RefDate = planWithdrawEntity.RefDate // }; // planWithdrawResponse.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity); // if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) // { // planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; // return planWithdrawResponse; // } // //insert lan 2 // generalLedgerEntity.GeneralLedgerId = Guid.NewGuid().ToString(); // generalLedgerEntity.AccountNumber = buPlanDrawDetail.CreditAccount; // //generalLedgerEntity.CorrespondingAccountNumber = buPlanDrawDetail.DebitAccount; // generalLedgerEntity.DebitAmount = 0; // generalLedgerEntity.DebitAmountOC = 0; // generalLedgerEntity.CreditAmount = buPlanDrawDetail.Amount; // generalLedgerEntity.CreditAmountOC = buPlanDrawDetail.AmountOC; // planWithdrawResponse.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity); // if (!string.IsNullOrEmpty(planWithdrawResponse.Message)) // { // planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; // return planWithdrawResponse; // } //} planWithdrawResponse.RefId = planWithdrawEntity.RefId; // Kiểm tra đã tồn tại trong bảng Account Balance //foreach (var accountBalanceEntity in accountBalances) //{ // var obAccoutBalanceExit = AccountBalanceDao.GetExitsAccountBalance(accountBalanceEntity); // if (obAccoutBalanceExit != null) // { // // cập nhật bên TK nợ // if (accountBalanceEntity.MovementCreditAmountOC == 0) // { // obAccoutBalanceExit.ExchangeRate = accountBalanceEntity.ExchangeRate; // obAccoutBalanceExit.MovementDebitAmountExchange = // obAccoutBalanceExit.MovementDebitAmountExchange + // accountBalanceEntity.MovementDebitAmountExchange; // obAccoutBalanceExit.MovementDebitAmountOC = // obAccoutBalanceExit.MovementDebitAmountOC + // accountBalanceEntity.MovementDebitAmountOC; // AccountBalanceDao.UpdateAccountBalance(obAccoutBalanceExit); // } // else // { // obAccoutBalanceExit.ExchangeRate = accountBalanceEntity.ExchangeRate; // obAccoutBalanceExit.MovementCreditAmountExchange = // obAccoutBalanceExit.MovementCreditAmountExchange + // accountBalanceEntity.MovementCreditAmountExchange; // obAccoutBalanceExit.MovementCreditAmountOC = // obAccoutBalanceExit.MovementCreditAmountOC + // accountBalanceEntity.MovementCreditAmountOC; // AccountBalanceDao.UpdateAccountBalance(obAccoutBalanceExit); // } // } // else // { // AccountBalanceDao.InsertAccountBalance(accountBalanceEntity); // } //} //var autoNumber = AutoNumberDao.GetAutoNumberByRefType(planWithdrawEntity.RefType); //autoNumber.Value += 1; //if (planWithdrawEntity.RefType != 600)//Khong cap nhat khi la chung tu luong //{ // planWithdrawResponse.Message = AutoNumberDao.UpdateAutoNumber(autoNumber); //} } if (planWithdrawResponse.Message != null) { planWithdrawResponse.Acknowledge = AcknowledgeType.Failure; scope.Dispose(); return(planWithdrawResponse); } scope.Complete(); } return(planWithdrawResponse); } catch (Exception ex) { planWithdrawResponse.Message = ex.Message; return(planWithdrawResponse); } }
/// <summary> /// Updates the cash entity. /// </summary> /// <param name="receipt">The receipt.</param> /// <returns>System.String.</returns> public string UpdateBUPlanWithdraw(BUPlanWithdrawEntity receipt) { const string procedures = @"uspUpdate_BUPlanWithdraw"; return(Db.Update(procedures, true, Take(receipt))); }