public static AccountingTransactionTempDto GetUnpostedVoucherByNo(int voucherNo)
        {
            try
            {
                var table = AccountingDataProvider.GetUnpostedVoucherByNo(voucherNo);

                var model = new AccountingTransactionTempDto
                {
                    CompanyId         = table.CompanyId,
                    CreditAccount     = table.CreditAccount,
                    CreditAccountName = AccountingDataProvider.GetAccountByCode(table.CompanyId, table.CreditAccount).AccountName,
                    DebitAccount      = table.DebitAccount,
                    DebitAccountName  = AccountingDataProvider.GetAccountByCode(table.CompanyId, table.DebitAccount).AccountName,
                    AccountingYearId  = table.AccountingYearId,
                    VoucherNo         = table.VoucherNo,
                    CurrencyCode      = table.Currency,
                    LineId            = table.LineId,
                    Total             = table.Total,
                    UserId            = table.UserId,
                    ValueTotal        = table.ValueTotal,
                    VoucherDate       = table.VoucherDate
                };

                return(model);
            }

            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
        public static VoucherTemplateDto GetlVoucherTemplateByCode(string shortCode, int companyId)
        {
            try
            {
                var voucherTemplate = AccountingDataProvider.GetVoucherTemplateByCode(shortCode, companyId);

                var viewModel = new VoucherTemplateDto
                {
                    CompanyId         = voucherTemplate.CompanyId,
                    CompanyName       = "",
                    CreditAccountCode = voucherTemplate.CreditAccount,
                    CreditAccountName = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.CreditAccount).AccountName,
                    DebitAccountCode  = voucherTemplate.DebitAccount,
                    DebitAccountName  = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.DebitAccount).AccountName,
                    Narration         = voucherTemplate.Narration,
                    ShortCode         = voucherTemplate.ShortCode,
                };

                return(viewModel);
            }

            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
 public static tChartOfAccount GetAccountByCode(int companyId, int accountcode)
 {
     try
     {
         return(AccountingDataProvider.GetAccountByCode(companyId, accountcode));
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
        public static IEnumerable <AccountingTransactionTempDto> GetAllUnpostedVoucher()
        {
            try
            {
                var vouchers         = AccountingDataProvider.GetAllUnpostedVoucher() as List <tAccountingTransactionTemp>;
                var voucherViewModel = new List <AccountingTransactionTempDto>();
                AccountingTransactionTempDto model;

                if (vouchers != null)
                {
                    vouchers.ForEach(delegate(tAccountingTransactionTemp table)
                    {
                        model = new AccountingTransactionTempDto
                        {
                            CompanyId         = table.CompanyId,
                            CreditAccount     = table.CreditAccount,
                            CreditAccountName = AccountingDataProvider.GetAccountByCode(table.CompanyId, table.CreditAccount).AccountName,
                            DebitAccount      = table.DebitAccount,
                            DebitAccountName  = AccountingDataProvider.GetAccountByCode(table.CompanyId, table.DebitAccount).AccountName,
                            AccountingYearId  = table.AccountingYearId,
                            VoucherNo         = table.VoucherNo,
                            CurrencyCode      = table.Currency,
                            LineId            = table.LineId,
                            Total             = table.Total,
                            UserId            = table.UserId,
                            ValueTotal        = table.ValueTotal,
                            VoucherDate       = table.VoucherDate
                        };
                        voucherViewModel.Add(model);
                    }
                                     );

                    return(voucherViewModel);
                }
            }

            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }

            return(null);
        }
        public static IEnumerable <VoucherTemplateDto> GetAllVoucherTemplates()
        {
            try
            {
                var vouchers         = (List <tVoucherTemplate>)AccountingDataProvider.GetAllVoucherTemplates();
                var voucherViewModel = new List <VoucherTemplateDto>();
                VoucherTemplateDto model;

                if (vouchers != null)
                {
                    vouchers.ForEach(delegate(tVoucherTemplate voucherTemplate)
                    {
                        model = new VoucherTemplateDto
                        {
                            CompanyId         = voucherTemplate.CompanyId,
                            CompanyName       = "",
                            CreditAccountCode = voucherTemplate.CreditAccount,
                            CreditAccountName = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.CreditAccount).AccountName,
                            DebitAccountCode  = voucherTemplate.DebitAccount,
                            DebitAccountName  = AccountingDataProvider.GetAccountByCode(voucherTemplate.CompanyId, voucherTemplate.DebitAccount).AccountName,
                            Narration         = voucherTemplate.Narration,
                            ShortCode         = voucherTemplate.ShortCode,
                        };
                        voucherViewModel.Add(model);
                    }
                                     );

                    return(voucherViewModel);
                }
            }

            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }

            return(null);
        }