Beispiel #1
0
 private AbstractExpenseItem CreateExpenseItem(Claim claim, ExpenseType type, DateTime dateIncurred, string description, decimal amount) {
     AbstractExpenseItem item = (claim.CreateNewExpenseItem(type));
     item.ModifyDateIncurred(dateIncurred);
     item.ModifyDescription(description);
     item.ModifyAmount(Money(amount, claim));
     return item;
 }
        public ExpenseType Save(ExpenseType expense)
        {
            if (expense.ExpenseTypeID == 0)
                claimRulerDBContext.ExpenseType.Add(expense);

            claimRulerDBContext.SaveChanges();

            return expense;
        }
Beispiel #3
0
 public  void Install() {
     GENERAL = CreateType(typeof (GeneralExpense), "General Expense");
     AIRFARE = CreateType(typeof (Airfare), "Airfare");
     CAR_RENTAL = CreateType(typeof (CarRental), "Car Rental");
     HOTEL = CreateType(typeof (Hotel), "Hotel");
     MEAL = CreateType(typeof (GeneralExpense), "Meal");
     MOBILE_PHONE = CreateType(typeof (GeneralExpense), "Mobile Phone");
     PRIVATE_CAR = CreateType(typeof (PrivateCarJourney), "Private Car Journey");
     TAXI = CreateType(typeof (Taxi), "Taxi");
 }
 public RouteFacility(
     string uid,
     FacilityType type,
     string name,
     int serviceLevel,
     ExpenseType eType,
     double expense,
     FeeType feeType)
     : this(uid, type, name, serviceLevel, eType, expense, feeType, null)
 {
 }
Beispiel #5
0
 public RouteFacility(string uid, FacilityType type, string name, int serviceLevel, ExpenseType eType, double expense, FeeType feeType,AirlineFacility requires)
 {
     this.Type = type;
     this.Name = name;
     this.Uid = uid;
     this.ServiceLevel = serviceLevel;
     this.EType = eType;
     this.ExpensePerPassenger = expense;
     this.FeeType = feeType;
     this.Requires = requires;
 }
Beispiel #6
0
        public ExpenseType Save([FromBody] ExpenseType model)
        {
            ModelState.Validate();

            if (model.Id > 0)
            {
                _repository.Update(model);
            }
            else
            {
                _repository.Insert(model);
            }

            return(model);
        }
Beispiel #7
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ExpenseType = await _context.ExpenseTypes.FirstOrDefaultAsync(m => m.ExpenseTypeId == id);

            if (ExpenseType == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Beispiel #8
0
        protected void gvExpenseType_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         expenseID = 0;
            ExpenseType expense   = null;

            if (e.CommandName == "DoEdit")
            {
                expenseID = Convert.ToInt32(e.CommandArgument);

                using (ExpenseTypeManager repository = new ExpenseTypeManager()) {
                    expense = repository.Get(expenseID);
                }
                if (expense != null)
                {
                    showEditPanel();

                    txtExpenseDescription.Text = expense.ExpenseDescription;

                    txtExpenseName.Text = expense.ExpenseName;

                    ViewState["ExpenseTypeID"] = expenseID.ToString();
                }
            }
            else if (e.CommandName == "DoDelete")
            {
                try {
                    expenseID = Convert.ToInt32(e.CommandArgument);

                    using (ExpenseTypeManager repository = new ExpenseTypeManager()) {
                        expense = repository.Get(expenseID);

                        if (expense != null)
                        {
                            expense.IsActive = false;

                            expense = repository.Save(expense);

                            // refresh grid
                            bindData();
                        }
                    }
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                    showErrorMessage();
                }
            }
        }
