Skip to content

Integrating with 3rd party PO/SO generation #1421

Closed

Description

@miniPCR-Jesse

First off, really impressive piece of software that fills a large hole in the open source community for SMB needs! I have a question regarding 3rd party integration. I would assume a large amount of people using InvenTree are small companies that use QB Online to handle purchase orders and Shopify/WooCommerce to handle sales orders. I know InvenTree has an API, but I wasn't able to find any discussions on how people have specifically integrated InvenTree with other common applications.

Has anyone come up with a script to push PO's from Inventree to QB online, and/or pull sales orders from Shopify/WooCommerce into Inventree? Or the more general question would be: how are people handling POs/SOs in multiple systems?

Activity

  1. eeintech commented on Mar 29, 2021

    @eeintech
    Contributor

    Hello @miniPCR-Jesse

    Good questions and definitely relevant topic. My company does have a online shop but it's not yet connected to our inventory. It would be very interesting to develop tools to connect shopping systems to InvenTree.
    I'm sure in the near future this is something we're going to want, and I'm going to volunteer to make it happen 😄

    In the meantime, could you share your experience in the details of such implementation such as:

    • connection between commerce/book-keeping platforms and InvenTree's API (do commerce platform have APIs too?)
    • chain of events after a sales order is placed on commerce platform
    • chain of events after a purchase order is recorded on InvenTree
  2. SchrodingersGat commented on Mar 30, 2021

    @SchrodingersGat
    Member

    @miniPCR-Jesse glad you are excited about the project :)

    Currently I am working on a branch which adds a very crucial feature required for third party integration. It adds support for a background process runner, which can handle periodic tasks like checking third-party services for updates, and performing other actions like sending email, etc.

    Once that branch is merged, then considerations of other third party integrations will be much easier!

    In the mean time, as @eeintech says, any information on how you might want to see such features integrated would be helpful.

  3. miniPCR-Jesse commented on Apr 13, 2021

    @miniPCR-Jesse
    Author

    I've been trying to get detailed info from our operations person, but he's been out for a bit. Figure in the meantime I'll write out my best guess.

    We use WooCommerce to handle all of our orders (orders are manually entered into WooCommerce if they're not made online) and Quickbooks Online for our accounting. Both seem to have pretty thorough APIs implemented (documentation here and here). QB has pseudo inventory-management but it's laughably bad (just a "qty on hand" field).

    I think fundamentally there's three main events that require passing information between the systems:

    1. Pushing PO info from Inventree to QB (one way)
    2. Syncing Item information from Inventree to QB (one way)
    3. Pushing Sales info between Inventree and WooCommerce (two way) and Inventree and QB (one way)

    In my opinion the inventory management system should be the default source of info when it comes to vendors, part/BOM info, and sales orders (at least when it comes to part fulfillment) and so it acts as a middle man between WooCommerce and QB.

    Purchase Orders
    When a purchase order is marked as placed in Inventree the following actions would occur:

    • QB is queried to see if the vendor is in its database. If not, the vendor is added to QB.
    • For each line item of the PO, QB is queried to see if the IPN in Inventree matches a SKU in QB. For any that don't have a match, the item is added to QB.
    • The purchase order is created in QB and marked as open.

    When a purchase order is marked as complete in Inventree the following actions would occur:

    • The purchase order is edited in QB to reflect the final line items and quantities.
    • The purchase order is marked as closed in quickbooks.
    • The QtyOnHand field in QB is updated for each line item.

    Syncing item information
    While not strictly necessary, this would make end of year tax prep much simpler. The idea is that either at a regular interval or via a manual trigger Inventree will sync all item information and quantities with QB. When the event happens the following actions would occur:

    • For each item in Inventree, QB is queried to see if the IPN matches a SKU in QB. For any that don't have a match, the item is added to QB.
    • QB's QtyOnHand value for each item is updated with Inventree's quantity.
    • Optional: A report is generated that lists "dangling" items in QB (i.e. items in QB that have a SKU that does not match an Inventree IPN), along with its QtyOnHand.

    Sales
    This one is a little trickier since there's two systems and bi-directional info.

    Either at a regular interval or via a manual trigger WooCommerce is queried for any sales order numbers that don't match an Inventree sales reference number. For each one:

    • The customer is checked to see if there's a matching entry in Inventree, and a new customer is created if there is not.
    • A new sales order is created by matching the WooCommerce SKU to Inventree's IPN for each order line.

    When a sales order is marked as shipped in Inventree, the actions would occur:

    • Update date_completed field of WooCommerce order.
    • Update stock_quantity for each item in WooCommerce.
    • Optional: WooCommerce has a shipping tracking extension that adds additional accessible fields to its API. Ideally there would be a shipping tracking field that could be populated in Inventree that would be pushed to WooCommerce.
    • QB is queried to see if the customer is in its database. If not, the customer is added.
    • For each item in the sales order, QB is queried to see if the IPN matches a SKU in QB. For any that don't have a match, the item is added to QB.
    • A SalesReceipt is generated in QB.
    • The QtyOnHand field in QB is updated for each line item.

    I think that covers all the major interactions between the systems. There's some minor interactions (e.g. refunds/returns) which could be handled manually. While I wrote this up with regards to the two platforms we use, I would guess that the flow of information would be similar across most accounting and e-commerce software. I believe the other two big ones typically used in small companies are Wave and Shopify. Hope this info is helpful!

  4. matmair commented on Apr 13, 2021

    @matmair
    Member

    I do not have experience with WooCommerce itself but when working with ticket-/inventory-/chat-systems I came to appreciate webhooks for those tasks.
    A Webhook is a api-call made to another system with a payload informing the other system of the triggering action and some additional information in the json-payload. Modern webhooks are singed for security. One can greatly reduce the number of background tasks required with webhooks as they just need to establish an (DRF) API-endpoint and the logic in the own system, ignoring the auth and api-structure for the triggering system.
    Implementing a Webhook-system for calling other systems on a trigger is also not to difficult - although I do not like the library's I used so far for this project as all of them were either outdated or used celery for background tasks.

    WooCommerce provides webhooks as well as QuickBooks.

  5. matmair commented on Apr 24, 2021

    @matmair
    Member

    @miniPCR-Jesse @SchrodingersGat I just had to implemented webhooks in a project and found this libary to be very fast in implementing and running, could be async with django-g. Also it is made by zapier, who i admire for their great webhook / api-based plattform

  6. SchrodingersGat commented on Apr 28, 2021

    @SchrodingersGat
    Member

    Looks very interesting @matmair !

  7. Matthewmads commented on Jul 9, 2021

    @Matthewmads

    Has there been any development on this? I'm looking at integrating inventree into an existing door and hardware supply company and 3rd party apps like quickbooks is a big deal for the end user. I'm considering setting up a test environment to play around with links to QB but in the past I've always looked at QB as an island that's very difficult to get data in and out of. Any insight that anyone has would be appreciated. Thanks

  8. matmair commented on Jul 9, 2021

    @matmair
    Member

    @Matthewmads not that I know of. From my side it seemed like there was low interest in this, so I did not pursue it further.
    Intuit provides Webhooks so you could use django signals or DRF Webhooks to get changes to QB, a API-endpoint for call-backs from QB and background tasks for regular tasks. Maybe a changed Plugin-Interface will impact this effort (#749 (comment)).

  9. miniPCR-Jesse commented on Jul 9, 2021

    @miniPCR-Jesse
    Author

    As far as I'm aware this issue is what's stopping the small startup I work for from using Inventree for inventory management. Given that we're actively looking at paid solutions, I may be able to convince them to back a paid bounty for successful implantation of integration QuickBooks / WooCommerce. Has something like this been done for any Inventree features in the past?

  10. matmair commented on Jul 9, 2021

    @matmair
    Member

    @miniPCR-Jesse the tech for getting and setting data would not be difficult but at least for QB there are strict security requirements.

    Generally, if you or anyone else wants to try to implement it: be aware that especially handling the keys for 3rd party APIs has to be done right to avoid leaking financial data! I recommend asking @SchrodingersGat if he wants such confidential data in the mainline app before developing stuff.

  11. SchrodingersGat commented on Jul 10, 2021

    @SchrodingersGat
    Member

    Similar integrations have been requested for services such as opencart and shopify. In principle I am open and encouraging of the idea. The major caveat is that integration with any of these platforms would require intimate knowledge of them (which I don't currently have)!

    However some of the recent major features implemented in InvenTree have been done so (at least partly) to be able to support these integrations.

    For example, the addition of the "background worker" which could be extended to periodically communicate with an externally connected service.

    As @matmair rightfully points out we would need to closely consider any security requirements...

    If we can come up with a clear proposal and development path, I'd be supportive.

  12. matmair commented on Jul 10, 2021

    @matmair
    Member

    @SchrodingersGat I would be open to make a prototype implementation for a simple async webhook integration - would be for some sort of OSS website though.

    The question is how proper implementations - which should be easy to be added and updated - should integrate into InvenTree. If they are directly in InvenTree it could be inferred that you/the project are responsible. A implementation like action plugins could be working used with git submodules. There should also be some sort of compatibility check (maybe via API version or version string).

  13. matmair commented on Jul 10, 2021

    @matmair
    Member

    @SchrodingersGat made a quick and dirty test implementation and there is a lot to figure out with this. Will loose reliable internet for the next week soon so I will leave my thoughts here for whomever wants to poke around.

    I suggest a single API-Endpoint that will be called by incoming webhooks. API-Plugins (working title) register functions against a signal that triggers every time this endpoint is called. This enables multiple plugins to act on the same incoming hook. Each Plugin can define settings for itself in its modules init.py, which get shown in a separate tab in the InvenTree settings. This way we can handle keys safely (encrypting at rest etc.).
    Additional webhooks get implemented and maybe a function for plugins to register additional hooks.

    We should also establish a list with people that want to do specific implementations so we have people to ping about testing.

  14. matmair commented on Jul 10, 2021

    @matmair
    Member

    @Matthewmads @miniPCR-Jesse what plattforms would interest you and would you be up to develop and/or test the specific implementations for these? I would love to do the groundwork but I am reluctant to do stuff for things I do not know and use.

  15. SchrodingersGat commented on Jul 12, 2021

    @SchrodingersGat
    Member

    I like the idea of implementing a "plugin" system here. Even "first party" plugins that are developed could be implemented in this manner.

    For example, we might have a "plugins" directory, under which each sub directory defines a plugin system.

    Each "plugin" could have the following features (among others):

    API Endpoint

    An endpoint specific to that plugin / a way to hook into the plugin via the API

    Settings

    A sub-page under "settings" for that plugin to control it's own run-time configuration. For example, configuration of API keys, etc.

    Tasks

    A given plugin may wish to implement some background processes ("tasks") which run periodically

    =======

    Implementation

    The first thing here would be to decide what a stable plugin architecture might look like. Previously I would have just started writing one and "winging it" - but InvenTree is now large enough that I'd like to consider it properly.

  16. Matthewmads commented on Jul 12, 2021

    @Matthewmads

    @matmair yes I'd be interested in testing a quick books integration and potentially some others but im still learning so I think I would need some guidance. My role in this project is as a consultant helping to streamline workflows and make things more digital in an aging company.

    I need to speak to my customer but a part of my deal is to set up a working inventory system and a training program for whatever system we end up on. I don't think they are opposed to putting a training program in the open domain but I will ask today and update this thread.

  17. miniPCR-Jesse commented on Jul 12, 2021

    @miniPCR-Jesse
    Author

    @matmair Similar answer to Mathewmads regarding interest. My background isn't SW development, so I don't know how much help I'd be in that regard. But if you're looking for someone to test some usage scenarios I'd be happy to lend a hand.

  18. matmair commented on Aug 23, 2021

    @matmair
    Member

    So I did a lot of prototyping and testing and here is a small roadmap what needs to be done (right, I have a very bad copied together prototype that works with QB).

  19. added
    roadmap
    on Aug 24, 2021
  20. self-assigned this
    on Aug 24, 2021
  21. added a commit that references this issue on Aug 24, 2021
  22. added
    enhancement
    plugin
    on Sep 7, 2021
  23. matmair commented on Sep 7, 2021

    @matmair
    Member

    @SchrodingersGat could you add issues #2036, #2037, #2038 to the milestones for the plugin system as todo? I do not have sufficient rights to change anything in projects/milestones.

  24. matmair commented on Oct 19, 2021

    @matmair
    Member

    A sample implementation will be / is available as ShopifyIntegrationPlugin. Until #2074 is merged you need to use that branch for testing. Follow instructions placed in the readme for installation.

  25. wolflu05 commented on Jun 15, 2023

    @wolflu05
    Member

    @andrewwetzel23 If you have a question, please use the discussion Q&A feature instead of commenting to a really old, already closed issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementpluginroadmap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions