Skip to main content
# Shopping List - Do More, Pay Less

`shopping_list` is a simple tool to calculate the cost breakdown and total of a shopping list containing items in multiple categories.

It allows to create **different variation of prices**, to compare the influence in the total cost.
See the corresponding section [Pro Tip - Price combinations](#pro-tip---price-combinations)

## `shopping_list` in action
The project was originally created to estimate the total cost of devices in a Home-Automation project and **see the influence of different purchase decisions**.

#### Given:
* A list of prices
* A shopping list of items per category (per room in the example)

#### It generates an output breaking down the costs.


```shell
> shoppinglist shopping_list.yaml prices.yaml

Total cost breakdown

---
Living Room: 77.5 €
Kitchen: 45 €
Extra: 15 €
---

Total: 137.5 €

```

#### With `shopping_list.yaml`
```yaml
Living-room:
- InWallSwitch
- InWallSwitch
- PaddleSwitch
- MotionSensor

Kitchen:
- BulbBasic
- BulbAmbiance

Extra:
- Shipping
```

#### And `prices.yaml`
```yaml
InWallSwitch: 26
PaddleSwitch: 15

MotionSensor: 10.5

BulbBasic: 15
BulbAmbiance: 30

Shipping: 15
```


#### Demo versions of these files can be find under `demo/`
```shell
shoppinglist demo/shopping_list.yaml demo/prices.yaml
```

## Usage
### Installation
```bash
pip install shoppinglist
```

### Usage
```
Usage: shoppinglist [OPTIONS] SHOPPING_LIST_FILE PRICES_FILE
[PRICE_OVERRIDES_FILES]...

Options:
--with-count Display the count for each item
--help Show this message and exit.
```
#### Arguments
##### `SHOPPING_LIST_FILE`
* The shopping list
* `shopping_list.yaml` in the previous examples

##### `PRICES_FILE`
* The base prices
* `prices.yaml` in the previous examples

##### `[PRICE_OVERRIDES_FILES]`
* Zero or multiple _price overrides files_
* A _price override_ has the same format as the `PRICES_FILE` file
* `PRICE_OVERRIDES_FILES` define prices overridings the base prices present in `PRICES_FILE`
* Kinda like _mixins_ for the price list
* In case of _multiple overrides_, only the _last one_ is taken into account

#### Format for the files
##### `prices.yaml` and `price_overrides_*.yaml`
* 1 item per line, with its price
* See example

##### `shopping_list.yaml`
* 1 block per category
* Each block contains a list on items
* Item prices must have been defined in `prices.yaml`
* Duplicates allowed, they will be counted twice
* See example

## Pro Tip - Price combinations
Create different combination of **prices** to see quickly see the influence of your purchase decisions.

#### To do so, you have 2 options:
* Define **multiple base prices**
* Define **a base price** and **override individual items**

### Using multiple base prices
##### For instance `amazon.yaml`
```yaml
InWallSwitch: 56 <- More expensive InWallSwitch
PaddleSwitch: 7 <- Cheaper PaddleSwitch

MotionSensor: 10.5

BulbBasic: 15
BulbAmbiance: 30

Shipping: 0 <- Free shipping
```

##### Or `upgrade_basic_to_ambiance.yaml`
```yaml
InWallSwitch: 26
PaddleSwitch: 15

MotionSensor: 10.5

BulbBasic: 30 <- Bump the price of 'basic' bulb to match
BulbAmbiance: 30 the one of the 'ambiance' variation
and see how it affects the Total!
Shipping: 15
```

##### Results
```shell
> shoppinglist demo/shopping_list.yaml demo/prices.yaml
...
Total: 137.5 €

> shoppinglist demo/shopping_list.yaml demo/amazon.yaml
...
Total: 174.5 €

> shoppinglist demo/shopping_list.yaml demo/upgrade_basic_to_ambiance.yaml
...
Total: 152.5 €
```


### Using prices overrides
##### With base `prices.yaml`
```yaml
InWallSwitch: 26
PaddleSwitch: 15

MotionSensor: 10.5

BulbBasic: 15
BulbAmbiance: 30

Shipping: 15
```

##### First override `free_shipping.yaml`
```yaml
Shipping: 0 <- Free shipping
```

##### Second override `tradfri_bulb_instead_of_hue.yaml`
```yaml
BulbBasic: 10 <- Cheaper Bulbs
BulbAmbiance: 20 <- Cheaper Bulbs
```

##### Results
```shell
> shoppinglist demo/shopping_list.yaml demo/prices.yaml
...
Total: 137.5 €

> shoppinglist demo/shopping_list.yaml demo/prices.yaml demo/free_shipping.yaml
...
Total: 122.5 €

> shoppinglist demo/shopping_list.yaml demo/prices.yaml demo/free_shipping.yaml demo/tradfri_bulb_instead_of_hue.yaml
...
Total: 107.5 €
```

## Development
### Prerequisites: Pipenv
This project needs `pipenv` in order to work.

If you haven't set it up already... please do yourself a favor and read about it. That thing made my life just slightly better... but to the point where I actually notice an increase in my mood while working with python projects.
Kudos to them :)

More info on: [Pipenv: Python Development Workflow for Humans](https://github.com/pypa/pipenv)

**Interested in having that setup automatically for you?**
Then check out my ansible role that does just that ;)
**==>** [FlorianKempenich.python-virtualenv](https://github.com/FlorianKempenich/ansible-role-python-virtualenv)

### Installation
```bash
git clone git@github.com:FlorianKempenich/Shopping-List.git
cd Shopping-List
pipenv install --dev
pipenv shell
```

### Tests
```bash
pytest
# Or
./start_tdd.sh
```





## Author Information
Follow me on Twitter: [@ThisIsFlorianK](https://twitter.com/ThisIsFlorianK)
Find out more about my work: [Florian Kempenich - Personal Website](https://floriankempenich.com)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shoppinglist-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shoppinglist-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file shoppinglist-1.0.0.tar.gz.

File metadata

  • Download URL: shoppinglist-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for shoppinglist-1.0.0.tar.gz
Algorithm Hash digest
SHA256 82304b7f6d9054975b0877ecf874d4d47d7f1b7dafc006a1ed600008ddd68838
MD5 3de66a30b44dc0733eef94dbba2de6dc
BLAKE2b-256 422aadf65cd1f7000e1c6cfd98341704d196a095de05e574d8e60e6b64c4e279

See more details on using hashes here.

File details

Details for the file shoppinglist-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for shoppinglist-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff95994cf35263d7f69ed11d171f021500b42ba2f14fdc25394c0b1de29a15e3
MD5 b9b6d4d663222febf76f2f7e6f9b4fea
BLAKE2b-256 00d9d78318c1617db57143fd200fe00cfc78917133743524250b7c04f94ba70f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page