Beispiel #9
0
        public Result GetExpenseTypes(string nameSearch, string descriptionSearch, string orderBy, string direction,
                                      int startRowIndex, int maximumRows, int branchId)
        {
            Result objResult = new Result();

            try
            {
                var param = new DbParam[7];

                param[0] = new DbParam("@SortBy", orderBy, SqlDbType.VarChar);
                param[1] = new DbParam("@SortDirection", direction, SqlDbType.VarChar);
                param[2] = new DbParam("@StartRowIndex", startRowIndex, SqlDbType.Int);
                param[3] = new DbParam("@MaximumRows", maximumRows, SqlDbType.Int);
                param[4] = new DbParam("@NameSearch", nameSearch, SqlDbType.VarChar);
                param[5] = new DbParam("@DescriptionSearch", descriptionSearch, SqlDbType.VarChar);
                param[6] = new DbParam("@BranchId", branchId, SqlDbType.Int);

                DataSet ds = Db.GetDataSet("SP_EXPENSETYPE_GET", param);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    IList <ExpenseType> expenseTypes = new List <ExpenseType>();
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        ExpenseType expenseType = new ExpenseType();
                        expenseType.ExpenseTypeId   = Db.ToInteger(row["ExpenseTypeId"]);
                        expenseType.TypeName        = Db.ToString(row["TypeName"]);
                        expenseType.TypeDescription = Db.ToString(row["TypeDescription"]);
                        expenseType.IsActive        = Db.ToBoolean(row["IsActive"]);
                        expenseTypes.Add(expenseType);
                    }

                    objResult.Items = expenseTypes;

                    objResult.ItemCount = 0;

                    if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0)
                    {
                        objResult.ItemCount = Db.ToInteger(ds.Tables[1].Rows[0]["TypeCount"]);
                    }
                }
            }
            catch (Exception ex)
            {
                //CommonFunctions.LogError(ex, ErrorLog.LogSeverity.Error);
            }
            return(objResult);
        }
 public ExpenseType DeleteExpenseType(ExpenseType expenseType)
 {
     try
     {
         expenseType.LastEditedDateTime = DateTime.UtcNow;
         expenseType.IsActive           = false;
         DbContext.ExpenseTypes.Update(expenseType);
         DbContext.SaveChanges();
         return(expenseType);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }
Beispiel #11
0
        public async Task <IActionResult> Edit(int id, ExpenseType obj)
        {
            if (id != obj.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                TempData["confirm"] = "Tipo de despesa " + obj.Name + " atualizado com sucesso.";
                await _expenseTypeService.UpdateAsync(obj);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(obj));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="etName"></param>
        /// <param name="userID"></param>
        ///<returns>returns 1 if success, 0 if fail because ExpenseType does not exists</returns>
        internal static int DeleteExpenseType(string etName, int userID)
        {
            using (var ctx = new BudgetContext())
            {
                ExpenseType eType = ctx.ExpenseTypes.FirstOrDefault(et => et.ExpenseTypeName == etName && et.ExpenseCategory.User_ID == userID);

                if (eType == null)
                {
                    return(0);
                }

                ctx.ExpenseTypes.Remove(eType);
                ctx.SaveChanges();
                return(1);
            }
        }
        internal static bool TypeOfExpenseCategoryExists(string eCat, int userID)
        {
            using (var ctx = new BudgetContext())
            {
                ExpenseType eType = ctx.ExpenseTypes.FirstOrDefault(et => et.ExpenseCategory.ExpenseCategoryName == eCat && et.ExpenseCategory.User_ID == userID);

                if (eType == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Beispiel #14
0
        public void DeclareData()
        {
            List <String> expenses = FileReader.GetUserExpenses();


            for (int i = 0; i < expenses.Count; i++)
            {
                if (expenses[i] != String.Empty)
                {
                    string      type        = expenses[i].Split(' ')[0];
                    ExpenseType expenseType = (ExpenseType)Enum.Parse(typeof(ExpenseType), type, true);
                    decimal     amount      = Convert.ToDecimal(expenses[i].Split(' ')[1]);
                    ExpensesData[expenseType] += amount;
                }
            }
        }
Beispiel #15
0
        // GET: ExpenseTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ExpenseType expenseType = db.ExpenseTypes.Find(id);

            if (expenseType == null)
            {
                return(HttpNotFound());
            }

            return(View(expenseType));
        }
Beispiel #16
0
 /// <summary>
 /// Loads a DTO version of expense type given the DB version of expense type
 /// </summary>
 /// <param name="expense">The DB model of an expense type.</param>
 /// <returns>The DTO version of an expense type.</returns>
 public static ExpenseTypeModel LoadExpenseType(ExpenseType expense)
 {
     return(new ExpenseTypeModel()
     {
         AutomationCode = expense.AutomationCode,
         CompanyPercent = expense.CompanyPercent,
         DriverPercent = expense.DriverPercent,
         ExpenseTypeDesc = expense.ExpenseTypeDesc,
         ExpenseTypeID = expense.ExpenseTypeID,
         ExpenseTypeName = expense.ExpenseTypeName,
         FrequencyTypeId = expense.FrequencyTypeId,
         FrequencyTypeName = expense.FrequencyType.FrequencyName,
         CompanyGLAccount = expense.SMEGLAccount,
         DriverGLAccount = expense.DriverGLAccount
     });
 }
Beispiel #17
0
 public Expense(
     DateTime transactionDate,
     DateTime postDate,
     string description,
     ExpenseCategory category,
     ExpenseType type,
     decimal amount)
 {
     TransactionDate = transactionDate;
     PostDate        = postDate;
     Description     = description;
     Category        = category;
     Type            = type;
     Amount          = amount;
     ImportDate      = DateTime.UtcNow;
 }
Beispiel #18
0
        internal Expense(ExpenseType expenseType, decimal value, DateTime expenseDate, int expenseMonth, Guid?expenseRecipientId, int?expenseCategoryId, string expenseRecipientDetailCode, string details1, string details2, Guid?expenseSourceId)
        {
            ExpenseId                  = Guid.NewGuid();
            ExpenseType                = expenseType;
            Value                      = value;
            ExpenseDate                = expenseDate;
            ExpenseMonth               = expenseMonth;
            ExpenseRecipientId         = expenseRecipientId;
            ExpenseCategoryId          = expenseCategoryId;
            ExpenseRecipientDetailCode = expenseRecipientDetailCode;
            Details1                   = details1;
            Details2                   = details2;
            ExpenseSourceId            = expenseSourceId;

            AddEvent(new ExpenseAdded(ExpenseId, ExpenseType, Value, ExpenseDate, ExpenseRecipientId, ExpenseCategoryId, ExpenseRecipientDetailCode, Details1, Details2, ExpenseSourceId, ExpenseMonth));
        }
Beispiel #19
0
        protected void dgTravelAdvanceRequestCost_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            tac = Session["tac"] as TravelAdvanceRequestDetail;
            if (e.CommandName == "AddNew")
            {
                try
                {
                    TravelAdvanceCost taCost = new TravelAdvanceCost();
                    taCost.TravelAdvanceRequestDetail = tac;
                    DropDownList ddlAccountDescription = e.Item.FindControl("ddlAccountDescription") as DropDownList;
                    ItemAccount  itemAccount           = _presenter.GetItemAccount(Convert.ToInt32(ddlAccountDescription.SelectedValue));
                    taCost.ItemAccount = itemAccount;
                    taCost.AccountCode = itemAccount.AccountCode;
                    DropDownList ddlExpenseType = e.Item.FindControl("ddlExpenseType") as DropDownList;
                    ExpenseType  expensetype    = _presenter.GetExpenseType(int.Parse(ddlExpenseType.SelectedValue));
                    taCost.ExpenseType = expensetype;
                    TextBox txtDays = e.Item.FindControl("txtDays") as TextBox;
                    taCost.Days = Convert.ToInt32(txtDays.Text);
                    TextBox txtUnitCost = e.Item.FindControl("txtUnitCost") as TextBox;
                    taCost.UnitCost = Convert.ToDecimal(txtUnitCost.Text);
                    TextBox txtNoOfUnits = e.Item.FindControl("txtNoOfUnits") as TextBox;
                    taCost.NoOfUnits = Convert.ToInt32(txtNoOfUnits.Text);
                    //TextBox txtTotal = e.Item.FindControl("txtTotal") as TextBox;
                    taCost.Total = Convert.ToInt32(txtDays.Text) * Convert.ToDecimal(txtUnitCost.Text) * Convert.ToInt32(txtNoOfUnits.Text);
                    _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance = _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance + taCost.Total;
                    txtTotal.Text = (_presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance).ToString();
                    if (_presenter.CurrentTravelAdvanceRequest.Id > 0)
                    {
                        _presenter.CurrentTravelAdvanceRequest.GetTravelAdvanceRequestDetail(Convert.ToInt32(hfDetailId.Value)).TravelAdvanceCosts.Add(taCost);
                    }
                    else
                    {
                        _presenter.CurrentTravelAdvanceRequest.TravelAdvanceRequestDetails[Convert.ToInt32(hfDetailId.Value)].TravelAdvanceCosts.Add(taCost);
                    }

                    dgTravelAdvanceRequestCost.EditItemIndex = -1;
                    BindCostsGrid(taCost.TravelAdvanceRequestDetail);
                    ScriptManager.RegisterStartupScript(this, GetType(), "showCostModal", "showCostModal();", true);
                }
                catch (Exception ex)
                {
                    Master.ShowMessage(new AppMessage("Error: Unable to Save Travel Advance Cost " + ex.Message, RMessageType.Error));
                    ExceptionUtility.LogException(ex, ex.Source);
                    ExceptionUtility.NotifySystemOps(ex, _presenter.CurrentUser().FullName);
                }
            }
        }
        protected void dgTravelAdvanceRequestCost_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            tac = Session["tac"] as TravelAdvanceRequestDetail;
            int id = (int)dgTravelAdvanceRequestCost.DataKeys[e.Item.ItemIndex];
            TravelAdvanceCost taCost;
            decimal           pretacost = 0;

            if (id > 0)
            {
                taCost = tac.GetTravelAdvanceCost(id);
            }
            else
            {
                taCost = tac.TravelAdvanceCosts[e.Item.ItemIndex];
            }

            try
            {
                taCost.TravelAdvanceRequestDetail = taCost.TravelAdvanceRequestDetail;
                DropDownList ddlEdtAccountDescription = e.Item.FindControl("ddlEdtAccountDescription") as DropDownList;
                ItemAccount  itemEdtAccount           = _presenter.GetItemAccount(Convert.ToInt32(ddlEdtAccountDescription.SelectedValue));
                taCost.ItemAccount = itemEdtAccount;
                taCost.AccountCode = itemEdtAccount.AccountCode;
                DropDownList ddlExpenseType = e.Item.FindControl("ddlEdtExpenseType") as DropDownList;
                ExpenseType  expensetype    = _presenter.GetExpenseType(int.Parse(ddlExpenseType.SelectedValue));
                taCost.ExpenseType = expensetype;
                TextBox txtEdtDays = e.Item.FindControl("txtEdtDays") as TextBox;
                taCost.Days = Convert.ToInt32(txtEdtDays.Text);
                TextBox txtEdtUnitCost = e.Item.FindControl("txtEdtUnitCost") as TextBox;
                taCost.UnitCost = Convert.ToDecimal(txtEdtUnitCost.Text);
                TextBox txtEdtNoOfUnits = e.Item.FindControl("txtEdtNoOfUnits") as TextBox;
                taCost.NoOfUnits = Convert.ToInt32(txtEdtNoOfUnits.Text);
                //TextBox txtEdtTotal = e.Item.FindControl("txtEdtTotal") as TextBox;
                pretacost    = taCost.Total;
                taCost.Total = Convert.ToInt32(txtEdtDays.Text) * Convert.ToDecimal(txtEdtUnitCost.Text) * Convert.ToInt32(txtEdtNoOfUnits.Text);
                _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance = (_presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance + taCost.Total) - pretacost;
                txtTotal.Text = (_presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance).ToString();
                dgTravelAdvanceRequestCost.EditItemIndex = -1;
                BindCostsGrid(taCost.TravelAdvanceRequestDetail);
                pnlTACost_ModalPopupExtender.Show();
                Master.ShowMessage(new AppMessage("Travel Advance Cost Successfully Updated", Chai.WorkflowManagment.Enums.RMessageType.Info));
            }
            catch (Exception ex)
            {
                Master.ShowMessage(new AppMessage("Error: Unable to Update Travel Advance Cost " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error));
            }
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            string name = nameTextBox.Text;

            if (name == "")
            {
                MessageBox.Show("Choose a name");
                return;
            }

            ExpenseType = new ExpenseType()
            {
                Name = name
            };

            this.DialogResult = true;
        }
 public IActionResult Post([FromBody] ExpenseType type)
 {
     if (ModelState.IsValid)
     {
         if (type.Id == 0)
         {
             _service.AddNewType(type);
             return(Created("/expenseTypes/" + type.Id, type));
         }
         else
         {
             _service.EditType(type);
             return(Ok());
         }
     }
     return(BadRequest(ModelState));
 }
        public static Expense ToExpense(ExpensePostModel expense)
        {
            ExpenseType expenseType = 0;

            if (expense.ExpenseType == "other")
            {
                expenseType = Models.ExpenseType.other;
            }
            if (expense.ExpenseType == "food")
            {
                expenseType = Models.ExpenseType.food;
            }
            else if (expense.ExpenseType == "utilities")
            {
                expenseType = Models.ExpenseType.utilities;
            }
            else if (expense.ExpenseType == "transportation")
            {
                expenseType = Models.ExpenseType.transportation;
            }
            else if (expense.ExpenseType == "outing")
            {
                expenseType = Models.ExpenseType.outing;
            }
            else if (expense.ExpenseType == "groceries")
            {
                expenseType = Models.ExpenseType.groceries;
            }
            else if (expense.ExpenseType == "clothes")
            {
                expenseType = Models.ExpenseType.clothes;
            }
            else if (expense.ExpenseType == "electronics")
            {
                expenseType = Models.ExpenseType.electronics;
            }
            return(new Expense
            {
                Description = expense.Description,
                Sum = expense.Sum,
                Location = expense.Location,
                Date = expense.Date,
                Comments = expense.Comments,
                ExpenseType = expenseType
            });
        }
Beispiel #24
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                ExpenseType obj = await _expenseTypeService.FindByIdAsync(id);

                await _expenseTypeService.RemoveAsync(id);

                TempData["confirm"] = "Tipo de despesa " + obj.Name + " excluído com sucesso.";
                return(RedirectToAction(nameof(Index)));
            }
            catch (IntegrityException e)
            {
                TempData["error"] = e.Message;
                return(RedirectToAction(nameof(Index)));
            }
        }
