/// <summary>
 /// Takes the specified general ledger entity.
 /// </summary>
 /// <param name="generalLedgerEntity">The general ledger entity.</param>
 /// <returns>System.Object[].</returns>
 private object[] Take(GeneralLedgerEntity generalLedgerEntity)
 {
     return(new object[]
     {
         "@GeneralLedgerID", generalLedgerEntity.GeneralLedgerId,
         "@RefID", generalLedgerEntity.RefId,
         "@RefDetailID", generalLedgerEntity.RefDetailId,
         "@RefType", generalLedgerEntity.RefType,
         "@RefNo", generalLedgerEntity.RefNo,
         "@CurrencyCode", generalLedgerEntity.CurrencyCode,
         "@ExchangeRate", generalLedgerEntity.ExchangeRate,
         "@RefDate", generalLedgerEntity.RefDate,
         "@PostedDate", generalLedgerEntity.PostedDate,
         "@InvNo", generalLedgerEntity.InvNo,
         "@InvDate", generalLedgerEntity.InvDate,
         "@AccountNumber", generalLedgerEntity.AccountNumber,
         "@CorrespondingAccountNumber", generalLedgerEntity.CorrespondingAccountNumber,
         "@DebitAmountOC", generalLedgerEntity.DebitAmountOC,
         "@DebitAmount", generalLedgerEntity.DebitAmount,
         "@CreditAmountOC", generalLedgerEntity.CreditAmountOC,
         "@CreditAmount", generalLedgerEntity.CreditAmount,
         "@JournalMemo", generalLedgerEntity.JournalMemo,
         "@Description", generalLedgerEntity.Description,
         "@BudgetSourceID", generalLedgerEntity.BudgetSourceId,
         "@BudgetChapterCode", generalLedgerEntity.BudgetChapterCode,
         "@BudgetKindItemCode", generalLedgerEntity.BudgetKindItemCode,
         "@BudgetSubKindItemCode", generalLedgerEntity.BudgetSubKindItemCode,
         "@BudgetItemCode", generalLedgerEntity.BudgetItemCode,
         "@BudgetSubItemCode", generalLedgerEntity.BudgetSubItemCode,
         "@MethodDistributeID", generalLedgerEntity.MethodDistributeId,
         "@CashWithDrawTypeID", generalLedgerEntity.CashWithDrawTypeId,
         "@AccountingObjectID", generalLedgerEntity.AccountingObjectId,
         "@ActivityID", generalLedgerEntity.ActivityId,
         "@ProjectID", generalLedgerEntity.ProjectId,
         "@ListItemID", generalLedgerEntity.ListItemId,
         "@Approved", generalLedgerEntity.Approved,
         "@BudgetDetailItemCode", generalLedgerEntity.BudgetDetailItemCode,
         "@BankId", generalLedgerEntity.BankId,
         "@IsReadjust", generalLedgerEntity.IsReadjust,
         "@OrgRefNo", generalLedgerEntity.OrgRefNo,
         "@OrgRefDate", generalLedgerEntity.OrgRefDate,
         "@FundStructureID", generalLedgerEntity.FundStructureId,
         "@SortOrder", generalLedgerEntity.SortOrder,
         "@BudgetProvideCode", generalLedgerEntity.BudgetProvideCode,
         "@BudgetExpenseID", generalLedgerEntity.BudgetExpenseId,
         "@ContractID", generalLedgerEntity.ContractId,
         "@CapitalPlanID", generalLedgerEntity.CapitalPlanId,
     });
 }
        /// <summary>
        /// Inserts the general ledger.
        /// </summary>
        /// <param name="generalLedgerEntity">The general ledger entity.</param>
        /// <returns>System.Int32.</returns>
        public string InsertGeneralLedger(GeneralLedgerEntity generalLedgerEntity)
        {
            const string procedures = @"uspInsert_GeneralLedger";

            return(Db.Insert(procedures, true, Take(generalLedgerEntity)));
        }
Example #3
0
        public OpeningAccountEntryReponse UpdateOpeningAccountEntry(
            IList <OpeningAccountEntryEntity> openingAccountEntryDetails)
        {
            var openingAccountEntryResponse = new OpeningAccountEntryReponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                using (var scope = new TransactionScope())
                {
                    if (openingAccountEntryDetails != null && openingAccountEntryDetails.Count > 0)
                    {
                        openingAccountEntryResponse.Message =
                            OpeningAccountEntryDao.DeleteOpeningAccountEntryByAccountNumber(
                                openingAccountEntryDetails.First().AccountNumber);

                        // Xóa bảng GeneralLedger
                        openingAccountEntryResponse.Message =
                            //GeneralLedgerDao.DeleteGeneralLedger(openingAccountEntry.AccountNumber, openingAccountEntry.RefType);
                            GeneralLedgerDao.DeleteGeneralLedger(openingAccountEntryDetails.First().AccountNumber,
                                                                 openingAccountEntryDetails.First().RefType);
                        if (openingAccountEntryResponse.Message != null)
                        {
                            openingAccountEntryResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(openingAccountEntryResponse);
                        }
                        foreach (var openingAccountEntry in openingAccountEntryDetails)
                        {
                            openingAccountEntry.RefId             = Guid.NewGuid().ToString();
                            openingAccountEntry.BudgetChapterCode = openingAccountEntry.BudgetChapterCode == null ? null : openingAccountEntry.BudgetChapterCode;

                            if (!openingAccountEntry.Validate())
                            {
                                foreach (string error in openingAccountEntry.ValidationErrors)
                                {
                                    openingAccountEntryResponse.Message += error + Environment.NewLine;
                                }
                                openingAccountEntryResponse.Acknowledge = AcknowledgeType.Failure;
                                return(openingAccountEntryResponse);
                            }
                            openingAccountEntryResponse.Message =
                                OpeningAccountEntryDao.InsertOpeningAccountEntry(openingAccountEntry);
                            if (!string.IsNullOrEmpty(openingAccountEntryResponse.Message))
                            {
                                openingAccountEntryResponse.Acknowledge = AcknowledgeType.Failure;
                                return(openingAccountEntryResponse);
                            }

                            #region Insert Ledger

                            // Insert số tiền theo tính chất của tài khoản
                            // Nếu tài khoản có tính chất dư nợ: Insert số tiền vào cột DebitAmount
                            // Nếu tài khoản có tính chất dư có: Insert số tiền vào cột CreditAmount

                            var account = AccountDao.GetAccountByAccountNumber(openingAccountEntry.AccountNumber);

                            var accountCategoryKind = account.AccountCategoryKind;

                            // insert bang GeneralLedger

                            if (openingAccountEntry.AccountNumber != null)
                            {
                                var generalLedgerEntity = new GeneralLedgerEntity
                                {
                                    RefType               = openingAccountEntry.RefType,
                                    RefNo                 = "OPN",
                                    CurrencyCode          = String.IsNullOrEmpty(openingAccountEntry.CurrencyCode)? "VND" :openingAccountEntry.CurrencyCode,
                                    ExchangeRate          = openingAccountEntry.ExchangeRate,
                                    AccountingObjectId    = openingAccountEntry.AccountingObjectId,
                                    BudgetChapterCode     = openingAccountEntry.BudgetChapterCode,
                                    ProjectId             = openingAccountEntry.ProjectId,
                                    BudgetSourceId        = openingAccountEntry.BudgetSourceId,
                                    RefDetailId           = openingAccountEntry.RefId,
                                    ActivityId            = openingAccountEntry.ActivityId,
                                    BudgetSubKindItemCode = openingAccountEntry.BudgetSubKindItemCode,
                                    BudgetKindItemCode    = openingAccountEntry.BudgetKindItemCode,
                                    RefId                 = openingAccountEntry.RefId,
                                    PostedDate            = openingAccountEntry.PostedDate,
                                    MethodDistributeId    = openingAccountEntry.MethodDistributeId,
                                    BudgetItemCode        = openingAccountEntry.BudgetItemCode,
                                    BudgetSubItemCode     = openingAccountEntry.BudgetSubItemCode,
                                    BudgetDetailItemCode  = openingAccountEntry.BudgetDetailItemCode,
                                    CashWithDrawTypeId    = openingAccountEntry.CashWithdrawTypeId,
                                    AccountNumber         = openingAccountEntry.AccountNumber,
                                    DebitAmount           = openingAccountEntry.DebitAmount,
                                    DebitAmountOC         = openingAccountEntry.DebitAmountOC,
                                    CreditAmount          = openingAccountEntry.CreditAmount,
                                    CreditAmountOC        = openingAccountEntry.CreditAmountOC,
                                    FundStructureId       = openingAccountEntry.FundStructureId,
                                    GeneralLedgerId       = Guid.NewGuid().ToString(),
                                    RefDate               = openingAccountEntry.PostedDate,
                                    BudgetExpenseId       = openingAccountEntry.BudgetExpenseId,
                                    BankId                = openingAccountEntry.BankId,
                                    ContractId            = openingAccountEntry.ContractId,
                                    CapitalPlanId         = openingAccountEntry.CapitalPlanId
                                };
                                openingAccountEntryResponse.Message =
                                    GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity);
                                if (!string.IsNullOrEmpty(openingAccountEntryResponse.Message))
                                {
                                    openingAccountEntryResponse.Acknowledge = AcknowledgeType.Failure;
                                    return(openingAccountEntryResponse);
                                }

                                #endregion

                                #region Insert OriginalGeneralLedger

                                // Tạm thời chưa dùng đến đoạn insert vào bảng này

                                //var originalGeneralLedgerEntity = new OriginalGeneralLedgerEntity
                                //{
                                //    OriginalGeneralLedgerId = Guid.NewGuid().ToString(),
                                //    RefType = openingAccountEntry.RefType,
                                //    RefId = openingAccountEntry.RefId,
                                //    CurrencyCode = openingAccountEntry.CurrencyId,
                                //    ExchangeRate = openingAccountEntry.ExchangeRate,
                                //    RefDetailId = openingAccountEntry.RefId,
                                //    RefDate = openingAccountEntry.PostedDate,
                                //    RefNo = "OPN",
                                //    AccountingObjectId = openingAccountEntry.AccountingObjectId,
                                //    ActivityId = openingAccountEntry.ActivityId,
                                //    Amount = openingAccountEntry.DebitAmount,
                                //    AmountOC = openingAccountEntry.DebitAmountOC,
                                //    Approved = openingAccountEntry.Approved,
                                //    BudgetChapterCode = openingAccountEntry.BudgetChapterCode,
                                //    BudgetDetailItemCode = openingAccountEntry.BudgetDetailItemCode,
                                //    BudgetItemCode = openingAccountEntry.BudgetItemCode,
                                //    BudgetKindItemCode = openingAccountEntry.BudgetKindItemCode,
                                //    BudgetSourceId = openingAccountEntry.BudgetSourceId,
                                //    BudgetSubItemCode = openingAccountEntry.BudgetSubItemCode,
                                //    BudgetSubKindItemCode = openingAccountEntry.BudgetSubKindItemCode,
                                //    CashWithDrawTypeId = openingAccountEntry.CashWithdrawTypeId,
                                //    DebitAccount = openingAccountEntry.AccountNumber,
                                //    FundStructureId = openingAccountEntry.FundStructureId,
                                //    ProjectActivityId = openingAccountEntry.ProjectActivityId,
                                //    MethodDistributeId = openingAccountEntry.MethodDistributeId,
                                //    ProjectId = openingAccountEntry.ProjectId,
                                //    PostedDate = openingAccountEntry.PostedDate,
                                //};
                                //openingAccountEntryResponse.Message =
                                //    OriginalGeneralLedgerDao.InsertOriginalGeneralLedger(originalGeneralLedgerEntity);
                                //if (!string.IsNullOrEmpty(openingAccountEntryResponse.Message))
                                //{
                                //    openingAccountEntryResponse.Acknowledge = AcknowledgeType.Failure;
                                //    return openingAccountEntryResponse;
                                //}

                                #endregion
                            }

                            openingAccountEntryResponse.RefId = openingAccountEntryDetails.First().RefId;
                        }
                        scope.Complete();
                    }
                }
                return(openingAccountEntryResponse);
            }

            catch (Exception ex)
            {
                openingAccountEntryResponse.Message = ex.Message;
                return(openingAccountEntryResponse);
            }
        }
