Пример #1
0
 public void InsertServiceCharge(ServiceCharge serviceCharge)
 {
     using( var uow= new ShipwayUnitOfWork())
     {
         uow.ServiceChargeRepository.Add(serviceCharge);
     }
 }
Пример #2
0
 public ServiceCharge UpdateServiceCharge(ServiceCharge serviceCharge)
 {
     using( var uow= new ShipwayUnitOfWork())
     {
         return uow.ServiceChargeRepository.Update(serviceCharge);
     }
 }
Пример #3
0
        public PaymentSlip GetPaymentSlipBy(Person person)
        {
            try
            {
                if (person == null || person.Id <= 0 || person.Type == null || person.Type.Id <= 0)
                {
                    throw new ArgumentNullException("person");
                }

                ServiceCharge serviceCharge = _serviceCharge.GetChargesBy(person.Type);
                if (serviceCharge == null || serviceCharge.Id <= 0)
                {
                    throw new Exception("Service Charge retreival failed! Please try again");
                }

                Payment     payment = _da.GetModelBy <Payment, PAYMENT>(p => p.Person_Id == person.Id && p.Service_Charge_Id == serviceCharge.Id);
                PaymentSlip slip    = GenerateSlip(payment);

                return(slip);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #4
0
        public ServiceCharge getServiceCharges()
        {
            ServiceCharge ob = new ServiceCharge();

            ob.serviceChargeApplicable = 100F;
            return(ob);
        }
        public async Task <IActionResult> PutServiceCharge([FromRoute] int id, [FromBody] ServiceCharge serviceCharge)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != serviceCharge.Id)
            {
                return(BadRequest());
            }

            _context.Entry(serviceCharge).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServiceChargeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #6
0
        public void AddServiceCharge()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(
                empId, "Bill", "Home", 15.25, database);

            t.Execute();
            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            UnionAffiliation af = new UnionAffiliation();

            e.Affiliation = af;
            int memberId = 86; // Maxwell Smart

            database.AddUnionMember(memberId, e);
            ServiceChargeTransaction sct =
                new ServiceChargeTransaction(
                    memberId, new DateTime(2005, 8, 8), 12.95, database);

            sct.Execute();
            ServiceCharge sc =
                af.GetServiceCharge(new DateTime(2005, 8, 8));

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, .001);
        }
Пример #7
0
        public void TestAddServiceCharge()
        {
            int empId           = 2;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Kubing", "Home", 15.25, database);

            t.Execute();

            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);

            int memberId = 86;

            database.AddUnionMember(memberId, e);

            UnionAffiliation ua = new UnionAffiliation(memberId, 99.52);

            e.Affiliation = ua;

            var date = new DateTime(2005, 8, 8);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, 12.95, database);

            sct.Execute();

            var           serviceCharges = database.GetServiceCharges(memberId);
            ServiceCharge sc             = serviceCharges.FirstOrDefault(x => x.Date == date);

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, 0.001);
        }
        public void TestAddServiceCharge()
        {
            #region Arrange
            int employeeId          = 9;
            AddSalariedEmployee asd = new AddSalariedEmployee(employeeId, "user", "home", 1000.0);
            asd.Execute();
            Employee e = PayrollRepository.GetEmployee(employeeId);
            e.Should().NotBeNull();

            UnionAffiliation af = new UnionAffiliation();
            e.Affiliation = af;
            int memberId = 886;
            PayrollRepository.AddUnionMember(memberId, e);

            ServiceChargeTransaction sct = new ServiceChargeTransaction(
                memberId, new DateTime(2019, 10, 10), 10.0);
            #endregion

            #region Action
            sct.Execute();
            #endregion

            #region Assert
            ServiceCharge sc = af.GetServiceCharge(new DateTime(2019, 10, 10));
            sc.Should().NotBeNull();
            sc.Date.Should().Be(new DateTime(2019, 10, 10));
            sc.Amount.Should().Be(10.0);
            #endregion
        }
Пример #9
0
        public void AddServiceCharge()
        {
            int empId = SetupHourlyEmployee();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);

            const int memberId = 86; // Maxwell Smart
            var       af       = new UnionAffiliation(memberId, 12.95);

            e.Affiliation = af;
            PayrollDatabase.AddUnionMember(memberId, e);

            var sct = new ServiceChargeTransaction(memberId,
                                                   new DateTime(2005, 8, 8),
                                                   12.95);

            sct.Execute();

            ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8));

            Assert.NotNull(sc);
            Assert.Equal(12.95, sc.Amount);
        }
