蜂巢/发票

0.2.3 2018-12-12 13:44 UTC

This package is auto-updated.

Last update: 2024-09-13 02:08:22 UTC


README

为HoneyComb CMS提供的发票包 https://github.com/honey-comb/invoices

描述

HoneyComb CMS发票功能

注意

这是HoneyComb CMS包的一部分发票包。

需求

  • php: ^7.1
  • laravel: ^5.6
  • composer

安装

首先通过Composer安装此包。

	{
	    "require": {
	        "honey-comb/invoices": "0.1.*"
	    }
	}

或者

    composer require honey-comb/invoices

用法

如果您使用honey-comb/payments包,您可以使用我们生成的支付创建事件监听器示例来生成发票。

  • 运行php artisan vendor:publish --tag=hc-invoice

  • 在EventServiceProvider中注册事件

protected $listen = [
    \HoneyComb\Payments\Events\HCPaymentCreated::class => [
        \App\Listeners\HCPaymentCreatedListener::class
    ],
];

有两个DTO:HCInvoiceDTOHCInvoiceItemDTO

创建发票

$invoiceItemDto = (new HCInvoiceItemDTO())
        ->setLabel('Product')
        ->setQuantity(1)
        ->setVat(2)
        ->setAmount(10)
        ->setUnitPrice(10)
        ->setVatTotal(2)
        ->setAmountTotal(12);

$invoiceDto = (new HCInvoiceDTO())
    ->setAmount(10)
    ->setAmountTotal(12)
    ->setVat(2)
    ->setInvoiceDate('2016-04-13')
    ->setItems([
        $invoiceItemDto->toArray(),
    ]);

return $this->invoiceService->createAdvanceInvoice($invoiceDto->toArray());