byrokrat/billing
最新稳定版本:2.1.0
Composer 安装命令:
composer require byrokrat/billing
包简介
Data types for creating and formatting invoices
README 文档
README
ABANDONED! This package is discontinued and will not be updated.
Billing
Data types for creating and formatting invoices.
Installation
composer require byrokrat/billing
Usage
Invoices are created using the InvoiceBuilder:
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:
Billablerepresents a purchasable item.AgentInterfacerepresents a selling or buying party.
Item and Agent offers simple implementations
of these interfaces, but you may of course provide your own implementations and
extend the interfaces as needed.
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 |
byrokrat/billing 适用场景与选型建议
byrokrat/billing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 6, 最近一次更新时间为 2015 年 02 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「invoice」 「OCR」 「billing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 byrokrat/billing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 byrokrat/billing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 byrokrat/billing 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy invoice generation using Laravel Eloquent
Laravel Cashier provides an expressive, fluent interface to Braintree's subscription billing services.
Metamel Addresses is a polymorphic Laravel package, for address book management. You can add addresses to any eloquent model with ease.
Laravel MPdf : Easily generate PDF files with arabic support
Szamlazz.hu integration for Laravel
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unlicense
- 更新时间: 2015-02-11