Skip to content

Instantly share code, notes, and snippets.

@23maverick23
23maverick23 / fiscal_date_convert.sql
Last active Jan 12, 2021
NS: Fiscal date conversion (Convert calendar date to fiscal date - Return sortable string)
View fiscal_date_convert.sql
-- Convert calendar date to Oracle fiscal month (MM-MON)
CASE WHEN MOD(TO_NUMBER(TO_CHAR({date_field}, 'MM')), 12) >= 6 THEN TO_CHAR(MOD(TO_NUMBER(TO_CHAR({date_field}, 'MM')), 12) - 5, '09') ELSE TO_CHAR(MOD(TO_NUMBER(TO_CHAR({date_field}, 'MM')), 12) + 7, '09') END || '-' || TO_CHAR({date_field}, 'MON')
-- Convert calendar date to Oracle fiscal quarter (Q#)
CASE WHEN TO_CHAR({date_field}, 'MM') IN ('06', '07', '08') THEN 'Q1' WHEN TO_CHAR({date_field}, 'MM') IN ('09', '10', '11') THEN 'Q2' WHEN TO_CHAR({date_field}, 'MM') IN ('12', '01', '02') THEN 'Q3' WHEN TO_CHAR({date_field}, 'MM') IN ('03', '04', '05') THEN 'Q4' END
-- Convert calendar date to Oracle fiscal year (YYYY)
CASE WHEN TO_NUMBER(TO_CHAR({date_field}, 'MM')) < 6 THEN TO_CHAR(TO_NUMBER(TO_CHAR({date_field}, 'YYYY')) - 1, '9999') ELSE TO_CHAR(TO_NUMBER(TO_CHAR({date_field}, 'YYYY')), '9999') END
@23maverick23
23maverick23 / chart_by_item_type.ftl
Created Dec 16, 2020
NS: Freemarker PDF Template - Chart by Item Type
View chart_by_item_type.ftl
<table align="left" border="0" width="100%">
<tr>
<td>
<piegraph width="150" height="150" display-key="flat-outer">
<#assign previous_itemtype = "">
<#assign item_name = "">
<#list record.item?sort_by('itemtype') as item>
<#if item.itemtype != previous_itemtype>
<#assign current_itemtype = item.itemtype>
@23maverick23
23maverick23 / customerUuidBeforeSave.ns.js
Created Aug 19, 2020
NS: Generate a unique UUID for a Customer
View customerUuidBeforeSave.ns.js
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
// Load two standard modules.
define ( ['N/record', 'N/search', 'N/ui/serverWidget'] ,
// Add the callback function.
function(record, search, serverWidget) {
@23maverick23
23maverick23 / chart011.js
Created Aug 14, 2020
NS: Chart 011 (Engagement Trend)
View chart011.js
function getData() {
var recordType = "customrecord_sc_request";
var searchId = "customsearch_rcm_dealtracker_timeline";
var results = nlapiSearchRecord(recordType, searchId);
var _data = null;
var categories = [];
if (!results || results.length === 0) { return None; }
@23maverick23
23maverick23 / chart012.js
Last active Aug 14, 2020
NS: Chart 012 (Heatmap)
View chart012.js
function getData() {
var recordType = "customrecord_sc_request";
var searchId = "customsearch_scm_eng_by_sc_12_mos";
var results = nlapiSearchRecord(recordType, searchId);
if (!results || results.length === 0) { return None; }
var data_all = [];
function DataEntry(x, y) {
@23maverick23
23maverick23 / fix_schedule_exception.js
Created Jul 17, 2020
OA: Fix timesheet exception bug (Tampermonkey)
View fix_schedule_exception.js
// ==UserScript==
// @name DEMO: Hide OpenAir schedule exception icons (bug workaround; 17 Jul 2020)
// @namespace http://rymo.io/
// @version 0.1
// @description DEMO: Hides all schedule exception icons on the timesheet.
// @author @rymoio
// @match https://demo.openair.com/timesheet.pl?*
// @run-at document-idle
// @grant none
// ==/UserScript==
View notion_progress_bar.txt
slice("●●●●●●●●●●", 0, floor(prop("Progress") * 10)) + slice("◌◌◌◌◌◌◌◌◌◌", 0, ceil((1 - prop("Progress")) * 10)) + " " + format(prop("Progress") * 100) + "%"
View notion_due_this_week.txt
(formatDate(prop("Due Date"), "YW") == formatDate(now(), "YW")) ? true : false
View notion_days_until_due.txt
if(empty(prop("Due Date")), "N/A", if(dateBetween(prop("Due Date"), now(), "days") + 1 < 0, "Past Due", if(dateBetween(prop("Due Date"), now(), "days") + 1 == 0, "Today", if(dateBetween(prop("Due Date"), now(), "days") + 1 == 1, "Tomorrow", format(dateBetween(prop("Due Date"), now(), "days") + 1) + " days"))))
@23maverick23
23maverick23 / nodemon_heroku_local.sh
Created Jan 3, 2020
Reload Heroku local on any file change
View nodemon_heroku_local.sh
# https://stackoverflow.com/questions/34146236/restart-heroku-local-on-file-change
nodemon --exec "heroku local" --signal SIGTERM