コード例 #1
0
        public async Task <IActionResult> Edit(Allowance all)
        {
            if (!ModelState.IsValid)
            {
                return(View(all));
            }

            int currentUsersCompanyId = User.Identity.GetCompanyId();

            all.CompanyId = currentUsersCompanyId;

            _context.Attach(all).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AllowanceExists(all.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToAction("Index"));
        }
コード例 #2
0
        private static Allowance GetAllowance()
        {
            Allowance _allowance       = null;
            var       _allowanceResult = SalaryHandler.Instance.SalaryClient.GetAllowances(SalaryHandler.Instance.Token);

            foreach (var _apiMessage in _allowanceResult.Messages)
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug(_apiMessage.Message);
                }
            }

            if (_allowanceResult.ResponseState == TransactionalApi.SDK.SalaryService.ExecutionStatus.Success)
            {
                _allowance = _allowanceResult.Return.FirstOrDefault();
            }

            if (_allowance == null)
            {
                throw new ArgumentException("No allowance found");
            }

            if (Logger.IsDebugEnabled)
            {
                Logger.Debug("Allowance selected: " + _allowance.Name);
            }

            return(_allowance);
        }
コード例 #3
0
        public IActionResult UpdateAllowances([FromBody] Allowance model)
        {
            try
            {
                var allowance = _service.AddAllowance(model);
                // Audit Log
                var audit = new AuditLog
                {
                    UserId         = CurrentUser.Id,
                    EntityId       = model.Id.ToString(),
                    EntityType     = AuditLogs.EntityType.Allowances,
                    ActionType     = AuditLogs.ActionType.UpdatedAllowance,
                    PostValue      = Serializer.Serialize(model),
                    DistrictId     = CurrentUser.DistrictId,
                    OrganizationId = CurrentUser.OrganizationId == "-1" ? null : CurrentUser.OrganizationId
                };
                _audit.InsertAuditLog(audit);

                return(Ok(allowance));
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
            return(null);
        }
コード例 #4
0
        private async Task SendMail(Allowance allowance = null)
        {
            var user = await userManager.GetUserAsync(HttpContext.User);

            var users = _context.User.Where(e => e.CategoryId == user.CategoryId).ToList();

            if (allowance != null)
            {
                await emailService.SendEmailAsync(allowance.CreatedBy?.Email, "Allowance " + allowance.ApprovedStatus,
                                                  GetUserAllowanceHtml(allowance, allowance.CreatedBy?.Name));

                await emailService.SendEmailAsync(user.Email, "Allowance " + allowance.ApprovedStatus,
                                                  GetTLAllowanceHtml(allowance, user.Name));
            }

            List <Allowance> allowancesAll = new List <Allowance>();

            foreach (var item in users)
            {
                var allowances = _context.Allowance.Where(e => e.CreatedById == item.Id && e.ApprovedStatus.ToString() == Constants.PENDING).Include(a => a.AllowanceType).Include(e => e.AssignedBy)
                                 .Include(e => e.AssignedCategory).Include(e => e.CreatedBy).ToList();
                allowancesAll.AddRange(allowances);
            }
            if (allowancesAll.Where(e => e.ApprovedStatus.ToString() == Constants.PENDING).ToList().Count == 0)
            {
                var financeTeam = userManager.Users.Where(e => e.Category.CategoryName == Constants.FINANCE);
                foreach (var finance in financeTeam)
                {
                    await emailService.SendEmailAsync(finance.Email, "Allowance Approved",
                                                      GetTeamAllowanceHtml(user.Category?.CategoryName, finance.Name));
                }
            }
        }
コード例 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Allowance allowance = db.Allowances.Find(id);

            db.Allowances.Remove(allowance);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "AllowanceId,Type,Amount,Currency")] Allowance allowance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(allowance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(allowance));
 }
コード例 #7
0
ファイル: AllowancesController.cs プロジェクト: MdZaeed/BUEMS
 public ActionResult Edit([Bind(Include = "SerialNo,DutyName,AllowanceAmount")] Allowance allowance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(allowance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(allowance));
 }
 public void RegisterResult(long requestSerial, Allowance requestAllowance)
 {
     lock (_resultsProcessingLock)
     {
         if (requestSerial > _processedSerial)
         {
             _processedSerial   = requestSerial;
             _currentMeterValue = requestAllowance.Remaining;
         }
     }
 }
コード例 #9
0
        private string GetUserAllowanceHtml(Allowance allowance, string name)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<!DOCTYPE html><html><body><p>Dear " + name + ",</p>");

            sb.Append("<p> Your allowance amount " + allowance.Price + " has been " + allowance.ApprovedStatus + "</p>");

            sb.Append("<hr><p><font color='red'> ***This is an automatically generated message, please do not reply to this message * **</font></p></body></html>");
            return(sb.ToString());
        }
