Skip to content

Latest commit

 

History

History
207 lines (203 loc) · 13.1 KB

readme.md

File metadata and controls

207 lines (203 loc) · 13.1 KB

Keep an Eye on It: SALARY CHECKER

Don't want to drain your salary as quick as you use to do?
Keep an Eye on It: Salary Checker is a Java project developed to better manage your monthly expenses through the years.

  • Class
  • Config
  • Exception
  • Output
  • Main

CLASS

  • Outcome

    Each expense has an amount, a category, an id and a description.
  • Salary

    Each Salary has a single income, and several outcomes.
    All the outcomes are stored in an HashMap with key: Integer (auto incrementing id) and a value (outcome).
    It has these methods worth mentioning:
    • printOutcomeHashMap

      Prints the outcomes stored in the Salary Hashmap.
    • setSingleOutcome

    • editSingleOutcome

      Several methods to edit a single expense description, outcome or category
    • incomeGraphics

      Used to better display the Salary data.
    • printSalary

      Displays all the infos related to a Salary, such as income, gain and expenses value, description, n_ID, category
    • printSalaryFiltered

      Displays all the infos related to a Salary, such as expenses value, description, category
    • printOutcomesHashMapFilter

      Displays all the infos related to the outcome
    • printOutcomesHashMapGroupCat

      Displays expenses grouped by category and ordered by amount.
  • Year

    It has a String year and an HashMap for the year months.
    • Add/Remove Month

    • getMonths

      Returns the HashMap which represents the year months.
    • compareTo

      Year implements Comparable, compareTo is used to set the year String as parameter to order the ArrayList in the main.
  • FileReaderAndWriter

    It gives persistence to the program by loading all the already saved values and by storing the new ones into files that can be used as the project storage system.
    It has 2 methods:
    • writingFile

      Given a YEARS ArrayList, the method iterates through it and saves all its data in a txt file, created in order to save the data and making therefore possible for the readingFile method to load the already existing data.
      Everytime it's called, it overwrites the txt file deleting the old content.
    • backupFile

      Given a YEARS ArrayList, the method iterates through it and saves all its data in a txt file, created in order to backup the data and making therefore possible for write.txt to have a backup. The .txt is called after the actual time when the function is called.
      Everytime it's called, it creates a new file.
      Future rework: delete the older backups, keep a maximum number of files, where the maximum is represented by X: it can be defined by the user, by default should be a value of 5 or 10.
    • readingFile

      Given an already existing txt file written by the previous "writingFile" method, it loads the data retrieved from the txt file into the YEARS ArrayList.
    • deleteBackup

      Given a folder with different txt files, each named in the format YYYY_MM_DD_hh_mm_ss.txt, a list is created with all the files name.
      The list is then reverse-sorted, and with the help of the list all the files, except for the first N (most recents), are deleted.
    • writeCategoriesToTXT

      Given HashMap categoriesMap, writes CategoriesCFG file with CODE, DESCR entries.
    • readCategoriesFromTXT

      Given a txt file CATEGORIES, which consists of entries of the type CODE() DESCR(). Returns an HashMap (key: CODE , value: DESCR )
  • Utils

    This class has static methods and attributes used without any instance for this class by all the others Classes.
    • ANSI_COLOR_CODES
    • MonthToInt

      Given a string, returns an integer from 0 to 11, or -1.
    • Intro

      KAE-SC logo, displayed on the boot-up.
    • Menu

      the main's possible choices.
    • convertDecimalFormat

      converts a double value to a string, cutting it to 2 or 1 decimal values
    • doubleIsNumeric

      returns true if the String is a valid double, false otherwise.
    • integerIsNumeric

      returns true if the String is a valid integer, false otherwise.
    • hasComma

      returns true if the String contains "comma" character, false otherwise.
    • hasDot

      returns true if the String contains "dot" character, false otherwise.
    • checkCategories

      Given a category code, returns true if categoriesMap has no equal code to categoryCode, or returns false if categoriesMap has at least a code equal to categoryCode
    • capitalizeFirstLetter

      returns the string with the first letter capitalized
    • capitalizeFirstLetterAfterLowerCase

      returns the string with the first letter capitalized after lower case
    • cursor

      prints the cursor for the menu input choice (unused as of now)
  • switch Manager Utils

    This class has static methods used by the switch manager, these are the main features.
    • addSalary

    • Adds a Month Salary
    • modifySalary

      Given the year and the month, edits a salary income with a new value
    • addExpense

    • Adds an expense to a specific Month
    • modifyExpense

      Given the year and the month, edits a salary income with a new value
    • printAll

      Prints the data related to all the Years. Depending on the flag 'detailsFlag', details about expenses will also be printed.
    • printYear

      Prints all the data related to a specific Year
    • loadData

      Loads from write.txt file (overwrites actual data)
    • saveData

      Saves current data into write.txt and it creates a backup file, for a maximum of 5 backups (through the FileHandler method deleteBackup)
    • showStats

      Displays stats for each month, giving a percentage representation for expenses and gains
    • printByCategories

      Displays expenses grouped by Categories, per month, ordered by amount
    • insertCategoriesIntoMap

      Given an HashMap and the input entry, returns the HashMap with the new element added
    • readCategories

      Given an HashMap, which is populated by reading CategoriesCFG.txt, all the entries CODE DESCRIPTION are displayed.
    • modifyExpense

      Given the expense id, the year and the month, edits an expense with several options:
      1. Edit expense outcome
      2. Edit expense description
      3. Edit expense category
      4. Remove expense
    • filterByCategories

      Given the year arraylist and a category in input,returns the same collection but filtered by expenses with the selected category.
    • filterByDescription

      Given the year arraylist and a description in input, returns the same collection but filtered by expenses which contains the description in input in their descriptions.
    • printAllFilters

      Given an ArrayList, displays all the data related to all the Years but with a different format from printAll

