Merge branch 'master' into datagrid-lang-issue
This commit is contained in:
commit
53c681b931
|
|
@ -13,11 +13,14 @@ class OrderInvoicesDataGrid extends DataGrid
|
|||
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
$dbPrefix = DB::getTablePrefix();
|
||||
|
||||
$queryBuilder = DB::table('invoices')
|
||||
->leftJoin('orders as ors', 'invoices.order_id', '=', 'ors.id')
|
||||
->select('invoices.id as id', 'ors.increment_id as order_id', 'invoices.state as state', 'invoices.base_grand_total as base_grand_total', 'invoices.created_at as created_at');
|
||||
->select('invoices.id as id', 'ors.increment_id as order_id', 'invoices.state as state', 'invoices.base_grand_total as base_grand_total', 'invoices.created_at as created_at')
|
||||
->selectRaw("CASE WHEN {$dbPrefix}invoices.increment_id IS NOT NULL THEN {$dbPrefix}invoices.increment_id ELSE {$dbPrefix}invoices.id END AS increment_id");
|
||||
|
||||
$this->addFilter('id', 'invoices.id');
|
||||
$this->addFilter('increment_id', 'invoices.increment_id');
|
||||
$this->addFilter('order_id', 'ors.increment_id');
|
||||
$this->addFilter('base_grand_total', 'invoices.base_grand_total');
|
||||
$this->addFilter('created_at', 'invoices.created_at');
|
||||
|
|
@ -28,9 +31,9 @@ class OrderInvoicesDataGrid extends DataGrid
|
|||
public function addColumns()
|
||||
{
|
||||
$this->addColumn([
|
||||
'index' => 'id',
|
||||
'label' => trans('admin::app.datagrid.invoice-id'),
|
||||
'type' => 'number',
|
||||
'index' => 'increment_id',
|
||||
'label' => trans('admin::app.datagrid.id'),
|
||||
'type' => 'string',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
|
|
|
|||
|
|
@ -70,11 +70,11 @@ class ConfigurationForm extends FormRequest
|
|||
]);
|
||||
}
|
||||
|
||||
if (request()->has('sales.orderSettings.invoice_slip_design.logo')
|
||||
&& ! request()->input('sales.orderSettings.invoice_slip_design.logo.delete')
|
||||
if (request()->has('sales.invoice_setttings.invoice_slip_design.logo')
|
||||
&& ! request()->input('sales.invoice_setttings.invoice_slip_design.logo.delete')
|
||||
) {
|
||||
$this->rules = array_merge($this->rules, [
|
||||
'sales.orderSettings.invoice_slip_design.logo' => 'required|mimes:bmp,jpeg,jpg,png,webp|max:5000',
|
||||
'sales.invoice_setttings.invoice_slip_design.logo' => 'required|mimes:bmp,jpeg,jpg,png,webp|max:5000',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ class ConfigurationForm extends FormRequest
|
|||
return [
|
||||
'general.design.admin_logo.logo_image' => 'Logo Image',
|
||||
'general.design.admin_logo.favicon' => 'Favicon Image',
|
||||
'sales.orderSettings.invoice_slip_design.logo' => 'Invoice Logo'
|
||||
'sales.invoice_setttings.invoice_slip_design.logo' => 'Invoice Logo'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1442,6 +1442,12 @@ return [
|
|||
'order-number-length' => 'طول رقم الطلب',
|
||||
'order-number-suffix' => 'لاحقة رقم الطلب',
|
||||
'order-number-generator-class' => 'مولد رقم الطلب',
|
||||
'invoice-settings' => 'إعدادات الفاتورة',
|
||||
'invoice-number' => 'إعدادات رقم الفاتورة',
|
||||
'invoice-number-prefix' => 'بادئة رقم الفاتورة',
|
||||
'invoice-number-length' => 'طول رقم الفاتورة',
|
||||
'invoice-number-suffix' => 'لاحقة رقم الفاتورة',
|
||||
'invoice-number-generator-class' => 'مولد رقم الفاتورة',
|
||||
'minimum-order' => 'الحد الأدنى من إعدادات الطلب',
|
||||
'minimum-order-amount' => 'الحد الأدنى للطلب',
|
||||
'default' => 'إفتراضي',
|
||||
|
|
|
|||
|
|
@ -1450,6 +1450,12 @@ return [
|
|||
'order-number-length' => 'Auftragsnummer Länge',
|
||||
'order-number-suffix' => 'Auftragsnummer Suffix',
|
||||
'order-number-generator-class' => 'Bestell nummern generator',
|
||||
'invoice-settings' => 'Rechnungseinstellungen',
|
||||
'invoice-number' => 'Rechnungsnummerneinstellungen',
|
||||
'invoice-number-prefix' => 'Rechnungsnummer-Präfix',
|
||||
'invoice-number-length' => 'Länge der Rechnungsnummer',
|
||||
'invoice-number-suffix' => 'Rechnungsnummer-Suffix',
|
||||
'invoice-number-generator-class' => 'Rechnungsnummerngenerator',
|
||||
'minimum-order' => 'Einstellungen für die Mindestbestellmenge',
|
||||
'minimum-order-amount' => 'Mindestbestellmenge',
|
||||
'default' => 'Standard',
|
||||
|
|
@ -1483,7 +1489,7 @@ return [
|
|||
'generate-invoice' => 'Automatically generate the invoice after placing an order',
|
||||
'set-invoice-status' => 'Set the invoice status after creating the invoice to',
|
||||
'set-order-status' => 'Set the order status after creating the invoice to',
|
||||
'generate-invoice-applicable' => 'Applicable if automatic generate invoice is enabled'
|
||||
'generate-invoice-applicable' => 'Applicable if automatic generate invoice is enabled',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1458,6 +1458,13 @@ return [
|
|||
'order-number-prefix' => 'Order Number Prefix',
|
||||
'order-number-length' => 'Order Number Length',
|
||||
'order-number-suffix' => 'Order Number Suffix',
|
||||
'order-number-generator-class' => 'Order Number Generator',
|
||||
'invoice-settings' => 'Invoice Settings',
|
||||
'invoice-number' => 'Invoice Number Settings',
|
||||
'invoice-number-prefix' => 'Invoice Number Prefix',
|
||||
'invoice-number-length' => 'Invoice Number Length',
|
||||
'invoice-number-suffix' => 'Invoice Number Suffix',
|
||||
'invoice-number-generator-class' => 'Invoice Number Generator',
|
||||
'minimum-order' => 'Minimum Order Settings',
|
||||
'minimum-order-amount' => 'Minimum Order Amount',
|
||||
'default' => 'Default',
|
||||
|
|
@ -1509,7 +1516,6 @@ return [
|
|||
'accepted-currencies' => 'Accepted currencies',
|
||||
'accepted-currencies-info' => 'Add currency code comma seperated e.g. USD,INR,...',
|
||||
'buy-now-button-display' => 'Allow customers to directly buy products',
|
||||
'order-number-generator-class' => 'Order Number Generator',
|
||||
'show-search-input-field' => 'Show Search Input Field',
|
||||
'allow-no-of-new-product-homepage' => 'Allowed No of New Product in Homepage',
|
||||
'allow-no-of-featured-product-homepage' => 'Allowed No of Featured Product in Homepage',
|
||||
|
|
|
|||
|
|
@ -1454,6 +1454,12 @@ return [
|
|||
'order-number-length' => 'Largo para Pedido #',
|
||||
'order-number-suffix' => 'Sufijo para Pedido #',
|
||||
'order-number-generator-class' => 'Generado de Números de Pedido',
|
||||
'invoice-settings' => 'Configuración de facturas',
|
||||
'invoice-number' => 'Configuración del número de factura',
|
||||
'invoice-number-prefix' => 'Prefijo de número de factura',
|
||||
'invoice-number-length' => 'Longitud del número de factura',
|
||||
'invoice-number-suffix' => 'Sufijo de número de factura',
|
||||
'invoice-number-generator-class' => 'Generador de números de facturas',
|
||||
'minimum-order' => 'Configuración de Pedido Mínimo',
|
||||
'minimum-order-amount' => 'Cantidad Mínima de Pedido',
|
||||
'default' => 'Predeterminado',
|
||||
|
|
|
|||
|
|
@ -1434,6 +1434,12 @@ return [
|
|||
'order-number-length' => 'طول شماره سفارش',
|
||||
'order-number-suffix' => 'تعداد کافی شماره سفارش',
|
||||
'order-number-generator-class' => 'تولید کننده شماره سفارش',
|
||||
'invoice-settings' => 'تنظیمات فاکتور',
|
||||
'invoice-number' => 'تنظیمات شماره فاکتور',
|
||||
'invoice-number-prefix' => 'پیش شماره شماره فاکتور',
|
||||
'invoice-number-length' => 'طول شماره فاکتور',
|
||||
'invoice-number-suffix' => 'پسوند شماره فاکتور',
|
||||
'invoice-number-generator-class' => 'تولید کننده شماره فاکتور',
|
||||
'minimum-order' => 'حداقل تنظیمات سفارش',
|
||||
'minimum-order-amount' => 'حداقل مقدار سفارش',
|
||||
'default' => 'پیش فرض',
|
||||
|
|
|
|||
|
|
@ -1442,6 +1442,12 @@ return [
|
|||
'order-number-length' => 'Lunghezza Numero Ordine',
|
||||
'order-number-suffix' => 'Suffisso Numero Ordine',
|
||||
'order-number-generator-class' => 'Generatore di numeri dordine',
|
||||
'invoice-settings' => 'Impostazioni fattura',
|
||||
'invoice-number' => 'Impostazioni numero fattura',
|
||||
'invoice-number-prefix' => 'Prefisso numero fattura',
|
||||
'invoice-number-length' => 'Lunghezza numero fattura',
|
||||
'invoice-number-suffix' => 'Suffisso numero fattura',
|
||||
'invoice-number-generator-class' => 'Generatore di numeri di fattura',
|
||||
'minimum-order' => 'Impostazioni dell\'ordine minimo',
|
||||
'minimum-order-amount' => 'Importo minimo dell\'ordine',
|
||||
'default' => 'Default',
|
||||
|
|
|
|||
|
|
@ -1436,6 +1436,12 @@ return [
|
|||
'order-number-length' => 'Bestelnummer Lengte',
|
||||
'order-number-suffix' => 'Achtervoegsel bestelnummer',
|
||||
'order-number-generator-class' => 'Ordernummer Generator',
|
||||
'invoice-settings' => 'Factuurinstellingen',
|
||||
'invoice-number' => 'Instellingen factuurnummer',
|
||||
'invoice-number-prefix' => 'Voorvoegsel factuurnummer',
|
||||
'invoice-number-length' => 'Lengte factuurnummer',
|
||||
'invoice-number-suffix' => 'Achtervoegsel factuurnummer',
|
||||
'invoice-number-generator-class' => 'Factuurnummergenerator',
|
||||
'minimum-order' => 'Minimale bestelling instellen',
|
||||
'minimum-order-amount' => 'Minimaal bedrag van de bestelling',
|
||||
'default' => 'Standaard',
|
||||
|
|
|
|||
|
|
@ -1439,6 +1439,12 @@ return [
|
|||
'order-number-length' => 'Długość numeru zamówienia',
|
||||
'order-number-suffix' => 'Sufiks numeru zamówienia”',
|
||||
'order-number-generator-class' => 'Generator numeru zamówienia',
|
||||
'invoice-settings' => 'Ustawienia faktury',
|
||||
'invoice-number' => 'Ustawienia numeru faktury',
|
||||
'invoice-number-prefix' => 'Prefiks numeru faktury',
|
||||
'invoice-number-length' => 'Długość numeru faktury',
|
||||
'invoice-number-suffix' => 'Sufiks numeru faktury',
|
||||
'invoice-number-generator-class' => 'Generator numerów faktur',
|
||||
'minimum-order' => 'Minimalne ustawienia zamówienia',
|
||||
'minimum-order-amount' => 'Minimalna kwota zamówienia',
|
||||
'default' => 'Domyślna',
|
||||
|
|
|
|||
|
|
@ -1440,6 +1440,12 @@ return [
|
|||
'order-number-length' => 'Tamanho do Número do Pedido',
|
||||
'order-number-suffix' => 'Sufixo do Número de Pedido',
|
||||
'order-number-generator-class' => 'Gerador de número de pedido',
|
||||
'invoice-settings' => 'Configurações de fatura',
|
||||
'invoice-number' => 'Configurações de número de fatura',
|
||||
'invoice-number-prefix' => 'Prefixo do número da fatura',
|
||||
'invoice-number-length' => 'Comprimento do número da fatura',
|
||||
'invoice-number-suffix' => 'Sufixo do número da fatura',
|
||||
'invoice-number-generator-class' => 'Gerador de número de fatura',
|
||||
'minimum-order' => 'Configurações de pedido mínimo ',
|
||||
'minimum-order-amount' => 'Quantidade Mínima do Pedido',
|
||||
'default' => 'Padrão',
|
||||
|
|
|
|||
|
|
@ -1426,6 +1426,12 @@ return [
|
|||
'order-number-length' => 'Numara Uzunluğu',
|
||||
'order-number-suffix' => 'Numara Son Eki',
|
||||
'order-number-generator-class' => 'Sipariş Numarası Üreticisi',
|
||||
'invoice-settings' => 'Fatura Ayarları',
|
||||
'invoice-number' => 'Fatura Numarası Ayarları',
|
||||
'invoice-number-prefix' => 'Fatura Numarası Ön Eki',
|
||||
'invoice-number-length' => 'Fatura Numarası Uzunluğu',
|
||||
'invoice-number-suffix' => 'Fatura Numarası Eki',
|
||||
'invoice-number-generator-class' => 'Fatura Numarası Oluşturucu',
|
||||
'minimum-order' => 'Minimum Sipariş Ayarları',
|
||||
'minimum-order-amount' => 'Minimum Sipariş Tutarı',
|
||||
'default' => 'Varsayılan',
|
||||
|
|
|
|||
|
|
@ -127,9 +127,9 @@
|
|||
<h1 class="text-center">{{ __('admin::app.sales.invoices.invoice') }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
@if (core()->getConfigData('sales.orderSettings.invoice_slip_design.logo'))
|
||||
@if (core()->getConfigData('sales.invoice_setttings.invoice_slip_design.logo'))
|
||||
<div class="image">
|
||||
<img class="logo" src="{{ Storage::url(core()->getConfigData('sales.orderSettings.invoice_slip_design.logo')) }}"/>
|
||||
<img class="logo" src="{{ Storage::url(core()->getConfigData('sales.invoice_setttings.invoice_slip_design.logo')) }}"/>
|
||||
</div>
|
||||
@endif
|
||||
<div class="merchant-details">
|
||||
|
|
@ -157,7 +157,7 @@
|
|||
<div class="invoice-summary">
|
||||
<div class="row">
|
||||
<span class="label">{{ __('admin::app.sales.invoices.invoice-id') }} -</span>
|
||||
<span class="value">#{{ $invoice->id }}</span>
|
||||
<span class="value">#{{ $invoice->increment_id ?? $invoice->id }}</span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@extends('admin::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('admin::app.sales.invoices.view-title', ['invoice_id' => $invoice->id]) }}
|
||||
{{ __('admin::app.sales.invoices.view-title', ['invoice_id' => $invoice->increment_id ?? $invoice->id]) }}
|
||||
@stop
|
||||
|
||||
@section('content-wrapper')
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sales.invoices.index') }}'"></i>
|
||||
|
||||
{{ __('admin::app.sales.invoices.view-title', ['invoice_id' => $invoice->id]) }}
|
||||
{{ __('admin::app.sales.invoices.view-title', ['invoice_id' => $invoice->increment_id ?? $invoice->id]) }}
|
||||
|
||||
{!! view_render_event('sales.invoice.title.after', ['order' => $order]) !!}
|
||||
</h1>
|
||||
|
|
|
|||
|
|
@ -490,7 +490,7 @@
|
|||
<tbody>
|
||||
@foreach ($order->invoices as $invoice)
|
||||
<tr>
|
||||
<td>#{{ $invoice->id }}</td>
|
||||
<td>#{{ $invoice->increment_id ?? $invoice->id }}</td>
|
||||
<td>{{ $invoice->created_at }}</td>
|
||||
<td>#{{ $invoice->order->increment_id }}</td>
|
||||
<td>{{ $invoice->address->name }}</td>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
/**
|
||||
* Order Settings
|
||||
*/
|
||||
[
|
||||
'key' => 'sales.orderSettings',
|
||||
'name' => 'admin::app.admin.system.order-settings',
|
||||
|
|
@ -35,7 +38,7 @@ return [
|
|||
'locale_based' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'order_number_generator-class',
|
||||
'name' => 'order_number_generator_class',
|
||||
'title' => 'admin::app.admin.system.order-number-generator-class',
|
||||
'type' => 'text',
|
||||
'validation' => false,
|
||||
|
|
@ -57,8 +60,55 @@ return [
|
|||
'locale_based' => true,
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
/**
|
||||
* Invoice Settings
|
||||
*/
|
||||
[
|
||||
'key' => 'sales.invoice_setttings',
|
||||
'name' => 'admin::app.admin.system.invoice-settings',
|
||||
'sort' => 4,
|
||||
], [
|
||||
'key' => 'sales.orderSettings.invoice_slip_design',
|
||||
'key' => 'sales.invoice_setttings.invoice_number',
|
||||
'name' => 'admin::app.admin.system.invoice-number',
|
||||
'sort' => 0,
|
||||
'fields' => [
|
||||
[
|
||||
'name' => 'invoice_number_prefix',
|
||||
'title' => 'admin::app.admin.system.invoice-number-prefix',
|
||||
'type' => 'text',
|
||||
'validation' => false,
|
||||
'channel_based' => true,
|
||||
'locale_based' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'invoice_number_length',
|
||||
'title' => 'admin::app.admin.system.invoice-number-length',
|
||||
'type' => 'text',
|
||||
'validation' => 'numeric',
|
||||
'channel_based' => true,
|
||||
'locale_based' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'invoice_number_suffix',
|
||||
'title' => 'admin::app.admin.system.invoice-number-suffix',
|
||||
'type' => 'text',
|
||||
'validation' => false,
|
||||
'channel_based' => true,
|
||||
'locale_based' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'invoice_number_generator_class',
|
||||
'title' => 'admin::app.admin.system.invoice-number-generator-class',
|
||||
'type' => 'text',
|
||||
'validation' => false,
|
||||
'channel_based' => true,
|
||||
'locale_based' => true,
|
||||
],
|
||||
]
|
||||
], [
|
||||
'key' => 'sales.invoice_setttings.invoice_slip_design',
|
||||
'name' => 'admin::app.admin.system.invoice-slip-design',
|
||||
'sort' => 2,
|
||||
'fields' => [
|
||||
|
|
@ -70,5 +120,5 @@ return [
|
|||
'channel_based' => true,
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Sales\Contracts;
|
||||
|
||||
interface Sequencer
|
||||
{
|
||||
/**
|
||||
* Create and return the next sequence number for e.g. an order.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generate(): string;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Sales\Generators;
|
||||
|
||||
use Webkul\Sales\Models\Invoice;
|
||||
|
||||
class InvoiceSequencer extends Sequencer
|
||||
{
|
||||
/**
|
||||
* Create invoice sequencer instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setAllConfigs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all configs.
|
||||
*
|
||||
* @param string $configKey
|
||||
* @return void
|
||||
*/
|
||||
public function setAllConfigs()
|
||||
{
|
||||
$this->prefix = core()->getConfigData('sales.invoice_setttings.invoice_number.invoice_number_prefix');
|
||||
|
||||
$this->length = core()->getConfigData('sales.invoice_setttings.invoice_number.invoice_number_length');
|
||||
|
||||
$this->suffix = core()->getConfigData('sales.invoice_setttings.invoice_number.invoice_number_suffix');
|
||||
|
||||
$this->generatorClass = core()->getConfigData('sales.invoice_setttings.invoice_number.invoice_number_generator_class');
|
||||
|
||||
$this->lastId = $this->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastId()
|
||||
{
|
||||
$lastOrder = Invoice::query()->orderBy('id', 'desc')->limit(1)->first();
|
||||
|
||||
return $lastOrder ? $lastOrder->id : 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Sales\Generators;
|
||||
|
||||
use Webkul\Sales\Models\Order;
|
||||
|
||||
class OrderSequencer extends Sequencer
|
||||
{
|
||||
/**
|
||||
* Create order sequencer instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setAllConfigs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all configs.
|
||||
*
|
||||
* @param string $configKey
|
||||
* @return void
|
||||
*/
|
||||
public function setAllConfigs()
|
||||
{
|
||||
$this->prefix = core()->getConfigData('sales.orderSettings.order_number.order_number_prefix');
|
||||
|
||||
$this->length = core()->getConfigData('sales.orderSettings.order_number.order_number_length');
|
||||
|
||||
$this->suffix = core()->getConfigData('sales.orderSettings.order_number.order_number_suffix');
|
||||
|
||||
$this->generatorClass = core()->getConfigData('sales.orderSettings.order_number.order_number_generator_class');
|
||||
|
||||
$this->lastId = $this->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastId()
|
||||
{
|
||||
$lastOrder = Order::query()->orderBy('id', 'desc')->limit(1)->first();
|
||||
|
||||
return $lastOrder ? $lastOrder->id : 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Sales\Generators;
|
||||
|
||||
use Webkul\Sales\Contracts\Sequencer as SequencerContract;
|
||||
|
||||
class Sequencer implements SequencerContract
|
||||
{
|
||||
/**
|
||||
* Length.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $length;
|
||||
|
||||
/**
|
||||
* Prefix.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $prefix;
|
||||
|
||||
/**
|
||||
* Suffix.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $suffix;
|
||||
|
||||
/**
|
||||
* Generator class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $generatorClass;
|
||||
|
||||
/**
|
||||
* Last id.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $lastId = 0;
|
||||
|
||||
/**
|
||||
* Set length from the core config.
|
||||
*
|
||||
* @param string $configKey
|
||||
* @return void
|
||||
*/
|
||||
public function setLength($configKey)
|
||||
{
|
||||
$this->length = core()->getConfigData($configKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set prefix from the core config.
|
||||
*
|
||||
* @param string $configKey
|
||||
* @return void
|
||||
*/
|
||||
public function setPrefix($configKey)
|
||||
{
|
||||
$this->prefix = core()->getConfigData($configKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set suffix from the core config.
|
||||
*
|
||||
* @param string $configKey
|
||||
* @return void
|
||||
*/
|
||||
public function setSuffix($configKey)
|
||||
{
|
||||
$this->suffix = core()->getConfigData($configKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set generator class from the core config.
|
||||
*
|
||||
* @param string $configKey
|
||||
* @return void
|
||||
*/
|
||||
public function setGeneratorClass($configKey)
|
||||
{
|
||||
$this->generatorClass = core()->getConfigData($configKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve generator class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function resolveGeneratorClass()
|
||||
{
|
||||
if (
|
||||
$this->generatorClass !== ''
|
||||
&& class_exists($this->generatorClass)
|
||||
&& in_array(SequencerContract::class, class_implements($this->generatorClass), true)
|
||||
) {
|
||||
return app($this->generatorClass)->generate();
|
||||
}
|
||||
|
||||
return $this->generate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return the next sequence number for e.g. an order.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generate(): string
|
||||
{
|
||||
if ($this->length && ($this->prefix || $this->suffix)) {
|
||||
$number = ($this->prefix) . sprintf(
|
||||
"%0{$this->length}d",
|
||||
0
|
||||
) . ($this->lastId + 1) . ($this->suffix);
|
||||
} else {
|
||||
$number = $this->lastId + 1;
|
||||
}
|
||||
|
||||
return $number;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Event;
|
|||
use Illuminate\Support\Facades\DB;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Sales\Contracts\Invoice;
|
||||
use Webkul\Sales\Generators\InvoiceSequencer;
|
||||
|
||||
class InvoiceRepository extends Repository
|
||||
{
|
||||
|
|
@ -103,6 +104,7 @@ class InvoiceRepository extends Repository
|
|||
}
|
||||
|
||||
$invoice = $this->model->create([
|
||||
'increment_id' => $this->generateIncrementId(),
|
||||
'order_id' => $order->id,
|
||||
'total_qty' => $totalQty,
|
||||
'state' => $state,
|
||||
|
|
@ -221,6 +223,16 @@ class InvoiceRepository extends Repository
|
|||
return $invoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate increment id.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function generateIncrementId()
|
||||
{
|
||||
return app(InvoiceSequencer::class)->resolveGeneratorClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Webkul\Sales\Contracts\Invoice $invoice
|
||||
* @return \Webkul\Sales\Contracts\Invoice
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
namespace Webkul\Sales\Repositories;
|
||||
|
||||
use Webkul\Sales\Contracts\Order;
|
||||
use Illuminate\Container\Container as App;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Shop\Generators\Sequencer;
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Shop\Generators\OrderNumberIdSequencer;
|
||||
use Webkul\Sales\Contracts\Order;
|
||||
use Webkul\Sales\Generators\OrderSequencer;
|
||||
|
||||
class OrderRepository extends Repository
|
||||
{
|
||||
|
|
@ -213,19 +212,7 @@ class OrderRepository extends Repository
|
|||
*/
|
||||
public function generateIncrementId()
|
||||
{
|
||||
/**
|
||||
* @var $generatorClass Sequencer
|
||||
*/
|
||||
$generatorClass = core()->getConfigData('sales.orderSettings.order_number.order_number_generator-class') ?: false;
|
||||
|
||||
if ($generatorClass !== false
|
||||
&& class_exists($generatorClass)
|
||||
&& in_array(Sequencer::class, class_implements($generatorClass), true)
|
||||
) {
|
||||
return $generatorClass::generate();
|
||||
}
|
||||
|
||||
return OrderNumberIdSequencer::generate();
|
||||
return app(OrderSequencer::class)->resolveGeneratorClass();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Webkul\Shop\Generators;
|
||||
|
||||
|
||||
use Webkul\Sales\Models\Order;
|
||||
|
||||
class OrderNumberIdSequencer implements Sequencer
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function generate(): string
|
||||
{
|
||||
foreach ([
|
||||
'Prefix' => 'prefix',
|
||||
'Length' => 'length',
|
||||
'Suffix' => 'suffix',
|
||||
] as
|
||||
$varSuffix => $confKey) {
|
||||
$var = "invoiceNumber{$varSuffix}";
|
||||
$$var = core()->getConfigData('sales.orderSettings.order_number.order_number_' . $confKey) ?: false;
|
||||
}
|
||||
|
||||
$lastOrder = Order::query()->orderBy('id', 'desc')->limit(1)->first();
|
||||
$lastId = $lastOrder ? $lastOrder->id : 0;
|
||||
|
||||
if ($invoiceNumberLength && ($invoiceNumberPrefix || $invoiceNumberSuffix)) {
|
||||
$invoiceNumber = ($invoiceNumberPrefix) . sprintf("%0{$invoiceNumberLength}d",
|
||||
0) . ($lastId + 1) . ($invoiceNumberSuffix);
|
||||
} else {
|
||||
$invoiceNumber = $lastId + 1;
|
||||
}
|
||||
|
||||
return $invoiceNumber;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Webkul\Shop\Generators;
|
||||
|
||||
|
||||
interface Sequencer
|
||||
{
|
||||
/**
|
||||
* create and return the next sequence number for e.g. an order
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generate(): string;
|
||||
}
|
||||
|
|
@ -129,9 +129,9 @@
|
|||
<h1 class="text-center">{{ __('admin::app.sales.invoices.invoice') }}</h1>
|
||||
</div>
|
||||
</div>
|
||||
@if (core()->getConfigData('sales.orderSettings.invoice_slip_design.logo'))
|
||||
@if (core()->getConfigData('sales.invoice_setttings.invoice_slip_design.logo'))
|
||||
<div class="image">
|
||||
<img class="logo" src="{{ Storage::url(core()->getConfigData('sales.orderSettings.invoice_slip_design.logo')) }}" alt=""/>
|
||||
<img class="logo" src="{{ Storage::url(core()->getConfigData('sales.invoice_setttings.invoice_slip_design.logo')) }}" alt=""/>
|
||||
</div>
|
||||
@endif
|
||||
<div class="merchant-details">
|
||||
|
|
@ -160,7 +160,7 @@
|
|||
|
||||
<div class="row">
|
||||
<span class="label">{{ __('shop::app.customer.account.order.view.invoice-id') }} -</span>
|
||||
<span class="value">#{{ $invoice->id }}</span>
|
||||
<span class="value">#{{ $invoice->increment_id ?? $invoice->id }}</span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@
|
|||
|
||||
<div class="sale-section">
|
||||
<div class="secton-title">
|
||||
<span>{{ __('shop::app.customer.account.order.view.individual-invoice', ['invoice_id' => $invoice->id]) }}</span>
|
||||
<span>{{ __('shop::app.customer.account.order.view.individual-invoice', ['invoice_id' => $invoice->increment_id ?? $invoice->id]) }}</span>
|
||||
|
||||
<a href="{{ route('customer.orders.print', $invoice->id) }}" class="pull-right">
|
||||
{{ __('shop::app.customer.account.order.view.print') }}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<div style="padding: 30px;">
|
||||
<div style="font-size: 20px;color: #242424;line-height: 30px;margin-bottom: 34px;">
|
||||
<span style="font-weight: bold;">
|
||||
{{ __('shop::app.mail.invoice.heading', ['order_id' => $order->increment_id, 'invoice_id' => $invoice->id]) }}
|
||||
{{ __('shop::app.mail.invoice.heading', ['order_id' => $order->increment_id, 'invoice_id' => $invoice->increment_id ?? $invoice->id]) }}
|
||||
</span> <br>
|
||||
|
||||
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@
|
|||
|
||||
<div class="sale-section">
|
||||
<div class="section-title">
|
||||
<span>{{ __('shop::app.customer.account.order.view.individual-invoice', ['invoice_id' => $invoice->id]) }}</span>
|
||||
<span>{{ __('shop::app.customer.account.order.view.individual-invoice', ['invoice_id' => $invoice->increment_id ?? $invoice->id]) }}</span>
|
||||
|
||||
<a href="{{ route('customer.orders.print', $invoice->id) }}" class="float-right">
|
||||
{{ __('shop::app.customer.account.order.view.print') }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue