GithubHelp home page GithubHelp logo

receipt_creator's Introduction

Shopping Basket

This Ruby application simulates a shopping basket, designed to manage purchases and calculate sales taxes according to specific rules. It elegantly handles tax calculations for both exempt and non-exempt items, including imported goods, ensuring accurate billing and receipt generation.

Features

  • Item Management: Add items with quantity, name, and price.
  • Tax Calculation: Automatically calculates sales tax for items, distinguishing between exempt, non-exempt, and imported products.
  • Receipt Generation: Produces a detailed receipt that includes each item's final price (tax inclusive) and the total cost.
  • Tax Rounding: Rounds sales tax to the nearest 0.05 for precise accounting.
  • Formatted Output: Ensures all numbers are presented with two decimal places for readability.

Installation

No installation is necessary for running this program directly. However, ensure Ruby is installed on your system. This program was developed and tested with Ruby 3.0.0, but it should be compatible with most recent Ruby versions.

Usage

The ShoppingBasket class is at the core of this application. You can instantiate this class and use its methods to simulate a shopping experience.

Here's a quick start guide:

require_relative '../lib/shopping_basket'

# Initialize a new Shopping Basket
basket = ShoppingBasket.new

# Add items to the basket
basket.add_item(1, 'imported bottle of perfume', 27.99)
basket.add_item(1, 'bottle of perfume', 18.99)
basket.add_item(1, 'packet of headache pills', 9.75)
basket.add_item(1, 'imported box of chocolates', 11.25)

# Generate and print the receipt
basket.generate_receipt

Testing

Comprehensive RSpec tests are included to verify functionality across different scenarios, from tax calculations to receipt generation.

Running Tests

To run the tests, ensure you have RSpec installed. If not, you can install it with:

gem install rspec

Then Clone this repository to your local machine:

git clone https://github.com/lautarob/receipt_creator.git

Change to the project directory:

cd receipt_creator

Run the tests using the following command:

rspec

This will run all spec files located in the spec directory, providing a detailed report of each test case.

receipt_creator's People

Contributors

lautarobertuzzi-lk avatar lautarob avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.