• Stars
    star
    267
  • Rank 148,636 (Top 4 %)
  • Language
    Python
  • License
    Other
  • Created over 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python price handling for humans.

Prices: Python price handling for humans

Build Status codecov.io


Money:

from prices import Money
a = Money(10, 'USD')
a += Money(20, 'USD')
a.value
# Decimal('30')
a = a.quantize()
a.value
# Decimal('30.00')
a = Money('5.00', 'JPY')
a.quantize()
a.value
# Decimal('5')

Taxed money:

from prices import Money, TaxedMoney
p = TaxedMoney(net=Money(20, 'EUR'), gross=Money(30, 'EUR'))
p.net
# Money('20', 'EUR')
p.gross
# Money('30', 'EUR')
p.tax
# Money('10', 'EUR')
p = p.quantize()
p.net
# Money('20.00', 'EUR')

Taxed ranges:

from prices import Money, TaxedMoney, TaxedMoneyRange
price1 = TaxedMoney(Money(1, 'USD'), Money(1, 'USD'))
price2 = TaxedMoney(Money(10, 'USD'), Money(10, 'USD'))
pr = TaxedMoneyRange(price1, price2)
pr.min_price
# TaxedMoney(net=Money('1', 'USD'), gross=Money('1', 'USD'))
pr.max_price
# TaxedMoney(net=Money('10', 'USD'), gross=Money('10', 'USD'))
price3 = TaxedMoney(net=Money(5, 'USD'), gross=Money(5, 'USD'))
price3 in pr
# True
pr = pr.quantize()
pr.min_price.net
# Money('1.00', 'USD')

Taxes:

from decimal import Decimal
from prices import Money, TaxedMoney, TaxedMoneyRange, flat_tax
p = TaxedMoney(Money('1.99', 'GBP'), Money('1.99', 'GBP'))
p = flat_tax(p, Decimal('0.23'))
p = p.quantize()
p.gross
# Money('2.45', 'GBP')

While protecting you from all sorts of mistakes:

from prices import Money
Money(10, 'USD') < Money(15, 'GBP')
# ValueError: Cannot compare amounts in 'USD' and 'GBP'
from prices import Money, TaxedMoney
price1 = TaxedMoney(Money(5, 'BTC'), Money(5, 'BTC'))
price2 = TaxedMoney(Money(7, 'INR'), Money(7, 'INR'))
price1 + price2
# ValueError: Cannot add amount in 'BTC' to 'INR'

More Repositories

1

ariadne

Python library for implementing GraphQL servers using schema-first approach.
Python
2,134
star
2

satchless

E-commerce for Python
Python
784
star
3

ariadne-codegen

Generate fully typed Python client for any GraphQL API from schema, queries and mutations
Python
203
star
4

django-prices

Django fields for the prices module
Python
157
star
5

google-i18n-address

Google's i18n address data packaged for Python.
Python
130
star
6

google-measurement-protocol

A Python implementation of Google Analytics Measurement Protocol
Python
103
star
7

ariadne-django

ariadne_django makes integrating ariadne and django together easier.
Python
65
star
8

django-images

A database-driven thumbnailing solution for Django
Python
63
star
9

django-messages

A Django application handling private messages between users.
Python
52
star
10

saleor-app-framework-python

Python Saleor App/Extension boilerplate. Batteries included.
Python
49
star
11

chromedebug

A Chrome remote debugging protocol server for Python
Python
36
star
12

ariadne-graphql-modules

Ariadne package for implementing Ariadne GraphQL schemas using modular approach.
Python
34
star
13

django-prices-openexchangerates

openexchangerates.org support for django-prices
Python
33
star
14

ariadne-website

The code that powers Ariadne website
JavaScript
22
star
15

gql-federation-gateway

Simple gateway for Apollo Federation with JWT
JavaScript
18
star
16

django-offsite-storage

Cloud static and media file storage suitable for app containers
Python
18
star
17

serverless-saleor-app-example

Example implementation of Saleor app using AWS Lambda
Python
17
star
18

django-prices-vatlayer

Vatlayer API support for django-prices
Python
15
star
19

django-voice

A simple user feedback application for your Django project
Python
14
star
20

bestest

Some of the bestestâ„¢ and cleverestestâ„¢ code out there
Python
14
star
21

legacy-views

A legacy fork of Saleor that contains the old storefront and dashboard code
Python
14
star
22

graphql-workshop

A GraphQL workshop for DjangoCon EU 2019
Python
13
star
23

django-bootstrap-mockups

A template mocking tool for Django
Python
11
star
24

overv.io-beta

Private beta feedback
11
star
25

django-ariadne-deprecated

Django bindings for the Ariadne GraphQL library.
11
star
26

ariadne-graphql-proxy

Ariadne toolkit for building GraphQL proxies.
Python
11
star
27

trapecssoid

CSS-based trapezoid blocks
CSS
10
star
28

saleor-demo

Saleor's demo setup
HTML
10
star
29

ariadne-graphql-chat-example

Simple Chat application using Ariadne and GraphQL Subscriptions
JavaScript
4
star
30

subgraph-template-ariadne-fastapi

Python
4
star
31

codeclimate-isort

An isort plugin for codeclimate
Python
3
star
32

opentracing-asgi

ASGI middleware reporting to the OpenTracing API
Python
3
star
33

saleor-product-mockups

Free Saleor product templates
3
star
34

saleor-sdk-python

Python
3
star
35

python-invoicible

Invoicible/CentrumFaktur library that provides pure Python interface to CentrumFaktur API
Python
2
star
36

overv.io-splash

Overv.io public webpage
HTML
1
star
37

graphql-wroclaw-website

GraphQL Wrocław Meetup
JavaScript
1
star
38

saleor-graphql-deprecations

Deprecations tracker for Saleor's GraphQL API
Python
1
star
39

js-invoicible

Invoicible/CentrumFaktur library that provides JavaScript interface to CentrumFaktur API
JavaScript
1
star
40

aws_secrets_cache

Cache AWS Secrets
Python
1
star
41

saleor-algolia-demo

Python
1
star
42

smyth

A versatile tool that enhances your AWS Lambda development experience.
Python
1
star