Example #4
0
        public BUPlanAdjustmentResponse InsertBuPlanAdjustment(BUPlanAdjustmentEntity buPlanAdjustment)
        {
            var buPlanAdjustmentResponse = new BUPlanAdjustmentResponse {
                Acknowledge = AcknowledgeType.Success
            };


            if (buPlanAdjustment != null && !buPlanAdjustment.Validate())
            {
                foreach (var error in buPlanAdjustment.ValidationErrors)
                {
                    buPlanAdjustmentResponse.Message += error + Environment.NewLine;
                }
                buPlanAdjustmentResponse.Acknowledge = AcknowledgeType.Failure;
                return(buPlanAdjustmentResponse);
            }

            using (var scope = new TransactionScope())
            {
                if (buPlanAdjustment != null)
                {
                    var buPlanReceiptForExisting = BuPlanAdjustmentDao.GetBuPlanAdjustmentEntitybyRefNo(buPlanAdjustment.RefNo.Trim(), buPlanAdjustment.PostedDate);
                    if (buPlanReceiptForExisting != null && buPlanReceiptForExisting.PostedDate.Year == buPlanAdjustment.PostedDate.Year)
                    {
                        buPlanAdjustmentResponse.Acknowledge = AcknowledgeType.Failure;
                        buPlanAdjustmentResponse.Message     = @"Số chứng từ '" + buPlanAdjustment.RefNo.Trim() + @"' đã tồn tại!";
                        return(buPlanAdjustmentResponse);
                    }

                    buPlanAdjustment.RefId           = Guid.NewGuid().ToString();
                    buPlanAdjustmentResponse.Message = BuPlanAdjustmentDao.InsertBUPlanAdjustment(buPlanAdjustment);

                    if (!string.IsNullOrEmpty(buPlanAdjustmentResponse.Message))
                    {
                        buPlanAdjustmentResponse.Acknowledge = AcknowledgeType.Failure;
                        return(buPlanAdjustmentResponse);
                    }

                    foreach (var buPlanAdjustmentDetail in buPlanAdjustment.BUPlanAdjustmentDetails)
                    {
                        buPlanAdjustmentDetail.RefId       = buPlanAdjustment.RefId;
                        buPlanAdjustmentDetail.RefDetailId = Guid.NewGuid().ToString();
                        if (!buPlanAdjustmentDetail.Validate())
                        {
                            foreach (var error in buPlanAdjustmentDetail.ValidationErrors)
                            {
                                buPlanAdjustmentResponse.Message += error + Environment.NewLine;
                            }
                            buPlanAdjustmentResponse.Acknowledge = AcknowledgeType.Failure;
                            return(buPlanAdjustmentResponse);
                        }
                        buPlanAdjustmentResponse.Message =
                            BuPlanAdjustmentDetailDao.InsertBUPlanAdjustmentDetail(buPlanAdjustmentDetail);
                        if (!string.IsNullOrEmpty(buPlanAdjustmentResponse.Message))
                        {
                            buPlanAdjustmentResponse.Acknowledge = AcknowledgeType.Failure;
                            return(buPlanAdjustmentResponse);
                        }

                        #region Insert to AccountBalance

                        InsertAccountBalance(buPlanAdjustment, buPlanAdjustmentDetail);

                        #endregion

                        #region Insert into GeneralLedger
                        if (buPlanAdjustmentDetail.DebitAccount != null)
                        {
                            var generalLedgerEntity = new GeneralLedgerEntity
                            {
                                RefType               = buPlanAdjustment.RefType,
                                RefNo                 = buPlanAdjustment.RefNo,
                                ProjectId             = buPlanAdjustmentDetail.ProjectId,
                                ActivityId            = buPlanAdjustmentDetail.ActivityId,
                                BudgetSourceId        = buPlanAdjustmentDetail.BudgetSourceId,
                                Description           = buPlanAdjustmentDetail.ItemName,
                                RefDetailId           = buPlanAdjustmentDetail.RefDetailId,
                                ExchangeRate          = buPlanAdjustment.ExchangeRate,
                                BudgetSubKindItemCode = buPlanAdjustmentDetail.BudgetSubKindItemCode,
                                CurrencyCode          = buPlanAdjustment.CurrencyCode,
                                BudgetKindItemCode    = buPlanAdjustmentDetail.BudgetKindItemCode,
                                RefId                 = buPlanAdjustment.RefId,
                                PostedDate            = buPlanAdjustment.PostedDate,
                                BudgetItemCode        = buPlanAdjustmentDetail.BudgetItemCode,
                                ListItemId            = buPlanAdjustmentDetail.ListItemId,
                                BudgetSubItemCode     = buPlanAdjustmentDetail.BudgetSubItemCode,
                                BudgetDetailItemCode  = buPlanAdjustmentDetail.BudgetDetailItemCode,
                                AccountNumber         = buPlanAdjustmentDetail.DebitAccount,
                                DebitAmount           = (buPlanAdjustmentDetail.DebitAccount == null ? 0 : buPlanAdjustmentDetail.AdjustmentAmount) / (buPlanAdjustment.ExchangeRate == null || buPlanAdjustment.ExchangeRate == 0 ? 1 : buPlanAdjustment.ExchangeRate),
                                DebitAmountOC         = buPlanAdjustmentDetail.DebitAccount == null ? 0 : buPlanAdjustmentDetail.AdjustmentAmount,
                                CreditAmount          = 0,
                                CreditAmountOC        = 0,
                                FundStructureId       = buPlanAdjustmentDetail.FundStructureId,
                                GeneralLedgerId       = Guid.NewGuid().ToString(),
                                JournalMemo           = buPlanAdjustment.JournalMemo,
                                RefDate               = buPlanAdjustment.RefDate,
                                SortOrder             = buPlanAdjustmentDetail.SortOrder,
                                CashWithDrawTypeId    = 28,
                                ContractId            = buPlanAdjustmentDetail.ContractId,
                                CapitalPlanId         = buPlanAdjustmentDetail.CapitalPlanId,
                                BudgetChapterCode     = buPlanAdjustmentDetail.BudgetChapterCode
                            };

                            buPlanAdjustmentResponse.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity);

                            if (!string.IsNullOrEmpty(buPlanAdjustmentResponse.Message))
                            {
                                buPlanAdjustmentResponse.Acknowledge = AcknowledgeType.Failure;
                                return(buPlanAdjustmentResponse);
                            }
                        }
                        #endregion

                        #region Insert OriginalGeneralLedger
                        var originalGeneralLedgerEntity = new OriginalGeneralLedgerEntity
                        {
                            OriginalGeneralLedgerId = Guid.NewGuid().ToString(),
                            RefType               = buPlanAdjustment.RefType,
                            RefId                 = buPlanAdjustment.RefId,
                            RefDetailId           = buPlanAdjustmentDetail.RefDetailId,
                            RefDate               = buPlanAdjustment.RefDate,
                            RefNo                 = buPlanAdjustment.RefNo,
                            Amount                = buPlanAdjustmentDetail.AdjustmentAmount,
                            AmountOC              = buPlanAdjustmentDetail.AdjustmentAmount,
                            BankId                = buPlanAdjustmentDetail.BankAccount,
                            BudgetChapterCode     = buPlanAdjustmentDetail.BudgetChapterCode,
                            BudgetDetailItemCode  = buPlanAdjustmentDetail.BudgetDetailItemCode,
                            BudgetItemCode        = buPlanAdjustmentDetail.BudgetItemCode,
                            BudgetKindItemCode    = buPlanAdjustmentDetail.BudgetKindItemCode,
                            BudgetSourceId        = buPlanAdjustmentDetail.BudgetSourceId,
                            BudgetSubItemCode     = buPlanAdjustmentDetail.BudgetSubItemCode,
                            BudgetSubKindItemCode = buPlanAdjustmentDetail.BudgetSubKindItemCode,
                            DebitAccount          = buPlanAdjustmentDetail.DebitAccount,
                            Description           = buPlanAdjustmentDetail.ItemName,
                            FundStructureId       = buPlanAdjustmentDetail.FundStructureId,
                            JournalMemo           = buPlanAdjustment.JournalMemo,
                            ProjectId             = buPlanAdjustmentDetail.ProjectId,
                            ActivityId            = buPlanAdjustmentDetail.ActivityId,
                            //ToBankId = buPlanAdjustmentDetail.BankAccount,
                            SortOrder          = buPlanAdjustmentDetail.SortOrder,
                            PostedDate         = buPlanAdjustment.PostedDate,
                            CurrencyCode       = buPlanAdjustment.CurrencyCode,
                            ExchangeRate       = buPlanAdjustment.ExchangeRate,
                            CashWithDrawTypeId = 28,
                            ContractId         = buPlanAdjustmentDetail.ContractId,
                        };
                        buPlanAdjustmentResponse.Message = OriginalGeneralLedgerDao.InsertOriginalGeneralLedger(originalGeneralLedgerEntity);
                        if (!string.IsNullOrEmpty(buPlanAdjustmentResponse.Message))
                        {
                            buPlanAdjustmentResponse.Acknowledge = AcknowledgeType.Failure;
                            return(buPlanAdjustmentResponse);
                        }

                        #endregion
                    }

                    if (buPlanAdjustmentResponse.Message != null)
                    {
                        buPlanAdjustmentResponse.Acknowledge = AcknowledgeType.Failure;
                        scope.Dispose();
                        return(buPlanAdjustmentResponse);
                    }
                    buPlanAdjustmentResponse.RefId = buPlanAdjustment.RefId;
                    scope.Complete();
                }

                return(buPlanAdjustmentResponse);
            }
        }
