Merge pull request #444 from jitendra-webkul/jitendra

Jitendra
This commit is contained in:
JItendra Singh 2019-01-11 15:33:33 +05:30 committed by GitHub
commit 54fd9aa972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 76 additions and 7632 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{
"/js/admin.js": "/js/admin.js?id=c70dacdf945a32e04b77",
"/css/admin.css": "/css/admin.css?id=d40a640933cbcc121f1d"
"/css/admin.css": "/css/admin.css?id=3e790c2215bf5c60ac21"
}

View File

@ -159,6 +159,7 @@ class ShipmentController extends Controller
$inventory = $product->inventories()
->where('inventory_source_id', $data['shipment']['source'])
->where('vendor_id', 0)
->first();
if ($orderItem->qty_to_ship < $qty || $inventory->qty < $qty) {

View File

@ -7,7 +7,7 @@
$qty = 0;
foreach ($product->inventories as $inventory) {
if($inventory->inventory_source_id == $inventorySource->id) {
if($inventory->inventory_source_id == $inventorySource->id && !$inventory->vendor_id) {
$qty = $inventory->qty;
break;
}

View File

@ -325,7 +325,7 @@
sourceInventoryQty (inventorySourceId) {
var inventories = this.variant.inventories.filter(function(inventory) {
return inventorySourceId === inventory.inventory_source_id;
return inventorySourceId === inventory.inventory_source_id && !inventory.vendor_id;
})
if(inventories.length)

View File

@ -306,6 +306,19 @@
}
?>
<?php
$sourceQty = 0;
$product = $item->type == 'configurable' ? $item->child->product : $item->product;
foreach ($product->inventories as $inventory) {
if($inventory->inventory_source_id == $inventorySource->id && !$inventory->vendor_id) {
$sourceQty = $inventory->qty;
break;
}
}
?>
{{ $sourceQty }}
</td>

View File

@ -1,8 +1,8 @@
const { mix } = require("laravel-mix");
require("laravel-mix-merge-manifest");
// var publicPath = 'publishable/assets';
var publicPath = "../../../public/vendor/webkul/admin/assets";
var publicPath = 'publishable/assets';
// var publicPath = "../../../public/vendor/webkul/admin/assets";
mix.setPublicPath(publicPath).mergeManifest();
mix.disableNotifications();

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddVendorIdColumnInProductInventoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('product_inventories', function (Blueprint $table) {
$table->integer('vendor_id')->default(0);
$table->unique(['product_id', 'inventory_source_id', 'vendor_id'], 'product_source_vendor_index_unique');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('product_inventories', function (Blueprint $table) {
//
});
}
}

View File

@ -163,10 +163,10 @@ class Product extends Model
*
* @return bool
*/
public function inventory_source_qty($inventorySource)
public function inventory_source_qty($inventorySourceId)
{
return $this->inventories()
->where('inventory_source_id', $inventorySource->id)
->where('inventory_source_id', $inventorySourceId)
->sum('qty');
}

View File

@ -9,7 +9,7 @@ class ProductInventory extends Model
{
public $timestamps = false;
protected $fillable = ['qty', 'product_id', 'inventory_source_id'];
protected $fillable = ['qty', 'product_id', 'inventory_source_id', 'vendor_id'];
/**
* Get the product attribute family that owns the product.

View File

@ -33,36 +33,32 @@ class ProductInventoryRepository extends Repository
if ($product->type == 'configurable')
return;
$inventorySourceIds = $product->inventory_sources->pluck('id');
if(isset($data['inventories'])) {
foreach($data['inventories'] as $inventorySourceId => $qty) {
if(is_null($qty))
continue;
if(is_null($qty)) {
$qty = 0;
}
$productInventory = $this->findOneWhere([
'product_id' => $product->id,
'inventory_source_id' => $inventorySourceId,
'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0
]);
if($productInventory) {
if(is_numeric($index = $inventorySourceIds->search($inventorySourceId))) {
$inventorySourceIds->forget($index);
}
$this->update(['qty' => $qty], $productInventory->id);
if($productInventory) {
$productInventory->qty = $qty;
$productInventory->save();
} else {
$this->create([
'qty' => $qty,
'product_id' => $product->id,
'inventory_source_id' => $inventorySourceId,
'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0
]);
}
}
}
if($inventorySourceIds->count()) {
$product->inventory_sources()->detach($inventorySourceIds);
}
}
}

View File

@ -50,6 +50,7 @@ class ShipmentItemRepository extends Repository
}
$inventory = $data['product']->inventories()
->where('vendor_id', $data['vendor_id'])
->where('inventory_source_id', $data['shipment']->inventory_source_id)
->first();

View File

@ -134,7 +134,8 @@ class ShipmentRepository extends Repository
'shipment' => $shipment,
'shipmentItem' => $shipmentItem,
'product' => $product,
'qty' => $qty
'qty' => $qty,
'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0
]);
$this->orderItem->update(['qty_shipped' => $orderItem->qty_shipped + $qty], $orderItem->id);

View File

@ -1,27 +0,0 @@
<?php
namespace Webkul\Sales\Repositories;
use Illuminate\Container\Container as App;
use Webkul\Core\Eloquent\Repository;
/**
* ShipmentItem Reposotory
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ShipmentItemRepository extends Repository
{
/**
* Specify Model class name
*
* @return Mixed
*/
function model()
{
return 'Webkul\Sales\Contracts\ShipmentItem';
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{
"/js/ui.js": "/js/ui.js?id=c3ee60fd11e29aca2922",
"/css/ui.css": "/css/ui.css?id=0b2b51d90a970c9a4219"
"/css/ui.css": "/css/ui.css?id=1edd188de8c037f174a0"
}

View File

@ -1,8 +1,9 @@
const { mix } = require("laravel-mix");
require("laravel-mix-merge-manifest");
// var publicPath = 'publishable/assets';
var publicPath = "../../../public/vendor/webkul/ui/assets";
var publicPath = 'publishable/assets';
// var publicPath = "../../../public/vendor/webkul/ui/assets";
mix.setPublicPath(publicPath).mergeManifest();
mix.disableNotifications();