static void CalculateTaxesOfA_VATNr(List <object> 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!"); } } }
static void AddBillToA_VATNr(List <object> 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("Enter a VAT number: "); string inputCode = Console.ReadLine(); /* Cerca nelle P.IVA "normali". */ /* Creazione d'un oggetto VATNumberNormal vuoto/null. */ VATNumberNormal selectedNormal = null; foreach (string vAT in vATs) { //if (vATs.TCode == inputCode) //{ // /* Se esiste una P.IVA corrispondente di tipo "normale", // * viene "riempito" l'oggetto « selectedNormal » con la corrispettiva P.IVA // * (altrimenti l'oggetto resta vuoto/null). */ // selectedNormal = normals[vATKey]; // break; //} } /* Trovata una P.IVA "normale" (l'oggetto « selectedNormal » è stato "riempito" quindi non è più vuoto/null). */ if (selectedNormal != null) { Console.Write(INVITE_BILL); decimal newBill; while (true) { if (decimal.TryParse(Console.ReadLine(), out newBill)) { break; } Console.WriteLine(STR_ERR_BILL); } selectedNormal.Bills.Add(newBill); } /* Cerca nelle P.IVA "semplici" (se non è una P.IVA "normale" ...). */ else { /* Creazione d'un oggetto VATNumberNormal vuoto/null. */ VATNumberSimple selectedSimple = null; //foreach (string vATKey in simples.Keys) //{ // if (simples[vATKey].VATCode == inputCode) // { // selectedSimple = simples[vATKey]; // break; // } //} /* Trovata una P.IVA "normale" (l'oggetto « selectedSimple » è stato "riempito" quindi non è più vuoto/null). */ if (selectedSimple != null) { Console.Write(INVITE_BILL); decimal newBill; while (true) { if (decimal.TryParse(Console.ReadLine(), out newBill)) { break; } Console.WriteLine(STR_ERR_BILL); Console.Write(INVITE_BILL); } selectedSimple.Bills.Add(newBill); } /* P.IVA non trovata. */ else { Console.WriteLine(STR_NOT_A_VAT_NR); } } //break; return; }
static void AddExpenseToAVATNr(List <object> 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; }
static VATNumberNormal SearchVATNr(List <object> vATs) { VATNumberNormal foudVATNormal = new VATNumberNormal(); return(foudVATNormal); }