示例#1
0
        public static void ProcessInput(Ledger ledger, Taxation taxMachine)
        {
            // open terminal
            Terminal.Output("Wecome to..");
            Console.WriteLine();

            bool done = false;

            while (!done)
            {
                Terminal.Output("== Imaginaria Income Calculator ==");
                Console.WriteLine();

                if (ledger.RecordsCount() > 0)
                {
                    Terminal.Output($"( The ledger contains {ledger.RecordsCount()} records )");
                }
                Console.WriteLine();

                Terminal.Output("> Please choose an action:");
                Terminal.Output(" (1 or i) New income record");
                Terminal.Output(" (2 or f) Find a particular income record");
                Terminal.Output(" (3 or r) Review saved income records");
                Terminal.Output(" (4 or t) Review and update taxation terms");
                Terminal.Output(" (0 or x) Exit");


                char nextKey = Console.ReadKey().KeyChar;
                Console.WriteLine();
                Console.WriteLine();
                switch (Char.ToLower(nextKey))
                {
                case '1':
                case 'i':
                    AddNewRecord(ledger);
                    break;

                case '2':
                case 'f':
                    FindRecord(ledger);
                    break;

                case '3':
                case 'r':
                    ReviewRecords(ledger);
                    break;

                case '4':
                case 't':
                    ReviewTerms(taxMachine, ledger);
                    break;

                case '0':
                case 'x':
                    done = true;
                    break;
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Taxation taxation = new Taxation();
            Ledger   ledger   = new Ledger(taxation);

            SeedSampleValues(ledger); // comment this method call out to skip initial seeding with sample valued
            ProcessInput(ledger, taxation);
        }
示例#3
0
 public Ledger(Taxation taxMachine)
 {
     records         = new List <IncomeRecord>();
     this.taxMachine = taxMachine;
 }
示例#4
0
        private static void ReviewTerms(Taxation taxation, Ledger ledger)
        {
            Terminal.Output("> Current taxation terms are:");
            Terminal.Output($". Tax percentage: {taxation.TaxationPercentage}%");
            Terminal.Output($". Social contributions percentage: {taxation.SocialContributionsPercentage}%");
            Terminal.Output($". Minimum taxable amount: {taxation.MinimumTaxableAmount} IDR");
            Terminal.Output($". Maximum amount subject to social contributions: {taxation.MaximumAmountSubjectYoSC} IDR");
            Console.WriteLine();

            bool update = Terminal.ConfirmationInput("? Would you like to update any of the values? (Y/y for 'yes'): ", 'y');

            Console.WriteLine();
            Console.WriteLine();
            if (update)
            {
                Terminal.Output("> Please select a value to update");
                Terminal.Output(" (1) Tax percentage");
                Terminal.Output(" (2) Social contributions percentage");
                Terminal.Output(" (3) Minimum taxable amount");
                Terminal.Output(" (4) Maximum amount subject to social contributions");
                Terminal.Output(" (0) Exit");

                bool done = false;

                while (!done)
                {
                    char nextKey = Console.ReadKey().KeyChar;
                    Console.WriteLine();
                    Console.WriteLine();
                    switch (Char.ToLower(nextKey))
                    {
                    case '1':
                        taxation.UpdateTaxationPercentge();
                        ledger.UpdateAllRecords();
                        break;

                    case '2':
                        taxation.UpdateSocialContributionPercentge();
                        ledger.UpdateAllRecords();
                        break;

                    case '3':
                        taxation.UpdateMinimumAmountPercentge();
                        ledger.UpdateAllRecords();
                        break;

                    case '4':
                        taxation.UpdateMaximumAmountSubjToSC();
                        ledger.UpdateAllRecords();
                        break;

                    case '0':
                        done = true;
                        ledger.UpdateAllRecords();
                        break;
                    }
                    done = true;
                }
            }

            Console.Clear();
        }