Introduction

About

This is a simple implementation of a point of sale system. It is a simple POS system that allows users to add items to a cart, and then checkout. The goal of this project is to have a point of sale system where a business is able to have employees press icons that represent items when checking some one else. Some businesses have employees memorize all the prices of goods and then manually enter them into the cash register, but that requires more time training their employees and it could lead to the employees entering the wrong prices for goods. Instead of relying on employees memory which can result in error and loss of sales it is more efficient for them to just press the icon for the corresponding items. Once the has entered all of the required items, they will be able to press complete transactions which will tell them how much the sale was and enter the sale in a database. There will be an admin panel where the database entries can be deleted or altered and there will be an option to allow cash transactions to be added in the sale database.

Inspiration

I got inspirated to create this project after I started working at a donut shop where we did not have a POS system. It took us a while to train me and new members. I wanted to see if I could create a POS system that was simple and easy to use for the business.

Installation

Backend

cargo install --git https://github.com/bsikar/pos-system.git --branch main

Frontend

npm run build

Usage

Backend

cargo run --release

Frontend

npm run build

Backend

Cargo

  • Install the rust toolchain in order to have cargo installed by following this guide.
  • run cargo install pos-system

start the backend

make <database>.db

diesel migration run

delete and make new <database>.db * you will lose all your database data

diesel migration redo

start the server

cargo run --release

config files

the code currently uses config files located at ./config/

diesel uses a .env file for its cli utils while developing, this file can be ignored, but if you are developing you need to make sure the file is properly updated

in pos_config.toml

in pos_config.toml add changes to the backend the default values are:

default values

[database]
file_path = "pos_db.db"

[webserver]
net_id = "0.0.0.0"
port = 8080
folder = "../frontend/web-folder/"

example config

[database]
file_path = "database.db"

[webserver]
port = 3030

this will only change the database's file_path and the webserver's port all other values will be defaulted to

development

install dependencies

cd scripts
bash bootstrap.sh

before pushing run the presubmit.sh script

cd scripts
bash presubmit.sh

to quickly add data to the database run the test-db.sh script

cd scripts
bash test-db.sh

testing

cd scripts
pip install -r requirements.txt
python test-backend.py

this will start the server and run the tests by adding seed data to the database

Common Problems

  • make sure that the ports you are binding to are not already in use
  • make sure you have sqlite installed
sudo apt install libsqlite3-dev

Frontend

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

npm run lint

Runs the linter.
See the section about linting for more information.

npm run lint:fix

Runs the linter and automatically fixes any linting errors.

npm run fmt

Runs the formatter.
See the section about formatting for more information.

npm run fmt:fix

Runs the formatter and automatically fixes any formatting errors.

npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Contribution guidelines

First off, thank you for considering contributing to pos-system.

If your contribution is not straightforward, please first discuss the change you wish to make by creating a new issue before making the change.

Reporting issues

Before reporting an issue on the issue tracker, please check that it has not already been reported by searching for some related keywords.

Updating the changelog

Update the changes you have made in CHANGELOG file under the Unreleased section.

Add the changes of your pull request to one of the following subsections, depending on the types of changes defined by Keep a changelog:

  • Added for new features.
  • Changed for changes in existing functionality.
  • Deprecated for soon-to-be removed features.
  • Removed for now removed features.
  • Fixed for any bug fixes.
  • Security in case of vulnerabilities.

If the required subsection does not exist yet under Unreleased, create it!

Contributor Covenant Code of Conduct

Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

Our Standards

Examples of behavior that contributes to creating a positive environment include:

  • Using welcoming and inclusive language
  • Being respectful of differing viewpoints and experiences
  • Gracefully accepting constructive criticism
  • Focusing on what is best for the community
  • Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

  • The use of sexualized language or imagery and unwelcome sexual attention or advances
  • Trolling, insulting/derogatory comments, and personal or political attacks
  • Public or private harassment
  • Publishing others' private information, such as a physical or electronic address, without explicit permission
  • Other conduct which could reasonably be considered inappropriate in a professional setting

Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at bsikar@tuta.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4

Reporting Issues

Make sure to use this template for reporting issues.

---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

## Bug description

<!-- A clear and concise description of what the bug is. -->

- Would you like to work on a fix? [y/n]

## To Reproduce

Steps to reproduce the behavior:

1. ...
2. ...
3. ...
4. ...

<!-- Make sure you are able to reproduce the bug in the main branch, too. -->

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Screenshots

<!-- If applicable, add screenshots to help explain your problem. -->

## Environment

<!-- Please fill the following information. -->

- OS: [e.g. Ubuntu 20.04]
- pos-system version: [e.g. 0.1.0]

## Additional context

<!-- Add any other context about the problem here. -->

Feature request

Make sure to use this template for reporting issues.

---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

## Motivations

<!--
If your feature request is related to a problem, please describe it.
-->

- Would you like to implement this feature? [y/n]

## Solution

<!-- Describe the solution you'd like. -->

## Alternatives

<!-- Describe any alternative solutions or features you've considered. -->

## Additional context

<!-- Add any other context or screenshots about the feature request here. -->

Pull Requests

Try to do one pull request per change.

Backend changes

Make sure to run this script from the /backend/scripts directory before submitting a pull request.

#!/bin/bash

# Script to run presubmit checks. Devs can run this script locally before sending out PRs for review to ensure
# CI is passing for their PR.

set -e

FMT_COMMAND="cargo fmt"
echo "Running $FMT_COMMAND..."
EXIT_CODE=0
$FMT_COMMAND -- --check || EXIT_CODE=$?
if [[ $EXIT_CODE -ne 0 ]]; then
    echo 'Run `'$FMT_COMMAND'` to fix.'
    exit $EXIT_CODE
fi
echo "$FMT_COMMAND succeeded..."

echo "Running clippy..."
cargo clippy --tests -- -D warnings
echo "clippy succeeded..."

echo "Running cargo test..."
python test-backend.py
echo "Tests succeeded..."

echo "Congrats! All presubmits checks passed."

Frontend changes

Make sure to run this script from the /frontend/scripts directory before submitting a pull request.

#!/bin/bash

# Script to run presubmit checks. Devs can run this script locally before sending out PRs for review to ensure
# CI is passing for their PR.

set -e

FMT_COMMAND="npm run fmt"
echo "Running $FMT_COMMAND..."
EXIT_CODE=0
$FMT_COMMAND:check || EXIT_CODE=$?
if [[ $EXIT_CODE -ne 0 ]]; then
    echo 'Run `'$FMT_COMMAND'` to fix.'
    exit $EXIT_CODE
fi
echo "$FMT_COMMAND succeeded..."

LINT_COMMAND="npm run lint"
echo "Running $LINT_COMMAND..."
EXIT_CODE=0
$LINT_COMMAND || EXIT_CODE=$?
if [[ $EXIT_CODE -ne 0 ]]; then
    echo 'Run `'$LINT_COMMAND':fix` to fix.'
    exit $EXIT_CODE
fi
echo "$LINT_COMMAND succeeded..."

echo "Congrats! All presubmits checks passed."

Updating the changelog

Update the changes you have made in CHANGELOG file under the Unreleased section.

Add the changes of your pull request to one of the following subsections, depending on the types of changes defined by Keep a changelog:

  • Added for new features.
  • Changed for changes in existing functionality.
  • Deprecated for soon-to-be removed features.
  • Removed for now removed features.
  • Fixed for any bug fixes.
  • Security in case of vulnerabilities.

If the required subsection does not exist yet under Unreleased, create it!

License

MIT License

Copyright (c) 2022 Brighton Sikarskie

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.