merge remote-tracking branch 'bagisto/master' into fix-tax-handling

This commit is contained in:
Steffen Mahler 2020-02-04 17:55:53 +01:00
commit 0d6aee18e4
33 changed files with 405 additions and 35 deletions

View File

@ -4,11 +4,13 @@ namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Event;
use Webkul\Customer\Repositories\CustomerRepository;
use Webkul\Customer\Repositories\CustomerGroupRepository;
/**
* Customer controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @author Vivek Sharma <viveksh047@webkul.com> @vivek-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CustomerController extends Controller
@ -28,13 +30,28 @@ class CustomerController extends Controller
protected $customerRepository;
/**
* @param CustomerRepository object $customer
* Repository object
*
* @var array
*/
public function __construct(CustomerRepository $customerRepository)
{
protected $customerGroupRepository;
/**
* Create a new controller instance.
*
* @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
* @return void
*/
public function __construct(
CustomerRepository $customerRepository,
CustomerGroupRepository $customerGroupRepository
) {
$this->_config = request('_config');
$this->customerRepository = $customerRepository;
$this->customerGroupRepository = $customerGroupRepository;
}
/**
@ -56,10 +73,11 @@ class CustomerController extends Controller
$data = array_merge($data, [
'password' => bcrypt($data['password']),
'channel_id' => core()->getCurrentChannel()->id,
'is_verified' => 1,
'customer_group_id' => 1
'is_verified' => 1
]);
$data['customer_group_id'] = $this->customerGroupRepository->findOneWhere(['code' => 'general'])->id;
Event::dispatch('customer.registration.before');
$customer = $this->customerRepository->create($data);

View File

@ -59,7 +59,14 @@ class LocalesDataGrid extends DataGrid
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true
'filterable' => true,
'closure' => true,
'wrapper' => function ($value) {
if ($value->direction == 'ltr')
return trans('admin::app.datagrid.ltr');
else
return trans('admin::app.datagrid.rtl');
}
]);
}

View File

@ -3,7 +3,7 @@
namespace Webkul\Admin\DataGrids;
use Webkul\Ui\DataGrid\DataGrid;
use DB;
use Illuminate\Support\Facades\DB;
/**
* ProductDataGrid Class
@ -19,16 +19,44 @@ class ProductDataGrid extends DataGrid
protected $itemsPerPage = 10;
protected $locale = 'all';
protected $channel = 'all';
public function __construct()
{
parent::__construct();
$this->locale = request()->get('locale') ?? 'all';
$this->channel = request()->get('channel') ?? 'all';
}
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('product_flat')
->leftJoin('products', 'product_flat.product_id', '=', 'products.id')
->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id')
->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id')
->select('product_flat.product_id as product_id', 'products.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty) as quantity'))
->where('channel', core()->getCurrentChannelCode())
->where('locale', app()->getLocale())
->groupBy('product_flat.product_id');
->select(
'product_flat.product_id as product_id',
'products.sku as product_sku',
'product_flat.name as product_name',
'products.type as product_type',
'product_flat.status',
'product_flat.price',
'attribute_families.name as attribute_family',
DB::raw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty) as quantity')
);
if ($this->locale !== 'all') {
$queryBuilder->where('locale', $this->locale);
}
if ($this->channel !== 'all') {
$queryBuilder->where('channel', $this->channel);
}
$queryBuilder->groupBy('product_flat.product_id');
$this->addFilter('product_id', 'product_flat.product_id');
$this->addFilter('product_name', 'product_flat.name');

View File

@ -150,7 +150,9 @@ return [
'role' => 'الدور',
'sub-total' => 'المجموع الفرعي',
'no-of-products' => 'عدد المنتجات',
'refunded' => 'Refunded'
'refunded' => 'Refunded',
'rtl' => 'RTL',
'ltr' => 'LTR',
],
'account' => [

View File

@ -213,7 +213,9 @@ return [
'times-used' => 'Times Used',
'created-date' => 'Created Date',
'expiration-date' => 'Expiration Date',
'delete' => 'Delete'
'delete' => 'Delete',
'rtl' => 'RTL',
'ltr' => 'LTR',
],
'account' => [
@ -776,7 +778,8 @@ return [
'seo' => 'Home page SEO',
'seo-title' => 'Meta title',
'seo-description' => 'Meta description',
'seo-keywords' => 'Meta keywords'
'seo-keywords' => 'Meta keywords',
],
'sliders' => [
@ -1263,7 +1266,9 @@ return [
'order-number-length' => 'Order Number Length',
'order-number-suffix' => 'Order Number Suffix',
'default' => 'Default',
'sandbox' => 'Sandbox'
'sandbox' => 'Sandbox',
'all-channels' => 'All',
'all-locales' => 'All'
]
]
];

View File

@ -167,7 +167,9 @@ return [
'disc_quantity' => 'مقدار استفاده نشده',
'disc_threshold' => 'آستانه استفاده نشده',
'use_coupon' => 'استافده از کوپن',
'refunded' => 'Refunded'
'refunded' => 'Refunded',
'rtl' => 'RTL',
'ltr' => 'LTR',
],
'account' => [

View File

@ -155,7 +155,9 @@ return [
'per-cust' => 'Por cliente',
'usage-throttle' => 'Tempos de uso',
'for-guest' => 'Para convidados',
'refunded' => 'Refunded'
'refunded' => 'Refunded',
'rtl' => 'RTL',
'ltr' => 'LTR',
],
'account' => [
'title' => 'Minha Conta',

View File

@ -4,7 +4,7 @@
<accordian :title="'{{ __('admin::app.catalog.products.categories') }}'" :active="false">
<div slot="body">
{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.categories.controls.before', ['product' => $product]) !!}
<tree-view behavior="normal" value-field="id" name-field="categories" input-type="checkbox" items='@json($categories)' value='@json($product->categories->pluck("id"))'></tree-view>

View File

@ -6,9 +6,45 @@
@section('content')
<div class="content" style="height: 100%;">
<?php $locale = request()->get('locale') ?: null; ?>
<?php $channel = request()->get('channel') ?: null; ?>
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.catalog.products.title') }}</h1>
<div class="control-group">
<select class="control" id="channel-switcher" name="channel" onchange="reloadPage('channel', this.value)" >
<option value="all" {{ ! isset($channel) ? 'selected' : '' }}>
{{ __('admin::app.admin.system.all-channels') }}
</option>
@foreach (core()->getAllChannels() as $channelModel)
<option
value="{{ $channelModel->code }}" {{ (isset($channel) && ($channelModel->code) == $channel) ? 'selected' : '' }}>
{{ $channelModel->name }}
</option>
@endforeach
</select>
</div>
<div class="control-group">
<select class="control" id="locale-switcher" name="locale" onchange="reloadPage('locale', this.value)" >
<option value="all" {{ ! isset($locale) ? 'selected' : '' }}>
{{ __('admin::app.admin.system.all-locales') }}
</option>
@foreach (core()->getAllLocales() as $localeModel)
<option
value="{{ $localeModel->code }}" {{ (isset($locale) && ($localeModel->code) == $locale) ? 'selected' : '' }}>
{{ $localeModel->name }}
</option>
@endforeach
</select>
</div>
</div>
<div class="page-action">
@ -46,4 +82,14 @@
@push('scripts')
@include('admin::export.export', ['gridName' => $products])
<script>
function reloadPage(getVar, getVal) {
let url = new URL(window.location.href);
url.searchParams.set(getVar, getVal);
window.location.href = url.href;
}
</script>
@endpush

View File

@ -51,7 +51,8 @@
<div class="control-group" :class="[errors.has('gender') ? 'has-error' : '']">
<label for="gender" class="required">{{ __('admin::app.customers.customers.gender') }}</label>
<select name="gender" class="control" v-validate="'required'" data-vv-as="&quot;{{ __('shop::app.customers.customers.gender') }}&quot;">
<select name="gender" class="control" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.customers.customers.gender') }}&quot;">
<option value=""></option>
<option value="Other">{{ __('admin::app.customers.customers.other') }}</option>
<option value="Male">{{ __('admin::app.customers.customers.male') }}</option>
<option value="Female">{{ __('admin::app.customers.customers.female') }}</option>

View File

@ -55,9 +55,10 @@
<span class="control-error" v-if="errors.has('email')">@{{ errors.first('email') }}</span>
</div>
<div class="control-group">
<div class="control-group" :class="[errors.has('gender') ? 'has-error' : '']">
<label for="gender" class="required">{{ __('admin::app.customers.customers.gender') }}</label>
<select name="gender" class="control" value="{{ $customer->gender }}" v-validate="'required'" data-vv-as="&quot;{{ __('shop::app.customers.customers.gender') }}&quot;">
<option value="" {{ $customer->gender == "" ? 'selected' : '' }}></option>
<option value="Other" {{ $customer->gender == "Other" ? 'selected' : '' }}>{{ __('admin::app.customers.customers.other') }}</option>
<option value="Male" {{ $customer->gender == "Male" ? 'selected' : '' }}>{{ __('admin::app.customers.customers.male') }}</option>
<option value="Female" {{ $customer->gender == "Female" ? 'selected' : '' }}>{{ __('admin::app.customers.customers.female') }}</option>

View File

@ -3,9 +3,9 @@
<tr>
@foreach ($columns as $key => $value)
<?php
$value == 'increment_id' ? $value : 'order_id';
$title = $value == 'increment_id' ? 'order_id' : $value;
?>
<th>{{ $value }}</th>
<th>{{ $title }}</th>
@endforeach
</tr>
</thead>

View File

@ -350,7 +350,7 @@
attribute_type_indexes: {
'product': 0
},
},
condition_operators: {
'price': [{
@ -516,7 +516,7 @@
if (matchedAttribute[0]['type'] == 'multiselect' || matchedAttribute[0]['type'] == 'checkbox') {
this.condition.operator = '{}';
this.condition.value = this.condition.value == '' && this.condition.value != undefined ? [] : this.condition.value;
this.condition.value = this.condition.value == '' && this.condition.value != undefined ? [] : [ this.condition.value ];
}
return matchedAttribute[0];

View File

@ -170,7 +170,7 @@ class CategoryController extends Controller
session()->flash('warning', trans('admin::app.response.delete-category-root', ['name' => 'Category']));
} else {
try {
Event:: fire('catalog.category.delete.before', $id);
Event::dispatch('catalog.category.delete.before', $id);
$this->categoryRepository->delete($id);

View File

@ -0,0 +1,18 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Webkul\Checkout\Models\CartAddress;
$factory->define(CartAddress::class, function (Faker $faker) {
$now = date("Y-m-d H:i:s");
return [
'first_name' => $faker->firstName(),
'last_name' => $faker->lastName,
'email' => $faker->email,
'created_at' => $now,
'updated_at' => $now,
'address_type' => 'billing',
];
});

View File

@ -0,0 +1,41 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Illuminate\Support\Facades\DB;
use Webkul\Customer\Models\Customer;
use Webkul\Checkout\Models\Cart;
use Webkul\Checkout\Models\CartAddress;
$factory->define(Cart::class, function (Faker $faker) {
$now = date("Y-m-d H:i:s");
$lastOrder = DB::table('orders')
->orderBy('id', 'desc')
->select('id')
->first();
$customer = factory(Customer::class)->create();
$cartAddress = factory(CartAddress::class)->create();
return [
'is_guest' => 0,
'is_active' => 1,
'customer_id' => $customer->id,
'customer_email' => $customer->email,
'customer_first_name' => $customer->first_name,
'customer_last_name' => $customer->last_name,
'is_gift' => 0,
'base_currency_code' => 'EUR',
'channel_currency_code' => 'EUR',
'grand_total' => 0.0000,
'base_grand_total' => 0.0000,
'sub_total' => 0.0000,
'base_sub_total' => 0.0000,
'channel_id' => 1,
'created_at' => $now,
'updated_at' => $now,
];
});

View File

@ -0,0 +1,16 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Webkul\Checkout\Models\CartItem;
$factory->define(CartItem::class, function (Faker $faker) {
$now = date("Y-m-d H:i:s");
return [
'created_at' => $now,
'updated_at' => $now,
];
});

View File

@ -0,0 +1,16 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Webkul\Checkout\Models\CartPayment;
$factory->define(CartPayment::class, function (Faker $faker) {
$now = date("Y-m-d H:i:s");
return [
'created_at' => $now,
'updated_at' => $now,
];
});

View File

@ -5,6 +5,7 @@ namespace Webkul\Checkout\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;
use Webkul\Checkout\Facades\Cart;
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
class CheckoutServiceProvider extends ServiceProvider
{
@ -17,6 +18,8 @@ class CheckoutServiceProvider extends ServiceProvider
$this->app->register(ModuleServiceProvider::class);
$this->app->register(EventServiceProvider::class);
$this->registerEloquentFactoriesFrom(__DIR__ . '/../Database/Factories');
}
/**
@ -48,4 +51,16 @@ class CheckoutServiceProvider extends ServiceProvider
$this->app->bind('cart', 'Webkul\Checkout\Cart');
}
/**
* Register factories.
*
* @param string $path
*
* @return void
*/
protected function registerEloquentFactoriesFrom($path): void
{
$this->app->make(EloquentFactory::class)->load($path);
}
}