コード例 #10
0
        public ActionResult Create([Bind(Include = "AllowanceId,Type,Amount,Currency")] Allowance allowance)
        {
            if (ModelState.IsValid)
            {
                db.Allowances.Add(allowance);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(allowance));
        }
コード例 #11
0
 public bool CreateAllowance(Allowance allowance)
 {
     _dbContext.Allowances.Add(new Allowance()
     {
         AllowanceID     = allowance.AllowanceID,
         AllowanceDetail = allowance.AllowanceDetail,
         AllowanceMoney  = allowance.AllowanceMoney
     });
     _dbContext.SaveChanges();
     return(true);
 }
コード例 #12
0
ファイル: AllowancesController.cs プロジェクト: MdZaeed/BUEMS
        public ActionResult Create([Bind(Include = "SerialNo,DutyName,AllowanceAmount")] Allowance allowance)
        {
            if (ModelState.IsValid)
            {
                db.Allowances.Add(allowance);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(allowance));
        }
コード例 #13
0
 public Minutes MinutesWhichCanCover(PhoneCall phoneCall, IClock clock)
 {
     if (Allowance.IsGreaterOrEqualTo(phoneCall.Minutes))
     {
         return(phoneCall.Minutes);
     }
     else
     {
         return(Allowance);
     }
 }
コード例 #14
0
        private string GetProcurementAllowanceHtml(Allowance allowance, string tlName)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<!DOCTYPE html><html><body><p>Dear " + tlName + ",</p>");

            sb.Append("<p> Allowance amount " + allowance.Price + " has been applied by " + allowance.CreatedBy?.Name + "</p>");

            sb.Append("<hr><p><font color='red'> ***This is an automatically generated message, please do not reply to this message * **</font></p></body></html>");
            return(sb.ToString());
        }
コード例 #15
0
        public async Task <IActionResult> Create(AllowanceViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = await userManager.GetUserAsync(HttpContext.User);

                var allowance = new Allowance();
                allowance.Description      = viewModel.Comments;
                allowance.ApprovedStatus   = ApprovedStatus.PENDING;
                allowance.AllowanceType    = _context.AllowanceType.SingleOrDefault(e => e.AllowanceTypeId.ToString() == viewModel.AllowanceTypeId);
                allowance.AllowanceDates   = JsonConvert.SerializeObject(AllowanceDates);
                allowance.NumberOfDays     = AllowanceDates.Count();
                allowance.Price            = viewModel.Price;
                allowance.CreatedOn        = DateTime.Now;
                allowance.CreatedBy        = user;
                allowance.AssignedBy       = user;
                allowance.AssignedCategory = _context.Category.SingleOrDefault(e => e.CategoryId == user.CategoryId);
                allowance.Month            = Convert.ToDateTime(AllowanceDates.FirstOrDefault());
                _context.Add(allowance);
                await _context.SaveChangesAsync();

                if (user.Category.CategoryName == "PROCUREMENT")
                {
                    ApplicationUser teamLeader = (from tl in _context.User
                                                  join role in _context.UserRoles
                                                  on tl.Id equals role.UserId
                                                  where tl.CategoryId == user.CategoryId
                                                  select tl).FirstOrDefault();

                    if (teamLeader?.Id != null)
                    {
                        await Task.Run(() => emailService.SendEmailAsync(teamLeader.Email, "Allowance " + allowance.ApprovedStatus,
                                                                         GetProcurementAllowanceHtml(allowance, user.Name)));
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            viewModel.AllowanceTypes = _context.AllowanceType.Where(e => e.IsActive).Select(e => new SelectListItem
            {
                Text     = e.AllowanceTypeName,
                Value    = e.AllowanceTypeId.ToString(),
                Selected = e.AllowanceTypeId.ToString() == viewModel.AllowanceTypeId ? true : false
            }).ToList();
            viewModel.ApprovedStatus = Enum.GetValues(typeof(ApprovedStatus)).Cast <ApprovedStatus>().Select(v => new SelectListItem
            {
                Text     = v.ToString(),
                Value    = ((int)v).ToString(),
                Selected = ((int)v).ToString() == viewModel.ApprovedStatusId ? true : false
            }).ToList();
            return(View(viewModel));
        }
コード例 #16
0
        // GET: /Allowance/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Allowance allowance = db.Allowances.Find(id);

            if (allowance == null)
            {
                return(HttpNotFound());
            }
            return(View(allowance));
        }
コード例 #17
0
        public void TestInvoiceAllowance()
        {
            //1. 設定開立折讓資訊
            var allowance = new Allowance
            {
                //廠商編號。
                MerchantID = "2000132",
                //發票號碼。
                InvoiceNo = "XW00006065",
                //通知類別
                allowanceNotify = AllowanceNotifyEnum.SMS,
                //客戶名稱
                CustomerName = "客戶名稱",
                //客戶手機號碼
                NotifyPhone = "0912345678",
                //客戶電子信箱
                NotifyMail = "",
                //折讓單總金額(含稅總金額)。
                AllowanceAmount = "1"
            };

            //2. 商品資訊的集合類別
            allowance.Items.Add(new Item
            {
                ItemName   = "糧食", //商品名稱
                ItemPrice  = "1",  //商品單價
                ItemCount  = "1",  //商品數量
                ItemWord   = "個",  //單位
                ItemAmount = "1",  //總金額
                //ItemTaxType  =TaxTypeEnum.DutyFree//商品課稅別
            });

            //3. 執行API的回傳結果
            var response = Client.Post <AllowanceReturn, Allowance>(allowance);

            //TODO : 會因為測試讓金額變得越小

            //表示成功
            Assert.AreEqual("1", response.RtnCode);

            //要有時間
            Assert.AreNotEqual("", response.IA_Date);

            //折讓單號
            Assert.AreNotEqual("", response.IA_Allow_No);

            //發票號碼要和送出時一樣
            Assert.AreEqual(allowance.InvoiceNo, response.IA_Invoice_No);
        }
コード例 #18
0
        public IActionResult AddAllowances([FromBody] Allowance model)
        {
            try
            {
                var allowance = _service.AddAllowance(model);

                return(Ok(allowance));
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
            return(null);
        }
コード例 #19
0
 public HttpResponseMessage PostNewAllowance(Allowance allowance)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid data!!!"));
         }
         allowanceManager.CreateAllowance(allowance);
         return(Request.CreateResponse(HttpStatusCode.OK, "Allowance created!"));
     }
     catch (Exception e)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error occured while executing PostNewAllowance:" + e.Message));
     }
 }
コード例 #20
0
ファイル: A2.cs プロジェクト: nb-spaceship/ontology-test
        public static object allowance_ong(object[] args)
        {
            byte[] address =
            {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x02
            };

            byte[] from = (byte[])args[0];
            byte[] to   = (byte[])args[1];

            Allowance allowanceparam = new Allowance {
                From = from, To = to
            };

            return(Native.Invoke(0, address, "allowance", allowanceparam));
        }
コード例 #21
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            int currentUsersCompanyId = User.Identity.GetCompanyId();

            Allowance allowance = await _context.Allowances.FirstOrDefaultAsync(x => x.Id == id && x.CompanyId == currentUsersCompanyId);

            if (allowance == null)
            {
                return(NotFound());
            }

            return(View(allowance));
        }
コード例 #22
0
        public Allowance AddAllowance(Allowance allowance)
        {
            var sql         = allowance.Id > 0 ? "[Location].[sp_updateAllowance]" : "[Location].[sp_insertAllowance]";
            var queryParams = new DynamicParameters();

            queryParams.Add("@Id", allowance.Id);
            queryParams.Add("@DistrictId", allowance.DistrictId);
            queryParams.Add("@Title", allowance.Title);
            queryParams.Add("@YearlyAllowance", allowance.YearlyAllowance);
            queryParams.Add("@IsDeductAllowance", allowance.IsDeductAllowance);
            queryParams.Add("@IsResidualDays", allowance.IsResidualDays);
            queryParams.Add("@IsEnalbled", allowance.IsEnalbled);
            queryParams.Add("@ExpirationStartDate", allowance.ExpirationStartDate);
            queryParams.Add("@ExpirationEndDate", allowance.ExpirationEndDate);
            queryParams.Add("@IsExpired", allowance.IsExpired);
            queryParams.Add("@IsExpiredAtEndOfYear", allowance.IsExpiredAtEndOfYear);
            return(Db.Query <Allowance>(sql, queryParams, commandType: CommandType.StoredProcedure).FirstOrDefault());
        }
コード例 #23
0
ファイル: AllowanceController.cs プロジェクト: acyl/.Net
        public ActionResult Index(AllowanceViewModel Model)
        {
            //1. 設定開立折讓資訊
            Allowance invc = new Allowance();

            invc.MerchantID      = Model.MerchantID;
            invc.InvoiceNo       = Model.InvoiceNo;
            invc.allowanceNotify = Model.AllowanceNotify;
            invc.CustomerName    = Model.CustomerName;
            invc.NotifyPhone     = Model.NotifyPhone;
            invc.NotifyMail      = Model.NotifyMail;
            invc.AllowanceAmount = Model.AllowanceAmount;
            invc.Items.Add(new Item()
            {
                ItemName   = Model.ItemName,
                ItemPrice  = Model.ItemPrice,
                ItemCount  = Model.ItemCount,
                ItemWord   = Model.ItemWord,
                ItemAmount = Model.ItemAmount
            });

            //2. 初始化發票Service物件
            Invoice <Allowance> inv = new Invoice <Allowance>();

            //3. 指定測試環境, 上線時請記得改Prod
            inv.Environment = EInvoice.Integration.Enumeration.EnvironmentEnum.Stage;

            //4. 設定歐付寶提供的 Key 和 IV
            inv.HashIV  = "q9jcZX8Ib9LM8wYk";
            inv.HashKey = "ejCk326UnaZWKisg";

            //5. 執行API的回傳結果(JSON)字串
            string json = inv.post(invc);

            //6. 解序列化,還原成物件使用
            //AllowanceReturn obj = new AllowanceReturn();
            //obj = JsonConvert.DeserializeObject<AllowanceReturn>(json);
            //obj.XXX;
            // ...

            ViewBag.message = json;

            return(View());
        }
コード例 #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //1. 設定開立折讓資訊
            Allowance invc = new Allowance();

            invc.MerchantID      = "2000132";               //廠商編號。
            invc.InvoiceNo       = "XW00006065";            //發票號碼。
            invc.allowanceNotify = AllowanceNotifyEnum.SMS; //通知類別
            invc.CustomerName    = "客戶名稱";                  //客戶名稱
            invc.NotifyPhone     = "0912345678";            //客戶手機號碼
            invc.NotifyMail      = "";                      //客戶電子信箱
            invc.AllowanceAmount = "10";                    //折讓單總金額(含稅總金額)。
            //商品資訊的集合類別
            invc.Items.Add(new Item()
            {
                ItemName   = "糧食", //商品名稱
                ItemPrice  = "10", //商品單價
                ItemCount  = "1",  //商品數量
                ItemWord   = "個",  //單位
                ItemAmount = "10", //總金額
                //ItemTaxType  =TaxTypeEnum.DutyFree//商品課稅別
            });
            //2. 初始化發票Service物件
            Invoice <Allowance> inv = new Invoice <Allowance>();

            //3. 指定測試環境, 上線時請記得改Prod
            inv.Environment = EnvironmentEnum.Stage;
            //4. 設定歐付寶提供的 Key 和 IV
            inv.HashIV  = "q9jcZX8Ib9LM8wYk";
            inv.HashKey = "ejCk326UnaZWKisg";
            //5. 執行API的回傳結果(JSON)字串
            string json = inv.post(invc);
            //6. 解序列化,還原成物件使用
            AllowanceReturn obj = new AllowanceReturn();

            obj = JsonConvert.DeserializeObject <AllowanceReturn>(json);
            //**印出來**

            string temp = string.Empty;

            temp = string.Format("折讓結果<br> IA_Allow_No={0}<br> IA_Date={1}<br> IA_Invoice_No={2}<br> RtnCode={3} <br> RtnMsg={4} <br>IA_Remain_Allowance_Amt ={5} ", obj.IA_Allow_No, obj.IA_Date, obj.IA_Invoice_No, obj.RtnCode, obj.RtnMsg, obj.IA_Remain_Allowance_Amt);
            Response.Write(temp);
        }
コード例 #25
0
ファイル: AllowanceController.cs プロジェクト: vc2001/.Net
        public ActionResult Index(AllowanceViewModel Model)
        {
            //1. 設定開立折讓資訊
            Allowance invc = new Allowance();
            invc.MerchantID = Model.MerchantID;
            invc.InvoiceNo = Model.InvoiceNo;
            invc.allowanceNotify = Model.AllowanceNotify;
            invc.CustomerName = Model.CustomerName;
            invc.NotifyPhone = Model.NotifyPhone;
            invc.NotifyMail = Model.NotifyMail;
            invc.AllowanceAmount = Model.AllowanceAmount;
            invc.Items.Add(new Item()
            {
                ItemName = Model.ItemName,
                ItemPrice = Model.ItemPrice,
                ItemCount = Model.ItemCount,
                ItemWord = Model.ItemWord,
                ItemAmount = Model.ItemAmount
            });

            //2. 初始化發票Service物件
            Invoice<Allowance> inv = new Invoice<Allowance>();

            //3. 指定測試環境, 上線時請記得改Prod
            inv.Environment = EInvoice.Integration.Enumeration.EnvironmentEnum.Stage;

            //4. 設定歐付寶提供的 Key 和 IV
            inv.HashIV = "q9jcZX8Ib9LM8wYk";
            inv.HashKey = "ejCk326UnaZWKisg";

            //5. 執行API的回傳結果(JSON)字串
            string json = inv.post(invc);

            //6. 解序列化,還原成物件使用
            //AllowanceReturn obj = new AllowanceReturn();
            //obj = JsonConvert.DeserializeObject<AllowanceReturn>(json);
            //obj.XXX;
            // ...

            ViewBag.message = json;

            return View();
        }
コード例 #26
0
        /// <summary>
        /// Calculate Abroad trips allowance
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCalculateAbroad_Click(object sender, EventArgs e)
        {
            double abroadAllowance = double.Parse(txtAbroadAllowance.Text);
            DateTime startD = startMonthCalendar.SelectionStart; //Start date
            DateTime returnD = returnMonthCalendar.SelectionEnd; //Return date
            String strStartT = startTimeMaskedTextBox.Text; //start time in string
            String strReturnT = returnTimeMaskedTextBox.Text; //return time in string
            bool verifyInput = VerifyAborad(startD, returnD, strStartT, strReturnT); //Calling a method to do validation of input
            if (verifyInput)
            {
                TimeSpan difference;
                double calculatedAllowance;

                // create an object of the class ....
                Allowance a = new Allowance();
                difference = a.CalculateDays(startD, returnD, strStartT, strReturnT);
                if (difference.Days == 0)
                {
                    //call domestic
                    calculatedAllowance = a.CalculateDailyAllowance(double.Parse(txtFullDayAllowance.Text),
                        double.Parse(txtHalfDayAllowance.Text));
                }
                else // Call Abroad
                {
                    calculatedAllowance = a.CalculateAllowanceAbroad(abroadAllowance);
                }

                int days = difference.Days;
                txtDaysData.Text = "" + days;
                int hours = difference.Hours;
                txtHoursData.Text = "" + hours;
                int minutes = difference.Minutes;
                txtMinutesData.Text = "" + minutes;
                txtKMallowanceData.Text = "0" ;
                txtDailyAllowanceData.Text = "" + calculatedAllowance;
                txtTotalData.Text = "" + calculatedAllowance;
            }
        }
