public static OtherExpenseListViewModel GetOtherExpenseByUser(string username)
        {
            Entities entities      = new Entities();
            var      otherExpenses = entities.Expenses.Where(x => x.Username.Equals(username) &&
                                                             x.ExpenseType == (int)Constants.Constants.EXPENSE_TYPE.OTHERS &&
                                                             !x.DisabledDate.HasValue).OrderBy(x => x.Name).ToList();
            OtherExpenseListViewModel result = new OtherExpenseListViewModel();

            foreach (var otherExpense in otherExpenses)
            {
                OtherExpenseViewModel viewModel = new OtherExpenseViewModel
                {
                    Id            = otherExpense.Id,
                    Source        = otherExpense.Name,
                    ExpenseDay    = otherExpense.ExpenseDay,
                    Expense       = otherExpense.Value,
                    AnnualExpense = otherExpense.Value * 12,
                    Note          = otherExpense.Note
                };

                result.Expenses.Add(viewModel);
            }

            result.TotalExpense       = result.Expenses.Sum(x => x.Expense.Value);
            result.TotalAnnualExpense = result.TotalExpense * 12;
            result.IsInitialized      = UserQueries.IsCompleteInitialized(username);

            return(result);
        }
Ejemplo n.º 2
0
        public string InsertUpdateOtherExpense(OtherExpenseViewModel otherExpenseViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //removiing combined code
                    int len = otherExpenseViewModel.AccountCode.IndexOf(':');
                    otherExpenseViewModel.AccountCode = otherExpenseViewModel.AccountCode.Remove(len);
                    //

                    AppUA appUA = Session["AppUA"] as AppUA;
                    otherExpenseViewModel.commonObj = new CommonViewModel();
                    SPAccounts.DataAccessObject.DTO.Common common = new SPAccounts.DataAccessObject.DTO.Common();
                    otherExpenseViewModel.commonObj.CreatedBy   = appUA.UserName;
                    otherExpenseViewModel.commonObj.CreatedDate = common.GetCurrentDateTime();
                    otherExpenseViewModel.commonObj.UpdatedBy   = appUA.UserName;
                    otherExpenseViewModel.commonObj.UpdatedDate = common.GetCurrentDateTime();
                    OtherExpenseViewModel otherExpenseVM = null;

                    switch (otherExpenseViewModel.ID == Guid.Empty)
                    {
                    //INSERT
                    case true:
                        otherExpenseVM = Mapper.Map <OtherExpense, OtherExpenseViewModel>(_otherExpenseBusiness.InsertOtherExpense(Mapper.Map <OtherExpenseViewModel, OtherExpense>(otherExpenseViewModel)));
                        return(JsonConvert.SerializeObject(new { Result = "OK", Record = otherExpenseVM }));

                    default:
                        //Getting UA
                        otherExpenseVM = Mapper.Map <OtherExpense, OtherExpenseViewModel>(_otherExpenseBusiness.UpdateOtherExpense(Mapper.Map <OtherExpenseViewModel, OtherExpense>(otherExpenseViewModel)));
                        return(JsonConvert.SerializeObject(new { Result = "OK", Record = otherExpenseVM }));
                    }
                }
                catch (Exception ex)
                {
                    return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
                }
            }
            //Model state errror
            else
            {
                List <string> modelErrors = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        modelErrors.Add(modelError.ErrorMessage);
                    }
                }
                return(JsonConvert.SerializeObject(new { Result = "VALIDATION", Message = string.Join(",", modelErrors) }));
            }
        }
Ejemplo n.º 3
0
 public string GetOpeningBalance(string OpeningDate)
 {
     try
     {
         OtherExpenseViewModel otherExpenseObj = Mapper.Map <OtherExpense, OtherExpenseViewModel>(_otherExpenseBusiness.GetOpeningBalance(OpeningDate));
         return(JsonConvert.SerializeObject(new { Result = "OK", Records = otherExpenseObj }));
     }
     catch (Exception ex)
     {
         AppConstMessage cm = c.GetMessage(ex.Message);
         return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
     }
 }
