mauricecalhoun / inventory Goto Github PK
View Code? Open in Web Editor NEWInventory Management for Laravel 4 / 5
Inventory Management for Laravel 4 / 5
The documentation of LocationTrait::getLocation() suggests that it will perform a type check against a Location
class, but the actual check looks for the Laravel's Illuminate\Database\Eloquent\Model
.
Is this a bug or the intended behavior?
The VerifyTrait::isModel() method's body is practically identical, but its name and documentation accurately represent the behavior which suggests to me that this might actually be a bug.
Hey,
I try to install the package but i'm getting the following error:
Can't locate path: </var/www/laravel/vendor/stevebauman/inventory/src/Stevebauman/Inventory../../../config/config.php> Can't locate path: </var/www/laravel/vendor/stevebauman/inventory/src/Stevebauman/Inventory../../../migrations/>
Any idea? (Laravel 5)
So the creation and management of assemblies is underway, however I'm not sure how to prevent a parent item from being added to its own assembly. Doing so right now creates an infinite recursive query since the assembly item is apart of itself.
So, the questions:
Any help is extremely appreciated, thanks!
It is possible that an operator enters a different product when creating a sell/purchase in a system. How do you design the system so you can revert/correct such operations? Do you link each line in an order to a stock transaction and change the transaction when the line is changed? Do you create another set of transactions?
Thanks for this awesome library.
New feature to be implemented. Prices and costs per item can be managed. This will allow devs to add currencies (ex. USD, CAD, Euros) and have separate costs/currencies per item.
I'm not sure if this is on your roadmap or not, but it would be great if this package supported kitting/bundling or assemblies. I'm currently using this in an app for a company who assembles all of their end products from raw materials and needs to track both materials and assembled goods. I'm currently using a closure table to handle the assemblies and it seems to be working out ok so far. If this is something you want to/plan on adding, I'd be happy to extract out the relevant code once this project wraps up and send a PR if you'd like (or assist with another implementation).
Say you have to manage an inventory of hats. These can be identified by color and size. How to you create an inventory item and add these properties to it? Should these properties be metrics? But now you can only assign one metric to an item, right?
What would you advise?
Hi, All set for Laravel 4.2 but when I try to migrate I found this error :
Migration table created successfully.
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1005 Can't create table 'db_laravel_invento
ry.#sql-ad0_237' (errno: 150) (SQL: alter table metrics
add constraint me
trics_user_id_foreign foreign key (user_id
) references users
(id
) on
delete set null on update restrict)
[PDOException]
SQLSTATE[HY000]: General error: 1005 Can't create table 'db_laravel_invento
ry.#sql-ad0_237' (errno: 150)
migrate [--bench[="..."]] [--database[="..."]] [--force] [--path[="..."]] [--pac
kage[="..."]] [--pretend] [--seed]
If any way to solve this issue? Thank you
Should the prefix
and code
columns on the inventory_skus
table be merged? There's small benefits to keeping them separate, however having a single column would allow easier and more flexible searching, and the configuration values could be changed at any time in production and this wouldn't affect the method Invenory::findBySku()
method.
Though keeping them separate, I could add more columns down the line such as a SKU suffix and allow possible transformation functions for displaying SKU's differently, for a small example, someone might prefer hyphens inside the sku:
DRI00001
becomes DRI-00001-SFX
SFX
being a new suffix column.
If anyone has any thoughts please let me know, thanks!
Hey @stevebauman , this is a great package and I'm really lloking Forward to work with it. The Kits feature is something I would love to see, is it comming soon?
Is there something we can help you with to bring this to life?
Currently getSkuAttribute() is called every time a model is booted since eloquent tries to cache the value of the attribute. So this means even if skus are disabled in the config the db is still being hit when the model is booted looking for the sku. The getSku method needs to check the config to see if skus are enabled to avoid this.
The other issue with this method is that it prevents eloquent from caching the query since getSku() is explicitly hitting the db each time it's called via $this->sku()-first(), even when the model has been eager loaded.
After a quick look at the code, If getSkuAttribute() was removed and calls to $this->sku()->first() in the trait were shifted to $this->sku everything could be properly cached. Not sure if removing is possible since I didn't comb through it enough to see if there was a specific reason this method exists.
In the line 26 of the UserIdentificationTrait.php file is missing a backslash before Auth::user()->getAuthIdentifier();.
To reproduce from new laravel 5.2 project:
php artisan make:auth
php artisan migrate
php artisan inventory:install
php artisan migrate:refresh
Fatal Error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Fatal error: Class 'CreateInventoryAssembliesTable' not found
Stacktrace:
[2016-01-27 09:36:01] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError:
Fatal error: Class 'CreateInventoryAssembliesTable' not found in
/home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:336
#0 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(227): Illuminate\Database\Migrations\Migrator->resolve('create_inventor...')
#1 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(206): Illuminate\Database\Migrations\Migrator->runDown(Object(stdClass), false)
#2 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php(69): Illuminate\Database\Migrations\Migrator->reset(false)
#3 [internal function]: Illuminate\Database\Console\Migrations\ResetCommand->fire()
#4 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#5 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#6 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#7 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#8 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(185): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))
#9 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php(45): Illuminate\Console\Command->call('migrate:reset', Array)
#10 [internal function]: Illuminate\Database\Console\Migrations\RefreshCommand->fire()
#11 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Container/Container.php(507): call_user_func_array(Array, Array)
#12 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#13 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Application.php(787): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\RefreshCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /home/vagrant/Code/InventoryManagement/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /home/vagrant/Code/InventoryManagement/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /home/vagrant/Code/InventoryManagement/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 {main}
If you delete an inventory item that belongs to an assembly, when you access the assembly items, the deleted item still appears.
Hi @stevebauman,
When I tried reserving with backorder flag turned on, I got this exception:
Stevebauman\Inventory\Exceptions\InvalidTransactionStateException with message 'Transaction state: commerce-reserved cannot be changed to a: commerce-back-ordered state.'
These are the statements causing that error (I used php artisan tinker):
>>> $s = InventoryStock::find(1)
=> Stevebauman\Inventory\Models\InventoryStock {#707
id: "1",
created_at: "2015-07-23 07:05:16",
updated_at: "2015-07-23 08:22:04",
deleted_at: null,
user_id: null,
inventory_id: "1",
location_id: "1",
quantity: "20.00",
aisle: null,
row: null,
bin: null,
}
>>> $t = $s->newTransaction();
=> Stevebauman\Inventory\Models\InventoryTransaction {#691
stock_id: "1",
name: "",
}
>>> $t->reserved(30, true);
Stevebauman\Inventory\Exceptions\InvalidTransactionStateException with message 'Transaction state: commerce-reserved cannot be changed to a: commerce-back-ordered state.'
Is there something I missed to enable backorder reservation?
Thanks,
Hendra
I was having a look at the relation between Inventory and Metric models.
I noticed this:
public function metric()
{
return $this->hasOne('Stevebauman\Inventory\Models\Metric', 'id', 'metric_id');
}
And in the Metric class:
public function items()
{
return $this->hasMany('Stevebauman\Inventory\Models\Inventory', 'metric_id', 'id');
}
AFAIK, reading the docs, the hasOne relation should be used for one-to-one relations, the inverse of hasMany
being belongsTo
. Am I wrong? Did you have something else in mind when using hasOne
?
When adding items to stocks it is easy to provide the associated cost (it's the price from the invoice). How would you go about calculating the cost when items leave the stock? AWC seems the easiest but I haven't figured it out. I can't even think of implementing LIFO/FIFO.
Thinking of adding an inventory_transactions
table with it's own InventoryTransaction
model. This would add the ability of reserving a certain amount of an items stock for a specific transaction. Each transaction would have their own state
such as:
//Reserved State
const STATE_RESERVED_CHECKOUT = 'checkout';
const STATE_RESERVED_ONHOLD = 'onhold';
const STATE_RESERVED_BACKORDERED = 'backordered';
//Cleared State
const STATE_CLEARED_SOLD = 'sold';
const STATE_CLEARED_RETURNED = 'returned';
const STATE_CLEARED_COMPLETED = 'completed';
When a transaction would be created, this would automatically generate a stock movement, so anytime a quantity is reserved for a transaction, it's shown in an item stock movement.
A transaction would be on a 'per stock' basis, so a transaction would be triggered on a specific inventory stock record.
Possibly an API such as:
$stock = InventoryStock::find(1);
$stock->reserve(20, InventoryTransaction::STATE_RESERVED_ONHOLD);
An example use case:
An inventory stock is empty, and reserve()
is called on the stock. The stock isn't available, so the transactions state would be automatically set to STATE_RESERVED_BACKORDERED
.
When quantity is added to the stock, you could call:
$stock->fillBackorders();
//Or call it on the item to trigger it on all stocks with an optional stock parameter?
$item->fillBackorders($stock);
This would automatically check for the transactions that were created from first to last, and automatically remove the quantity from the stock if it's available. If there still isn't stock available then the transaction stays open.
I'm adding Category but got above error. What did I miss? I've added outlet_id field in database table and my model as follows,
// Category.php
<?php namespace Slurp\Entities;
use Stevebauman\Inventory\Traits\CategoryTrait;
use Baum\Node;
class Category extends Node
{
use CategoryTrait;
protected $table = 'categories';
protected $scoped = ['belongs_to'];
public function inventories()
{
return $this->hasMany('Inventory', 'category_id');
}
public function outlet()
{
return $this->belongsTo('Outlet', 'outlet_id');
}
}
create function in my controller,
...
public function createCategory()
{
$category = new Category;
$category->name = $this->request->input('name');
$category->outlet_id = \Auth::user()->outlet_id;
if( $category->save())
return $this->redirector->back()->with('success', 'Added category inventory');
return $this->redirector->back()->withError('Failed add category inventory');
}
...
update: no error when I set $category->belongs_to = null;
Hello @stevebauman
I'm looking into using your package, as it feels very complete, but one requirement, for me at least, is to have inventory tracking for products that have variants.
With the most common example, T-shirt with Colors and Sizes.
One way would be to have a parent_id
column on the, in this case inventories
table, and each variant
would be a new product with it's parent being the root one, and the parent_id
on the root product would be obviously 0
, makes sense? xD
How would you go about this with your package?
While going through and checking out v1.5 I noticed that any transaction that is marked as sold is not removed from the transaction. If someone happens to be comparing the quantity_after column on sold transactions to something, all counts will be incorrect. Since the stock is being released, this should be removed from the transaction when it's marked as sold. It technically should create a stock movement but I don't think this is possible since it's already been reduced with the reservation.
Hi,
What's lft and rgt use in categories table? Thank you
Hello,
I noticed that the receivedPartial() method is passing the wrong value in the quantity parameter of processStockPutAndSave() method. Right now, the amount left to be received is the quantity that is being passed to processStockPutAndSave, which leads to wrong before and after quantity in the stock movement.
The value passed in the quantity parameter of receivedPartial() is the value that should be passed to quantity parameter of processStockPutAndSave() method.
How can I deploy app easily way?
I try to install, but locate error occurs as #31 mention, I'm using lastest version.
I've got MenuItem
model in my F&B app and I want to implement inventory feature, how do I do this?
Hi,
How to catch a move exception in controller? Because it's still moved the category while the exception's displayed. I want to prevent the save method from processing if any move exception occured. Thank you
Something I noticed today when doing some testing that that any stock movements that were the result of a transaction have just the default reason populated. It would be great if a 'reason' could be passed to the action methods on the transaction e.g. reserved($qty, 'My Reason), which would get passed to the corresponding stock method so it gets recorded in the movements table. Or at the very least, pass the transaction name or ID to the stock method when it's called so there is some link between transactions and movements (other than additional complex queries).
Thoughts?
base on your DB design, i think the suppliers should bind to inventory stock too. please advise, thanks
If an item already has an SKU and the $item->generateSku()
method is called, it will return the actual SKU code such as 'DRI00001' instead of the model record.
This will be fixed tomorrow morning.
I am current use this plugin to build a warehouse management system for shoes.
We known that shoes could have different size such as 5, 5.5, 6 etc..
How do we add different specification for one particular inventory?
So we can know how many stocks do we got of every size for one shoes.
Thanks.
Hi! I have an error when execute "php artisan vendor:publish"
The error is "Can't locate path: </mifolder/vendor/stevebauman/inventory/src/Stevebauman/Inventory../../../config/config.php>
"
Hey,
There is any release date for 1.8?
I really wait for the kits/bundle feature.
Thanks
How do I go about tracking every single piece of item that has unique barcode attached? I've tried setting up the code and did the example in usage document but it seems like this code tracks the quantity of item as a whole for each location. Is it possible to use this code to track movement of each piece of item through the different locations?
Version: 1.7.*
After creating a new transaction and reserving an item, I found the column "reason" in the table "inventory_stock_movements" had a problem.
That is, the ":ID" doesn't be replaced by the transaction ID.
The column "reason" just displays like "Reservation occurred on Transaction ID: on 2016-05-20 20:58:27"
$item = Inventory::find(13);
$stock = $item->getStockFromLocation($location);
$transaction = $stock->newTransaction();
$transaction->reserved(5);
Thank you for your masterpiece!!
Something that came to mind is that having a default location could be valuable in certain situations. For instance, since stock currently has aisle/row/bin fields, it's not extremely likely that these would be created as locations. So locations would typically be used in more of a 'Warehouse A', 'Warehouse B' type situation. If that's the case and there is only 1 location, having to constantly query and pass the location for each stock add could be tedious. The same could be said for the assemblies, where in many cases the assemblies will be built from stock in one location the majority of the time (until you get into larger scale manufacturing situations).
So maybe being able to specify a default location in config or setting it as a field on the location table could be useful. Then a method called createStock()
could be added to the inventory trait which would in turn call createStockOnLocation()
passing the default location.
Thoughts?
Hi,
I tried to install but got following error with composer update command:
illuminate/support suggests installing jeremeamia/superclosure (Required to be able to serialize closures (~2.2).)
illuminate/support suggests installing paragonie/random_compat (Provides a compatible interface like PHP7's random_bytes() in PHP 5 projects (~1.1).)
illuminate/support suggests installing symfony/polyfill-php56 (Required to use the hash_equals function on PHP 5.5 (~1.0).)
illuminate/support suggests installing symfony/process (Required to use the composer class (2.8.|3.0.).)
illuminate/support suggests installing symfony/var-dumper (Improves the dd function (2.8.|3.0.).)
illuminate/filesystem suggests installing league/flysystem (Required to use the Flysystem local and FTP drivers (~1.0).)
illuminate/filesystem suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (~1.0).)
illuminate/filesystem suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
symfony/translation suggests installing symfony/config ()
symfony/translation suggests installing psr/log (To use logging capability in translator)
illuminate/database suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (~2.4).)
illuminate/database suggests installing fzaninotto/faker (Required to use the eloquent factory builder (~1.4).)
illuminate/database suggests installing illuminate/pagination (Required to paginate the result set (5.2.).)
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/process ()
symfony/console suggests installing psr/log (For using the console logger)
illuminate/console suggests installing guzzlehttp/guzzle (Required to use the ping methods on schedules (~5.3|~6.0).)
illuminate/console suggests installing mtdowling/cron-expression (Required to use scheduling component (~1.0).)
illuminate/console suggests installing symfony/process (Required to use scheduling component (2.8.|3.0.).)
sebastian/global-state suggests installing ext-uopz ()
phpdocumentor/reflection-docblock suggests installing dflydev/markdown (~1.0)
phpdocumentor/reflection-docblock suggests installing erusev/parsedown (~1.0)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
Please show me how to fix it.
Thank you.
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL
: alter tablemetrics
add constraintmetrics_user_id_foreign
foreign ke
y (user_id
) referencesusers
(id
) on delete set null on update restri
ct)
[PDOException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
Above is the error message when running migration.
Hi, I followed the installation steps. The tables got migrated but I cant see any views and controllers in my project
I'm not getting artisan file at project root folder. Please inform me. Thank you !
Good Morning, i like to use stevebauman/inventory. Sorry for my english.
I have created an application where some users can manage a little inventory (every warehouse is separeted by users). I have added a column into inventory table and add an restriction (a where into query) for show the items of a user.
How i can do for make the possibility to insert multiple SKU code (from barcode reader)? The first save correct, but other has the auto SKU code (because there is also into db).
can you help me?
The documentation shows the transaction->ordered() method to accept a "reason" and "cost" but the code shows that it only accepts quantity.
Also, I cannot find in the database where the "reason" would be stored.
Hi Steve,
Great package! Very big help for my project. I got an issue with adding supplier by ID,
This line return $this->suppliers()->find($id);
under InventoryTrait, it returns NULL. I am quite new to traits. As per description it is the belongs to many relationship. Am I correct?
I changed the code to return Supplier::find($id);
, it worked fine. Am missing something?
thank you
Hey Steve,
Great package!
My client has a lot of big stock, transformers, generators, big electrical/construction stuff. It's common for one inventory item to have many locations (wherever it fits pretty much), so in it's current form, the package doesn't work for my situation.
Inventory can be big, or it can be extremely big, so the "locations" of where stock can be are pretty much endless.
Rather than re-write any code, one thing I have been toying with is generating a unique location per a stocks aisle
, row
, and bin
. Stock can span over one single aisle, or can span over multiple.
So if I have a 10x Item 1
at row 1
, section A-B
(we call aisle section), it'll generate a new location with the name of: 1A-B
. That way we could check to see if location 1A-B is free, and if it's not, then throw a StockAlreadyExistsException
The only downside that I can foresee is that if there's stock on Row 1 A-B and a user tries to add stock on Row 1 A, then it wouldn't consider Row 1 A-B as an existing location. But maybe I can just leave that up to the client take those precautions.
Do you have any ideas that may help?
Cheers, Steve!
hello, im historian student and made with a friend a inventory (in paper and pencil, and now excel) of archaeological artifacts. When more youth i get some contact with php so, im here trying to run your Laravel app for the first time to later do a mysql db.
When i access the public folder through the browser i got:
Whoops, looks like something went wrong.
(i used find in the files but.... got 21 matches.)
I installed without errors.
Let`s say I have a product: a T-Shirt.
It comes in different sizes: XS, S, M, L, XL.
Each Size (Metric) should have a Stock, eg.: XL (2 pieces), L (17 pieces) and so on.
Is there a straight-forward way to implement this?
Maybe its something obvious, but Im new to this Laravel world and I can
t seem to get my head around this.
Thanks :)
Have you ever consider the SN for every item? thanks
In L5, currently an exception is thrown when attempting to use localization in the config files. The exception is thrown by the container and relates to the Log class, and based on some quick testing I don't think this is an issue with the package but with laravel itself. I've filed an issue on the framework repo laravel/framework#7467 to see if this is a bug or expected behavior when using localization in the config files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.