View File

@ -0,0 +1,14 @@
<?php
use Faker\Generator as Faker;
use Webkul\Core\Models\Currency;
/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(Currency::class, function (Faker $faker, array $attributes) {
return [
'code' => $faker->unique()->currencyCode,
'name' => $faker->word,
];
});

View File

@ -1,10 +1,9 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Webkul\Core\Models\Locale;
/** @var \Illuminate\Database\Eloquent\Factory $factory */
$factory->define(Locale::class, function (Faker $faker, array $attributes) {
return [

View File

@ -3,6 +3,7 @@
namespace Webkul\Inventory\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
class InventoryServiceProvider extends ServiceProvider
{
@ -14,6 +15,8 @@ class InventoryServiceProvider extends ServiceProvider
public function boot()
{
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->app->make(EloquentFactory::class)->load(__DIR__ . '/../Database/Factories');
}
/**

View File

@ -0,0 +1,31 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Webkul\Product\Models\ProductDownloadableLink;
use Webkul\Product\Models\ProductDownloadableLinkTranslation;
$factory->define(ProductDownloadableLink::class, function (Faker $faker) {
$now = date("Y-m-d H:i:s");
$filename = 'ProductImageExampleForUpload.jpg';
$filepath = '/tests/_data/';
return [
'url' => '',
'file' => $filepath . $filename,
'file_name' => $filename,
'type' => 'file',
'price' => 0.0000,
'downloads' => $faker->randomNumber(1),
'created_at' => $now,
'updated_at' => $now,
];
});
$factory->define(ProductDownloadableLinkTranslation::class, function (Faker $faker) {
return [
'locale' => 'en',
'title' => $faker->word,
];
});

View File

@ -19,6 +19,8 @@ class ProductServiceProvider extends ServiceProvider
{
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->app->make(EloquentFactory::class)->load(__DIR__ . '/../Database/Factories');
$this->app->register(EventServiceProvider::class);
$this->publishes([

View File

@ -510,8 +510,13 @@ abstract class AbstractType
return true;
} else {
if (core()->isChannelDateInInterval($this->product->special_price_from, $this->product->special_price_to))
if (core()->isChannelDateInInterval($this->product->special_price_from, $this->product->special_price_to)) {
return true;
} else if ($rulePrice) {
$this->product->special_price = $rulePrice->price;
return true;
}
}
}

View File

@ -0,0 +1,41 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Webkul\Product\Models\Product;
use Webkul\Sales\Models\Invoice;
use Webkul\Sales\Models\InvoiceItem;
use Webkul\Sales\Models\OrderItem;
$factory->define(InvoiceItem::class, function (Faker $faker, array $attributes) {
$basePrice = $faker->randomFloat(2);
$quantity = $faker->randomNumber();
if (! $attributes['order_item_id']) {
$attributes['order_item_id'] = function () {
return factory(OrderItem::class)->create()->id;
};
}
$orderItem = OrderItem::find($attributes['order_item_id']);
return [
'name' => $faker->word,
'sku' => $faker->unique()->ean13,
'qty' => $quantity,
'price' => $basePrice,
'base_price' => $basePrice,
'total' => $quantity * $basePrice,
'base_total' => $quantity * $basePrice,
'tax_amount' => 0,
'base_tax_amount' => 0,
'product_id' => $orderItem->product_id,
'product_type' => $orderItem->product_type,
'order_item_id' => $attributes['order_item_id'],
'invoice_id' => function () {
return factory(Invoice::class)->create()->id;
},
];
});

View File

@ -0,0 +1,38 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Webkul\Product\Models\Product;
use Webkul\Sales\Models\Order;
use Webkul\Sales\Models\OrderItem;
$factory->define(OrderItem::class, function (Faker $faker) {
$now = date("Y-m-d H:i:s");
$product = factory(Product::class, 'simple')->create();
return [
'sku' => $product->sku,
'type' => $product->type,
'name' => $product->name,
'price' => $product->price,
'base_price' => $product->price,
'total' => $product->price,
'base_total' => $product->price,
'product_id' => $product->id,
'qty_ordered' => 1,
'qty_shipped' => 0,
'qty_invoiced' => 0,
'qty_canceled' => 0,
'qty_refunded' => 0,
'order_id' => function () {
return factory(Order::class)->create()->id;
},
'created_at' => $now,
'updated_at' => $now,
];
});

View File

@ -0,0 +1,17 @@
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Faker\Generator as Faker;
use Illuminate\Support\Facades\DB;
use Webkul\Sales\Models\OrderPayment;
$factory->define(OrderPayment::class, function (Faker $faker) {
$now = date("Y-m-d H:i:s");
return [
'created_at' => $now,
'updated_at' => $now,
];
});

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{
"/js/ui.js": "/js/ui.js?id=fc16a516045fc2b1ab87",
"/js/ui.js": "/js/ui.js?id=d4f31631ea9c862c6dc5",
"/css/ui.css": "/css/ui.css?id=0895b560bbc19259cee8"
}

View File

@ -44,7 +44,10 @@
},
created () {
let index = this.savedValues.indexOf(this.items[this.valueField])
if (! this.savedValues)
return;
let index = this.savedValues.indexOf(this.items[this.valueField].toString())
if(index !== -1) {
this.value.push(this.items);
}

View File

@ -69,7 +69,7 @@
computed: {
savedValues () {
if(!this.value)
if(! this.value)
return [];
if(this.inputType == 'radio')

View File

@ -2,7 +2,6 @@
namespace Tests\Functional\Admin\Catalog;
use FunctionalTester;
use Webkul\Attribute\Models\Attribute;
@ -76,7 +75,7 @@ class AttributeCest
private function fillForm(FunctionalTester $I, bool $skipType = false): array
{
$testData = [
'code' => $I->fake()->word,
'code' => $I->fake()->firstName,
'type' => $I->fake()->randomElement([
'text',
'textarea',
@ -85,7 +84,7 @@ class AttributeCest
'select',
'multiselect'
]),
'admin_name' => $I->fake()->word,
'admin_name' => $I->fake()->firstName,
];
$I->fillField('code', $testData['code']);