Ejemplo n.º 1
0
        public virtual async Task <HttpResponseMessage> GetCashesAndBanks()
        {
            var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

            BankRule bankRule = new BankRule();
            var      banks    = await bankRule.GetAllByOrganIdAsync(organId);

            CashRule cashRule = new CashRule();
            var      cashs    = await cashRule.GetAllByOrganIdAsync(organId);

            var cashes = new Cashe();

            cashes.banks  = new List <BankVM>();
            cashes.cashes = new List <CashVM>();

            foreach (var bank in banks)
            {
                decimal balance = await CalcBalanceBank(bank.Code, organId);

                cashes.banks.Add(new BankVM()
                {
                    AccountNumber = bank.AccountNumber,
                    Balance       = balance,
                    Branch        = bank.Branch,
                    Code          = bank.Code,
                    FullName      = bank.FullName,
                    ID            = bank.ID,
                    Name          = bank.Name,
                    OrganId       = bank.OrganId,
                    //Id = bank.ID,
                    DetailAccount = new DetailAccount()
                    {
                        Accounts = new List <AccountVM>(),
                        Balance  = bank.Balance,
                        Name     = bank.Name,
                        Node     = new Node(),
                    }
                });
            }

            foreach (var cash in cashs)
            {
                decimal balance = await CalcBalanceCash(cash.Code, organId);

                cashes.cashes.Add(new CashVM()
                {
                    Balance = balance,
                    Code    = cash.Code,
                    ID      = cash.ID,
                    Name    = cash.Name,
                    OrganId = cash.OrganId,
                    //DetailAccount = new DetailAccount() {
                    //    Balance = cash.Balance,
                    //    Name = cash.Name,
                    //    Node = new Node()
                    //}
                });
            }
            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)ZhivarEnums.ResultCode.Successful, data = cashes }));
        }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> LoadInvoiceTransObj([FromBody] int id)
        {
            try
            {
                var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

                var invoice = await Rule.FindAsync(id);

                InvoiceTransObj invoiceTransObj = new InvoiceTransObj();

                invoiceTransObj.invoice      = Mapper.Map <InvoiceVM>(invoice);
                invoiceTransObj.invoiceItems = invoiceTransObj.invoice.InvoiceItems;
                //invoiceTransObj.payments =  await transactionRule.GetAllByInvoiceIdAsync(id,true,false);
                PayRecevieRule payRecevieRule = new PayRecevieRule();
                invoiceTransObj.tempPayments = await payRecevieRule.GetTempPaymentsByInvoiceIdAsync(id);

                for (int i = 0; i < invoiceTransObj.invoiceItems.Count; i++)
                {
                    ItemRule itemRule = new ItemRule();
                    invoiceTransObj.invoiceItems[i].Item = Mapper.Map <ItemVM>(await itemRule.FindAsync(invoiceTransObj.invoiceItems[i].ItemId));
                }

                ContactRule contactRule = new ContactRule();
                invoiceTransObj.invoice.Contact = Mapper.Map <ContactVM>(await contactRule.FindAsync(invoice.ContactId));
                CashRule cashRule = new CashRule();
                var      cashes   = await cashRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                invoiceTransObj.cashes = Mapper.Map <List <CashVM> >(cashes);

                BankRule bankRule = new BankRule();
                var      banks    = await bankRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                invoiceTransObj.banks = Mapper.Map <List <BankVM> >(banks);


                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = ZhivarEnums.ResultCode.Successful, data = invoiceTransObj }));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public async Task <HttpResponseMessage> LoadCostTransObj([FromBody] int id)
        {
            try
            {
                var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

                var cost = await Rule.FindAsync(id);

                CostTransObj costTransObj = new CostTransObj();

                costTransObj.cost      = Mapper.Map <CostVM>(cost);
                costTransObj.costItems = costTransObj.cost.CostItems;
                TransactionRule transactionRule = new TransactionRule();
                costTransObj.payments = await transactionRule.GetAllByCostIdAsync(id);

                for (int i = 0; i < costTransObj.costItems.Count; i++)
                {
                    costTransObj.costItems[i].Item = await this.BusinessRule.UnitOfWork.RepositoryAsync <DomainClasses.Accounting.Account>().FindAsync(costTransObj.costItems[i].ItemId);
                }

                ContactRule contactRule = new ContactRule();
                costTransObj.cost.Contact = Mapper.Map <ContactVM>(await contactRule.FindAsync(cost.ContactId));
                CashRule cashRule = new CashRule();
                var      cashes   = await cashRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                costTransObj.cashes = Mapper.Map <List <CashVM> >(cashes);

                BankRule bankRule = new BankRule();
                var      banks    = await bankRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                costTransObj.banks = Mapper.Map <List <BankVM> >(banks);


                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = ZhivarEnums.ResultCode.Successful, data = costTransObj }));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        public virtual async Task <HttpResponseMessage> ChangeChequeStatus([FromBody] ChequesAndStatsVM chequesAndStatsVM)
        {
            var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

            ChequeVM chequeVM = new ChequeVM();

            switch (chequesAndStatsVM.change)
            {
            // وصول چک پرداختی
            case "PaidChequeReceipt":
            {
                chequesAndStatsVM.description = " وصول چک پرداختی";
                var doucument = await CreateDocumentPaidChequeReceipt(chequesAndStatsVM, organId);

                ChequeRule chequeRule = new ChequeRule();
                var        cheque     = await chequeRule.FindAsync(chequesAndStatsVM.chequeId);

                cheque.Status = ZhivarEnums.ChequeStatus.Passed;
                chequeRule.Update(cheque);
                await chequeRule.SaveChangesAsync();

                DocumentRule documentRule = new DocumentRule();
                await documentRule.InsertAsync(doucument, organId);

                await documentRule.SaveChangesAsync();



                //AccountNumber: ""
                chequeVM.Amount     = cheque.Amount;
                chequeVM.BankBranch = cheque.BankBranch;
                //chequeVM.BankDetailAccount: null
                chequeVM.BankName     = cheque.BankName;
                chequeVM.ChequeNumber = cheque.ChequeNumber;
                chequeVM.Contact      = cheque.Contact;
                chequeVM.Date         = cheque.Date;
                chequeVM.DepositBank  = cheque.DepositBank;
                //chequeVM.DepositDate = cheque.DepositBank;
                chequeVM.DisplayDate = cheque.DisplayDate;
                chequeVM.ID          = cheque.ID;
                //chequeVM.MyCheque = cheque.DepositBank;
                //chequeVM.Overdue = cheque.Overdue;
                //chequeVM.Payee = cheque.Payee;
                //chequeVM.Payer = cheque.Payer;
                chequeVM.ReceiptDate = cheque.ReceiptDate;
                //chequeVM.ReturnDate = cheque.ReturnDate;
                chequeVM.Status       = cheque.Status;
                chequeVM.StatusString = "وصول شده";
                break;
            }

            // وصول چک دریافتی
            case "ReceivedChequeReceipt":
            {
                chequesAndStatsVM.description = " وصول چک دریافتی";

                var doucument = await CreateDocumentChangeChequeStatus(chequesAndStatsVM, organId);


                ChequeRule chequeRule = new ChequeRule();
                var        cheque     = await chequeRule.FindAsync(chequesAndStatsVM.chequeId);

                cheque.Status = ZhivarEnums.ChequeStatus.Passed;
                chequeRule.Update(cheque);

                await chequeRule.SaveChangesAsync();

                DocumentRule documentRule = new DocumentRule();
                await documentRule.InsertAsync(doucument, organId);

                await documentRule.SaveChangesAsync();


                //AccountNumber: ""
                chequeVM.Amount     = cheque.Amount;
                chequeVM.BankBranch = cheque.BankBranch;
                //chequeVM.BankDetailAccount: null
                chequeVM.BankName     = cheque.BankName;
                chequeVM.ChequeNumber = cheque.ChequeNumber;
                chequeVM.Contact      = cheque.Contact;
                chequeVM.Date         = cheque.Date;
                chequeVM.DepositBank  = cheque.DepositBank;
                //chequeVM.DepositDate = cheque.DepositBank;
                chequeVM.DisplayDate = cheque.DisplayDate;
                chequeVM.ID          = cheque.ID;
                //chequeVM.MyCheque = cheque.DepositBank;
                //chequeVM.Overdue = cheque.Overdue;
                //chequeVM.Payee = cheque.Payee;
                //chequeVM.Payer = cheque.Payer;
                chequeVM.ReceiptDate = cheque.ReceiptDate;
                //chequeVM.ReturnDate = cheque.ReturnDate;
                chequeVM.Status       = cheque.Status;
                chequeVM.StatusString = "وصول شده";
                break;
            }

            // وصول چک واگذار شده به بانک
            case "DepositChequeReceipt":
            {
                chequesAndStatsVM.description = "وصول چک واگذار شده به بانک";
                var doucument = await CreateDocumentDepositChequeReceipt(chequesAndStatsVM, organId);

                ChequeRule chequeRule = new ChequeRule();
                var        cheque     = await chequeRule.FindAsync(chequesAndStatsVM.chequeId);

                cheque.Status = ZhivarEnums.ChequeStatus.Passed;
                chequeRule.Update(cheque);

                await chequeRule.SaveChangesAsync();

                DocumentRule documentRule = new DocumentRule();
                await documentRule.InsertAsync(doucument, organId);

                await documentRule.SaveChangesAsync();


                //AccountNumber: ""
                chequeVM.Amount     = cheque.Amount;
                chequeVM.BankBranch = cheque.BankBranch;
                //chequeVM.BankDetailAccount: null
                chequeVM.BankName     = cheque.BankName;
                chequeVM.ChequeNumber = cheque.ChequeNumber;
                chequeVM.Contact      = cheque.Contact;
                chequeVM.Date         = cheque.Date;
                chequeVM.DepositBank  = cheque.DepositBank;
                //chequeVM.DepositDate = cheque.DepositBank;
                chequeVM.DisplayDate = cheque.DisplayDate;
                chequeVM.ID          = cheque.ID;
                //chequeVM.MyCheque = cheque.DepositBank;
                //chequeVM.Overdue = cheque.Overdue;
                //chequeVM.Payee = cheque.Payee;
                //chequeVM.Payer = cheque.Payer;
                chequeVM.ReceiptDate = cheque.ReceiptDate;
                //chequeVM.ReturnDate = cheque.ReturnDate;
                chequeVM.Status       = cheque.Status;
                chequeVM.StatusString = "وصول شده";
                break;
            }

            // واگذاری چک به بانک
            case "ReceivedChequeDeposit":
            {
                chequesAndStatsVM.description = "واگذاری چک به بانک";

                var doucument = await CreateDocumentReceivedChequeDeposit(chequesAndStatsVM, organId);

                ChequeRule chequeRule = new ChequeRule();
                var        cheque     = await chequeRule.FindAsync(chequesAndStatsVM.chequeId);

                cheque.Status = ZhivarEnums.ChequeStatus.InProgress;

                BankRule bankRule = new BankRule();
                var      banks    = await bankRule.GetAllByOrganIdAsync(organId);

                var bank = banks.Where(x => x.Code == chequesAndStatsVM.detailAccount.Code).SingleOrDefault();
                cheque.DepositBankId = bank.ID;

                chequeRule.Update(cheque);
                await chequeRule.SaveChangesAsync();

                DocumentRule documentRule = new DocumentRule();
                await documentRule.InsertAsync(doucument, organId);

                await documentRule.SaveChangesAsync();



                //AccountNumber: ""
                chequeVM.Amount     = cheque.Amount;
                chequeVM.BankBranch = cheque.BankBranch;
                //chequeVM.BankDetailAccount: null
                chequeVM.BankName     = cheque.BankName;
                chequeVM.ChequeNumber = cheque.ChequeNumber;
                chequeVM.Contact      = cheque.Contact;
                chequeVM.Date         = cheque.Date;
                chequeVM.DepositBank  = cheque.DepositBank;
                //chequeVM.DepositDate = cheque.DepositBank;
                chequeVM.DisplayDate = cheque.DisplayDate;
                chequeVM.ID          = cheque.ID;
                //chequeVM.MyCheque = cheque.DepositBank;
                //chequeVM.Overdue = cheque.Overdue;
                //chequeVM.Payee = cheque.Payee;
                //chequeVM.Payer = cheque.Payer;
                chequeVM.ReceiptDate = cheque.ReceiptDate;
                //chequeVM.ReturnDate = cheque.ReturnDate;
                chequeVM.Status       = cheque.Status;
                chequeVM.StatusString = "وصول شده";
                break;
            }

            // عودت دادن چک پرداختی
            case "PaidChequeReturn":
            {
                //chequesAndStatsVM.description = "عودت دادن چک پرداختی";

                var doucument = await CreateDocumentPaidChequeReturn(chequesAndStatsVM, organId);

                ChequeRule chequeRule = new ChequeRule();
                var        cheque     = await chequeRule.FindAsync(chequesAndStatsVM.chequeId);

                cheque.Status = ZhivarEnums.ChequeStatus.ChequeReturn;
                chequeRule.Update(cheque);

                await chequeRule.SaveChangesAsync();

                DocumentRule documentRule = new DocumentRule();
                await documentRule.InsertAsync(doucument, organId);

                await documentRule.SaveChangesAsync();


                //AccountNumber: ""
                chequeVM.Amount     = cheque.Amount;
                chequeVM.BankBranch = cheque.BankBranch;
                //chequeVM.BankDetailAccount: null
                chequeVM.BankName     = cheque.BankName;
                chequeVM.ChequeNumber = cheque.ChequeNumber;
                chequeVM.Contact      = cheque.Contact;
                chequeVM.Date         = cheque.Date;
                chequeVM.DepositBank  = cheque.DepositBank;
                //chequeVM.DepositDate = cheque.DepositBank;
                chequeVM.DisplayDate = cheque.DisplayDate;
                chequeVM.ID          = cheque.ID;
                //chequeVM.MyCheque = cheque.DepositBank;
                //chequeVM.Overdue = cheque.Overdue;
                //chequeVM.Payee = cheque.Payee;
                //chequeVM.Payer = cheque.Payer;
                chequeVM.ReceiptDate = cheque.ReceiptDate;
                //chequeVM.ReturnDate = cheque.ReturnDate;
                chequeVM.Status       = cheque.Status;
                chequeVM.StatusString = "وصول شده";
                break;
            }

            // عودت دادن چک دریافتی
            case "ReceivedChequeReturn":
            {
                chequesAndStatsVM.description = "عودت دادن چک دریافتی";

                var doucument = await CreateDocumentReceivedChequeReturn(chequesAndStatsVM, organId);

                ChequeRule chequeRule = new ChequeRule();
                var        cheque     = await chequeRule.FindAsync(chequesAndStatsVM.chequeId);

                cheque.Status = ZhivarEnums.ChequeStatus.ChequeReturn;
                chequeRule.Update(cheque);

                await chequeRule.SaveChangesAsync();

                DocumentRule documentRule = new DocumentRule();
                await documentRule.InsertAsync(doucument, organId);

                await documentRule.SaveChangesAsync();


                //AccountNumber: ""
                chequeVM.Amount     = cheque.Amount;
                chequeVM.BankBranch = cheque.BankBranch;
                //chequeVM.BankDetailAccount: null
                chequeVM.BankName     = cheque.BankName;
                chequeVM.ChequeNumber = cheque.ChequeNumber;
                chequeVM.Contact      = cheque.Contact;
                chequeVM.Date         = cheque.Date;
                chequeVM.DepositBank  = cheque.DepositBank;
                //chequeVM.DepositDate = cheque.DepositBank;
                chequeVM.DisplayDate = cheque.DisplayDate;
                chequeVM.ID          = cheque.ID;
                //chequeVM.MyCheque = cheque.DepositBank;
                //chequeVM.Overdue = cheque.Overdue;
                //chequeVM.Payee = cheque.Payee;
                //chequeVM.Payer = cheque.Payer;
                chequeVM.ReceiptDate = cheque.ReceiptDate;
                //chequeVM.ReturnDate = cheque.ReturnDate;
                chequeVM.Status       = cheque.Status;
                chequeVM.StatusString = "وصول شده";
                break;
            }

            // تغییر وضعیت چک پرداختی به پاس نشده
            case "PaidChequeToNotPass":
            {
                chequesAndStatsVM.description = "تغییر وضعیت چک پرداختی به پاس نشده";
                chequesAndStatsVM.date        = PersianDateUtils.ToPersianDate(DateTime.Now);

                var doucument = await CreateDocumentPaidChequeToNotPass(chequesAndStatsVM, organId);

                ChequeRule chequeRule = new ChequeRule();
                var        cheque     = await chequeRule.FindAsync(chequesAndStatsVM.chequeId);

                cheque.Status = ZhivarEnums.ChequeStatus.Normal;
                chequeRule.Update(cheque);
                await chequeRule.SaveChangesAsync();

                DocumentRule documentRule = new DocumentRule();
                await documentRule.InsertAsync(doucument, organId);

                await documentRule.SaveChangesAsync();


                //AccountNumber: ""
                chequeVM.Amount     = cheque.Amount;
                chequeVM.BankBranch = cheque.BankBranch;
                //chequeVM.BankDetailAccount: null
                chequeVM.BankName     = cheque.BankName;
                chequeVM.ChequeNumber = cheque.ChequeNumber;
                chequeVM.Contact      = cheque.Contact;
                chequeVM.Date         = cheque.Date;
                chequeVM.DepositBank  = cheque.DepositBank;
                //chequeVM.DepositDate = cheque.DepositBank;
                chequeVM.DisplayDate = cheque.DisplayDate;
                chequeVM.ID          = cheque.ID;
                //chequeVM.MyCheque = cheque.DepositBank;
                //chequeVM.Overdue = cheque.Overdue;
                //chequeVM.Payee = cheque.Payee;
                //chequeVM.Payer = cheque.Payer;
                chequeVM.ReceiptDate = cheque.ReceiptDate;
                //chequeVM.ReturnDate = cheque.ReturnDate;
                chequeVM.Status       = cheque.Status;
                chequeVM.StatusString = "وصول شده";
                break;
            }

            // تغییر وضعیت چک دریافتی به وصول نشده
            case "ReceivedChequeToNotPass":
            {
                chequesAndStatsVM.description = "تغییر وضعیت چک دریافتی به وصول نشده";

                ChequeRule chequeRule = new ChequeRule();
                var        cheque     = await chequeRule.FindAsync(chequesAndStatsVM.chequeId);

                PayRecevieRule  payRecevieRule = new PayRecevieRule();
                List <Document> doucuments     = await payRecevieRule.GetDoucumentIDByChequeIdAsync(chequesAndStatsVM.chequeId);

                cheque.Status = ZhivarEnums.ChequeStatus.Normal;
                chequeRule.Update(cheque);

                Document     newDocument  = new Document();
                DocumentRule documentRule = new DocumentRule();

                foreach (var document in doucuments)
                {
                    newDocument = new Document()
                    {
                        Credit         = document.Credit,
                        Description    = chequesAndStatsVM.description,
                        Debit          = document.Debit,
                        DateTime       = DateTime.Now,
                        DisplayDate    = PersianDateUtils.ToPersianDate(DateTime.Now),
                        FinanYear      = document.FinanYear,
                        FinanYearId    = document.FinanYearId,
                        IsFirsDocument = document.IsFirsDocument,
                        IsManual       = document.IsManual,
                        Number         = await documentRule.createNumberDocumentAsync(organId),
                        Number2        = await documentRule.createNumberDocumentAsync(organId),
                        OrganId        = organId,
                        Status         = ZhivarEnums.DocumentStatus.TaeedShode,
                        StatusString   = document.StatusString,
                        Type           = ZhivarEnums.NoeDoc.Pay
                    };
                    TransactionRule transactionRule = new TransactionRule();
                    var             transactions    = await transactionRule.GetAllByOrganIdAsync(organId);

                    transactions = transactions.Where(x => x.DocumentId == document.ID).ToList();

                    newDocument.Transactions = new List <Transaction>();
                    Transaction newTransaction = new Transaction();

                    foreach (var transaction in transactions)
                    {
                        //newTransaction.AccDocument = newDocument;
                        //newTransaction.Account = transaction.Account;
                        newTransaction.AccountId             = transaction.AccountId;
                        newTransaction.Amount                = transaction.Amount;
                        newTransaction.Cheque                = transaction.Cheque;
                        newTransaction.ChequeId              = transaction.ChequeId;
                        newTransaction.ContactId             = transaction.ContactId;
                        newTransaction.Credit                = transaction.Debit;
                        newTransaction.Date                  = DateTime.Now;
                        newTransaction.Debit                 = transaction.Credit;
                        newTransaction.Description           = chequesAndStatsVM.description;
                        newTransaction.DisplayDate           = PersianDateUtils.ToPersianDate(DateTime.Now);
                        newTransaction.DocumentId            = newDocument.ID;
                        newTransaction.InvoiceId             = transaction.InvoiceId;
                        newTransaction.IsCredit              = transaction.IsDebit;
                        newTransaction.IsDebit               = transaction.IsCredit;
                        newTransaction.PaymentMethod         = transaction.PaymentMethod;
                        newTransaction.PaymentMethodString   = transaction.PaymentMethodString;
                        newTransaction.Reference             = transaction.Reference;
                        newTransaction.RefTrans              = transaction.RefTrans;
                        newTransaction.Remaining             = transaction.Remaining;
                        newTransaction.RemainingType         = transaction.RemainingType;
                        newTransaction.RowNumber             = transaction.RowNumber;
                        newTransaction.Stock                 = transaction.Stock;
                        newTransaction.TransactionTypeString = transaction.TransactionTypeString;
                        newTransaction.Type                  = transaction.Type;
                        newTransaction.UnitPrice             = transaction.UnitPrice;

                        newDocument.Transactions.Add(newTransaction);
                    }
                }

                await documentRule.InsertAsync(newDocument, organId);

                await documentRule.SaveChangesAsync();


                //AccountNumber: ""
                chequeVM.Amount     = cheque.Amount;
                chequeVM.BankBranch = cheque.BankBranch;
                //chequeVM.BankDetailAccount: null
                chequeVM.BankName     = cheque.BankName;
                chequeVM.ChequeNumber = cheque.ChequeNumber;
                chequeVM.Contact      = cheque.Contact;
                chequeVM.Date         = cheque.Date;
                chequeVM.DepositBank  = cheque.DepositBank;
                //chequeVM.DepositDate = cheque.DepositBank;
                chequeVM.DisplayDate = cheque.DisplayDate;
                chequeVM.ID          = cheque.ID;
                //chequeVM.MyCheque = cheque.DepositBank;
                //chequeVM.Overdue = cheque.Overdue;
                //chequeVM.Payee = cheque.Payee;
                //chequeVM.Payer = cheque.Payer;
                chequeVM.ReceiptDate = cheque.ReceiptDate;
                //chequeVM.ReturnDate = cheque.ReturnDate;
                chequeVM.Status       = cheque.Status;
                chequeVM.StatusString = "وصول شده";
                break;
            }


            default:
                break;
            }

            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = ZhivarEnums.ResultCode.Successful, data = chequeVM }));
        }
