You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

refund_calculation

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refund_calculation

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

0.1
pipPyPI
Maintainers
1

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:

.. code:: python

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'),
)

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts