refactoring on Articles, minor fixes
This commit is contained in:
@@ -2,66 +2,41 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Invoice;
|
||||
use Carbon\Carbon;
|
||||
use LaravelDaily\Invoices\Invoice;
|
||||
use LaravelDaily\Invoices\Classes\Party;
|
||||
use LaravelDaily\Invoices\Classes\InvoiceItem;
|
||||
|
||||
class InvoicePDF
|
||||
{
|
||||
public static function getByUUID($uuid)
|
||||
{
|
||||
return self::get(Invoices::getIdByUUID($uuid));
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
$invoice = Invoices::getFull($id);
|
||||
|
||||
$client = new Party([
|
||||
'name' => 'Roosevelt Lloyd',
|
||||
'phone' => '(520) 318-9486',
|
||||
'custom_fields' => [
|
||||
'note' => 'IDDQD',
|
||||
'business id' => '365#GG',
|
||||
],
|
||||
]);
|
||||
|
||||
$customer = new Party([
|
||||
'name' => 'Ashley Medina',
|
||||
'address' => 'The Green Street 12',
|
||||
'code' => '#22663214',
|
||||
'name' => $invoice->customer->name,
|
||||
'address' => self::makeAddress($invoice->address),
|
||||
'custom_fields' => [
|
||||
'order number' => '> 654321 <',
|
||||
'order number' => $invoice->order->ref,
|
||||
],
|
||||
]);
|
||||
|
||||
$items = self::makeItems($order->details);
|
||||
$items = self::makeItems($invoice->order->detail);
|
||||
|
||||
$notes = [
|
||||
'your multiline',
|
||||
'additional notes',
|
||||
'in regards of delivery or something else',
|
||||
];
|
||||
$notes = implode("<br>", $notes);
|
||||
|
||||
$invoice = Invoice::make('receipt')
|
||||
->series('BIG')
|
||||
// ability to include translated invoice status
|
||||
// in case it was paid
|
||||
->status(__('invoices::invoice.paid'))
|
||||
->sequence(667)
|
||||
->serialNumberFormat('{SEQUENCE}/{SERIES}')
|
||||
->seller($client)
|
||||
$invoice = Invoice::make(__('invoices::invoice.invoice') . ' ' .$invoice->ref)
|
||||
->status(Invoices::getStatus($invoice->status))
|
||||
->buyer($customer)
|
||||
->date(now()->subWeeks(3))
|
||||
->dateFormat('m/d/Y')
|
||||
->shipping($invoice->shipping)
|
||||
->date(Carbon::parse($invoice->date_invoice))
|
||||
->payUntilDays(14)
|
||||
->currencySymbol('$')
|
||||
->currencyCode('USD')
|
||||
->currencyFormat('{SYMBOL}{VALUE}')
|
||||
->currencyThousandsSeparator('.')
|
||||
->currencyDecimalPoint(',')
|
||||
->filename($client->name . ' ' . $customer->name)
|
||||
->filename('invoice-' . $invoice->ref . '-' . $invoice->uuid)
|
||||
->addItems($items)
|
||||
->notes($notes)
|
||||
->logo(public_path('vendor/invoices/sample-logo.png'))
|
||||
// You can additionally save generated invoice to configured disk
|
||||
->notes($invoice->comment ?? '')
|
||||
->logo(public_path('img/logo.png'))
|
||||
->save('public');
|
||||
|
||||
$link = $invoice->url();
|
||||
@@ -71,12 +46,20 @@ class InvoicePDF
|
||||
return $invoice->stream();
|
||||
}
|
||||
|
||||
public static function makeAddress($address)
|
||||
{
|
||||
return $address->address . '<br>' . $address->zipcode . ' ' . $address->city;
|
||||
}
|
||||
|
||||
public static function makeItems($details)
|
||||
{
|
||||
$items = [];
|
||||
|
||||
foreach ($details as $detail) {
|
||||
$items[] = InvoiceItem::make($detail->name)->pricePerUnit($detail->price)->quantity($detail->quantity);
|
||||
$items[] = InvoiceItem::make($detail->name)
|
||||
->pricePerUnit($detail->price)
|
||||
->taxByPercent($detail->vat)
|
||||
->quantity($detail->quantity);
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
||||
Reference in New Issue
Block a user