Ejemplo n.º 5
0
        public async Task <HttpResponseMessage> GetAllByOrganId()
        {
            try
            {
                var organId = Convert.ToInt32(SecurityManager.CurrentUserContext.OrganizationId);

                BankRule bankRule = new BankRule();
                var      list     = await bankRule.GetAllByOrganIdAsync(Convert.ToInt32(organId));

                AccountRule accountRule = new AccountRule();
                var         accounts    = await accountRule.GetAllByOrganIdAsync(organId);

                BankVM        bankVM  = new BankVM();
                List <BankVM> bankVMs = new List <BankVM>();

                foreach (var item in list)
                {
                    var             bankAccount     = accounts.Where(x => x.ComplteCoding == "1103" + item.Code).SingleOrDefault();
                    TransactionRule transactionRule = new TransactionRule();
                    BalanceModelVM  transaction     = await transactionRule.GetBalanceAccountAsync(bankAccount.ID);

                    bankVMs.Add(new BankVM()
                    {
                        AccountNumber = item.AccountNumber,
                        Balance       = item.Balance,
                        Branch        = item.Branch,
                        Code          = item.Code,
                        FullName      = item.FullName,
                        ID            = item.ID,
                        Name          = item.Name,
                        DetailAccount = new DetailAccount()
                        {
                            Accounts = new List <AccountVM>()
                            {
                                new AccountVM()
                                {
                                    Balance     = transaction.Balance,
                                    BalanceType = transaction.BalanceType,
                                    Code        = bankAccount.Coding,
                                    Coding      = bankAccount.Coding,
                                    credit      = transaction.Credit,
                                    debit       = transaction.Debit,
                                    ID          = bankAccount.ID,
                                    ParentId    = bankAccount.ParentId,
                                    Name        = bankAccount.Name,
                                }
                            },
                            Code        = bankAccount.Coding,
                            Id          = bankAccount.ID,
                            Balance     = transaction.Balance,
                            credit      = transaction.Credit,
                            debit       = transaction.Debit,
                            BalanceType = transaction.BalanceType,
                            Name        = bankAccount.Name,
                        }
                    });
                }

                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)ZhivarEnums.ResultCode.Successful, data = bankVMs }));
            }
            catch (Exception ex)
            {
                throw;
            }
        }