• Stars
    star
    268
  • Rank 153,144 (Top 4 %)
  • Language
    Python
  • License
    Other
  • Created about 12 years ago
  • Updated about 2 years 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,191
star
2

satchless

E-commerce for Python
Python
783
star
3

ariadne-codegen

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

django-prices

Django fields for the prices module
Python
158
star
5

google-i18n-address

Google's i18n address data packaged for Python.
Python
137
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
64
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
53
star
10

saleor-app-framework-python

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

ariadne-graphql-modules

Ariadne package for implementing Ariadne GraphQL schemas using modular approach.
Python
36
star
12

chromedebug

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

django-prices-openexchangerates

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

ariadne-website

The code that powers Ariadne website
JavaScript
24
star
15

serverless-saleor-app-example

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

gql-federation-gateway

Simple gateway for Apollo Federation with JWT
JavaScript
18
star
17

django-offsite-storage

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

django-prices-vatlayer

Vatlayer API support for django-prices
Python
15
star
19

bestest

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

django-voice

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

ariadne-graphql-proxy

Ariadne toolkit for building GraphQL proxies.
Python
14
star
22

legacy-views

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

graphql-workshop

A GraphQL workshop for DjangoCon EU 2019
Python
13
star
24

django-bootstrap-mockups

A template mocking tool for Django
Python
11
star
25

django-ariadne-deprecated

Django bindings for the Ariadne GraphQL library.
11
star
26

overv.io-beta

Private beta feedback
10
star
27

trapecssoid

CSS-based trapezoid blocks
CSS
10
star
28

saleor-demo

Saleor's demo setup
HTML
10
star
29

lynara

Python ASGI applications in an AWS Lambda runtime
Python
9
star
30

ariadne-lambda

Python
5
star
31

ariadne-graphql-chat-example

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

subgraph-template-ariadne-fastapi

Python
4
star
33

saleor-sdk-python

Python
4
star
34

smyth

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

opentracing-asgi

ASGI middleware reporting to the OpenTracing API
Python
3
star
36

saleor-product-mockups

Free Saleor product templates
3
star
37

codeclimate-isort

An isort plugin for codeclimate
Python
3
star
38

python-invoicible

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

saleor-graphql-deprecations

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

graphql-wroclaw-website

GraphQL Wrocław Meetup
JavaScript
1
star
41

overv.io-splash

Overv.io public webpage
HTML
1
star
42

js-invoicible

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

aws_secrets_cache

Cache AWS Secrets
Python
1
star
44

saleor-contentful-app

TypeScript
1
star
45

saleor-algolia-demo

Python
1
star