Пример #10
0
        public void AddServiceCharge()
        {
            int empId = 2;

            app.ExexcuteTransaction("addHourlyEmployee", RequestFactory.rf.MakeHourlyEmployeeRequest(empId, "Bob", "Home", 50));

            Employee e = PayrollDb.GetEmployee(empId);

            Assert.IsNotNull(e);

            UnionAffiliation af = new UnionAffiliation(50, 100.50);

            e.Affiliation = af;

            int memeberId = 86;

            PayrollDb.AddUnionMember(memeberId, e);

            app.ExexcuteTransaction("addServiceCharge", RequestFactory.rf.MakeServiceChargeRequest(memeberId, new DateTime(2005, 8, 8), 12.95));

            ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8));

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, .001);
        }
Пример #11
0
        public void Create(ServiceChargeModel model)
        {
            try
            {
                if (_serviceChargeRepository.NameExist(model))
                {
                    throw new ArgumentException("Service CHarge Already Exists!");
                }


                var serviceCharge = new ServiceCharge()
                {
                    Name            = model.Name,
                    Amount          = model.Amount,
                    IsCompulsory    = model.IsCompulsory,
                    TotalAmountPaid = 0,
                    DateCreated     = model.DateCreated,
                    DueDay          = model.DueDay,
                    DueMonth        = model.DueMonth
                };
                if (model.BuildingModelIds.Any())
                {
                    serviceCharge.BuildingIds = string.Join(",", model.BuildingModelIds);
                }
                _serviceChargeRepository.Insert(serviceCharge);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #12
0
        public void UnionMemberWithTwoServiceCharge()
        {
            database.AddEmployee(employee);

            int memberId = 7783;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(employee.EmpId, memberId, 99.42, database);

            cmt.Execute();

            var date = new DateTime(2005, 8, 8);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, 12.95, database);

            sct.Execute();

            var date2 = new DateTime(2005, 8, 15);
            ServiceChargeTransaction sct2 = new ServiceChargeTransaction(memberId, date2, 4.52, database);

            sct2.Execute();

            var serviceCharges = database.GetServiceCharges(memberId);

            Assert.AreEqual(2, serviceCharges.Count);

            ServiceCharge sc1 = serviceCharges[0];

            Assert.IsNotNull(sc1);
            Assert.AreEqual(12.95, sc1.Amount, 0.001);

            ServiceCharge sc2 = serviceCharges[1];

            Assert.IsNotNull(sc2);
            Assert.AreEqual(4.52, sc2.Amount, 0.001);
        }
Пример #13
0
        protected void grdAll_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label   lblServiceCharge = (Label)e.Row.FindControl("lblServiceCharge");
                Label   lblServiceTax    = (Label)e.Row.FindControl("lblServiceTax");
                Label   lblTotalamt      = (Label)e.Row.FindControl("lblTotalamt");
                decimal lblcharge        = Convert.ToDecimal(lblServiceCharge.Text);
                decimal lblTax           = Convert.ToDecimal(lblServiceTax.Text);
                decimal lblamont         = Convert.ToDecimal(lblTotalamt.Text);
                ServiceCharge += lblcharge;
                Tax           += lblTax;
                TotalAmt      += lblamont;
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Font.Bold = true;
                e.Row.Cells[1].Font.Bold = false;
                if (txtFromDate.Text != "" && txtTodate.Text != "")
                {
                    Label lblcountry = (Label)e.Row.FindControl("lblfooterCountry");
                    lblcountry.Text = string.Empty;
                }
                Label lblCharge = (Label)e.Row.FindControl("lblCharge");
                lblCharge.Text = ServiceCharge.ToString();
                Label lblTax = (Label)e.Row.FindControl("lblTax");
                lblTax.Text = Tax.ToString();
                Label lblGrandtotl = ((Label)e.Row.FindControl("lblGrandtotl"));
                lblGrandtotl.Text = TotalAmt.ToString();
            }
        }
