Cross-platform cannabis math library for potency, dosing, pricing, taxes, rounding, and retail calculations.
Project description
CannabisMath
CannabisMath is a cross-platform cannabis calculation library for potency, dosing, weight conversions, pricing, packaging, taxes, rounding, and retail value calculations.
Built for cannabis apps, dashboards, dispensary tooling, POS workflows, inventory systems, calculators, and data projects.
Reliable weed math. Tested, reusable, and consistent across languages.
Status
Current version: v0.1.0
- C# library published to NuGet
- TypeScript port complete (in
/js) - Full parity between C# and JS logic
- 130+ combined tests across both implementations
Quick Start (C#)
using CannabisMath.Core.Composites;
var pricePerMg = CannabisValueCalculator.PricePerMgFromWeightAndPotency(
price: 35m,
weightGrams: 3.5m,
potencyPercent: 20m
);
// 0.05
Quick Start (TypeScript)
import { CannabisValueCalculator } from "./js/src/composites/cannabisValueCalculator";
const result = CannabisValueCalculator.pricePerMgFromWeightAndPotency(
35,
3.5,
20
);
// 0.05
Why CannabisMath?
Cannabis calculations are often inconsistent across apps, dashboards, and POS systems. Differences in rounding, weight assumptions, potency formulas, and tax handling can lead to mismatched results and operational issues.
CannabisMath provides a single, deterministic calculation layer to ensure consistent results across systems and languages.
Cross-Language Consistency
This project maintains identical calculation logic across:
- C# (.NET / NuGet)
- TypeScript (Node / Web)
Same inputs → same outputs → everywhere.
Project Structure
CannabisMath/
src/ (C# core library)
tests/ (C# tests)
js/
src/ (TypeScript implementation)
tests/ (Vitest)
Installation
C#
dotnet add package CannabisMath.Core
TypeScript (coming soon to NPM)
npm install cannabismath
Test Coverage
- C#: 68 tests
- TypeScript: 64 tests
Total: 130+ passing tests
Roadmap
- NPM package publish
- Python port
- Shared cross-language test fixtures
- Jurisdiction-aware tax configs
- POS rounding strategies
- Advanced pricing & margin tools
Disclaimer
CannabisMath is a calculation library, not legal or tax advice.
License
MIT
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 cannabismath-0.1.1.tar.gz.
File metadata
- Download URL: cannabismath-0.1.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b6ff5f01b2df25be29514bdd65a2d9005cb6adc7b5f03295376b16a13ee802
|
|
| MD5 |
282a4a5906e4ecee592c37c5bb2a110b
|
|
| BLAKE2b-256 |
b7685c738501e820cc4de4e8bb9726e749c64431fa727038e78a8d1a5456e1ea
|
File details
Details for the file cannabismath-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cannabismath-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e57645877944ad42dc5383c8c74f5f44e53cc504f100c13e5f4b317c596edaf
|
|
| MD5 |
06316de03b5d7383edf5b71312f2c64c
|
|
| BLAKE2b-256 |
7e50301bc5ecf9e2459cf9089326a516168c6d439514279d66cf3495ee54492e
|