diff --git a/app/Http/Controllers/Customers/Invoices.php b/app/Http/Controllers/Customers/Invoices.php index aea447a7f..42f4dd6ee 100644 --- a/app/Http/Controllers/Customers/Invoices.php +++ b/app/Http/Controllers/Customers/Invoices.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Events\InvoicePrinting; use App\Models\Banking\Account; use App\Models\Income\Customer; +use App\Models\Income\Revenue; use App\Models\Income\Invoice; use App\Models\Income\InvoiceStatus; use App\Models\Setting\Category; @@ -16,6 +17,7 @@ use App\Traits\DateTime; use App\Traits\Uploads; use App\Utilities\Modules; use File; +use Illuminate\Http\Request; use Image; use Storage; @@ -178,4 +180,37 @@ class Invoices extends Controller return $logo; } + + public function link(Invoice $invoice, Request $request) + { + $paid = 0; + + foreach ($invoice->payments as $item) { + $amount = $item->amount; + + if ($invoice->currency_code != $item->currency_code) { + $item->default_currency_code = $invoice->currency_code; + + $amount = $item->getDynamicConvertedAmount(); + } + + $paid += $amount; + } + + $invoice->paid = $paid; + + $accounts = Account::enabled()->pluck('name', 'id'); + + $currencies = Currency::enabled()->pluck('name', 'code')->toArray(); + + $account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first(); + + $customers = Customer::enabled()->pluck('name', 'id'); + + $categories = Category::enabled()->type('income')->pluck('name', 'id'); + + $payment_methods = Modules::getPaymentMethods(); + + return view('customers.invoices.link', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods')); + } } diff --git a/composer.json b/composer.json index 785330558..bc092a99f 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "akaunting/language": "1.0.*", "akaunting/money": "1.0.*", "akaunting/setting": "1.0.*", + "akaunting/signed-url": "1.0.*", "akaunting/version": "1.0.*", "almasaeed2010/adminlte": "2.3.*", "barryvdh/laravel-debugbar": "2.3.*", diff --git a/config/app.php b/config/app.php index 6bedfcac7..b820e9bd0 100644 --- a/config/app.php +++ b/config/app.php @@ -187,6 +187,7 @@ return [ Akaunting\Language\Provider::class, Akaunting\Money\Provider::class, Akaunting\Setting\Provider::class, + Akaunting\SignedUrl\Provider::class, Akaunting\Version\Provider::class, Barryvdh\DomPDF\ServiceProvider::class, Bkwld\Cloner\ServiceProvider::class, @@ -273,6 +274,7 @@ return [ 'Module' => Nwidart\Modules\Facades\Module::class, 'PDF' => Barryvdh\DomPDF\Facade::class, 'Setting' => Akaunting\Setting\Facade::class, + 'SignedUrl' => Akaunting\SignedUrl\Facade::class, 'Version' => Akaunting\Version\Facade::class, ], diff --git a/resources/views/customers/invoices/link.blade.php b/resources/views/customers/invoices/link.blade.php new file mode 100644 index 000000000..e0624212e --- /dev/null +++ b/resources/views/customers/invoices/link.blade.php @@ -0,0 +1,219 @@ +@extends('layouts.link') + +@section('title', trans_choice('general.invoices', 1) . ': ' . $invoice->invoice_number) + +@section('content') +
{{ trans('invoices.invoice_number') }}: | +{{ $invoice->invoice_number }} | +
---|---|
{{ trans('invoices.order_number') }}: | +{{ $invoice->order_number }} | +
{{ trans('invoices.invoice_date') }}: | +{{ Date::parse($invoice->invoiced_at)->format($date_format) }} | +
{{ trans('invoices.payment_due') }}: | +{{ Date::parse($invoice->due_at)->format($date_format) }} | +
{{ trans_choice('general.items', 1) }} | +{{ trans('invoices.quantity') }} | +{{ trans('invoices.price') }} | +{{ trans('invoices.total') }} | +
---|---|---|---|
+ {{ $item->name }}
+ @if ($item->sku)
+ {{ trans('items.sku') }}: {{ $item->sku }} + @endif + |
+ {{ $item->quantity }} | +@money($item->price, $invoice->currency_code, true) | +@money($item->total, $invoice->currency_code, true) | +
{{ trans_choice('general.notes', 2) }}
+ ++ {{ $invoice->notes }} +
+ @endif +{{ trans($total['name']) }}: | +@money($total->amount, $invoice->currency_code, true) | +
---|---|
{{ trans('invoices.paid') }}: | +- @money($invoice->paid, $invoice->currency_code, true) | +
{{ trans($total['name']) }}: | +@money($total->amount - $invoice->paid, $invoice->currency_code, true) | +