Skip to content

Instantly share code, notes, and snippets.

Avatar

Piyush Goel goelp

View GitHub Profile
@goelp
goelp / gas_qbo_oauth2.js
Last active Sep 23, 2021
Google Apps Script OAuth2 script for QuickBooks integration with Google Sheets
View gas_qbo_oauth2.js
var CLIENT_ID = '...'; // Get from Quickbooks Developer Console
var CLIENT_SECRET = '...'; // Get from Quickbooks Developer Console
var BASE_AUTH_URL = 'https://appcenter.intuit.com/connect/oauth2';
var TOKEN_URL = 'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer';
var API_SCOPE = 'com.intuit.quickbooks.accounting';
var REDIRECT_URI = '...'; // Generate using the logRedirectUri() function mentioned at the end of this script
var RESPONSE_TYPE = 'code';
/**
* Authorizes and makes a request to the Quickbooks API using OAuth 2.
@goelp
goelp / pick_range_sidebar.html
Last active May 1, 2020
Sidebar HTML code to show fields and buttons to select the range
View pick_range_sidebar.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
</head>
<body>
<div class="sidebar branding-below">
<div class="block form-group">
<label for="names-range"><b>Comissions</b></label>
@goelp
goelp / quickbooks_js_timezone.js
Last active Apr 11, 2018
Timezone conversion in Javascript for Quickbooks API
View quickbooks_js_timezone.js
/** Add hours to a given date object **/
Date.prototype.addHours = function(h) {
this.setTime(this.getTime() + (h*60*60*1000));
return this;
}
/** overall function to create QBO invoices **/
function generateInvoices(){
...
var invoiceDate = new Date();
@goelp
goelp / pick_range.js
Created Mar 27, 2018
Google Apps Script functions to pick a range and populate in text field in sidebar
View pick_range.js
// Add the options to the custom menu
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.createMenu('Custom Menu')
.addItem('Show Settings', 'showSidebar')
.addToUi();
}
// initiates the sidebar
function showSidebar() {