public void testFriendlyPositiveFee()
        {
            CalculateFee calc = new CalculateFee(FeeCalculator.FriendlyFee);
            decimal      fees = calc(100);

            Assert.AreEqual(1, fees);
        }
        public void testRealRipoff()
        {
            CalculateFee calc = new CalculateFee(FeeCalculator.RipoffFee);
            decimal      fees = calc(-1);

            Assert.AreEqual(100, fees);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            IAccount  [] accounts = new IAccount[MAX_CUST];
            accounts[0] = new CustomerAccount("Phuong");
            accounts[0].payInFunds(100);
            Console.WriteLine("Balance "+ accounts[0].Balance);

            accounts[1] = new BabyAccount("KKY","Nanterre");
            accounts[1].payInFunds(20);
            accounts[1].withdrawFunds(9);
            accounts[1].Name = "KKYPhuong";
            Console.WriteLine(accounts[0].printWarning());
            Console.WriteLine(accounts[0].ToString());
            Console.WriteLine(accounts[1].ToString());
            Console.WriteLine(accounts[0].Equals(accounts[1]));
            Console.WriteLine(accounts[1].Equals(accounts[0]));

            //Delegate
            CalculateFee calc; //declare an instance of delegate
            calc = new CalculateFee(RipOffFee); // map/call the ripofffee method
            calc(-1);     //execute the method

            calc = new CalculateFee(FriendlyFee);
            calc(-1);

            //Bank

            SGBank myBank = new SGBank();
            myBank.storeAccount(accounts[0]);
            myBank.storeAccount(accounts[1]);
            IAccount found = myBank.findAccount("Phuong");
            Console.WriteLine(found.ToString());
            string d = Console.ReadLine();
        }
Exemple #4
0
        public void TestMethod1()
        {
            CalculateFee calculateFee = new CalculateFee();

            object[][] data =
                new object[][]
            {
                new object[] { "7-ELEVEN", 100M, 30M },
                new object[] { "CIRCLE_K", 100M, 29.70M },
            };
            decimal expected;
            decimal actual;

            foreach (object[] values in data)
            {
                expected = (decimal)values[2];
                actual   = calculateFee
                           .CalculateClientFees(
                    values[0].ToString(),
                    (decimal)values[1]);

                Assert.AreEqual(expected, actual,
                                string.Format(
                                    "{0} fee is not correct"
                                    , values[0].ToString())
                                , null
                                );
            }
        }
Exemple #5
0
    public static void Main()
    {
        CalculateFee calc;

        calc = new CalculateFee(RipoffFee);
        calc(-1); // this will call the Ripoff method
        calc = new CalculateFee(FriendlyFee);
        calc(-1); // this will call the Friendly method
    }
Exemple #6
0
        public void CalculateTransactionFees(string sourceFilePath)
        {
            var line = string.Empty;

            using (var fileReader = new StreamReader(sourceFilePath))
            {
                while ((line = fileReader.ReadLine()) != null)
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            var transactionData = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                            var transaction     = new Transaction(new Date(DateTime.Parse(transactionData[0])),
                                                                  new Name(transactionData[1]),
                                                                  new Amount(double.Parse(transactionData[2])));
                            var command        = new CalculateFee(Guid.NewGuid(), transaction);
                            var transactionFee = _calculateFeeHandler.Handle(command);

                            var formattedDate = transaction.Date.Value.ToString(_outputSettings.DateFormatting,
                                                                                CultureInfo.InvariantCulture);
                            var formattedFee = transactionFee.Value.ToString(_outputSettings.FeeFormatting,
                                                                             CultureInfo.InvariantCulture);
                            var formattedMerchantName = transaction.MerchantName.Value;
                            _outputSettings.WriteToOutput(
                                $"{formattedDate} {formattedMerchantName} {formattedFee}");
                        }
                        else
                        {
                            _outputSettings.WriteToOutput(Environment.NewLine);
                        }
                    }
                    catch (Exception e)
                    {
                        _outputSettings.WriteToOutput(e.Message);
                    }
                }
            }
        }
 public void testRealRipoff()
 {
     CalculateFee calc = new CalculateFee(FeeCalculator.RipoffFee);
     decimal fees = calc(-1);
     Assert.AreEqual(100, fees);
 }
 public void testFriendlyPositiveFee()
 {
     CalculateFee calc = new CalculateFee(FeeCalculator.FriendlyFee);
     decimal fees = calc(100);
     Assert.AreEqual(1, fees);
 }
Exemple #9
0
        public async Task <ActionResult> CalCulateFeeForClass(CalculateFee model)
        {
            var school = await _schoolService.GetSchoolById(GetMySchoolId().ToString());

            var activeSessions = school.GetActiveSession();


            var cycle    = school.FeeCycles.FirstOrDefault(x => x.Id == model.FeeCycleId.AsObjectId());
            var students = new List <Student>();

            if (model.ClassId != "All")
            {
                students =
                    await
                    _studentService.Get(
                        x => x.ClassId == model.ClassId.AsObjectId() && x.DeactivateDate == null);
            }
            else
            {
                if (model.ClassId == "All")
                {
                    var allclassForSession =
                        await
                        _schoolClassService.Get(
                            x =>
                            x.SessionId == activeSessions.Id && x.DeactivateDate == null &&
                            x.SchoolId == Constants.TestingSchool_Id.AsObjectId());

                    var clssIds = allclassForSession.Select(x => x.Id);
                    students =
                        await _studentService.Get(x => clssIds.Contains(x.ClassId) && x.DeactivateDate == null);
                }
            }
            if (students.Count == 0)
            {
                return(BadRequest("The students are not avilable in the selected class"));
            }
            var count         = 0;
            var existingcount = 0;

            foreach (var student in students)
            {
                var issuccessfullyCalculate = await _feeService.GenerateFee(student, cycle, school);

                if (issuccessfullyCalculate != null)
                {
                    if (issuccessfullyCalculate.FeeStatus == FeeStatus.PendingApproval)
                    {
                        count = count + 1;
                    }
                    else
                    {
                        existingcount = existingcount + 1;
                    }
                }
            }

            if (count == 0 && existingcount == 0)
            {
                return(BadRequest("Please create fee components for the respective class before calculating fee"));
            }
            if (existingcount > 0 && count == 0)
            {
                return(Ok("The fee has been already calculated for this class"));
            }
            return(Ok("Fee for students has been calculated successfully"));
        }