2017 © Pedro PelĂĄez
 

library billing

Data types for creating and formatting invoices

image

byrokrat/billing

Data types for creating and formatting invoices

  • Thursday, December 7, 2017
  • by hanneskod
  • Repository
  • 3 Watchers
  • 5 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

ABANDONED! This package is discontinued and will not be updated., (*1)

Billing

Packagist Version Build Status Quality Score Scrutinizer Coverage, (*2)

Data types for creating and formatting invoices., (*3)

Installation

composer require byrokrat/billing

Usage

Invoices are created using the InvoiceBuilder:, (*4)

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

Billing uses an interface centered design:, (*5)

Item and Agent offers simple implementations of these interfaces, but you may of course provide your own implementations and extend the interfaces as needed., (*6)

API

InvoiceBuilder

Method signature description
setSerial(string $serial): self Set invoice serial number
setSeller(AgentInterface $seller): self Set seller
setBuyer(AgentInterface $buyer): self Set buyer
setOcr(string $ocr): self Set invoice reference number
generateOcr(): self Generate invoice reference number from serial number
addItem(Billable $billable): self Add billable to invoice
setBillDate(DateTimeInterface $date): self Set date of invoice creation
setExpiresAfter(int $nrOfDays): self Set number of days before invoice expires
setDeduction(Amount $deduction): self Set deduction (amount prepaid)
setAttribute(string $key, $value): self Set attribute defined by key
buildInvoice(): Invoice Build invoice

Invoice

Method signature description
getSerial(): string Get invoice serial number
getSeller(): AgentInterface Get registered seller
getBuyer(): AgentInterface Get registered buyer
getOcr(): string Get invoice reference number
getItems(): ItemBasket Get item basket
getInvoiceTotal(): Amount Get charged amount (VAT included)
getBillDate(): DateTimeInterface Get date of invoice creation
getExpiresAfter(): int Get number of days before invoice expires
getExpirationDate(): DateTimeInterface Get date when invoice expires
getDeduction(): Amount Get deducted prepaid amound
getAttribute(string $key, $default = ''): mixed Get attribute or default if attribute is not set
getAttributes(): array Get all loaded attributes

ItemBasket

Method signature description
getIterator(): Traversable Iterate over ItemEnvelope objects
getNrOfItems(): int Get number of items in basket
getNrOfUnits(): int Get number of units in basket (each item may contain multiple units)
getTotalUnitCost(): Amount Get total cost of all items (VAT excluded)
getTotalVatCost(): Amount Get total VAT cost for all items
getTotalCost(): Amount Get total cost of all items (VAT included)
getVatRates(): array Get unit and vat totals for non-zero vat rates

The Versions

07/12 2017

dev-master

9999999-dev https://github.com/byrokrat/billing

Data types for creating and formatting invoices

  Sources   Download

WTFPL Unlicense

The Requires

 

by Hannes ForsgÄrd

billing invoice ocr

07/12 2017

2.0.0

2.0.0.0 https://github.com/byrokrat/billing

Data types for creating and formatting invoices

  Sources   Download

Unlicense

The Requires

 

by Hannes ForsgÄrd

billing invoice ocr

18/08 2016

1.0.1

1.0.1.0 https://github.com/byrokrat/billing

Data types for creating and formatting invoices

  Sources   Download

WTFPL

The Requires

 

by Hannes ForsgÄrd

billing invoice ocr

03/05 2016

1.0.0

1.0.0.0 https://github.com/byrokrat/billing

Data types for creating and formatting invoices

  Sources   Download

WTFPL

The Requires

 

by Hannes ForsgÄrd

billing invoice ocr