honey-comb/invoices

0.2.3 2018-12-12 13:44 UTC

This package is auto-updated.

Last update: 2024-11-13 02:33:25 UTC


README

Invoices package for HoneyComb CMS https://github.com/honey-comb/invoices

Description

HoneyComb CMS invoices functions

Attention

This is part invoices package for HoneyComb CMS package.

Requirement

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

Installation

Begin by installing this package through Composer.

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

or

    composer require honey-comb/invoices

Usage

If you use honey-comb/payments package you can use our generated payment created event listener example to generate invoice.

  • Run php artisan vendor:publish --tag=hc-invoice

  • Register event in EventServiceProvider

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

The are two DTO's HCInvoiceDTO and HCInvoiceItemDTO

Create invoice:

$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());