Skip to main content

Infoicer is a simple invoice items handler.

Project description

infoicer

Infoicer is a simple invoice items handler. It can group items by type and tax rate which helps in building the invoice for a customer.

Features

  • All price handling is utilized with Decimal type to avoid float rounding problems
  • Easy to group invoice items by type and tax rate
  • Implemented object serialization
  • No external dependencies

Installation

From PyPi:

$ pip install infoicer

or clone repository:

$ git clone git@github.com:edkirin/infoicer.git

Basic usage

from infoicer import Invoice, InvoiceItem
from decimal import Decimal

invoice = Invoice()

invoice.add(InvoiceItem(
    name="Ham",
    item_type='food',
    price=Decimal(10),
    qty=1,
    tax_rate=Decimal(5),
))

invoice.add(InvoiceItem(
    name="Spam",
    item_type='food',
    price=Decimal(15),
    qty=3,
    tax_rate=Decimal(5),
))

print(invoice.serialize(json_output=True))

output:

{
   "items":[
      {
         "item_type":"food",
         "qty":1,
         "name":"Ham",
         "price":10.0,
         "net_price":9.52,
         "tax_rate":5.0,
         "sum":10.0,
         "net_sum":9.52,
         "tax_sum":0.48
      },
      {
         "item_type":"food",
         "qty":3,
         "name":"Spam",
         "price":15.0,
         "net_price":14.29,
         "tax_rate":5.0,
         "sum":45.0,
         "net_sum":42.87,
         "tax_sum":2.13
      }
   ],
   "total":{
      "price":55.0,
      "net":52.39,
      "tax":2.61
   }
}

Full demo

Check included demo.py for some more uses and features.

Licence

The code is available under MIT Licence.

Project details


Download files

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

Source Distribution

infoicer-0.0.1.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

infoicer-0.0.1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page