Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Turns a chronological sequence of balance-adjustment events into a timeline of periods during which particular balances were held.

Project Description

For example, this sequence of events …

  • A: $10
  • B: $10
  • C: ($18)
  • D: ($2)

… is turned into this timeline:

A             B             C             D
|             |             |             |
|_____________|_____________|             |
|                           |             |
|           $10             |             |
|___________________________|             |
              |             |             |
              |     $8      |             |
              |_____________|_____________|
              |                           |
              |            $2             |
              |___________________________|

This lets you determine, for each balance reduction event, the events from which the balance was added. In this example, we can see that:

  • The $18 reduction in event C came from $10 of event A and $8 of B.
  • The $2 reduction in event D came entirely from event B.

Code for this example:

from refund_calculation import *

history_from_event_sequence([
    Event(time='A', delta='10'),
    Event(time='B', delta='10'),
    Event(time='C', delta='-18'),
    Event(time='D', delta='-2'),
])

# Result:
History(
    closed=(
        Closed(amount=Decimal('10'), start='A', end='C'),
        Closed(amount=Decimal('8'),  start='B', end='C'),
        Closed(amount=Decimal('2'),  start='B', end='D'),
    ),
    open=(),
    debt=Decimal('0'),
)
Release History

Release History

This version
History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
refund_calculation-0.1.tar.gz (3.7 kB) Copy SHA256 Checksum SHA256 Source Oct 10, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting