Provide a general-purpose method of tracking inventory on the farm.

One use case: tracking inventory of Supplies/Materials, like Seeds, Feed, Medicine, etc etc.

The "Commerce Stock" module provides a way of managing inventory of products that are sold through the Commerce order system, but that is too narrow for our uses, and it does not provide much of an audit trail, other than looking at each order and how much was sold.

A real inventory tracking system needs to be completely based on ledger-like records: additions and subtractions, credits and debits, whatever you'd like to call it. The "available quantity" of any particular material should only be editable by logging a change to it, and should be calculated on-the-fly by adding/subtracting all of the changes, to arrive at the current amount. This provides a much more visible trail of records for the material.

Comments

m.stenta’s picture

Title: [META] Farm Inventory » Farm Inventory

Remove [META] from the title. I think this should be a specific implementation, not just a discussion.

m.stenta’s picture

Thinking about this more... I wonder if this can be accomplished simply with the Acquisition and Disposition log types... on any asset.

So for example, with a cow... you would have 1 Acquisition record for when you got the cow, and 1 Disposition record for when you sold the cow.

In the case of materials, you would have multiple records. Take "Cracked Corn" for example: every time you buy more, you add an Acquisition record to the "Cracked Corn" asset... and likewise when you use it (Disposition). Acquisition and Disposition records could have both a Value field, and a Quantity field... one to represent how much it was worth, and one to represent how much of it is added to the total quantity.

Then we wouldn't need a separate log type for "Credits/Debits".

m.stenta’s picture

Issue summary: View changes

(Below is a brainstorm from last fall, with some updates from this February and March. Decided to paste them here so others can see what the train of thought is. Note that a lot of these ideas are still in flux, and nothing is locked down yet. More conceptual issues to work through...)

Brainstormed a bit with Dorn this evening... the thought of "Inputs" and "Outputs" came up as a possible alternative to (and more general than) "Acquisitions" and "Dispositions/Disposals".

After a lot of thought, this is what I'm stuck on:

Example 1: You want to record that a crop of rye grass was planted in the fall, and in the summer of the next year it was harvested both for seed and for hay. This would involve an Input log (which decrements the inventory of your Rye Seeds asset), an Output log (which increments the inventory of your Rye Seeds asset), and a second Output log (which increments the inventory of your Hay asset).

(Side note: this means the Seeding log type is no longer necessary - what happens to the Transplanting log type? Does it just become a type of Movement? Are there Movement types? This could solve the Transit==Movement question: Transits are a movement type.)

Example 2: Your cow gives birth. The baby grows up and is slaughtered, which produces meat. This would involve an Output log (birth, which creates a new Animal), and various Output logs to represent the meat that was obtained.

Conflicts:
In Example 1, the Outputs (harvests) are incrementing the inventory of the Rye Seed and Hay assets. In Example 2, the Output (birth) is creating a whole new asset: Joey the cow. These are fundamentally different actions. Incrementing inventory of an asset vs creating a new asset.
In Example 2, what if the Outputs are milk production? The cow does not die. The "cow" asset remains. But when the outputs are meat, the cow is no longer an active entity. It's dead. There needs to be some way to represent that fact, and "Disposal" logs were going to be that way.
In Example 1, the Output quantity's unit of measure can vary, but in Example 2 the Output's quantity is just 1: the cow. If a rabbit gave birth to a litter of 6, would that be 6 separate Output logs with a quantity of 1? Or one Output log with a quantity of 6? For rabbits, it would be the latter. For materials, the former. Because when rabbits are the output you want to create 6 different assets. When rye seed is the output, you want to increment the "Rye Seed" asset.
So it seems that there needs to be some way to differentiate between these two types of assets: one is a singular entity ("Joey the cow"), while the other is a type of asset, with an ever-changing quantity.

Should the second group be taxonomy terms? With their own log type for adjusting their quantity?

-------------------

After giving it some more thought, I think we still need both sets...

Inputs and outputs are used to record how certain assets absorb or create other assets. For example: a Planting asset has inputs (water, fertilizer, etc) and outputs (produce, seeds, feed, etc). But it doesn't change the inherent quantity of the planting. There is one planting.

Acquisitions and disposals, on the other hand, are used to adjust the inventory of the particular asset at hand. For example, a Material asset (ie: rye seed) can be acquired (by buying it, harvesting it, etc) and it can be disposed (by selling it, planting it, etc).

Acquiring or disposing of an asset affects how much of THAT ASSET of it you have. Inputs and outputs affect how much of ANOTHER ASSET you have.

-----------------

So yea, that confirms it... it can't be done with just Input/Output. You also need a concept of Acquisitions/Disposals.

Both cause an asset to increase or decrease. But input/output affects the quantity of OTHER assets, and acquisitions/disposals affect the quantity of the CURRENT asset.

In the case of animals, their quantity can only increase or decrease by one. Whereas something like "Rye Seed" can increase by any amount if you purchase or harvest it, or decrease by any amount if you plant or sell it. Animals don't really have an "inventory", in other words. Well, they do... but that inventory is always just 1.

One asset's output is another asset's gain. And one asset's input is another asset's loss. This should be obvious in the UI - when you are viewing an asset, you should see a log of increments to it (both output logs and acquisition logs)

Entity+field architecture:

Input

  • Asset using input
  • Asset being used
  • Quantity used
  • Notes

Output

  • Asset creating output
  • Asset being created
  • Quantity created
  • Notes

Acquisition

  • Asset being acquired
  • Quantity acquired
  • Notes

Disposal

  • Asset being disposed
  • Quantity disposed
  • Notes

----------------------------

I wrote that a while ago... (back in the fall?) - here are some newer ideas...

Represent the concepts of "Input" and "Output" as asset reference fields on all farm_* log types.

Add a boolean property to asset types: "Inventory" - whether or not the asset maintains inventory of itself.

New field type: Farm Asset Reference - with a widget like the Term Reference field, for generating assets on-the-fly, or assigning to existing assets.

When an asset that has inventory is referenced, also display a quantity field, to specify how much of that asset was lost/gained.

Add "Input" and "Output" fields to all farm_* log types, as Farm Asset Reference fields, so any type of event can use resources, and create resources.

New log type: Inventory Adjustment - applicable to assets that maintain inventory, this log type is used to record an increase/decrease to the inventory of an asset. By adding up all the adjustments, the current inventory can be determined, and stored in the Drupal cache for later requests.

--------------------------

Perhaps farm_inventory is the log type, with a field for quantity. Whether or not a particular asset type can have inventory should determine whether or not the farm_inventory log type applies to it. Perhaps this simply a hook provided by a new farm_inventory module, which asks other modules for log types that should maintain inventory.

m.weinheimer’s picture

Inventory can get pretty complex. I didn't see a beginning inventory or goods on hand category. Everything else would have to be based on that. I can see the need for several inventory types. Seed, Inputs and Supplies with subcategories for pesticide and chemical inventories to satisfy EPA and OSHA requirements, Equipment and Infrastructure with a way to extract data for a depreciation schedule, Plantings with a way to extract data for FSA reporting and production reports, and more to come, I'm sure, for food safety, animal health, and other regulatory requirements. I need to get my own arms around how these all interact. Just adding FSA Crop Insurance categories to my crop list complicated the whole thing tremendously. The other thing that I haven't considered, since we aren't certified, is reporting for Organic certification. There was a conversation about crop planning on the CSA Farmer Discussion recently. It looks like the COG record keeping system takes certification as a starting point for their organization, and are starting to look at GAP certification, too. https://cog-pro.com
My primary interest in this project is the crop planning aspect, but it doesn't hurt to look beyond that to making the underlying database robust and flexible enough to handle the reporting that is becoming more and more a fact of life for anybody trying to produce anything, in this world.

m.stenta’s picture

... it doesn't hurt to look beyond that to making the underlying database robust and flexible enough to handle the reporting that is becoming more and more a fact of life for anybody trying to produce anything, in this world.

I agree! And that's how I'm looking at farmOS in general... trying to make it general enough to handle common use-cases that, in general, have only slight differences. So far we have the concept of "asset types" - plantings, animals, equipment, and the next logical additions would be ones like "Supplies/Materials" or "Infrastructure" - as you suggest. Then, within each of those (and across them), you can have logs that affect their inventory.

I've been stewing on this stuff for a while now, and I'm really leaning towards the following:

Create a new type of field that can be added to log entities: an "Inventory field". What it would do is provide a way to record "inventory adjustments" on an asset or assets. There would be two sub-fields for each: quantity (to describe how much inventory was involved), and a field to specify the actual asset whose inventory is being affected.

In some ways, it would be similar to the "Transaction" and "Account entry" entity types in the Ledger module (http://drupal.org/project/ledger). A transaction is basically the same as a log, and the account entries field is basically the same as the inventory field I'm proposing. In Ledger, an account entry represents an "adjustment" to an account (in the accounting sense) - it references an account, and has a value (if the value is negative it decreases the account balance, and the opposite if it's positive).

m.stenta’s picture

This is a very useful article: http://www.rd.usda.gov/files/sr41.pdf

It would be great to incorporate some of the inventory planning methods described there into farmOS in the future.

BruceDawson’s picture

I think you've managed to handle "inventory adjustments" with Movement Logs. (as long as you have an "out of the system" destination for things like deaths, solds, ...)

rbarreca’s picture

A couple things needed for organic certification in relation to seeds. Not sure if this falls under inventory, but seems like the right place to add my comment.

- Record of seed purchase: supplier, crop name/variety, quantity, certified organic or not, treated or not (implied by organic=true), GMO or not (implied by organic=true), seed lot number, and an attachment of screenshot of seed packet or photo of receipt
- For the case where organic=false, we need to document _three_ failed attempts to source that seed organically. I suppose this could likely be satisfied by uploading three attachments of screenshots of searching for "daikon" at Johnny's, High Mowing, Adaptive Seeds and it returning zero results.

m.stenta’s picture

Title: Farm Inventory » [META] Farm Inventory Brainstorm/Discussion
Status: Active » Fixed
Related issues: +#2912091: Farm Inventory

I have begun implementing a general-purpose Farm Inventory module. I started a new issue to track the specific implementation details, separate from this issue, which is more of a general brainstorm/discussion. Feel free to continue general discussion here - I'm going to close it and reference it from the new issue.

New issue: #2912091: Farm Inventory

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.