Пример #14
0
        public void AddServiceChargeTests()
        {
            int empId           = 2;
            var name            = "Bartosz";
            var hourlyRate      = 15.25;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, name, "Home", hourlyRate);

            t.Execute();
            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            var memberId        = 86;
            var dues            = 88.12;
            UnionAffiliation af = new UnionAffiliation(memberId, dues);

            e.Affiliation = af;
            var date   = new DateTime(2005, 8, 8);
            var charge = 12.95;

            PayrollDatabase.AddUnionMember(memberId, e);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, charge);

            sct.Execute();
            ServiceCharge sc = af.GetServiceCharge(date);

            Assert.IsNotNull(sc);
            Assert.AreEqual(charge, sc.Amount, .001);
        }
Пример #15
0
        private string Validate(string propertyName)
        {
            // Return error message if there is error on else return empty or null string
            string validationMessage = string.Empty;

            if (_firstLoad)
            {
                return(validationMessage);
            }
            switch (propertyName)
            {
            case "Sector":     // property name
                if (string.IsNullOrWhiteSpace(Sector))
                {
                    validationMessage = "No Sector Available";
                }
                break;

            case "Collection":     // property name
                if (string.IsNullOrWhiteSpace(Collection))
                {
                    validationMessage = "No Collection Type Available";
                }
                break;

            case "Amount":
                if (!double.TryParse(Amount.ToString(), out uselessParse))
                {
                    validationMessage = "Only Digits Are Allowed";
                }
                break;

            case "ServiceCharge":
                if (!double.TryParse(ServiceCharge.ToString(), out uselessParse))
                {
                    validationMessage = "Only Digits Are Allowed";
                }
                break;

            case "Installment":
                if (!double.TryParse(Installment.ToString(), out uselessParse))
                {
                    validationMessage = "Only Digits Are Allowed";
                }
                break;

            case "InstallmentAmount":
                if (!double.TryParse(InstallmentAmount.ToString(), out uselessParse))
                {
                    validationMessage = "Only Digits Are Allowed";
                }
                break;

            case "ID":
                break;
            }

            return(validationMessage);
        }
Пример #16
0
 public static decimal GetTotalWithServiceCharge(decimal value, ServiceCharge serviceCharge)
 {
     return(serviceCharge switch
     {
         ServiceCharge.Food => value + GetFoodServiceCharge(value),
         ServiceCharge.HotFood => value + GetHotFoodServiceCharge(value),
         _ => value,
     });
Пример #17
0
 public ActionResult EditServiceCharge(ServiceCharge serviceCharge)
 {
     if (ModelState.IsValid)
     {
         var service = serviceChargeProvider.UpdateServiceCharge(serviceCharge);
         return(RedirectToAction("Index", "ManageServiceCharge"));
     }
     return(RedirectToAction("Index", "ManageServiceCharge"));
 }
        public async Task <IActionResult> PostServiceCharge([FromBody] ServiceCharge serviceCharge)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ServiceCharge.Add(serviceCharge);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetServiceCharge", new { id = serviceCharge.Id }, serviceCharge));
        }
Пример #19
0
 public ServiceCharge GetChargesBy(ServiceCharge.Services serviceCharge)
 {
     try
     {
         ServiceCharge sc = _da.GetModelBy <ServiceCharge, SERVICE_CHARGE>(s => s.Service_Charge_Id == (int)serviceCharge);
         return(sc);
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #20
0
 private static ServiceChargeModel GetItem(ServiceCharge serviceCharge)
 {
     return(new ServiceChargeItem()
     {
         Id = serviceCharge.Id,
         Name = serviceCharge.Name,
         Amount = serviceCharge.Amount,
         IsCompulsory = serviceCharge.IsCompulsory,
         TotalAmountPaid = serviceCharge.TotalAmountPaid,
         DateCreated = serviceCharge.DateCreated,
         DueDay = serviceCharge.DueDay,
         DueMonth = serviceCharge.DueMonth
     });
 }
Пример #21
0
 public ActionResult SaveServiceCharge(ServiceCharge serviceCharge)
 {
     if (ModelState.IsValid)
     {
         serviceChargeProvider.InsertServiceCharge(serviceCharge);
         return(RedirectToAction("Index", "ManageServiceCharge"));
     }
     else
     {
         var errors = ModelState.Select(x => x.Value.Errors)
                      .Where(y => y.Count > 0)
                      .ToList();
     }
     return(RedirectToAction("Index", "ManageServiceCharge"));
 }
Пример #22
0
        public ActionResult DeleteServiceCharge(ServiceCharge serviceCharge)
        {
            serviceCharge = serviceChargeProvider.GetServiceChargeById(serviceCharge.ServiceChargeId);
            var success = serviceChargeProvider.DeleteServiceCharge(serviceCharge);

            if (success)
            {
                TempData["Success"] = "Xóa thành công biểu phí";
            }
            else
            {
                TempData["Success"] = "Xóa biểu phí thất bại";
            }
            return(RedirectToAction("Index", "ManageServiceCharge"));
        }
Пример #23
0
        private static ServiceChargeModel GetItem(ServiceCharge serviceCharge)
        {
            //return new ServiceChargeItem()
            //{
            //    Id = serviceCharge.Id,
            //    Name = serviceCharge.Name,
            //    Amount = serviceCharge.Amount,
            //    IsCompulsory = serviceCharge.IsCompulsory,
            //    TotalAmountPaid = serviceCharge.TotalAmountPaid,
            //    DateCreated = serviceCharge.DateCreated,
            //    DueDay = serviceCharge.DueDay,
            //    DueMonth = serviceCharge.DueMonth
            //};

            return(Mapper.Map <ServiceCharge, ServiceChargeModel>(serviceCharge));
        }
Пример #24
0
        public void Execute()
        {
            Employee e = PayrollRepository.GetUnionMember(_memberId);
            bool     isExistingMember = e != null;

            if (isExistingMember)
            {
                UnionAffiliation ua = e.Affiliation as UnionAffiliation;
                ServiceCharge    sc = new ServiceCharge(_date, _amount);
                ua.AddServiceCharge(sc);
            }
            else
            {
                throw new InvalidOperationException("No such union member.");
            }
        }
Пример #25
0
        public ServiceCharge GetChargesBy(PersonType personType)
        {
            try
            {
                if (personType == null || personType.Id <= 0)
                {
                    throw new ArgumentNullException("personType");
                }

                int           serviceChargeId = 0;
                ServiceCharge serviceCharge   = null;

                switch (personType.Id)
                {
                case (int)Person.Types.Teacher:
                {
                    serviceChargeId = (int)ServiceCharge.Services.TeacherSubscription;
                    break;
                }

                case (int)Person.Types.Parent:
                {
                    serviceChargeId = (int)ServiceCharge.Services.ParentSubscription;
                    break;
                }

                case (int)Person.Types.School:
                {
                    serviceChargeId = (int)ServiceCharge.Services.SchoolSubscription;
                    break;
                }

                default:
                {
                    throw new Exception("Invalid Person Type specified! Please contact your system administrator");
                }
                }

                serviceCharge = _da.GetModelBy <ServiceCharge, SERVICE_CHARGE>(sc => sc.Service_Charge_Id == serviceChargeId);

                return(serviceCharge);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public JsonResult TotalMoney(int?weigh, int?packagelong, int?wide, int?high, string citysender, string cityReceiver, int?kindService)
        {
            int                       router;
            ServiceCharge             serviceCharge            = null;
            var                       resultExhibiton          = new ResultExhibition();
            IServiceChargeProvider    serviceChargeProvider    = new ServiceChargeProvider();
            IKindTimeReceivedProvider kindTimeReceivedProvider = new KindTimeReceivedProvider();
            IProvinceProvider         provinceProvider         = new ProvinceProvider();
            IRouterProvider           routerProvider           = new RouterProvider();

            var regionSender   = provinceProvider.GetRegionOfProvince(citysender);
            var regionReceiver = provinceProvider.GetRegionOfProvince(cityReceiver);

            if (regionReceiver == -1 || regionSender == -1)
            {
                return(null);
            }
            if (citysender.Equals(cityReceiver))
            {
                router = routerProvider.GetIdRouterByName("Nội tỉnh");
            }
            else if (regionSender == regionReceiver)
            {
                router = routerProvider.GetIdRouterByName("Nội vùng");
            }
            else
            {
                router = routerProvider.GetIdRouterByName("Liên vùng");
            }
            serviceCharge = serviceChargeProvider.GetServiceChargeByKindService(router, kindService.Value);
            int numberOfDayReceive = kindTimeReceivedProvider.GetKindTimeReceivedById(serviceCharge.KindTimeReceivedId).NumberOfDay;

            if ((packagelong == null || wide == null || high == null) && weigh == null)
            {
                resultExhibiton.TotalMoney = serviceCharge.CostOderUrban;
            }
            else
            {
                var weighTemp = wide * high * packagelong / 5000;
                resultExhibiton.TotalMoney = weighTemp > weigh ? ((weighTemp > serviceCharge.Weigh) ? (serviceCharge.CostOderUrban + (int)(weighTemp - serviceCharge.Weigh) / serviceCharge.AddWeight * serviceCharge.AddMoney) : serviceCharge.CostOderUrban)
                    : ((weigh > serviceCharge.Weigh) ? (serviceCharge.CostOderUrban + (int)(weigh - serviceCharge.Weigh) / serviceCharge.AddWeight * serviceCharge.AddMoney) : serviceCharge.CostOderUrban);
            }

            resultExhibiton.DayReceiver = (DateTime.Now.Hour > 11) ? DateTime.Now.AddDays(numberOfDayReceive).ToString("dd/MM/yyyy"): DateTime.Now.AddDays(numberOfDayReceive + 1).ToString("dd/MM/yyyy");

            return(Json(resultExhibiton, JsonRequestBehavior.AllowGet));
        }
        public void Create_CopiesAllProperties()
        {
            var serviceCharge = new ServiceCharge(1972)
            {
                Amount = 11m,
                Date   = DateTime.Now,
            };

            var id = _repository.Create(serviceCharge);

            var storedReceipt = _repository.Get(id);

            storedReceipt.Amount.Should().Be(serviceCharge.Amount);
            storedReceipt.Date.Should().Be(serviceCharge.Date);
            storedReceipt.EmployeeId.Should().Be(serviceCharge.EmployeeId);
            storedReceipt.Id.Should().Be(id);
        }
Пример #28
0
        private string Validate(string propertyName)
        {
            // Return error message if there is error on else return empty or null string
            string validationMessage = string.Empty;

            if (_firstLoad)
            {
                return(validationMessage);
            }
            switch (propertyName)
            {
            case "Deposit":
                if (!double.TryParse(Deposit.ToString(), out uselessParse))
                {
                    validationMessage = "Only Digits Are Allowed";
                }
                break;

            case "Interest":
                if (!double.TryParse(Interest.ToString(), out uselessParse))
                {
                    validationMessage = "Only Digits Are Allowed";
                }
                break;

            case "Withdraw":
                if (!double.TryParse(Withdraw.ToString(), out uselessParse))
                {
                    validationMessage = "Only Digits Are Allowed";
                }
                break;

            case "ServiceCharge":
                if (!double.TryParse(ServiceCharge.ToString(), out uselessParse))
                {
                    validationMessage = "Only Digits Are Allowed";
                }
                break;
            }

            return(validationMessage);
        }
Пример #29
0
        public void UnionMemberWithOneServiceCharge()
        {
            database.AddEmployee(employee);

            int memberId = 7783;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(employee.EmpId, memberId, 99.42, database);

            cmt.Execute();

            var date = new DateTime(2005, 8, 8);
            ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, 12.95, database);

            sct.Execute();

            var           serviceCharges = database.GetServiceCharges(memberId);
            ServiceCharge sc             = serviceCharges.FirstOrDefault(x => x.Date == date);

            Assert.IsNotNull(sc);
            Assert.AreEqual(12.95, sc.Amount, 0.001);
        }
        public override void Execute()
        {
            var employee = payrollRepository.GetUnionMember(memberId);

            if (employee == null)
            {
                throw new ApplicationException($"Union member of id { memberId } cannot be found!");
            }

            var affiliation = employee.Affiliation;

            if (!(affiliation is UnionEmployeeAffiliation))
            {
                throw new ApplicationException($"Union member of id { memberId } does not have any affiliation!");
            }
            var serviceCharge = new ServiceCharge {
                Date = date, Amount = amount
            };

            (affiliation as UnionEmployeeAffiliation).AddServiceChange(serviceCharge);
        }
Пример #31
0
 public void AddServiceCharge(ServiceCharge sc)
 {
     charges[sc.Date] = sc;
 }