Beispiel #25
0
        public Expense(string description, Amount amount, ExpenseType type, DateTimeOffset date, Guid accountId, Guid tenantId,
                       IEnumerable <Tag> tags = default)
        {
            Description = description;
            Amount      = amount;
            Type        = type;
            Date        = date;
            AccountId   = accountId;
            TenantId    = tenantId;

            if (tags != default)
            {
                Tags = tags.ToList();
            }

            IsValid();
        }
        //编辑类别
        private void editType_Click(object sender, EventArgs e)
        {
            if (typeTree.SelectedNode == null ||
                db.Job.FirstOrDefault(x => x.name == typeTree.SelectedNode.Text) == null)
            {
                GeneralClass.printErrorMsg("没有选择类别!");
                return;
            }

            ExpenseType     job     = db.ExpenseType.FirstOrDefault(x => x.name == typeTree.SelectedNode.Text);
            ExpenseTypeForm editJob = new ExpenseTypeForm(db, job);

            if (editJob.ShowDialog() == DialogResult.OK)
            {
                createTree();
            }
        }
Beispiel #27
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ExpenseType = await _context.ExpenseTypes.FindAsync(id);

            if (ExpenseType != null)
            {
                _context.ExpenseTypes.Remove(ExpenseType);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        protected void dgTravelAdvanceRequestCost_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            tac = Session["tac"] as TravelAdvanceRequestDetail;
            if (e.CommandName == "AddNew")
            {
                try
                {
                    TravelAdvanceCost taCost = new TravelAdvanceCost();
                    taCost.TravelAdvanceRequestDetail = tac;
                    DropDownList ddlAccountDescription = e.Item.FindControl("ddlAccountDescription") as DropDownList;
                    ItemAccount  itemAccount           = _presenter.GetItemAccount(Convert.ToInt32(ddlAccountDescription.SelectedValue));
                    taCost.ItemAccount = itemAccount;
                    taCost.AccountCode = itemAccount.AccountCode;
                    DropDownList ddlExpenseType = e.Item.FindControl("ddlExpenseType") as DropDownList;
                    ExpenseType  expensetype    = _presenter.GetExpenseType(int.Parse(ddlExpenseType.SelectedValue));
                    taCost.ExpenseType = expensetype;
                    TextBox txtDays = e.Item.FindControl("txtDays") as TextBox;
                    taCost.Days = Convert.ToInt32(txtDays.Text);
                    TextBox txtUnitCost = e.Item.FindControl("txtUnitCost") as TextBox;
                    taCost.UnitCost = Convert.ToDecimal(txtUnitCost.Text);
                    TextBox txtNoOfUnits = e.Item.FindControl("txtNoOfUnits") as TextBox;
                    taCost.NoOfUnits = Convert.ToInt32(txtNoOfUnits.Text);
                    //TextBox txtTotal = e.Item.FindControl("txtTotal") as TextBox;
                    taCost.Total = Convert.ToInt32(txtDays.Text) * Convert.ToDecimal(txtUnitCost.Text) * Convert.ToInt32(txtNoOfUnits.Text);
                    _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance = _presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance + taCost.Total;
                    txtTotal.Text = (_presenter.CurrentTravelAdvanceRequest.TotalTravelAdvance).ToString();
                    if (_presenter.CurrentTravelAdvanceRequest.Id > 0)
                    {
                        _presenter.CurrentTravelAdvanceRequest.GetTravelAdvanceRequestDetail(Convert.ToInt32(hfDetailId.Value)).TravelAdvanceCosts.Add(taCost);
                    }
                    else
                    {
                        _presenter.CurrentTravelAdvanceRequest.TravelAdvanceRequestDetails[Convert.ToInt32(hfDetailId.Value)].TravelAdvanceCosts.Add(taCost);
                    }

                    dgTravelAdvanceRequestCost.EditItemIndex = -1;
                    BindCostsGrid(taCost.TravelAdvanceRequestDetail);
                    pnlTACost_ModalPopupExtender.Show();
                }
                catch (Exception ex)
                {
                    Master.ShowMessage(new AppMessage("Error: Unable to Save Travel Advance Cost " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error));
                }
            }
        }
