LaravelDaily/laravel-invoices

How to get the invoice number without saving the file to disk or outputting to browser

MattWiseParking opened this issue · 2 comments

Hi

I tried to retreive the invoice number without any output but it doesnt look like that you can obtain any properties of the invoice unless you choose an output option. i think it would be nice to have this availability to do so. One method I had to write my own function such as:

if(!function_exists('invoiceNumber')) {
    function invoiceNumber($number)
    {
        $array = config('invoices.serial_number');
        $format = $array['series'].$array['delimiter'].'%1$0'.$array['sequence_padding'].'d';
        return sprintf($format,$number,'');
    }
}

the above would print something like: INV-00001 etc... based off the invoice id.

This is similar to how the invoice would auto populate the invoice number

@MattWiseParking sorry, we don't have number auto-population in this package. We don't have any logic, in fact, this package is JUST to present the invoices as PDFs with your specified data.

mc0de commented

@MattWiseParking if you checked the default template, you would see that invoice number is retrieved like this $invoice->getSerialNumber().

so the method you implemented is completely redundant.

    public function getSerialNumber()
    {
        return strtr($this->serial_number_format, [
            '{SERIES}'    => $this->series,
            '{DELIMITER}' => $this->delimiter,
            '{SEQUENCE}'  => $this->sequence,
        ]);
    }