Skip to main content

Crate paycheck_utils

Crate paycheck_utils 

Source
Expand description

This library contains utility functions for calculating paycheck withholdings and net income given a hypothetical hourly wage and weekly working hours. The idea is pretty much like the “Sample Paycheck” tool found in the Paycom employee portal, but aimed at having a little more functionality and customization.

The entire library was developed with the perspective of an hourly paid employee in mind, focusing on bi-weekly paychecks as the standard pay period to simulate how employees typically view and plan their income.

The primary question this library aims to answer is: “Given an hourly wage and number of hours worked per week, what would my net paycheck be after taxes and deductions?”

The secondary question this library aims to answer is: “Given a total monthly expenses amount and hourly wage, how many hours would I need to work to cover my expenses with “x” amount left over after taxes and deductions?“ (this will be implemented in a future version).

The library is structured into several modules:

  • withholdings: Contains functions to estimate federal tax withholdings, Social Security, and Medicare deductions.
  • deductions: Defines structures and functions for handling pre-tax and post-tax deductions.
  • income: Contains functions to calculate gross paycheck based on hourly wage and hours worked.
  • expenses: Defines structures and functions for managing monthly expenses.
  • constants: Contains tax and time related constants necessary for calculations.
  • interaction: Contains functions for interacting with the user to receive input for employment scenario.
  • utils: Contains utility functions for rounding and formatting output.

A CLI tool has been added to this project to allow users to interact with the library and input their own employment scenarios, deductions, and expenses to calculate their net paycheck and compare it to their monthly expenses. There is only 1 command that starts a user interaction flow to gather the necessary inputs and then outputs the calculated net paycheck and comparison of monthly expenses to monthly income.

Run CLI: ‘check-paycheck start’ or ‘cargo run – start’

(future updates, improvements, and functionality planned)

Re-exports§

pub use crate::constants::*;
pub use crate::deductions::*;
pub use crate::expenses::*;
pub use crate::income::*;
pub use crate::interaction::*;
pub use crate::utils::*;
pub use crate::withholdings::*;

Modules§

constants
Module containing utility constants and enums for payroll calculations. Tax related constants are based on IRS guidelines for the year 2026. Focus is given to single filer status, with future implementation plans for other filing statuses.
deductions
Module for handling paycheck deductions. Defines structures and functions for managing pre-tax and post-tax deductions.
expenses
Module for handling expense calculations. Defines common standard expense categories and functions for totaling monthly expenses.
income
Module for handling paycheck income calculations for hourly paid employees This module calculates from a bi-weekly paycheck perspective to synthesize how an employee thinks about, views, and plans their income.
interaction
This module handles all user interaction to gather the necessary information to create an employment scenario struct This includes functions for displaying prompts, receiving input, and showing results. The main function in this module is get_user_input which orchestrates the entire process of gathering information from the user and creating an employment scenario struct.
utils
Utility functions for paycheck calculations and formatting. This module includes functions for rounding values to 2 decimal places and formatting output for display.
withholdings
Module for estimating various paycheck withholdings based on gross pay and filing status. Uses IRS guidelines for the year 2026, focusing on single filer status. Future implementation plans exist for other filing statuses.

Structs§

EmploymentScenario
Represents an employment scenario with hourly rate, hours worked per week, filing status, and deductions. Possible deductions avaialable are defined in the deductions module.