Download the PHP package ranskills/billing-boss without Composer

On this page you can find all versions of the php package ranskills/billing-boss. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package billing-boss

Billing Boss

Build Status codecov Scrutinizer Code Quality License: MIT

Billing Boss is a free, open-source library that implements billing using a domain-specific language (DSL) to express a billing structure to be applied.

The library has implementations in the following languages:

Features

Why Use This Library

Installation

The recommended installation is via composer by running the command:

$ composer require ranskills/billing-boss

OR

download the most recent archive from the releases page of the project.

Testing

Run tests with:

$ composer test

Make sure the test dependencies are installed by running composer install, if required

Usage

Notations

Explanation of common notations used throughout the library.

Notation Symbol Notation Name Note
| (pipe) Segment For segmented structures, i.e. those applying to different ranges, the interpreter determines which segment the billable amount falls in before the bill is applied
- (hyphen) Range All range specifications are inclusive. E.g., 1 - 1000 means the value should be at least 1 and at most 1,000.
The mathematical equivalent is .
The last range's upper boundary should be *
* (asterisk) Unspecified Amount In a range specification, min - max, this can only be used in the upper boundary, max

Billing Types/Interpreters Supported

  1. Flat Rate
  2. Percentage
  3. Capped
  4. Progressive
  5. Stepped

Flat Rate


Flat rate, aka fixed rate, billing

The same amount is applied for all billable amounts within the same range.

Structure: number, range (| number, range)*

Example 1: 0.50, 1 - *

Reads: A flat rate of 0.50 is charged for all amounts 1 or above

Amount Bill
1 1.00
5,000 1.00

*Example 2: `1, 1 - 499.99 | 10, 500 - `**

A charge of 1 applies for amounts below 500 to 1, otherwise a charge of 10 applies to amounts from 500 upwards

Amount Bill
1 1.00
5,000 10.00

Percentage


The bill is a percentage of the billable amount

Structure: number%, range (| number%, range)*

Example 1: 1%, 1 - *

Reads: For amounts greater than or equal to 1, charge 1%

Amount Bill
1 0.01
5,000 50.00

Example 2: 1%, 1 - 500 | 3%, 501 - 2000 | 5%, 2001 - *

Reads:

  • Charge 1% for amounts between 1 and 500
  • Charge 3% for amounts between 501 to 2,000
  • Charge 5% for amounts
Amount Bill
1 0.01
5,000 250.00

Capped


The bill is expressed as a percentage of the billable amount but it is constrained or capped, unlike the percentage billing, within a specified boundary that the bill can not fall outside of.

Structure: number% [min, max], range_start - range_end

Example 1: 1% [5, 100], 1 - *

Reads: For amounts of at least 1:
if the charge is below the minimum, take the minimum (5)
if the charge is above the maximum, take the maximum (100)
otherwise the charge applies
Amount Bill
10 5.00
100 5.00
5,000 50.00
10,000 100.00
100,000 100.00

Example 2: 1% [5, 100], 1 - 20000 | 2% [500, 1500], 20001 - *

Amount Bill
5,000 50.00
10,000 100.00
20,000 100.00
20,001 500.00
50,000 1,000.00
200,000 1,500.00
1,000,000 1,500.00

For an amount between 1 to 1,000, charge 1% which is capped between 5 to 100. All amounts at least 1,001 should be charged at 2% capped between 10 and 200.

Progressive


Progressively/iteratively applies the billing structure until the remaining amount to bill is exhausted

Structure: percent%, amount ( > percent%, amount)+

Example: 0%, 261 > 5%, 70 > 10%, 100 > 17.5%, 2810 > 25%, *

The example represents the structure for Ghana's income tax.

Stepped


Every step the amount graduates to attracts the fixed charge. The amount billed is the accumulation of these charges

Structure: charge, amount+

Example: 1, 100+

Extending The Library

Custom interpreters can be added to extend the capability of the library, provided your unique scenario cannot be handled by the library through the defined interpreters.

Steps

  1. Either implement the BillInterpreter interface or extend the AbstractBillInterpreter abstract class that do provide some convenient methods

  2. Define a unique structure for the bill, making use of the notations discussed in notations above, if need be

Sample Implementation Guide

Lets implement a bill for a hypothetical scenario where a bill is the squared value of the amount to be billed.

bill = amount * amount

The important decision to be made is the notation to use to represent this type of bill. The notation should be indicative of the nature of bill, so lets use ^2

Note: Each notation MUST be unique to ensure that it can be interpreted by only a SINGLE interpreter

  1. Implement the BillInterpreter interface or extend the AbstractBillInterpreter in the file SquareBillInterpreter.php

  2. Register your new custom interpreter by adding it to BillingBoss

That is it, you are done.

  1. Testing

Report


Report issues, feature requests, etc. here


All versions of billing-boss with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ranskills/billing-boss contains the following files

Loading the files please wait ....