Skip to content

Instantly share code, notes, and snippets.

@jeffreyjurgajtis
jeffreyjurgajtis / netsuite-data-setup.rb
Created August 13, 2018 13:02
NetSuite Data Setup
# These are "behind-the-scenes" setup tasks that must happen before we can
# start syncing invoice data to NetSuite.
# We'll call these "Groups" for now. These are shown to the user in the UI:
#
# ( ) Validating NetSuite Credentials
# ( ) Gathering Data from NetSuite
# ( ) Creating Custom Fields in NetSuite
[
###### New Business
transactions: [
Charge.new(
product_id: 1,
component_id: nil,
kind: "baseline",
amount_in_cents: 100_00,
memo: "Essential",
),
Charge.new(
# Customer Signs up
# $100 Advanced (Product)
# $50 Minutes (Component)
#
# -$10 Coupon One (Single Use)
# -$20 Coupon Two (Multi Use)
Sale.new(
sale_amount_in_cents: 150_00,
discount_amount_in_cents: -30_00,
# User signs up for 'free' and adds 'ip_addresses' (3 units)
# Datapoint1
# subcription.items:
[
{
product_id: free.id,
component_id: ip_addresses.id,
name: "IP Addresses",
mrr: 30_00,
mrr_movements: [{ amount: 30_00, category: "new_business" }],
#
# August 2017
# - Customer 2 renewal (+$35 plan, -$40 usage, -$5 net) overall contraction
# - Customer 3 renewal (+$50 plan, -$40 usage, +$10 net) overall expansion
# - Customer 4 renewal (-$50 plan, +$30 usage, -$20 net) overall contraction
#
# August
# expansion
# ------------
# plan 85
module MRR::Datapoint
# This class generates the `recurring_movement` object for an MRR datapoint.
class RecurringMovement
def initialize(datapoint, previous_datapoint)
@datapoint = datapoint
@previous_datapoint = previous_datapoint
end
def build
{
@jeffreyjurgajtis
jeffreyjurgajtis / gist:a731b9c779656309c06c
Created June 11, 2015 15:19
Heroku Postgres DB to local Postgres DB
Details:
https://devcenter.heroku.com/articles/heroku-postgres-backups
$ heroku pg:backups capture #=> <backup_number>
$ heroku pg:backups public-url <backup_number> #=> <backup_url>
$ curl -o latest.dump <backup_url>
(drop and re-create local database)
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
@jeffreyjurgajtis
jeffreyjurgajtis / feature_modeling.rb
Last active August 29, 2015 14:18
FeatureModeling
# models/feature.rb
class Feature
validates :name, presence: true, uniqueness: true
end
# models/feature_provider.rb
class FeatureProvider
belongs_to :feature
belongs_to :provider, polymorphic: true
@jeffreyjurgajtis
jeffreyjurgajtis / git_workflow.md
Last active January 3, 2016 15:19
Avoid merge commits
Updating your local master with origin/master

$ git checkout master
$ git fetch --all --prune
$ git rebase origin/master

Updating your feature branch with your local master

$ git checkout my-feature-branch
$ git rebase master