NS: Commish Statement Summary
// ==UserScript==
// @name Commish Screen Plus
// @namespace https://rymo.io/
// @version 0.1
// @description Add some cool enhancements to Commish screen
// @author rymo
// @match https://system.netsuite.com/app/accounting/transactions/commissn.nl?id=*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==// ==UserScript==
// @name Commish Screen Plus
// @namespace https://rymo.io/
// @version 0.1
// @description Add some cool enhancements to Commish screen
// @author rymo
// @match https://system.netsuite.com/app/accounting/transactions/commissn.nl?id=*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function () {
function objStore(basis, calculated, eligible, amount, forex) {
this.basis = basis;
this.calculated = calculated;
this.eligible = eligible;
this.amount = amount;
this.forex = forex;
}
var scope = this;
scope.total = new objStore(0, 0, 0, 0, 0);
scope.sales = new objStore(0, 0, 0, 0, 0);
scope.returns = new objStore(0, 0, 0, 0, 0);
scope.period = new objStore(0, 0, 0, 0, 0);
// iterate through all rows in the forecast
$('#bytransaction_splits tr:not(.uir-machine-headerrow)').each(function() {
var traxType = $(this).find('td:nth-child(3)').find('a').text();
var traxBasis = Number($(this).find('td:nth-child(10)').text().replace(/[^0-9\.\-]+/g,""));
var comCalc = Number($(this).find('td:nth-child(11)').text().replace(/[^0-9\.\-]+/g,""));
var comElig = Number($(this).find('td:nth-child(13)').text().replace(/[^0-9\.\-]+/g,""));
var comAmt = Number($(this).find('td:nth-child(14)').text().replace(/[^0-9\.\-]+/g,""));
var comAmtForex = Number($(this).find('td:nth-child(16)').text().replace(/[^0-9\.\-]+/g,""));
scope.type = (traxType[0] == 'R') ? 'returns' : 'sales';
scope[scope.type].basis += traxBasis;
scope[scope.type].calculated += comCalc;
scope[scope.type].eligible += comElig;
scope[scope.type].amount += comAmt;
scope[scope.type].forex += comAmtForex;
scope.total.basis += traxBasis;
scope.total.calculated += comCalc;
scope.total.eligible += comElig;
scope.total.amount += comAmt;
scope.total.forex += comAmtForex;
});
$('#byperiod_splits tr:not(.uir-machine-headerrow)').each(function() {
var traxBasis = Number($(this).find('td:nth-child(7)').text().replace(/[^0-9\.\-]+/g,""));
var comCalc = Number($(this).find('td:nth-child(8)').text().replace(/[^0-9\.\-]+/g,""));
var comElig = Number($(this).find('td:nth-child(10)').text().replace(/[^0-9\.\-]+/g,""));
var comAmt = Number($(this).find('td:nth-child(11)').text().replace(/[^0-9\.\-]+/g,""));
var comAmtForex = Number($(this).find('td:nth-child(13)').text().replace(/[^0-9\.\-]+/g,""));
scope.type = 'period';
scope[scope.type].amount += comAmt;
scope[scope.type].forex += comAmtForex;
scope.total.amount += comAmt;
scope.total.forex += comAmtForex;
});
console.log(scope);
/**
* *******************************************************************************************
* Begin HTML content for header info
* *******************************************************************************************
*/
var content = '' +
'<div id="uir-summary-section" class="uir_filters collapsed" style="background-color:#EFF3D7;">' +
'<div class="uir_filters_body uir_summary_body">' +
'<table style="width:100%;border-collapse:collapse">' +
'<tbody>' +
// Header summary row
'<tr>' +
'<td style="text-align:left;padding-bottom:10px"><h2 style="color:#34495e;font-style:bold">Commish Summary' +
'<td style="text-align:right;padding-bottom:10px"><h2 style="color:#34495e;font-style:bold">Basis: ' +
scope.total.basis.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;padding-bottom:10px"><h2 style="color:#34495e;font-style:bold">Calculated: ' +
scope.total.calculated.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;padding-bottom:10px"><h2 style="color:#34495e;font-style:bold">Eligible: ' +
scope.total.eligible.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;padding-bottom:10px"><h2 style="color:#34495e;font-style:bold">Amount: ' +
scope.total.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;padding-bottom:10px"><h2 style="color:#34495e;font-style:bold">Forex Amount: ' +
scope.total.forex.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'</tr>' +
// Detail Rows - Sales
'<tr>' +
'<td style="text-align:left;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Sales Summary' +
'<td style="text-align:right;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Basis: ' +
scope.sales.basis.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Calculated: ' +
scope.sales.calculated.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Eligible: ' +
scope.sales.eligible.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Amount: ' +
scope.sales.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Forex Amount: ' +
scope.sales.forex.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'</tr>' +
// Detail Rows - Returns
'<tr>' +
'<td style="text-align:left;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Returns Summary' +
'<td style="text-align:right;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Basis: ' +
scope.returns.basis.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Calculated: ' +
scope.returns.calculated.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Eligible: ' +
scope.returns.eligible.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Amount: ' +
scope.returns.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Forex Amount: ' +
scope.returns.forex.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'</tr>' +
// Detail Rows - By Period
'<tr>' +
'<td style="text-align:left;font-style:italic;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">By Period Summary' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">N/A' +
'</h2></td>' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">N/A' +
'</h2></td>' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">N/A' +
'</h2></td>' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Amount: ' +
scope.period.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e;padding-top:5px"><h2 style="color:#34495e;font-weight:normal">Forex Amount: ' +
scope.period.forex.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>' +
'</div>'
;
// $('#div__footer').prepend(content);
$('#liabilities_wrapper').prepend(content);
$('#div__body').css('height', $( window ).height() / 2);
$('#uir-summary-section').click(function() {
$(this).toggleClass('collapsed');
$('#div__body').css('height', $( window ).height() / 2);
});
}).call({});
(function () {
function objStore(basis, calculated, eligible, amount, forex) {
this.basis = basis;
this.calculated = calculated;
this.eligible = eligible;
this.amount = amount;
this.forex = forex;
}
var scope = this;
scope.total = new objStore(0, 0, 0, 0, 0);
scope.sales = new objStore(0, 0, 0, 0, 0);
scope.returns = new objStore(0, 0, 0, 0, 0);
scope.period = new objStore(0, 0, 0, 0, 0);
// iterate through all rows in the forecast
$('#bytransaction_splits tr:not(.uir-machine-headerrow)').each(function() {
var traxType = $(this).find('td:nth-child(3)').find('a').text();
var traxBasis = Number($(this).find('td:nth-child(10)').text().replace(/[^0-9\.\-]+/g,""));
var comCalc = Number($(this).find('td:nth-child(11)').text().replace(/[^0-9\.\-]+/g,""));
var comElig = Number($(this).find('td:nth-child(13)').text().replace(/[^0-9\.\-]+/g,""));
var comAmt = Number($(this).find('td:nth-child(14)').text().replace(/[^0-9\.\-]+/g,""));
var comAmtForex = Number($(this).find('td:nth-child(16)').text().replace(/[^0-9\.\-]+/g,""));
scope.type = (traxType[0] == 'R') ? 'returns' : 'sales';
scope[scope.type].basis += traxBasis;
scope[scope.type].calculated += comCalc;
scope[scope.type].eligible += comElig;
scope[scope.type].amount += comAmt;
scope[scope.type].forex += comAmtForex;
scope.total.basis += traxBasis;
scope.total.calculated += comCalc;
scope.total.eligible += comElig;
scope.total.amount += comAmt;
scope.total.forex += comAmtForex;
});
$('#byperiod_splits tr:not(.uir-machine-headerrow)').each(function() {
var traxBasis = Number($(this).find('td:nth-child(7)').text().replace(/[^0-9\.\-]+/g,""));
var comCalc = Number($(this).find('td:nth-child(8)').text().replace(/[^0-9\.\-]+/g,""));
var comElig = Number($(this).find('td:nth-child(10)').text().replace(/[^0-9\.\-]+/g,""));
var comAmt = Number($(this).find('td:nth-child(11)').text().replace(/[^0-9\.\-]+/g,""));
var comAmtForex = Number($(this).find('td:nth-child(13)').text().replace(/[^0-9\.\-]+/g,""));
scope.type = 'period';
scope[scope.type].basis += traxBasis;
scope[scope.type].calculated += comCalc;
scope[scope.type].eligible += comElig;
scope[scope.type].amount += comAmt;
scope[scope.type].forex += comAmtForex;
scope.total.basis += traxBasis;
scope.total.calculated += comCalc;
scope.total.eligible += comElig;
scope.total.amount += comAmt;
scope.total.forex += comAmtForex;
});
console.log(scope);
/**
* *******************************************************************************************
* Begin HTML content for header info
* *******************************************************************************************
*/
var content = '' +
'<div id="uir-summary-section" class="uir_filters collapsed" style="background-color:#EFF3D7;">' +
'<div class="uir_filters_body uir_summary_body">' +
'<table style="width:100%">' +
'<tbody>' +
// Header summary row
'<tr>' +
'<td style="text-align:left"><h2 style="color:#34495e;font-style:bold">Commish Summary' +
'<td style="text-align:right"><h2 style="color:#34495e;font-style:bold">Basis: ' +
scope.total.basis.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right"><h2 style="color:#34495e;font-style:bold">Calculated: ' +
scope.total.calculated.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right"><h2 style="color:#34495e;font-style:bold">Eligible: ' +
scope.total.eligible.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right"><h2 style="color:#34495e;font-style:bold">Amount: ' +
scope.total.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right"><h2 style="color:#34495e;font-style:bold">Forex Amount: ' +
scope.total.forex.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'</tr>' +
// Detail Rows - Sales
'<tr>' +
'<td style="text-align:left;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Sales Summary' +
'<td style="text-align:right;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Basis: ' +
scope.sales.basis.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Calculated: ' +
scope.sales.calculated.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Eligible: ' +
scope.sales.eligible.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Amount: ' +
scope.sales.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Forex Amount: ' +
scope.sales.forex.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'</tr>' +
// Detail Rows - Returns
'<tr>' +
'<td style="text-align:left"><h2 style="color:#34495e;font-weight:normal">Returns Summary' +
'<td style="text-align:right"><h2 style="color:#34495e;font-weight:normal">Basis: ' +
scope.returns.basis.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right"><h2 style="color:#34495e;font-weight:normal">Calculated: ' +
scope.returns.calculated.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right"><h2 style="color:#34495e;font-weight:normal">Eligible: ' +
scope.returns.eligible.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right"><h2 style="color:#34495e;font-weight:normal">Amount: ' +
scope.returns.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right"><h2 style="color:#34495e;font-weight:normal">Forex Amount: ' +
scope.returns.forex.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'</tr>' +
// Detail Rows - By Period
'<tr>' +
'<td style="text-align:left;font-style:italic;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">By Period Summary' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Basis: ' +
scope.period.basis.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Calculated: ' +
scope.period.calculated.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Eligible: ' +
scope.period.eligible.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Amount: ' +
scope.period.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'<td style="text-align:right;font-style:italic;border-top:1px solid #34495e"><h2 style="color:#34495e;font-weight:normal">Forex Amount: ' +
scope.period.forex.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,") +
'</h2></td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</div>' +
'</div>'
;
// $('#div__footer').prepend(content);
$('#liabilities_wrapper').prepend(content);
$('#div__body').css('height', $( window ).height() / 2);
$('#uir-summary-section').click(function() {
$(this).toggleClass('collapsed');
$('#div__body').css('height', $( window ).height() / 2);
});
}).call({});