View close_netsuite_sales_order_with_suitetalk.rb
# Description: Example of closing a SalesOrder with the NetSuite SuiteTalk API
# Author: <mike@suitesync.io>
def close_sales_order(ns_order_id)
# If you want to pull the order associated with an invoice `ns_order_id = ns_invoice.created_from.internal_id`
ns_order = NetSuite::Utilities.get_record(NetSuite::Records::SalesOrder, ns_order_id)
# http://mikebian.co/how-to-close-a-netsuite-salesorder-using-suitetalk/
View map_stripe_plans_to_netsuite.rb
# Mike Bianco <mike@suitesync.io>
# Description: Connect Stripe plans to existing NetSuite items
# Usage: map_stripe_plans_to_netsuite.rb mapping.csv
require 'stripe'
require 'csv'
Stripe.api_key = ENV['STRIPE_KEY']
View netsuite_determine_customer_for_job.rb
# Author <mike@suitesync.io>
# More info: http://mikebian.co/notes-on-working-with-jobs-projects-using-the-suitetalk-netsuite-api/
ns_job_internal_id = 123
mapping_search = NetSuite::Records::Job.search(
criteria: {
basic: [
{
field: 'internalId',
View shopify_auto_paging_each.rb
# NOTE pairs well with API request limit backoff
# https://gist.github.com/iloveitaly/cf0566bd598732c1e81bad0de1be4ff7
# https://github.com/Shopify/shopify_api/pull/339
ShopifyAPI::Base.class_eval do
def self.list(params = {})
find(:all, params: params)
end
View shopify_backoff.rb
ShopifyAPI::Connection.class_eval do
alias_method :shopify_request, :request
def request(*args)
count = 0
limit = 10
begin
count += 1
shopify_request(*args)
View stripe_ecommerce_with_relay.rb
# Michael Bianco <mike@suitesync.io>
# Usage:
#
# export STRIPE_KEY=sk_test
# gem install sinatra stripe
# ruby stripe_ecommerce_with_relay.rb
require 'stripe'
View customize_netsuite_invoice_with_subscription_metadata.rb
# Michael Bianco <mike@suitesync.io>
# Description: Customize NetSuite invoice data from Stripe Subscription
# Usage:
#
# export STRIPE_KEY=sk_test STRIPE_PUBLIC_KEY=sk_test_
# gem install sinatra stripe pry
# ruby customize_netsuite_invoice_with_subscription_metadata.rb
# open http://localhost:4567
View suitescript_retrieve_customer_id.js
// Author <mike@suitesync.io>
// ensure that an entity ID is actually a customer ID
// http://blog.prolecto.com/2016/02/12/how-to-distinguish-a-netsuite-entity-as-a-customer-vs-a-project/
function retrieveCustomerId(entityId) {
var isAdvancedJobs = nlapiGetContext().getFeature('ADVANCEDJOBS');
var customerId = entityId;
if(!isAdvancedJobs) {
View suitescript_copy_order_fields_to_transaction.js
/*
Author: <mike@suitesync.io>
Description: copies department, class, and location from the order (SalesOrder, Invoice)
to the transaction (customer deposit, customer refund, and customer payment)
Installation:
1. https://system.sandbox.netsuite.com/app/common/scripting/uploadScriptFile.nl
2. User Event
3. Name: Copy Order Fields to Transaction
4. ID: _suitesync_copy_order_fields
View suitescript_unify_and_backfill_stripe_ids.js
// Author: <mike@suitesync.io>
// Description: Scripts to copy Stripe IDs stored in multiple fields into a single field
// used by SuiteSync
// Utils
// https://gist.github.com/iloveitaly/db7d532e772b67f5b81d0199d094301f
function log(msg) {
nlapiLogExecution('DEBUG', msg);
}