This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def value_for(resource, methods) | |
unless methods.is_a?(Array) | |
resource.respond_to?(methods) ? resource.send(methods) : '' | |
else | |
methods.inject(resource) {|resource, method| resource.respond_to?(method) ? resource.send(method) : ''} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.validatesNumericality = function(options) { | |
return this.each(function() { | |
var el = $(this); | |
// TODO: I18n | |
var thousandsSep = ','; | |
var decimalSep = '.'; | |
var settings = $.extend({ | |
invalidClass: 'invalid-numericality', | |
onlyInteger: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
$ns('mnbb.global'); | |
var Util = mnbb.global.Util = function () { | |
var DECIMAL_SEP = '.'; | |
var THOUSANDS_SEP = ','; | |
function eachIsNumber (strs) { | |
for(var i = 0; i < strs.length; i++ ) { | |
if (isNaN(strs[i])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NameError in Services#index | |
Showing app/views/layouts/application.html.erb where line #13 raised: | |
`@gbl_mast-head' is not allowed as an instance variable name | |
Extracted source (around line #13): | |
10: <%= yield :stylesheets %> | |
11: </head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionController::Routing::Routes.draw do |map| | |
# The priority is based upon order of creation: first created -> highest priority. | |
# Sample of regular route: | |
# map.connect 'products/:id', :controller => 'catalog', :action => 'view' | |
# Keep in mind you can assign values other than :controller and :action | |
# Sample of named route: | |
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' | |
# This route can be invoked with purchase_url(:id => product.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# InventoryAdjustmentTransaction | |
def validate | |
return unless @item_id || !inventory_adjustment_entry.item | |
item = (self.inventory_adjustment_entry && self.inventory_adjustment_entry.item) || Item.find(@item_id) | |
if item.date_qty_falls_below_zero(inventory_adjustment_entry) | |
errors.add('item_qty', 'Cannot cause inventory qty to fall below zero.') | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MigrateCoaInventoryAndCogs < ActiveRecord::Migration | |
def self.up | |
Subscriber.all.each do |subscriber| | |
ApplicationGlobals.subscriber = subscriber | |
#Inventory Asset Account | |
inv_asset = Account.find_by_path("Inventory Asset") | |
if inv_asset && inv_asset.children.any? | |
inv_asset.update_attributes!(:name => 'Inventory Asset - Original') | |
inv_asset = nil | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.currActive; | |
$.imageCount; | |
$.fn.preCacheImageFromThumb = function () { | |
return $(this).each(function () { | |
var img = new Image(); | |
img.src = $(this).attr('href'); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def adjust_wac(time = Time.zone.now) | |
adjustment_date = time.beginning_of_day | |
qty = value = '0'.to_d | |
transaction do | |
# Compute WAC as of specified time.....then adjust future inventory adjustment entries | |
first_entry = true | |
(inv_adj_entries = inventory_adjustment_entries.find_all).each do |entry| | |
if entry.posted_date >= adjustment_date and !first_entry | |
# Adjust future entries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def qty_available_for_sale(as_of = Time.zone.new) | |
qty = wac_and_qty(as_of)[1] | |
inventory_adjustment_entries.find_after(as_of).each do |entry| | |
qty = qty + (entry.debit_credit_flag == 'Debit' ? entry.item_qty : -entry.item_qty) | |
min_qty = [qty, min_qty].min | |
end | |
qty | |
end |
OlderNewer