예제 #1
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;
        }
예제 #2
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!");
                }
            }
        }
예제 #3
0
        //ora +0- inutile
        static public List <VATNumber> CreateSimpleMockVATs()
        //static public Dictionary<string, VATNumberSimple> CreateSimpleMockVATs()
        {
            /* Creazione e pre_popolamento dizionari di P_IVA (simple), per lungo. */
            Dictionary <string, VATNumberSimple> dicVATSimple = new Dictionary <string, VATNumberSimple>();

            #region Creazione ed aggiunta P_IVA
            VATNumberSimple vAT_S1 = new VATNumberSimple();
            vAT_S1.Bills   = new List <decimal>();
            vAT_S1.VATCode = "222222";
            dicVATSimple.Add(vAT_S1.VATCode, vAT_S1);

            VATNumberSimple vAT_S2 = new VATNumberSimple();
            vAT_S2.Bills   = new List <decimal>();
            vAT_S2.VATCode = "333333";
            dicVATSimple.Add(vAT_S2.VATCode, vAT_S2);

            VATNumberSimple vAT_S3 = new VATNumberSimple();
            vAT_S3.Bills   = new List <decimal>();
            vAT_S3.VATCode = "741000";
            dicVATSimple.Add(vAT_S3.VATCode, vAT_S3);

            VATNumberSimple vAT_S4 = new VATNumberSimple();
            vAT_S4.Bills   = new List <decimal>();
            vAT_S4.VATCode = "111111";
            dicVATSimple.Add(vAT_S4.VATCode, vAT_S4);
            #endregion

            #region Aggiunte di Bills
            /* Creazione ed aggiunta per lungo, senza "scorciatoie". */
            decimal[] bills_S1 = { 1111.11m, 2222.22m, 3333.33m, 4444.44m };
            vAT_S1.Bills.Add(bills_S1[0]);
            vAT_S1.Bills.Add(bills_S1[1]);
            vAT_S1.Bills.Add(bills_S1[2]);
            vAT_S1.Bills.Add(bills_S1[3]);

            decimal[] bills_S2 = { 1111.11m, 2222.22m, 3333.33m, 4444.44m };
            vAT_S2.Bills.Add(bills_S2[0]);
            vAT_S2.Bills.Add(bills_S2[1]);
            vAT_S2.Bills.Add(bills_S2[2]);
            vAT_S2.Bills.Add(bills_S2[3]);

            decimal[] bills_S3 = { 1111.11m, 2222.22m, 3333.33m, 4444.44m };
            vAT_S3.Bills.Add(bills_S3[0]);
            vAT_S3.Bills.Add(bills_S3[1]);
            vAT_S3.Bills.Add(bills_S3[2]);
            vAT_S3.Bills.Add(bills_S3[3]);

            decimal[] bills_S4 = { 1111.11m, 2222.22m, 3333.33m, 4444.44m };
            vAT_S4.Bills.Add(bills_S4[0]);
            vAT_S4.Bills.Add(bills_S4[1]);
            vAT_S4.Bills.Add(bills_S4[2]);
            vAT_S4.Bills.Add(bills_S4[3]);
            #endregion

            /* I "simple" non hanno Expenses. */

            //return dicVATSimple;
            /*temporaneo aggiustamento*/
            List <VATNumber> outList = new List <VATNumber>();
            foreach (string vATKey in dicVATSimple.Keys)
            {
                outList.Add(dicVATSimple[vATKey]);
            }
            return(outList);
        }