gstpy is a simple and flexible Python module that allows you to calculate GST (Goods and Services Tax) in both exclusive and inclusive modes. It provides the option to return results as list values (ideal for developers) or display them in a formatted tabular output (perfect for CLI and reports).
Project description
gstpy Module
The gstpy module provides an easy and flexible way to calculate GST (Goods and Services Tax) for various item formats such as lists, dictionaries, and integers. It supports both exclusive and inclusive tax calculations and presents the output in multiple formats: list, dictionary, or a well-formatted table using the tabulate package.
Installation
You can install this module using pip:
pip install gstpy
GST Class
from gstpy import GST
Constructor
GST(items=0, rate=18, mode="exclusive")
Initializes a GST object.
Parameters:
- items: (int, list, dict) — Item(s) to calculate GST on. Defaults to 0.
- rate: (int, float) — GST rate. Defaults to 18.
- mode: (str) — Either "exclusive" or "inclusive" to specify GST type. Defaults to "exclusive".
Behavior:
- Automatically processes the provided items if valid.
- Supports multiple formats:
- List of integers or tuples/lists
- Dictionary with item names as keys and prices or [price, quantity] as values
- Single integer price
Methods
1. exclusive
Calculates GST using the exclusive method (GST is added to the price).
Parameters:
- items: Items to calculate GST for (int, list, dict)
- rate: GST rate (int, float)
- out: Output format - "list", "dict", or "table"
Returns:
- List or dictionary of results (if out is "list" or "dict")
- Table printed on screen (if out is "table")
Format Supported:
- Single price (int)
- List of prices (list)
- List of [item_name, price]
- List of [item_name, price, qty]
- Dict of {item_name: price} or {item_name: [price, qty]}
2. inclusive
Calculates GST using the inclusive method (price already includes GST).
Parameters:
- items: Items to calculate GST for (int, list, dict)
- rate: GST rate (int, float)
- out: Output format - "list", "dict", or "table"
Returns:
- List or dictionary of results (if out is "list" or "dict")
- Table printed on screen (if out is "table")
Format Supported:
- Single price (int)
- List of prices (list)
- List of [item_name, price]
- List of [item_name, price, qty]
- Dict of {item_name: price} or {item_name: [price, qty]}
Special Functions
ingst(total_price, gst_rate)→ returns only the GST amountexgst(base_price, gst_rate)→ returns only the GST amount
Documentation
You can download the full documentation for the gstpy module by clicking the button above.
Author
Developed by: Ankush
For any issues or bug reports, please open an issue on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gstpy-0.1.3.tar.gz.
File metadata
- Download URL: gstpy-0.1.3.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c35a99f05559d3142c5b72a405b741f3fac5bb2f5743bffd6c06ff0e126da6f3
|
|
| MD5 |
aa3bc70c5a5ae8a473fa49a2db341f09
|
|
| BLAKE2b-256 |
3803a365f8e08d95d68fd715241646ed745129f71789d55fbbb747fbd535f4a0
|
File details
Details for the file gstpy-0.1.3-py3-none-any.whl.
File metadata
- Download URL: gstpy-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46edbca53ef1942ab325811022121302315abd9e829991e1799078e545ef0031
|
|
| MD5 |
7bf3b84e8eb83440128a162a101f3ab0
|
|
| BLAKE2b-256 |
d14d6db360c8f2df60fbf636e10907b9b1f73746cd62a60dbac57a7780c535de
|