Ejemplo n.º 4
0
        public string Validate(OtherExpenseViewModel _otherexpenseObj)
        {
            AppUA  appUA  = Session["AppUA"] as AppUA;
            object result = null;

            try
            {
                result = _otherExpenseBusiness.Validate(Mapper.Map <OtherExpenseViewModel, OtherExpense>(_otherexpenseObj));
                return(JsonConvert.SerializeObject(new { Result = "OK", Message = "", Records = result }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message, Status = -1 }));
            }
        }
Ejemplo n.º 5
0
        public string GetExpenseDetailsByID(string ID)
        {
            try
            {
                OtherExpenseViewModel otherExpenseViewModel = Mapper.Map <OtherExpense, OtherExpenseViewModel>(_otherExpenseBusiness.GetOtherExpenseByID(Guid.Parse(ID)));
                if (otherExpenseViewModel != null)
                {
                    otherExpenseViewModel.creditAmountFormatted = _commonBusiness.ConvertCurrency(otherExpenseViewModel.Amount, 2);
                    otherExpenseViewModel.AccountCode           = otherExpenseViewModel.AccountCode + ":" + otherExpenseViewModel.chartOfAccountsObj.ISEmploy;
                }

                return(JsonConvert.SerializeObject(new { Result = "OK", Record = otherExpenseViewModel }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }
Ejemplo n.º 6
0
 public string GetOtherExpenseByIDForMobile(OtherExpense otherExpenseObj)
 {
     try
     {
         if (otherExpenseObj.ID != Guid.Empty && otherExpenseObj.ID != null)
         {
             OtherExpenseViewModel expenseObj = Mapper.Map <OtherExpense, OtherExpenseViewModel>(_otherExpenseBusiness.GetOtherExpenseByID(otherExpenseObj.ID));
             return(JsonConvert.SerializeObject(new { Result = true, Records = expenseObj }));
         }
         else
         {
             throw new Exception("Invalid Input");
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = false, Message = ex.Message }));
     }
 }
Ejemplo n.º 7
0
        public string SendNotification(OtherExpenseViewModel otherExpenseVM)
        {
            try
            {
                AppUA appUA = Session["AppUA"] as AppUA;
                SPAccounts.DataAccessObject.DTO.Common common = new SPAccounts.DataAccessObject.DTO.Common();
                otherExpenseVM.commonObj             = new CommonViewModel();
                otherExpenseVM.commonObj.UpdatedBy   = appUA.UserName;
                otherExpenseVM.commonObj.UpdatedDate = common.GetCurrentDateTime();
                bool result = _otherExpenseBusiness.NotifyOtherExpense(otherExpenseVM.ID);

                string  titleString       = "Expense Approval";
                string  descriptionString = otherExpenseVM.RefNo + ", Expense: " + otherExpenseVM.AccountCode + ", Amount: " + otherExpenseVM.Amount + ", Notes: " + otherExpenseVM.Description;
                Boolean isCommon          = true;
                string  customerID        = "";
                _commonBusiness.SendToFCM(titleString, descriptionString, isCommon, customerID);
                return(JsonConvert.SerializeObject(new { Result = "OK", Message = (result ? c.NotificationSuccess : "Failed") }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }
Ejemplo n.º 8
0
        public ActionResult Index(string id)
        {
            OtherExpenseViewModel otherExpenseViewModelObj = null;

            ViewBag.value = id;
            Settings s = new Settings();

            try
            {
                otherExpenseViewModelObj = new OtherExpenseViewModel();
                otherExpenseViewModelObj.ExpenseDateFormatted = DateTime.Today.ToString(s.dateformat);
                otherExpenseViewModelObj.Today = DateTime.Today.ToString(s.dateformat);
                List <SelectListItem>           selectListItem     = new List <SelectListItem>();
                List <ChartOfAccountsViewModel> chartOfAccountList = Mapper.Map <List <ChartOfAccounts>, List <ChartOfAccountsViewModel> >(_otherExpenseBusiness.GetAllAccountTypes("OE"));
                foreach (ChartOfAccountsViewModel cav in chartOfAccountList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text  = cav.TypeDesc,
                        Value = cav.Code + ":" + cav.ISEmploy,

                        Selected = false,
                    });
                }
                otherExpenseViewModelObj.AccountTypes = selectListItem;
                selectListItem = null;
                selectListItem = new List <SelectListItem>();
                List <BankViewModel> bankList = Mapper.Map <List <Bank>, List <BankViewModel> >(_otherExpenseBusiness.GetAllBankes());
                foreach (BankViewModel bvm in bankList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = bvm.Name,
                        Value    = bvm.Code,
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.bankList = selectListItem;

                otherExpenseViewModelObj.CompanyList = new List <SelectListItem>();
                selectListItem = new List <SelectListItem>();
                List <CompaniesViewModel> companiesList = Mapper.Map <List <Companies>, List <CompaniesViewModel> >(_otherExpenseBusiness.GetAllCompanies());
                foreach (CompaniesViewModel cvm in companiesList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = cvm.Name,
                        Value    = cvm.Code.ToString(),
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.CompanyList = selectListItem;

                otherExpenseViewModelObj.paymentModeList = new List <SelectListItem>();
                selectListItem = new List <SelectListItem>();
                List <PaymentModesViewModel> PaymentModeList = Mapper.Map <List <PaymentModes>, List <PaymentModesViewModel> >(_otherExpenseBusiness.GetAllPaymentModes());
                foreach (PaymentModesViewModel PMVM in PaymentModeList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = PMVM.Description,
                        Value    = PMVM.Code,
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.paymentModeList = selectListItem;
                //selectListItem = new List<SelectListItem>();
                //List<EmployeeViewModel> empList = Mapper.Map<List<Employee>, List<EmployeeViewModel>>(_otherExpenseBusiness.GetAllEmployees());
                //foreach (EmployeeViewModel evm in empList)
                //{
                //    selectListItem.Add(new SelectListItem
                //    {
                //        Text = evm.Name,
                //        Value = evm.ID.ToString(),
                //        Selected = false
                //    });
                //}
                //otherExpenseViewModelObj.EmployeeList = selectListItem;
                selectListItem = null;
                selectListItem = new List <SelectListItem>();
                List <EmployeeTypeViewModel> empTypeList = Mapper.Map <List <EmployeeType>, List <EmployeeTypeViewModel> >(_otherExpenseBusiness.GetAllEmployeeTypes());
                foreach (EmployeeTypeViewModel etvm in empTypeList)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = etvm.Name,
                        Value    = etvm.Code,
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.EmployeeTypeList = selectListItem;

                otherExpenseViewModelObj.ApprovalStatusList = new List <SelectListItem>();
                selectListItem = new List <SelectListItem>();
                List <ApprovalStatusViewModel> approvalStatus = Mapper.Map <List <ApprovalStatus>, List <ApprovalStatusViewModel> >(_approvalStatusBusiness.GetAllApprovalStatus());
                foreach (ApprovalStatusViewModel BL in approvalStatus)
                {
                    selectListItem.Add(new SelectListItem
                    {
                        Text     = BL.Description,
                        Value    = BL.Code,
                        Selected = false
                    });
                }
                otherExpenseViewModelObj.ApprovalStatusList = selectListItem;

                Permission permission = Session["UserRights"] as Permission;
                string     p          = permission.SubPermissionList.Where(li => li.Name == "DaysFilter").First().AccessCode;
                if (p.Contains("R") || p.Contains("W"))
                {
                    otherExpenseViewModelObj.ShowDaysFilter = true;
                }
                else
                {
                    otherExpenseViewModelObj.ShowDaysFilter = false;
                }
                p = null;
                p = permission.SubPermissionList.Where(li => li.Name == "ApprovalFilter").First().AccessCode;
                if (p.Contains("R") || p.Contains("W"))
                {
                    otherExpenseViewModelObj.ApprovalFilter = true;
                }
                else
                {
                    otherExpenseViewModelObj.ApprovalFilter = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(View(otherExpenseViewModelObj));
        }