예제 #1
0
        static void CalculateTaxesOfA_VATNr(List <VATNumber> vATs)
        {
            #region Const Tax values
            const decimal VAT_PERCENTAGE            = 22m; // IVA 22%
            const decimal INCOME_TAX                = 23m; // IRPEF 38%
            const decimal SIMPLE_TAXABLE_PERCENTAGE = 78m; // [% d'importo tassabile se P.IVA"semplice", 78%]
            const decimal SIMPLE_TAX_PERCENTAGE     = 15m; // [% aliquota se P.IVA"semplice"?, 78%]
            #endregion

            Console.Write("Enter a VAT number: ");
            string inputCode = Console.ReadLine();

            // LOOK IN NORMALS
            VATNumberNormal selectedNormal = null;
            //foreach (string vATKey in normals.Keys)
            //{
            //    if (normals[vATKey].VATCode == inputCode)
            //    {
            //        selectedNormal = normals[vATKey];
            //        break;
            //    }
            //}

            // FOUND A NORMAL VAT
            if (selectedNormal != null)
            {
                decimal billTotal = 0M;
                foreach (decimal bill in selectedNormal.Bills)
                {
                    billTotal += bill;
                }

                decimal expenseTotal = 0M;
                foreach (decimal expense in selectedNormal.Expenses)
                {
                    expenseTotal += expense;
                }

                decimal profit = billTotal - expenseTotal;

                if (profit > 0)
                {
                    decimal VATAmount        = profit * VAT_PERCENTAGE / 100;
                    decimal profitWithoutVAT = profit - VATAmount;
                    decimal incomeTaxAmount  = profitWithoutVAT * INCOME_TAX / 100;
                    decimal net      = profitWithoutVAT - incomeTaxAmount;
                    decimal taxTotal = VATAmount + incomeTaxAmount;

                    Console.WriteLine($"Total net gain: {net}; total taxes: {taxTotal}");
                }
                else
                {
                    Console.WriteLine("Profit: {profit}; total taxes: 0");
                }
            }
            // LOOK FOR A SIMPLE VAT
            else
            {
                // LOOK INTO SIMPLES
                VATNumberSimple selectedSimple = null;
                //foreach (string vatKey in simples.Keys)
                //{
                //    if (simples[vatKey].VATCode == inputCode)
                //    {
                //        selectedSimple = simples[vatKey];
                //        break;
                //    }
                //}
                // FOUND A SIMPLE VAT
                if (selectedSimple != null)
                {
                    decimal billTotal = 0M;
                    foreach (decimal bill in selectedSimple.Bills)
                    {
                        billTotal += bill;
                    }

                    decimal profit = billTotal;

                    if (profit > 0)
                    {
                        decimal taxable = profit * SIMPLE_TAXABLE_PERCENTAGE / 100;
                        decimal taxes   = taxable * SIMPLE_TAX_PERCENTAGE / 100;
                        decimal net     = profit - taxes;

                        Console.WriteLine($"Net gain: {net}; total taxation: {taxes}");
                    }
                    else
                    {
                        Console.WriteLine($"Profit: {profit}");
                    }
                }
                // VAT NUMBER NOT FOUND
                else
                {
                    Console.WriteLine("The entered VAT number does not exist!");
                }
            }
        }
예제 #2
0
        static void AddExpenseToA_VATNr(List <VATNumber> vATs)
        {
            #region ConstStrings
            const string STR_NAN          = "Il dato immesso NON è un numero.";
            const string STR_NOT_POSITIVE = "Il numero immesso NON è positivo.";
            const string STR_NOT_A_VAT_NR = "Il numero immesso NON corrisponde ad una P.IVA salvata.";
            const string STR_IS_A_VAT_NR  = "P.IVA presente.";

            const string IMPORT_IS_NEGATIVE = "L\'importo immesso è negativo.";

            const string INVITE_BILL  = "Immettere l\'importo della fattura d\'aggiungere: \a";
            const string STR_ERR_BILL = "Valore immesso non valido.";
            #endregion

            Console.Write("Immettere il numero della P.IVA.");
            string inputCode = Console.ReadLine();

            // LOOK IN NORMALS
            VATNumberNormal selectedNormal = null;
            //foreach (string vATKey in normals.Keys)
            //{
            //    if (normals[vATKey].VATCode == inputCode)
            //    {
            //        selectedNormal = normals[vATKey];
            //        break;
            //    }
            //}

            // FOUND A NORMAL VAT
            if (selectedNormal != null)
            {
                Console.Write("Enter the value of the expense: ");
                decimal newExpense;
                while (true)
                {
                    if (decimal.TryParse(Console.ReadLine(), out newExpense))
                    {
                        break;
                    }
                    Console.Write("Invalid value. Re-enter: ");
                }
                selectedNormal.Expenses.Add(newExpense);
            }
            // LOOK FOR A SIMPLE VAT
            else
            {
                // LOOK INTO SIMPLES
                VATNumberSimple selectedSimple = null;
                //foreach (string vATKey in simples.Keys)
                //{
                //    if (simples[vATKey].VATCode == inputCode)
                //    {
                //        selectedSimple = simples[vATKey];
                //        break;
                //    }
                //}
                // FOUND A SIMPLE VAT
                if (selectedSimple != null)
                {
                    Console.WriteLine("The selected VAT number is of type 'simple' and does not allow expenses");
                }
                // VAT NUMBER NOT FOUND
                else
                {
                    Console.WriteLine("The entered VAT number does not exist!");
                }
            }
            // break;
        }