PHPackages                             byrokrat/billing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. byrokrat/billing

AbandonedArchivedLibrary[Payment Processing](/categories/payments)

byrokrat/billing
================

Data types for creating and formatting invoices

2.1.0(6y ago)6242UnlicensePHPPHP &gt;=7.1

Since May 3Pushed 6y ago3 watchersCompare

[ Source](https://github.com/byrokrat/billing)[ Packagist](https://packagist.org/packages/byrokrat/billing)[ Docs](https://github.com/byrokrat/billing)[ RSS](/packages/byrokrat-billing/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (5)Used By (0)

> ABANDONED! This package is discontinued and will not be updated.

Billing
=======

[](#billing)

[![Packagist Version](https://camo.githubusercontent.com/ce88c233653583a72d97a1b39e8532e864289dd6df58c194ce67469d47d80614/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6279726f6b7261742f62696c6c696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/byrokrat/billing)[![Build Status](https://camo.githubusercontent.com/5b7153b6d620ee6c6688eb8f1f32fea8908e2f504ab4b17975121d2e77aaba9d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6279726f6b7261742f62696c6c696e672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/byrokrat/billing)[![Quality Score](https://camo.githubusercontent.com/1025789784915e058679da43237a499813c55bd7765db1cb35c8a23faa68a724/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6279726f6b7261742f62696c6c696e672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/byrokrat/billing)[![Scrutinizer Coverage](https://camo.githubusercontent.com/6a9f39311cfcefdd34986989b82bcacc64c0ca1e923d75eaa26a243c3cd7748b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6279726f6b7261742f62696c6c696e672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/byrokrat/billing/?branch=master)

Data types for creating and formatting invoices.

Installation
------------

[](#installation)

```
composer require byrokrat/billing
```

Usage
-----

[](#usage)

[`Invoices`](/src/Invoice.php) are created using the [`InvoiceBuilder`](/src/InvoiceBuilder.php):

```
namespace byrokrat\billing;

use byrokrat\amount\Currency\EUR;

// 1 unit of a 100 EUR item with 25% VAT
$item = new Item('Description', new EUR('100'), 1, .25);

$invoice = (new InvoiceBuilder)
    ->setSerial('1')
    ->setSeller(new Agent('Company X'))
    ->setBuyer(new Agent('Mrs Y'))
    ->generateOcr()
    ->addItem($item)
    ->setAttribute('message', 'custom invoice message')
    ->buildInvoice();

// prints 125 (100 EUR plus 25% VAT)
echo $invoice->getInvoiceTotal();
```

### Implementing your own billables and agents

[](#implementing-your-own-billables-and-agents)

Billing uses an interface centered design:

- [`Billable`](/src/Billable.php) represents a purchasable item.
- [`AgentInterface`](/src/AgentInterface.php) represents a selling or buying party.

[`Item`](/src/Item.php) and [`Agent`](/src/Agent.php) offers simple implementations of these interfaces, but you may of course provide your own implementations and extend the interfaces as needed.

API
---

[](#api)

### [`InvoiceBuilder`](/src/InvoiceBuilder.php)

[](#invoicebuilder)

Method signaturedescriptionsetSerial(string $serial): selfSet invoice serial numbersetSeller([`AgentInterface`](/src/AgentInterface.php) $seller): selfSet sellersetBuyer([`AgentInterface`](/src/AgentInterface.php) $buyer): selfSet buyersetOcr(string $ocr): selfSet invoice reference numbergenerateOcr(): selfGenerate invoice reference number from serial numberaddItem([`Billable`](/src/Billable.php) $billable): selfAdd billable to invoicesetBillDate([`DateTimeInterface`](http://php.net/manual/en/class.datetimeinterface.php) $date): selfSet date of invoice creationsetExpiresAfter(int $nrOfDays): selfSet number of days before invoice expiressetDeduction([`Amount`](https://github.com/byrokrat/amount) $deduction): selfSet deduction (amount prepaid)setAttribute(string $key, $value): selfSet attribute defined by keybuildInvoice(): [`Invoice`](/src/Invoice.php)Build invoice### [`Invoice`](/src/Invoice.php)

[](#invoice)

Method signaturedescriptiongetSerial(): stringGet invoice serial numbergetSeller(): [`AgentInterface`](/src/AgentInterface.php)Get registered sellergetBuyer(): [`AgentInterface`](/src/AgentInterface.php)Get registered buyergetOcr(): stringGet invoice reference numbergetItems(): [`ItemBasket`](/src/ItemBasket.php)Get item basketgetInvoiceTotal(): [`Amount`](https://github.com/byrokrat/amount)Get charged amount (VAT included)getBillDate(): [`DateTimeInterface`](http://php.net/manual/en/class.datetimeinterface.php)Get date of invoice creationgetExpiresAfter(): intGet number of days before invoice expiresgetExpirationDate(): [`DateTimeInterface`](http://php.net/manual/en/class.datetimeinterface.php)Get date when invoice expiresgetDeduction(): [`Amount`](https://github.com/byrokrat/amount)Get deducted prepaid amoundgetAttribute(string $key, $default = ''): mixedGet attribute or default if attribute is not setgetAttributes(): arrayGet all loaded attributes### [`ItemBasket`](/src/ItemBasket.php)

[](#itembasket)

Method signaturedescriptiongetIterator(): [`Traversable`](http://php.net/manual/en/class.traversable.php)Iterate over [`ItemEnvelope`](/src/ItemEnvelope.php) objectsgetNrOfItems(): intGet number of items in basketgetNrOfUnits(): intGet number of units in basket (each item may contain multiple units)getTotalUnitCost(): [`Amount`](https://github.com/byrokrat/amount)Get total cost of all items (VAT excluded)getTotalVatCost(): [`Amount`](https://github.com/byrokrat/amount)Get total VAT cost for all itemsgetTotalCost(): [`Amount`](https://github.com/byrokrat/amount)Get total cost of all items (VAT included)getVatRates(): arrayGet unit and vat totals for non-zero vat rates

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~440 days

Total

4

Last Release

2346d ago

Major Versions

1.0.1 → 2.0.02017-12-07

PHP version history (3 changes)1.0.0PHP ^7.0

2.0.0PHP ^7.1

2.1.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0af6567c7f4f5518a422192675445464fdcf18acbc9459b3205da9fd446f8d0?d=identicon)[hanneskod](/maintainers/hanneskod)

---

Top Contributors

[![hanneskod](https://avatars.githubusercontent.com/u/1369274?v=4)](https://github.com/hanneskod "hanneskod (49 commits)")

---

Tags

billinginvoiceocrbillinginvoiceOCR

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/byrokrat-billing/health.svg)

```
[![Health](https://phpackages.com/badges/byrokrat-billing/health.svg)](https://phpackages.com/packages/byrokrat-billing)
```

###  Alternatives

[horstoeko/zugferd

A library for creating and reading european electronic invoices

4174.3M18](/packages/horstoeko-zugferd)[atgp/factur-x

PHP library to manage your Factur-X / ZUGFeRD 2.0 PDF invoices files

138825.5k3](/packages/atgp-factur-x)[konekt/pdf-invoice

Library to generate PDF invoices

212200.7k](/packages/konekt-pdf-invoice)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