Example #5
0
        /// <summary>
        ///     Inserts the ba deposit.
        /// </summary>
        /// <param name="fAIncrementDecrementEntity">The b a deposit entity.</param>
        /// <returns></returns>
        public FAIncrementDecrementResponse InsertFAIncrementDecrement(
            FAIncrementDecrementEntity fAIncrementDecrementEntity)
        {
            var response = new FAIncrementDecrementResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!fAIncrementDecrementEntity.Validate())
                {
                    foreach (var error in fAIncrementDecrementEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                using (var scope = new TransactionScope())
                {
                    var fAIncrementDecrementByRefNo =
                        FAIncrementDecrementDao.GetFAIncrementDecrementByRefNo(fAIncrementDecrementEntity.RefNo, fAIncrementDecrementEntity.PostedDate);
                    if (fAIncrementDecrementByRefNo != null && fAIncrementDecrementByRefNo.PostedDate.Year == fAIncrementDecrementEntity.PostedDate.Year)
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        response.Message     = "Mã chứng từ đã tồn tại!";
                        return(response);
                    }
                    fAIncrementDecrementEntity.RefId = Guid.NewGuid().ToString();
                    response.Message = FAIncrementDecrementDao.InsertFAIncrementDecrement(fAIncrementDecrementEntity);
                    if (!string.IsNullOrEmpty(response.Message))
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        return(response);
                    }

                    #region insert FAIncrementDecrementDetails

                    //Tạo biến để xác định tài sản đã có không insert vào FixedAssetLedger entity thành dòng mới
                    var fixedAssetId = "";
                    if (fAIncrementDecrementEntity.FAIncrementDecrementDetails != null)
                    {
                        foreach (var fAIncrementDecrementDetailEntity in fAIncrementDecrementEntity.FAIncrementDecrementDetails)
                        {
                            fAIncrementDecrementDetailEntity.RefDetailId = Guid.NewGuid().ToString();
                            fAIncrementDecrementDetailEntity.RefId       = fAIncrementDecrementEntity.RefId;
                            response.Message =
                                FAIncrementDecrementDetailDao.InsertFAIncrementDecrementDetail(fAIncrementDecrementDetailEntity);
                            if (!string.IsNullOrEmpty(response.Message))
                            {
                                response.Acknowledge = AcknowledgeType.Failure;
                                return(response);
                            }

                            #region insert bang GeneralLedger

                            if (fAIncrementDecrementDetailEntity.DebitAccount != null && fAIncrementDecrementDetailEntity.CreditAccount != null)
                            {
                                var generalLedgerEntity = new GeneralLedgerEntity
                                {
                                    RefType                    = fAIncrementDecrementEntity.RefType,
                                    RefNo                      = fAIncrementDecrementEntity.RefNo,
                                    ProjectId                  = fAIncrementDecrementDetailEntity.ProjectId,
                                    BudgetSourceId             = fAIncrementDecrementDetailEntity.BudgetSourceId,
                                    Description                = fAIncrementDecrementDetailEntity.Description,
                                    RefDetailId                = fAIncrementDecrementDetailEntity.RefDetailId,
                                    ExchangeRate               = 1,
                                    BudgetSubKindItemCode      = fAIncrementDecrementDetailEntity.BudgetSubKindItemCode,
                                    CurrencyCode               = "VND",
                                    BudgetKindItemCode         = fAIncrementDecrementDetailEntity.BudgetKindItemCode,
                                    RefId                      = fAIncrementDecrementEntity.RefId,
                                    PostedDate                 = fAIncrementDecrementEntity.PostedDate,
                                    BudgetItemCode             = fAIncrementDecrementDetailEntity.BudgetItemCode,
                                    ListItemId                 = fAIncrementDecrementDetailEntity.ListItemId,
                                    BudgetSubItemCode          = fAIncrementDecrementDetailEntity.BudgetSubItemCode,
                                    BudgetDetailItemCode       = fAIncrementDecrementDetailEntity.BudgetDetailItemCode,
                                    AccountNumber              = fAIncrementDecrementDetailEntity.DebitAccount,
                                    CorrespondingAccountNumber = fAIncrementDecrementDetailEntity.CreditAccount,
                                    DebitAmount                =
                                        fAIncrementDecrementDetailEntity.DebitAccount == null
                                            ? 0
                                            : fAIncrementDecrementDetailEntity.Amount,
                                    DebitAmountOC =
                                        fAIncrementDecrementDetailEntity.DebitAccount == null
                                            ? 0
                                            : fAIncrementDecrementDetailEntity.Amount,
                                    CreditAmount       = 0,
                                    CreditAmountOC     = 0,
                                    FundStructureId    = fAIncrementDecrementDetailEntity.FundStructureId,
                                    GeneralLedgerId    = Guid.NewGuid().ToString(),
                                    JournalMemo        = fAIncrementDecrementEntity.JournalMemo,
                                    RefDate            = fAIncrementDecrementEntity.RefDate,
                                    SortOrder          = fAIncrementDecrementDetailEntity.SortOrder,
                                    AccountingObjectId = fAIncrementDecrementDetailEntity.AccountingObjectId,
                                };
                                response.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity);
                                if (!string.IsNullOrEmpty(response.Message))
                                {
                                    response.Acknowledge = AcknowledgeType.Failure;
                                    return(response);
                                }
                                generalLedgerEntity.GeneralLedgerId            = Guid.NewGuid().ToString();
                                generalLedgerEntity.AccountNumber              = fAIncrementDecrementDetailEntity.CreditAccount;
                                generalLedgerEntity.CorrespondingAccountNumber = fAIncrementDecrementDetailEntity.DebitAccount;
                                generalLedgerEntity.DebitAmount    = 0;
                                generalLedgerEntity.DebitAmountOC  = 0;
                                generalLedgerEntity.CreditAmount   = fAIncrementDecrementDetailEntity.Amount;
                                generalLedgerEntity.CreditAmountOC = fAIncrementDecrementDetailEntity.Amount;
                                response.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity);
                                if (!string.IsNullOrEmpty(response.Message))
                                {
                                    response.Acknowledge = AcknowledgeType.Failure;
                                    return(response);
                                }
                            }
                            else
                            {
                                var generalLedgerEntity = new GeneralLedgerEntity
                                {
                                    RefType               = fAIncrementDecrementEntity.RefType,
                                    RefNo                 = fAIncrementDecrementEntity.RefNo,
                                    ProjectId             = fAIncrementDecrementDetailEntity.ProjectId,
                                    BudgetSourceId        = fAIncrementDecrementDetailEntity.BudgetSourceId,
                                    Description           = fAIncrementDecrementDetailEntity.Description,
                                    RefDetailId           = fAIncrementDecrementDetailEntity.RefDetailId,
                                    ExchangeRate          = 1,
                                    BudgetSubKindItemCode = fAIncrementDecrementDetailEntity.BudgetSubKindItemCode,
                                    CurrencyCode          = "VND",
                                    BudgetKindItemCode    = fAIncrementDecrementDetailEntity.BudgetKindItemCode,
                                    RefId                 = fAIncrementDecrementEntity.RefId,
                                    PostedDate            = fAIncrementDecrementEntity.PostedDate,
                                    BudgetItemCode        = fAIncrementDecrementDetailEntity.BudgetItemCode,
                                    ListItemId            = fAIncrementDecrementDetailEntity.ListItemId,
                                    BudgetSubItemCode     = fAIncrementDecrementDetailEntity.BudgetSubItemCode,
                                    BudgetDetailItemCode  = fAIncrementDecrementDetailEntity.BudgetDetailItemCode,
                                    AccountNumber         = fAIncrementDecrementDetailEntity.DebitAccount ?? fAIncrementDecrementDetailEntity.CreditAccount,
                                    DebitAmount           =
                                        fAIncrementDecrementDetailEntity.DebitAccount == null
                                            ? 0
                                            : fAIncrementDecrementDetailEntity.Amount,
                                    DebitAmountOC =
                                        fAIncrementDecrementDetailEntity.DebitAccount == null
                                            ? 0
                                            : fAIncrementDecrementDetailEntity.Amount,
                                    CreditAmount    = 0,
                                    CreditAmountOC  = 0,
                                    FundStructureId = fAIncrementDecrementDetailEntity.FundStructureId,
                                    GeneralLedgerId = Guid.NewGuid().ToString(),
                                    JournalMemo     = fAIncrementDecrementEntity.JournalMemo,
                                    RefDate         = fAIncrementDecrementEntity.RefDate,
                                    SortOrder       = fAIncrementDecrementDetailEntity.SortOrder
                                };
                                response.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity);
                                if (!string.IsNullOrEmpty(response.Message))
                                {
                                    response.Acknowledge = AcknowledgeType.Failure;
                                    return(response);
                                }
                            }

                            #endregion

                            #region Insert FixedAssetLedger
                            // insert bang GeneralLedger
                            //1 tài sản lưu thành 1 dòng, số tiền = tổng số tiền của các dòng cùng tài sản
                            if (fAIncrementDecrementDetailEntity.FixedAssetId != null)
                            {
                                var totalAmount = (from f in fAIncrementDecrementEntity.FAIncrementDecrementDetails where f.FixedAssetId == fAIncrementDecrementDetailEntity.FixedAssetId select f).ToList();
                                if (fixedAssetId != fAIncrementDecrementDetailEntity.FixedAssetId)
                                {
                                    //get fixedAssetInfo
                                    var fixedAssetEntity = FixedAssetDao.GetFixedAssetById(fAIncrementDecrementDetailEntity.FixedAssetId);

                                    var fixedAssetLedgerEntity = new FixedAssetLedgerEntity
                                    {
                                        FixedAssetLedgerId = Guid.NewGuid().ToString(),
                                        RefId                    = fAIncrementDecrementEntity.RefId,
                                        RefType                  = fAIncrementDecrementEntity.RefType,
                                        RefNo                    = fAIncrementDecrementEntity.RefNo,
                                        RefDate                  = fAIncrementDecrementEntity.RefDate,
                                        PostedDate               = fAIncrementDecrementEntity.PostedDate,
                                        FixedAssetId             = fAIncrementDecrementDetailEntity.FixedAssetId,
                                        DepartmentId             = fAIncrementDecrementDetailEntity.DepartmentId,
                                        LifeTime                 = fixedAssetEntity.LifeTime,
                                        AnnualDepreciationRate   = fixedAssetEntity.DepreciationRate,
                                        AnnualDepreciationAmount = fixedAssetEntity.PeriodDepreciationAmount,
                                        OrgPriceAccount          = null,
                                        OrgPriceDebitAmount      = fAIncrementDecrementDetailEntity.DebitAccount.StartsWith("211") || fAIncrementDecrementDetailEntity.DebitAccount.StartsWith("213") ? totalAmount.Select(c => c.Amount).Sum() : 0,
                                        OrgPriceCreditAmount     = fAIncrementDecrementDetailEntity.DebitAccount.StartsWith("211") || fAIncrementDecrementDetailEntity.DebitAccount.StartsWith("213") ? 0 : totalAmount.Select(c => c.Amount).Sum(),
                                        DepreciationAccount      = null,
                                        DepreciationDebitAmount  = fAIncrementDecrementDetailEntity.DebitAccount.StartsWith("214") ? fixedAssetEntity.AccumDepreciationAmount + fixedAssetEntity.AccumDevaluationAmount : 0,
                                        DepreciationCreditAmount = fAIncrementDecrementDetailEntity.DebitAccount.StartsWith("214") ? 0 : fixedAssetEntity.AccumDepreciationAmount + fixedAssetEntity.AccumDevaluationAmount,
                                        CapitalAccount           = fixedAssetEntity.CapitalAccount,
                                        CapitalDebitAmount       = 0,
                                        CapitalCreditAmount      = 0,
                                        Quantity                 = (decimal)fAIncrementDecrementDetailEntity.Quantity,// fixedAssetEntity.Quantity,
                                        //Quantity = fixedAssetEntity.Quantity,
                                        JournalMemo             = fAIncrementDecrementEntity.JournalMemo,
                                        Description             = fAIncrementDecrementDetailEntity.Description,
                                        RemainingLifeTime       = fixedAssetEntity.RemainingLifeTime,
                                        EndYear                 = fixedAssetEntity.EndYear,
                                        DevaluationAmount       = fixedAssetEntity.DevaluationAmount,
                                        DevaluationPeriod       = fixedAssetEntity.DevaluationPeriod,
                                        EndDevaluationDate      = fixedAssetEntity.EndDevaluationDate == new DateTime(0001, 01, 01) ? fixedAssetEntity.DevaluationDate.AddMonths((int)fixedAssetEntity.DevaluationLifeTime) : fixedAssetEntity.EndDevaluationDate,
                                        PeriodDevaluationAmount = fixedAssetEntity.PeriodDevaluationAmount
                                    };

                                    response.Message = FixedAssetLedgerDao.InsertFixedAssetLedger(fixedAssetLedgerEntity);
                                    if (!string.IsNullOrEmpty(response.Message))
                                    {
                                        response.Acknowledge = AcknowledgeType.Failure;
                                        return(response);
                                    }
                                    fixedAssetId = fAIncrementDecrementDetailEntity.FixedAssetId;
                                }
                            }
                            #endregion

                            #region Insert OriginalGeneralLedger
                            var originalGeneralLedgerEntity = new OriginalGeneralLedgerEntity
                            {
                                OriginalGeneralLedgerId = Guid.NewGuid().ToString(),
                                RefType               = fAIncrementDecrementEntity.RefType,
                                RefId                 = fAIncrementDecrementEntity.RefId,
                                JournalMemo           = fAIncrementDecrementEntity.JournalMemo,
                                RefDate               = fAIncrementDecrementEntity.RefDate,
                                RefNo                 = fAIncrementDecrementEntity.RefNo,
                                RefDetailId           = fAIncrementDecrementDetailEntity.RefDetailId,
                                OrgRefDate            = null,
                                OrgRefNo              = null,
                                AccountingObjectId    = fAIncrementDecrementDetailEntity.AccountingObjectId,
                                ActivityId            = fAIncrementDecrementDetailEntity.ActivityId,
                                Amount                = fAIncrementDecrementDetailEntity.Amount,
                                AmountOC              = fAIncrementDecrementDetailEntity.Amount,
                                Approved              = true,
                                BankId                = null,
                                BudgetChapterCode     = fAIncrementDecrementDetailEntity.BudgetChapterCode,
                                BudgetDetailItemCode  = fAIncrementDecrementDetailEntity.BudgetDetailItemCode,
                                BudgetItemCode        = fAIncrementDecrementDetailEntity.BudgetItemCode,
                                BudgetKindItemCode    = fAIncrementDecrementDetailEntity.BudgetKindItemCode,
                                BudgetSourceId        = fAIncrementDecrementDetailEntity.BudgetSourceId,
                                BudgetSubItemCode     = fAIncrementDecrementDetailEntity.BudgetSubItemCode,
                                BudgetSubKindItemCode = fAIncrementDecrementDetailEntity.BudgetSubKindItemCode,
                                CashWithDrawTypeId    = fAIncrementDecrementDetailEntity.CashWithDrawTypeId,
                                CreditAccount         = fAIncrementDecrementDetailEntity.CreditAccount,
                                DebitAccount          = fAIncrementDecrementDetailEntity.DebitAccount,
                                Description           = fAIncrementDecrementDetailEntity.Description,
                                FundStructureId       = fAIncrementDecrementDetailEntity.FundStructureId,
                                ProjectActivityId     = fAIncrementDecrementDetailEntity.ProjectActivityId,
                                MethodDistributeId    = fAIncrementDecrementDetailEntity.MethodDistributeId,
                                ProjectId             = fAIncrementDecrementDetailEntity.ProjectId,
                                ToBankId              = null,
                                SortOrder             = fAIncrementDecrementDetailEntity.SortOrder,
                                PostedDate            = fAIncrementDecrementEntity.PostedDate,

                                // Không có Currency trong db : mặc định VNĐ và 1
                                CurrencyCode = "VND",
                                ExchangeRate = 1,
                            };
                            response.Message = OriginalGeneralLedgerDao.InsertOriginalGeneralLedger(originalGeneralLedgerEntity);
                            if (!string.IsNullOrEmpty(response.Message))
                            {
                                response.Acknowledge = AcknowledgeType.Failure;
                                return(response);
                            }

                            #endregion
                        }
                    }

                    #endregion

                    scope.Complete();
                }
                response.RefId = fAIncrementDecrementEntity.RefId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(response);
            }
        }
Example #6
0
        /// <summary>
        /// Updates the ca payment.
        /// </summary>
        /// <param name="buPlanReceiptEntity">The bu plan receipt entity.</param>
        /// <returns>
        /// CAPaymentResponse.
        /// </returns>
        public BUBudgetReserveResponse UpdateBUBudgetReservet(BUBudgetReserveEntity buPlanReceiptEntity)
        {
            var buPlanReceiptResponse = new BUBudgetReserveResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (buPlanReceiptEntity != null && !buPlanReceiptEntity.Validate())
                {
                    foreach (var error in buPlanReceiptEntity.ValidationErrors)
                    {
                        buPlanReceiptResponse.Message += error + Environment.NewLine;
                    }
                    buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                    return(buPlanReceiptResponse);
                }

                using (var scope = new TransactionScope())
                {
                    if (buPlanReceiptEntity != null)
                    {
                        var buPlanReceiptForExisting = BUBudgetReserveDao.GetBUBudgetReserve(buPlanReceiptEntity.RefNo.Trim(), buPlanReceiptEntity.PostedDate);
                        if (buPlanReceiptForExisting != null && buPlanReceiptForExisting.PostedDate.Year == buPlanReceiptEntity.PostedDate.Year)
                        {
                            if (buPlanReceiptForExisting.RefId != buPlanReceiptEntity.RefId)
                            {
                                buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                                buPlanReceiptResponse.Message     = @"Số chứng từ '" + buPlanReceiptEntity.RefNo.Trim() + @"' đã tồn tại!";
                                return(buPlanReceiptResponse);
                            }
                        }

                        buPlanReceiptResponse.Message = BUBudgetReserveDao.UpdateBUBudgetReserve(buPlanReceiptEntity);
                        if (buPlanReceiptResponse.Message != null)
                        {
                            buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(buPlanReceiptResponse);
                        }

                        #region Update account balance
                        //Trừ đi số tiền của chứng từ cũ trước khi cộng thêm số tiền mới

                        UpdateAccountBalance(buPlanReceiptEntity);
                        if (buPlanReceiptResponse.Message != null)
                        {
                            buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(buPlanReceiptResponse);
                        }

                        #endregion

                        // Xóa bảng BUBudgetReservetDetail
                        buPlanReceiptResponse.Message = BUBudgetReserveDetailDao.DeleteBUBudgetReserveDetail(buPlanReceiptEntity.RefId);
                        if (buPlanReceiptResponse.Message != null)
                        {
                            buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(buPlanReceiptResponse);
                        }

                        // Xóa bảng GeneralLedger
                        buPlanReceiptResponse.Message = GeneralLedgerDao.DeleteGeneralLedger(buPlanReceiptEntity.RefId);
                        if (buPlanReceiptResponse.Message != null)
                        {
                            buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(buPlanReceiptResponse);
                        }

                        // Xóa bảng OriginalGeneralLedger
                        buPlanReceiptResponse.Message = OriginalGeneralLedgerDao.DeleteOriginalGeneralLedger(buPlanReceiptEntity.RefId);
                        if (buPlanReceiptResponse.Message != null)
                        {
                            buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(buPlanReceiptResponse);
                        }

                        foreach (var buPlanReceiptDetail in buPlanReceiptEntity.BudgetReserveDetails)
                        {
                            buPlanReceiptDetail.RefId       = buPlanReceiptEntity.RefId;
                            buPlanReceiptDetail.RefDetailId = Guid.NewGuid().ToString();

                            if (!buPlanReceiptDetail.Validate())
                            {
                                foreach (string error in buPlanReceiptDetail.ValidationErrors)
                                {
                                    buPlanReceiptResponse.Message += error + Environment.NewLine;
                                }
                                buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                                return(buPlanReceiptResponse);
                            }
                            buPlanReceiptResponse.Message = BUBudgetReserveDetailDao.InsertBUBudgetReserveDetail(buPlanReceiptDetail);
                            if (!string.IsNullOrEmpty(buPlanReceiptResponse.Message))
                            {
                                buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                                return(buPlanReceiptResponse);
                            }

                            #region Insert into AccountBalance

                            // Cộng thêm số tiền mới sau khi sửa chứng từ
                            InsertAccountBalance(buPlanReceiptEntity, buPlanReceiptDetail);
                            if (buPlanReceiptResponse.Message != null)
                            {
                                buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                                scope.Dispose();
                                return(buPlanReceiptResponse);
                            }

                            #endregion

                            #region Insert into GeneralLedger
                            if (buPlanReceiptDetail.BankAccount != null)
                            {
                                var generalLedgerEntity = new GeneralLedgerEntity
                                {
                                    RefType               = buPlanReceiptEntity.RefType,
                                    RefNo                 = buPlanReceiptEntity.RefNo,
                                    ProjectId             = buPlanReceiptDetail.ProjectId,
                                    BudgetSourceId        = buPlanReceiptDetail.BudgetSourceId,
                                    Description           = buPlanReceiptDetail.Description,
                                    RefDetailId           = buPlanReceiptDetail.RefDetailId,
                                    ExchangeRate          = buPlanReceiptEntity.ExchangeRate,
                                    BudgetSubKindItemCode = buPlanReceiptDetail.BudgetSubKindItemCode,
                                    CurrencyCode          = buPlanReceiptEntity.CurrencyCode,
                                    BudgetKindItemCode    = buPlanReceiptDetail.BudgetKindItemCode,
                                    RefId                 = buPlanReceiptEntity.RefId,
                                    PostedDate            = buPlanReceiptEntity.PostedDate,
                                    BudgetItemCode        = buPlanReceiptDetail.BudgetItemCode,
                                    ListItemId            = buPlanReceiptDetail.ListItemId,
                                    BudgetSubItemCode     = buPlanReceiptDetail.BudgetSubItemCode,
                                    BudgetDetailItemCode  = buPlanReceiptDetail.BudgetDetailItemCode,
                                    //AccountNumber = buPlanReceiptDetail.DebitAccount,
                                    //DebitAmount = buPlanReceiptDetail.DebitAccount == null ? 0 : buPlanReceiptDetail.Amount,
                                    //DebitAmountOC = buPlanReceiptDetail.DebitAccount == null ? 0 : buPlanReceiptDetail.AmountOC,
                                    CreditAmount    = 0,
                                    CreditAmountOC  = 0,
                                    FundStructureId = buPlanReceiptDetail.FundStructureId,
                                    GeneralLedgerId = Guid.NewGuid().ToString(),
                                    JournalMemo     = buPlanReceiptEntity.JournalMemo,
                                    RefDate         = buPlanReceiptEntity.RefDate,
                                    SortOrder       = buPlanReceiptDetail.SortOrder
                                };

                                buPlanReceiptResponse.Message = GeneralLedgerDao.InsertGeneralLedger(generalLedgerEntity);

                                if (!string.IsNullOrEmpty(buPlanReceiptResponse.Message))
                                {
                                    buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                                    return(buPlanReceiptResponse);
                                }
                            }
                            #endregion

                            #region Insert OriginalGeneralLedger
                            var originalGeneralLedgerEntity = new OriginalGeneralLedgerEntity
                            {
                                OriginalGeneralLedgerId = Guid.NewGuid().ToString(),
                                RefType     = buPlanReceiptEntity.RefType,
                                RefId       = buPlanReceiptEntity.RefId,
                                RefDetailId = buPlanReceiptDetail.RefDetailId,
                                RefDate     = buPlanReceiptEntity.RefDate,
                                RefNo       = buPlanReceiptEntity.RefNo,
                                Amount      = buPlanReceiptDetail.Amount,
                                AmountOC    = buPlanReceiptDetail.AmountOC,
                                //BankId = buPlanReceiptDetail.BankId,
                                BudgetChapterCode     = buPlanReceiptEntity.BudgetChapterCode,
                                BudgetDetailItemCode  = buPlanReceiptDetail.BudgetDetailItemCode,
                                BudgetItemCode        = buPlanReceiptDetail.BudgetItemCode,
                                BudgetKindItemCode    = buPlanReceiptDetail.BudgetKindItemCode,
                                BudgetSourceId        = buPlanReceiptDetail.BudgetSourceId,
                                BudgetSubItemCode     = buPlanReceiptDetail.BudgetSubItemCode,
                                BudgetSubKindItemCode = buPlanReceiptDetail.BudgetSubKindItemCode,
                                //DebitAccount = buPlanReceiptDetail.DebitAccount,
                                Description     = buPlanReceiptDetail.Description,
                                FundStructureId = buPlanReceiptDetail.FundStructureId,
                                JournalMemo     = buPlanReceiptEntity.JournalMemo,
                                ProjectId       = buPlanReceiptDetail.ProjectId,
                                //ToBankId = buPlanReceiptDetail.BankId,
                                SortOrder    = buPlanReceiptDetail.SortOrder,
                                PostedDate   = buPlanReceiptEntity.PostedDate,
                                CurrencyCode = buPlanReceiptEntity.CurrencyCode,
                                ExchangeRate = buPlanReceiptEntity.ExchangeRate,
                            };
                            buPlanReceiptResponse.Message = OriginalGeneralLedgerDao.InsertOriginalGeneralLedger(originalGeneralLedgerEntity);
                            if (!string.IsNullOrEmpty(buPlanReceiptResponse.Message))
                            {
                                buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                                return(buPlanReceiptResponse);
                            }

                            #endregion
                        }

                        if (buPlanReceiptResponse.Message != null)
                        {
                            buPlanReceiptResponse.Acknowledge = AcknowledgeType.Failure;
                            scope.Dispose();
                            return(buPlanReceiptResponse);
                        }

                        buPlanReceiptResponse.RefId = buPlanReceiptEntity.RefId;
                    }
                    scope.Complete();
                }

                return(buPlanReceiptResponse);
            }
            catch (Exception ex)
            {
                buPlanReceiptResponse.Message = ex.Message;
                return(buPlanReceiptResponse);
            }
        }