CONFIG

  • CategoriesCFG.txt

    TXT file in which are stored the categories Code and Description

EXCEPTION

WORK IN PROGRESS
  • GenericException GenericException description

MAIN

  • KAE-SC

    Has an ArrayList for every year (12 months, key (1 aka January, 2 February and so on...), value))
    Has a method (monthToInt) used to convert String month names to Integers (which returns -1 if the month name is not valid), and a menù method to show all the options.
    The above methods are both static, as they are called inside the main.

    Welcome page

    The menù contains several options:

    • Add Salary
      Given a month name (e.g. November), an amount and an Year, through the Utils.MonthToInt method, the main allocates the Salary in its position in the HashMap(e.g. November = 11):

      If the inserted month already exists (the place into the HashMap is already assigned), it will be resetted with the new parameters.
      In other words, if a month needs to be erased, this functionality can be used in order to reinitialize it.
    • Edit Salary
      Given a month and an year, the income is updated with the new value.

    • Add Expense
      Given an amount, a description,, a category, a month and an year, the expense is added to the Salary which has the same month and year.

    • Edit Expense
      Given a month name (and a Year), followed by an ID (visible in the Print), the specific expense can be edited or deleted.
      To snchronize all the data, after the remove it follows a write into the file, to save the occured changes.

    • Print all the Years

      Print all the months for all the registered years, just listing gains in total and for each year.
      If a month or a year has a negative ingain, a warning is displayed.
    • Print all the Years

      Print all the months for all the registered years, also giving data for expenses and gains in total and for each year.
      If a month or a year has a negative ingain, a warning is displayed.

    • Print all the Years, filtering by Category

      Print all the months for all the registered years, filtering by the input Category.

    • Print all the Years, filtering by description

      Print all the months for all the registered years, filtering by the given words: each expense which contains the input in the description is displayed.

    • Print a Year

      Print all the months for the selected year.
      If a month or the year has a negative ingain, a warning is displayed.

    • Load data

      Loads from write.txt file (overwrites actual data)
      Read a txt file importing all the previously saved elements.
      Saves actual data into write.txt (overwritten each time) and also creates a unique backup file each time, to minimize data loss risk.
      When saving the backup, it also checks if there are already more than seven backups: if that's the case, the older are deleted.
      Writes all the data in a txt file, in order to retrieve those through the readingFile method.

    • Save current data

      Show stats for each month, giving a percentage representation for expenses and gains
      Displays the percentages associated with each month, in terms of gain and expenses, through the showStats method.

    • Display statistics

      Displays stats for each month, giving a percentage representation for expenses and gains.

    • Group months by Categories

      Expenses per month, grouped by Categories and ordered by amount
      Displays expenses grouped by categories ordering for amount, for each month.

    • Group years by Categories

      Expenses per month, grouped by Categories and ordered by amount
      Displays expenses grouped by categories ordering for amount, for each year.

    • Insert category

      Adds a category to the CategoriesCFG.txt file, which is used to store the categories.
    • Display all the categories

      Display all the categories stored in the CategoriesCFG.txt file.