Beispiel #29
0
        public JsonResult PayManagerFee(int[] IDs)
        {
            DateTime    date   = DateTime.Now;
            int         userID = db.CurrentUser.ID;
            ExpenseType type   = db.ExpenseTypes.FirstOrDefault(val => val.ManagerFee);

            if (type == null)
            {
                return(Json(new { Success = false, Error = "Необходимо настроить тип расхода для выдачи % менеджера" }));
            }
            List <Project> projects = db.Projects.Where(val => IDs.Contains(val.ID)).ToList();

            foreach (Project p in projects)
            {
                var e = new EntityJs.Client.Events.CheckPermissionsEventArgs(db, "Projects", "Project", p, EntityJs.Client.Events.ActionsEnum.Select);
                p.OnCheckPermissions(e);
                decimal sum = Math.Round(p.ManagerFeeAmount - p.ManagerFeePaid, 2);
                if (e.Cancel || sum <= 0)
                {
                    continue;
                }
                Employee employee = p.UserResponsible.Employee;
                if (employee == null)
                {
                    continue;
                }
                Expense ex = new Expense()
                {
                    Date       = date,
                    ChangeDate = date,
                    ChangerID  = userID,
                    CreateDate = date,
                    CreatorID  = userID,
                    EmployeeID = employee.ID,
                    ProjectID  = p.ID,
                    Sum        = sum,
                    PeriodSum  = sum,
                    TypeID     = type.ID,
                    WalletID   = employee.WalletID.Value
                };
                db.Expenses.AddObject(ex);
            }
            db.SaveChanges();
            return(Json(new { Success = true }));
        }
Beispiel #30
0
 private void ExecuteSaveExpense()
 {
     if (ValidateExpense())
     {
         using (var unitOfWork = new UnitOfWork(new MahalluDBContext())) {
             MahalluManager.Model.Expense expense = GetExpense();
             unitOfWork.Expenses.Add(expense);
             unitOfWork.Complete();
             ExpenseList.Add(expense);
             CurrentExpense = expense;
             ExpenseType totatExpenseType = new ExpenseType()
             {
                 Expense = CurrentExpense
             };
             eventAggregator.GetEvent <PubSubEvent <ExpenseType> >().Publish(totatExpenseType);
         }
     }
 }
        public saveExpense(string user)
        {
            currentUser = user;
            InitializeComponent();
            PharmacyDbContext  db    = new PharmacyDbContext();
            List <ExpenseType> types = db.ExpenseType.ToList();
            ExpenseType        first = new ExpenseType
            {
                Id   = "0",
                Type = "-- select one --"
            };

            types.Insert(0, first);
            cbExpenseType.DataSource    = types;
            cbExpenseType.DisplayMember = "Type"; // types.Select(o => o.Type).ToString();
            cbExpenseType.ValueMember   = "Id";   // types.Select(o => o.Id).ToString();
            db.Dispose();
        }
    public static void AddExpense(ExpenseType type, Departments dept, float amt, float amtMod = 0)
    {
        if (GameManager.isInDemoMode)
        {
            return;
        }
        RemoveExpense(type, dept);

        ExpensesData data = new ExpensesData()
        {
            type       = type,
            department = dept,
            amount     = amt,
            amountMod  = amtMod
        };

        instance.expenses.Add(data);
    }
Beispiel #33
0
        // Atualizar:
        public async Task UpdateAsync(ExpenseType obj)
        {
            bool hasAny = await _context.ExpensesTypes.AnyAsync(t => t.Id == obj.Id);

            if (!hasAny)
            {
                throw new Exception("not found");
            }
            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
Beispiel #34
0
        /// <summary>
        /// Load the KarmaLogEntry from the XmlNode.
        /// </summary>
        /// <param name="objNode">XmlNode to load.</param>
        public void Load(XmlNode objNode)
        {
            _guiID   = Guid.Parse(objNode["guid"].InnerText);
            _datDate = DateTime.Parse(objNode["date"]?.InnerText, GlobalOptions.InvariantCultureInfo);
            objNode.TryGetDecFieldQuickly("amount", ref _decAmount);
            objNode.TryGetStringFieldQuickly("reason", ref _strReason);
            if (objNode["type"] != null)
            {
                _objExpenseType = ConvertToExpenseType(objNode["type"].InnerText);
            }
            objNode.TryGetBoolFieldQuickly("refund", ref _blnRefund);

            if (objNode["undo"] != null)
            {
                _objUndo = new ExpenseUndo();
                _objUndo.Load(objNode["undo"]);
            }
        }
Beispiel #35
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ExpenseType expense   = null;
            int         expenseID = 0;

            lblMessage.Text     = string.Empty;
            lblMessage.CssClass = string.Empty;

            expenseID = Convert.ToInt32(ViewState["ExpenseTypeID"]);

            if (expenseID == 0)
            {
                expense          = new ExpenseType();
                expense.ClientID = this.clientID;
                expense.IsActive = true;
            }
            else
            {
                using (ExpenseTypeManager repository = new ExpenseTypeManager()) {
                    expense = repository.Get(expenseID);
                }
            }

            if (expense != null)
            {
                expense.ExpenseName        = txtExpenseName.Text.Trim();
                expense.ExpenseDescription = txtExpenseDescription.Text.Trim();

                try {
                    using (ExpenseTypeManager repository = new ExpenseTypeManager()) {
                        expense = repository.Save(expense);
                    }

                    showGridPanel();

                    // refresh grid
                    bindData();
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                    showErrorMessage();
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ExpenseType expense = null;
            int expenseID = 0;

            lblMessage.Text = string.Empty;
            lblMessage.CssClass = string.Empty;

            expenseID = Convert.ToInt32(ViewState["ExpenseTypeID"]);

            try {
                using (ExpenseTypeManager repository = new ExpenseTypeManager()) {
                    if (expenseID == 0) {
                        expense = new ExpenseType();
                        expense.ClientID = Core.SessionHelper.getClientId();
                        expense.IsActive = true;
                    }
                    else {
                        expense = repository.Get(expenseID);
                    }

                    if (expense != null) {
                        expense.ExpenseName = txtExpenseName.Text.Trim();
                        expense.ExpenseDescription = txtExpenseDescription.Text.Trim();
                        expense.ExpenseRate = txtRateAmount.ValueDecimal;

                        expense = repository.Save(expense);

                        showGridPanel();

                        // refresh grid
                        bindData();
                    }
                }

            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);
                showErrorMessage();
            }
        }
 public Expense(ExpenseType type, int amount)
 {
     this.type = type;
     this.amount = amount;
 }
Beispiel #38
0
 public virtual AbstractExpenseItem CreateNewExpenseItem(Claim claim, ExpenseType typeOfExpense) {
     var item = (AbstractExpenseItem) (NewTransientInstance(Type.GetType(typeOfExpense.CorrespondingClassName)));
     item.ExpenseType = typeOfExpense;
     item.ModifyProjectCode(claim.ProjectCode);
     item.Claim = claim;
     item.InitialiseAmount();
     return item;
 }
Beispiel #39
0
            public IList<AbstractExpenseItem> findExpenseItemsOfType(Employee employee, ExpenseType type) {
                IQueryable<AbstractExpenseItem> query =
                    from item in Instances<AbstractExpenseItem>()
                    where item.ExpenseType.Equals(type) && item.Claim.Claimant.Equals(employee)
                    select item;

                return query.ToList();
            }
        protected void btnAddExpense_save_Click(object sender, EventArgs e)
        {
            CarrierInvoiceProfileFeeItemized item = null;
            ExpenseType expense = null; //NEW to account for rate pointing to correct place
            Page.Validate("expense");
            if (!Page.IsValid)
                return;

            int profileID = Convert.ToInt32(ViewState["profileID"]);

            int id = Convert.ToInt32(ViewState["ID"]);

            if (id == 0) {
                item = new CarrierInvoiceProfileFeeItemized();

                item.CarrierInvoiceProfileID = profileID;

                item.IsActive = true;
            }
            else {
                item = CarrierInvoiceProfileFeeItemizedManager.Get(id);
            }

            if (item != null) {
                item.ExpenseTypeID = Convert.ToInt32(ddlExpenses.SelectedValue);

                item.ItemDescription = txtExpenseDescription.Text;

                item.ItemPercentage = txtExpensePercentage.ValueDecimal;

                item.ItemRate = txtExpenseRate.ValueDecimal;

                item.AdjusterPayroll = txtExpPayroll.Text == null ? 0 : txtExpPayroll.ValueDecimal;

                item.AdjusterPayrollFlatFee = txtExpPayrollFee.Text == null ? 0 : txtExpPayrollFee.ValueDecimal;

                if (ddlConditionalOperator.SelectedIndex > 0) {
                    item.LogicalOperator = Convert.ToInt32(ddlConditionalOperator.SelectedValue);
                    item.LogicalOperatorOperand = txtOperand.ValueDecimal;
                }
                else {
                    item.LogicalOperator = null;
                    item.LogicalOperatorOperand = 0;
                }

                try {
                    CarrierInvoiceProfileFeeItemizedManager.Save(item);
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }
                //new OC to save the expense rate into the expense type table 10/8/14
                try
                {
                    using (ExpenseTypeManager repository = new ExpenseTypeManager())
                    {
                        int expenseID = Convert.ToInt32(ddlExpenses.SelectedValue);
                        if (expenseID == 0)
                        {
                            expense = new ExpenseType();
                            expense.ClientID = Core.SessionHelper.getClientId();
                            expense.IsActive = true;
                        }
                        else
                        {
                            expense = repository.Get(expenseID);
                        }

                        if (expense != null)
                        {
                            expense.ExpenseRate = txtExpenseRate.ValueDecimal; //txtRateAmount.ValueDecimal;
                            expense = repository.Save(expense);

                        }
                    }

                }
                catch (Exception ex)
                {
                    Core.EmailHelper.emailError(ex);

                }

                pnlAddExpense.Visible = false;
                pnlGrid.Visible = true;

                bindItems(profileID);
            }
        }
 public RouteFacility(
     string uid,
     FacilityType type,
     string name,
     int serviceLevel,
     ExpenseType eType,
     double expense,
     FeeType feeType,
     AirlineFacility requires)
 {
     Type = type;
     Name = name;
     Uid = uid;
     ServiceLevel = serviceLevel;
     EType = eType;
     ExpensePerPassenger = expense;
     FeeType = feeType;
     Requires = requires;
 }
Beispiel #42
0
 /// <summary>
 /// Load the KarmaLogEntry from the XmlNode.
 /// </summary>
 /// <param name="objNode">XmlNode to load.</param>
 public void Load(XmlNode objNode)
 {
     _guiID = Guid.Parse(objNode["guid"].InnerText);
     _datDate = DateTime.Parse(objNode["date"].InnerText, GlobalOptions.Instance.CultureInfo);
     _intAmount = Convert.ToInt32(objNode["amount"].InnerText);
     _strReason = objNode["reason"].InnerText;
     _objExpenseType = ConvertToExpenseType(objNode["type"].InnerText);
     try
     {
         _blnRefund = Convert.ToBoolean(objNode["refund"].InnerText);
     }
     catch
     {
     }
     try
     {
         if (objNode["undo"] != null)
         {
             _objUndo = new ExpenseUndo();
             _objUndo.Load(objNode["undo"]);
         }
     }
     catch
     {
     }
 }
Beispiel #43
0
 /// <summary>
 /// Create a new Expense Log Entry.
 /// </summary>
 /// <param name="intKarma">Amount of the Karma/Nuyen expense.</param>
 /// <param name="strReason">Reason for the Karma/Nueyn change.</param>
 /// <param name="objExpenseType">Type of expense, either Karma or Nuyen.</param>
 /// <param name="datDate">Date and time of the Expense.</param>
 /// <param name="blnRefund">Whether or not this expense is a Karma refund.</param>
 public void Create(int intKarma, string strReason, ExpenseType objExpenseType, DateTime datDate, bool blnRefund = false)
 {
     if (blnRefund)
         strReason += " (" + LanguageManager.Instance.GetString("String_Expense_Refund") + ")";
     _intAmount = intKarma;
     _strReason = strReason;
     _datDate = datDate;
     _objExpenseType = objExpenseType;
     _blnRefund = blnRefund;
 }
Beispiel #44
0
 public virtual AbstractExpenseItem CreateNewExpenseItem(ExpenseType type) {
     return m_claimRepository.CreateNewExpenseItem(this, type);
 }
Beispiel #45
0
 //generalized recording expenses
 public void AddExpense(ExpenseType type, double expense)
 {
     ExpenseList.Add(new ExpenseRecord(type, expense));
 }