Giter Club home page Giter Club logo

cashierapp's Introduction

CashierApp

CashierApp provides tools to print out a receipt given some items. The items are taxed depending on whether the item was imported (+5%) and whether it was non-essential (+10%).

Given are three example shopping lists, whose receipts are printed out.

Requirements

Since CashierApp is written in Python, a working distribution needs to be installed and included in your PATH environment variable:

Run Examples

To run the examples, execute the following in the project's root directory:

python -m cashier

TODO: As a next step, a CLI interface can be implemented in order to input items via the terminal instead of running the given examples.

Usage

To use the receipt generation API provided, four classes are mainly used for that purpose:

  • Item: models an item to be bought
  • ItemCategory: models the category of the item, which can either be:
    • Food
    • Book
    • Medical
    • Non-essential
  • Register: models a cash register, which generates the receipt
  • Receipt: models a receipt output from a register

You can initialize an item as follows, given some properties:

from cashier.cash_register.item import Item 
item = Item(name="box of chocolates", price=10.00, category=ItemCategory.FOOD, quantity=1, imported=True)

To be able to process this item as if you were buying it, we need a Register for that:

from cashier.cash_register.register import Register
register = Register()

To scan the item:

register.process_item(item)

When you're done adding items, you can trigger the register to finish, output the receipt, and print it out via:

from cashier.cash_register.utils import ReceiptPrinter

receipt = register.get_receipt()
ReceiptPrinter.print_receipt(receipt)

Test

Requirements

Unit tests for this app are provided and implemented using pytest. To install the requirements for running the tests, execute the following in the project's root directory (preferable in a virtual environment):

pip install -r requirements-dev.txt

To run the tests, just execute pytest in the project's root directory:

pytest

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.