コード例 #27
0
ファイル: Users.cs プロジェクト: tidehc/MiniNVR
 public bool CanAccess(Allowance asset, User user)
 {
     foreach (string id in asset.Members)
     {
         Group group = FindGroup(id);
         if (group != null)
         {
             if (CanAccess(group, user))
             {
                 return(true);
             }
         }
         else
         {
             User foundUser = FindUser(id);
             if ((foundUser != null) && foundUser.Equals(user))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #28
0
        public IActionResult Dashboard()
        {
            int currentUsersCompanyId = User.Identity.GetCompanyId();
            int currentUserId         = _context.Employees.Where(x => x.Email.ToLower() == HttpContext.User.Identity.Name.ToLower()).Select(x => x.Id).FirstOrDefault();

            HomeViewModel viewModel = new HomeViewModel
            {
                Requests = _context.Requests.Include(r => r.RequestType).Where(x => x.EmployeeId == currentUserId).ToList()
            };

            // get first day and last day of the current year
            int      year             = DateTime.Now.Year;
            DateTime firstDay         = new DateTime(year, 1, 1);
            DateTime lastDay          = new DateTime(year, 12, 31);
            DateTime firstDayNextYear = lastDay.AddDays(1); // get first day of next year

            // Allowance balance to be displayed in a table on employee dashboard page
            // Using AllowanceBalanceDTO Data Transfer Object
            Allowance allowance = _context.Allowances.Where(x => x.EmployeeId == currentUserId && x.From == firstDay).FirstOrDefault();

            AllowanceBalanceDTO allowanceBalance = new AllowanceBalanceDTO
            {
                StandardAllowance = allowance.Amount,

                Pending = viewModel.Requests.Where(x => x.Status == 0 && x.RequestType.TakesFromAllowance == true && x.From >= firstDay && x.To < firstDayNextYear).Sum(x => x.RequestAmount),

                Taken = viewModel.Requests.Where(x => x.Status == 1 && x.RequestType.TakesFromAllowance == true && x.From >= firstDay && x.To < firstDayNextYear && x.From < DateTime.Now).Sum(x => x.RequestAmount),

                Approved = viewModel.Requests.Where(x => x.Status == 1 && x.RequestType.TakesFromAllowance == true && x.From >= firstDay && x.To <firstDayNextYear && x.From> DateTime.Now).Sum(x => x.RequestAmount)
            };

            viewModel.Balance = allowanceBalance;


            return(View(viewModel));
        }
コード例 #29
0
        private AllowanceViewModel GetAllowance(Allowance allowance)
        {
            AllowanceViewModel ViewModel = new AllowanceViewModel()
            {
                AllowanceDate             = allowance.CreatedOn,
                AllowanceID               = allowance.AllowanceID,
                AllowanceType             = allowance.AllowanceType,
                Status                    = allowance.ApprovedStatus,
                AssignedBy                = allowance.AssignedBy,
                CreatedBy                 = allowance.CreatedBy,
                Comments                  = allowance.Description,
                Price                     = allowance.Price,
                CreatedOn                 = allowance.CreatedOn,
                AssignedCategory          = allowance.AssignedCategory,
                AllowanceTypeId           = allowance.AllowanceTypeId.ToString(),
                AllownanceDates           = JsonConvert.DeserializeObject <List <string> >(allowance.AllowanceDates),
                AllownanceDatesjsonResult = allowance.AllowanceDates,
                NumberOfDays              = allowance.NumberOfDays,
                Month                     = allowance.Month,
                UserID                    = allowance.CreatedById
            };

            return(ViewModel);
        }
コード例 #30
0
 public Allowance AddAllowance(Allowance model)
 {
     return(_repo.AddAllowance(model));
 }
コード例 #31
0
        /// <summary>
        /// Read from File
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRead_Click(object sender, EventArgs e)
        {
            OpenFileDialog op = new OpenFileDialog();

            if (op.ShowDialog() == DialogResult.OK)
            {
                Allowance a = new Allowance();
                //string fileName = op.FileName;
                listBox1.DataSource = null;
                listBox1.ValueMember = "DailyAllowance";
                listBox1.DisplayMember = "Name";
                listBox1.DataSource = a.ReadCountiesAndDailyAllowances(op.FileName);
                txtFullDayAllowance.Text = a.FinFull;
                txtHalfDayAllowance.Text = a.FinHalf;
                txtKMAllowance.Text = a.FinKm;
                txtPersonsAccompanying.Text = a.FinPerson;

            }
        }
コード例 #32
0
        /// <summary>
        /// Calculates Domestic Trip and its allowance
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCalculateDomestic_Click(object sender, EventArgs e)
        {
            DateTime startD = startMonthCalendar.SelectionStart; //Start date
            DateTime returnD = returnMonthCalendar.SelectionEnd; //Return date
            String strStartT = startTimeMaskedTextBox.Text; //start time in string
            String strReturnT = returnTimeMaskedTextBox.Text; //return time in string
            strkmAllowance = txtKMAllowance.Text; // KM Allowance Per KM
            strkmAllowancePerPerson = txtPersonsAccompanying.Text; // KM Allowance per Person
            strHalfDayAllowance = txtHalfDayAllowance.Text;
            strFullDayAllowance = txtFullDayAllowance.Text;
            decimal totalKm = distanceNumericUpDown.Value;
            int kmDriven = (int)totalKm;
            bool inputValidate = VerifyDomestic(startD,returnD,strStartT,strReturnT); //Calling a method to do validation of input
            if (inputValidate)
            {
                TimeSpan difference;
                double calculatedAllowance;
                double dailyAllowance;

                // create an object of the class ....
                Allowance a = new Allowance();
                difference = a.CalculateDays(startD, returnD, strStartT, strReturnT);
                calculatedAllowance = a.KmAllowance(kmDriven, kmAllowancePerKm, numberOfPersons, kmAllowancePerPerson);
                dailyAllowance = a.CalculateDailyAllowance(fullDay, halfDay);
                double total = calculatedAllowance + dailyAllowance;

                int days = difference.Days;
                txtDaysData.Text = "" + days;
                int hours = difference.Hours;
                txtHoursData.Text = "" + hours;
                int minutes = difference.Minutes;
                txtMinutesData.Text = "" + minutes;
                txtKMallowanceData.Text = "" + calculatedAllowance;
                txtDailyAllowanceData.Text = "" + dailyAllowance;
                txtTotalData.Text = "" + total;
            }
        }
コード例 #33
0
        protected override void Seed(PlutoContext context)
        {
            AppUser appuser1 = new AppUser
            {
                username = "******",
                password = "******",
                email    = "*****@*****.**",
                alterEgo = "Admin"
            };


            Department department1 = new Department()
            {
                Id   = 1,
                name = "Business"
            };

            Department department2 = new Department()
            {
                Id   = 2,
                name = "Science"
            };

            StudentClass studentclass1 = new StudentClass()
            {
                Id               = 1,
                name             = "One",
                classamounttopay = 20,
                IsTerminated     = false
            };

            StudentClass studentclass2 = new StudentClass()
            {
                Id               = 2,
                name             = "Two",
                classamounttopay = 30,
                IsTerminated     = false
            };

            StudentStatus studentstatus1 = new StudentStatus()
            {
                Id   = 1,
                name = "Full Payment"
            };

            StudentStatus studentstatus2 = new StudentStatus()
            {
                Id   = 2,
                name = "Partial Payment"
            };

            Region region1 = new Region()
            {
                Id   = 1,
                name = "Ashanti"
            };

            Region region2 = new Region()
            {
                Id   = 2,
                name = "Grater Accra"
            };

            EmployeeCategory employeecategory1 = new EmployeeCategory()
            {
                Id   = 1,
                name = "Fixed",
                allowancepercentage = 70
            };

            EmployeeCategory employeecategory2 = new EmployeeCategory()
            {
                Id   = 2,
                name = "Variable",
                allowancepercentage = 50
            };
            EmployeeLevelOfEducation employeelevelofeducation1 = new EmployeeLevelOfEducation()
            {
                Id   = 1,
                name = "BSC"
            };

            EmployeeLevelOfEducation employeelevelofeducation2 = new EmployeeLevelOfEducation()
            {
                Id   = 2,
                name = "MBS"
            };

            PayrollRate payrollrate = new PayrollRate()
            {
                workday = 100, workdayovertime = 120, saturday = 140, saturdayovertime = 150, sunday = 160, sundayovertime = 160, holiday = 170, holidayovertime = 180
            };

            TaxRate taxrate1 = new TaxRate()
            {
                Id = 1, name = "first", amount = 300, rate = 2
            };
            TaxRate taxrate2 = new TaxRate()
            {
                Id = 2, name = "second", amount = 300, rate = 5
            };

            SSNITRate ssnitrate = new SSNITRate()
            {
                Id = 1, name = "SSNIT", Rate = 3
            };

            StudentSubject subject1 = new StudentSubject()
            {
                Id             = 1,
                name           = "Maths",
                studentclassid = 1
            };

            StudentSubject subject2 = new StudentSubject()
            {
                Id             = 2,
                name           = "English",
                studentclassid = 2
            };


            EmployeeType employeetype1 = new EmployeeType()
            {
                Id   = 1,
                name = "Regular"
            };

            EmployeeType employeetype2 = new EmployeeType()
            {
                Id   = 2,
                name = "Staff"
            };


            Student student1 = new Student
            {
                Id                 = 1,
                gender             = "female",
                firstname          = "Dede",
                lastname           = "Ansah",
                placeofbirth       = "Tema",
                dateofbirth        = DateTime.Now,
                studentclassId     = 2,
                departmentId       = 1,
                mothername         = "Joyce",
                fathername         = "Ankrah",
                regionId           = 2,
                city               = "Tema",
                address            = "P.O.Box 23332",
                email              = "*****@*****.**",
                phone              = "2323323",
                studentstatusId    = 1,
                scholarshippercent = 0,
                imagesrc           = "../../assets/images/default.png"
            };
            Student student2 = new Student
            {
                Id                 = 2,
                gender             = "Male",
                firstname          = "Ansah",
                lastname           = "Phillip",
                placeofbirth       = "Tema",
                dateofbirth        = DateTime.Now,
                studentclassId     = 1,
                departmentId       = 1,
                mothername         = "Joyce",
                fathername         = "Ankrah",
                regionId           = 2,
                city               = "Tema",
                address            = "P.O.Box 23332",
                email              = "*****@*****.**",
                phone              = "2323323",
                studentstatusId    = 2,
                scholarshippercent = 0,
                imagesrc           = "../../assets/images/default.png"
            };

            Payment payment1 = new Payment
            {
                Id          = 1,
                amounttopay = 50,
                amountpaid  = 20,
                amountowing = 30,
                studentId   = 1
            };

            PaymentHistory paymenthistory1 = new PaymentHistory
            {
                Id            = 1,
                amount        = 50,
                amountinwords = "Fifty Ghana Cedis",
                paymentdate   = DateTime.Now,
                studentId     = 1
            };

            Employee employee1 = new Employee()
            {
                Id              = 1, gender = "Male", firstname = "Emmanuel", lastname = "Atiapa", fullname = "Emmanuel Atiapa", placeofbirth = "Kpone", dateofbirth = DateTime.Now, categoryId = 1, departmentId = 1,
                classtoteachId  = 1, mothername = "Joyce", fathername = "Frank", regionId = 1, city = "Tema", address = "P.O.Box 233", email = "*****@*****.**", phone = "233254443",
                areaofexpertise = "Teaching", levelofeducationId = 1, yearsofexperience = 2, salary = 233, workinghours = 22, imagesrc = "../../assets/images/default.png",
                employeetypeId  = 1
            };

            Employee employee2 = new Employee()
            {
                Id          = 2, gender = "Female", firstname = "Kenneth", lastname = "Atsekpor", fullname = "Kenneth Atsekpor", placeofbirth = "Kpone",
                dateofbirth = DateTime.Now, categoryId = 2, departmentId = 2, classtoteachId = 2, mothername = "Joyce",
                fathername  = "Frank", regionId = 2, city = "Tema", address = "P.O.Box 233", email = "*****@*****.**",
                phone       = "233254443", areaofexpertise = "Accounting", levelofeducationId = 2, yearsofexperience = 4,
                salary      = 233, workinghours = 8, imagesrc = "../../assets/images/default.png", employeetypeId = 2
            };



            PayrollAllowance payrollallowance1 = new PayrollAllowance()
            {
                Id     = 1,
                name   = "Medical",
                amount = 200
            };

            PayrollAllowance payrollallowance2 = new PayrollAllowance()
            {
                Id     = 2,
                name   = "Leave",
                amount = 300
            };

            Allowance allowance1 = new Allowance()
            {
                Id = 1,
                payrollamountId = 1, payrollallowanceId = 1,
                amount          = 30
            };

            Allowance allowance2 = new Allowance()
            {
                Id = 2,
                payrollamountId    = 1,
                payrollallowanceId = 2,
                amount             = 40
            };


            //PayrollAmount payrollamount1 = new PayrollAmount()
            //{
            //    Id = 1,
            //    employeeId = 1,
            //    enddate = DateTime.Now,
            //    startdate = DateTime.Now,
            //    expectedworkhours = 23,
            //    grosssalary = 500,
            //    netsalary = 450,
            //    holiday = 23,
            //    loan = 34,
            //    payee = 3,
            //    saturday = 3,
            //    ssnit = 3,
            //    totalallowance = 45,
            //    workday = 34,
            //    workdayovertime = 2,
            //    sunday = 43,
            //    saturdayovertime = 3,
            //    sundayovertime = 3,
            //    totalworkdays = 3,
            //    holidayovertime = 4,
            //    allowances = new List<Allowance>()
            //    {
            //        allowance1,allowance2
            //    }
            //};


            EmployeeLoan employeeloan1 = new EmployeeLoan()
            {
                Id = 1, amount = 200, amountowing = 180, amountpaid = 20, interestrate = 5, interestamount = 20, monthlypayment = 200, loandate = DateTime.Now, employeeId = 1
            };

            EmployeeLoanHistory employeeloanhistory1 = new EmployeeLoanHistory()
            {
                Id = 1, amount = 20, employeeloanId = 1, paymentdate = DateTime.Now
            };

            Mark mark1 = new Mark()
            {
                Id               = 1,
                examId           = 1,
                mark             = 10,
                studentsubjectId = 1
            };

            Exam exam1 = new Exam()
            {
                Id        = 1,
                studentId = 1,
                marks     = new List <Mark>()
                {
                    mark1
                }
            };

            IncomeCategory incomecategory1 = new IncomeCategory()
            {
                Id   = 1,
                name = "First Income"
            };

            IncomeCategory incomecategory2 = new IncomeCategory()
            {
                Id   = 2,
                name = "Second Income"
            };

            ExpenseCategory expensecategory1 = new ExpenseCategory()
            {
                Id   = 1,
                name = "First Expense"
            };

            ExpenseCategory expensecategory2 = new ExpenseCategory()
            {
                Id   = 2,
                name = "Second Expense"
            };



            context.appusers.Add(appuser1);
            context.employeetypes.Add(employeetype1);
            context.employeetypes.Add(employeetype2);
            context.studentsubjects.Add(subject1);
            context.studentsubjects.Add(subject2);
            context.departments.Add(department1);
            context.departments.Add(department2);
            context.studentclasses.Add(studentclass1);
            context.studentclasses.Add(studentclass2);
            context.studentstatuses.Add(studentstatus1);
            context.studentstatuses.Add(studentstatus2);
            context.regions.Add(region1);
            context.regions.Add(region2);
            context.employeecategories.Add(employeecategory1);
            context.employeecategories.Add(employeecategory2);
            context.employeelevelsofeducation.Add(employeelevelofeducation1);
            context.employeelevelsofeducation.Add(employeelevelofeducation2);
            context.employees.Add(employee1);
            context.employees.Add(employee2);
            context.students.Add(student1);
            context.students.Add(student2);
            context.payrollallowances.Add(payrollallowance1);
            context.payrollallowances.Add(payrollallowance2);
            //context.payrollamounts.Add(payrollamount1);
            //context.allowances.Add(allowance1);
            //context.allowances.Add(allowance2);
            context.payrollrates.Add(payrollrate);
            context.taxrates.Add(taxrate1);
            context.taxrates.Add(taxrate2);
            context.ssnitrates.Add(ssnitrate);
            context.payments.Add(payment1);
            context.paymenthistories.Add(paymenthistory1);
            context.employeeloans.Add(employeeloan1);
            context.employeeloanhistories.Add(employeeloanhistory1);
            context.exams.Add(exam1);
            context.marks.Add(mark1);
            context.incomecategories.Add(incomecategory1);
            context.incomecategories.Add(incomecategory2);
            context.expensecategories.Add(expensecategory1);
            context.expensecategories.Add(expensecategory2);
            base.Seed(context);
        }
コード例 #34
0
 public void Subtract(Minutes minutes)
 {
     Allowance = Allowance.Subtract(minutes);
 }