Coder Social home page Coder Social logo

doom-squad / bean_counter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from acumenbrands/bean_counter

0.0 8.0 0.0 98 KB

A library for pulling inventory information from Netsuite, caching it, and writing it to a user specified location.

License: GNU General Public License v3.0

Ruby 100.00%

bean_counter's Introduction

Bean Counter

Release: 1.0

An Acumen Holdings gem for fetching and using inventory data from Netsuite. This gem decouples the fetching of data and the use of the uniquely cached data in order to allow for fast, fault-tolerant inventory level processing.

Installation

Just add the gem to your project's Gemfile:

gem 'bean_counter', git: '[email protected]:acumenbrands/bean_counter.git', tag: '1.0'

Configuration

Bean counter can either be configured at runtime or via a YAML file. If it is included in a Rails project, it will automatically attempt to configure itself from config/bean_counter.yml.

All settings can be configured at runtime by accessing the config namespace; either directly or via the configure call with a block.

# directly
BeanCounter::Config.cache_namespace = 'an-example-namespace'

# configure
BeanCounter.configure do |config|
  config.cache_namespace = 'an-example-namespace'
end

Settings

  • cache_namespace: This is the string that will be prepended to all redis keys
  • log_path: The string path to the log file to be used (Rails defaults to the rails logger instead)
  • log_level: Symbol for the default logger level (default: :error)
  • log_count: Max count of log files (default: 10)
  • log_size: Maximum size of the log files before a new file is created (default: 1048576)
  • netsuite_account_id: The account id for Netsuite access
  • netsuite_login: The login to be used for Netsuite access
  • netsuite_password: The password to be used for Netsuite access
  • netsuite_role_id: The role id to be used for Netsuite access
  • netsuite_searches: A hash of netsuite search ids (detailed below)
  • netsuite_vendor_quantity_field: Symbol of the vendor quantity field (default: custitem22)
  • netsuite_warehouse_quantity_field: Symbol of the warehouse quantity field (default: :quantityavailable)

Netsuite Searches

Netsuite searches are stores as a hash of names => ids. A convenience method on BeanCounter::NetsuiteToolbox exists for adding searches at runtime.

# example YAML
netsuite_searches:
  :example_search: '123'
  :other_search:   '456'

# via convenience method
BeanCounter::NetsuiteToolbox.add_search(:example_search, '123')
BeanCounter::NetsuiteToolbox.add_search(:other_search, '456')

# complete override
BeanCounter::Config.netsuite_searches = {
  example_search: '123',
  other_search:   '456'
}

Caching a Search

To execute and cache the results of a search in Redis:

BeanCounter.cache_search(:search_name)

Using Search Data

Bean Counter provides a class called BeanCounter::Bean to track the relationship between and item and its inventory data. To use it, in your application you will need to implement two things:

  • identifier_names: This should return an Array of Symbols that match method names which provide a sku and upc
  • update_from_cache: This should return true if an update was successful, false if an update was not

Example of a Simple Honest Engine Decorator

class HonestBean < BeanCounter::Bean

  def identifier_names
    [:upc_code, :sku_with_vendor]
  end

  def update_from_cache
    target.update_attributes(new_attributes)
    true
  rescue Exception => e # Don't actually do this, this is just a simple example
    false
  end

end

bean_counter's People

Contributors

jameschristie avatar fastjames avatar

Watchers

Christopher M. Hobbs avatar esmevane avatar  avatar Brian Sage (he/him) avatar James Cloos avatar Alex Williams avatar Mike Johnston avatar Kathryne avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.