From 2c66ae4dd6fc339808038116ef5180996be896dc Mon Sep 17 00:00:00 2001 From: Nathan Bruer Date: Tue, 27 Oct 2015 00:41:12 -0500 Subject: [PATCH 1/6] Added compiled version for nodejs --- compiled/get_caret_pos.js | 76 ++ compiled/pql/PQL.js | 115 +++ compiled/pql/config.js | 4 + compiled/pql/opcodes.js | 3 + compiled/pql/opcodes/and.js | 36 + .../pql/opcodes/comparitors/comparitor.js | 82 ++ compiled/pql/opcodes/comparitors/equal.js | 73 ++ .../pql/opcodes/comparitors/greater_than.js | 71 ++ compiled/pql/opcodes/comparitors/less_than.js | 71 ++ compiled/pql/opcodes/comparitors/like.js | 94 +++ compiled/pql/opcodes/comparitors/no_value.js | 42 + compiled/pql/opcodes/comparitors/not_equal.js | 74 ++ compiled/pql/opcodes/comparitors/not_like.js | 94 +++ compiled/pql/opcodes/constant.js | 71 ++ compiled/pql/opcodes/constants_array.js | 36 + compiled/pql/opcodes/field.js | 91 +++ compiled/pql/opcodes/function.js | 200 +++++ compiled/pql/opcodes/group.js | 131 +++ compiled/pql/opcodes/null.js | 36 + compiled/pql/opcodes/opcode.js | 57 ++ compiled/pql/opcodes/or.js | 36 + compiled/pql/opcodes/seperator.js | 36 + compiled/pql/opcodes/seperators.js | 36 + compiled/pql/opcodes/variable.js | 94 +++ compiled/pql/parser.js | 761 ++++++++++++++++++ compiled/pql/parser/comparitors.js | 87 ++ compiled/pql/parser/sql_builder.js | 304 +++++++ compiled/pql/parser/table_ref.js | 62 ++ compiled/pql/pql_query.js | 25 + compiled/unit_test/test_config.js | 699 ++++++++++++++++ compiled/unit_test/tests/compare.js | 211 +++++ compiled/unit_test/tests/constants.js | 48 ++ compiled/unit_test/tests/cross_table.js | 35 + compiled/unit_test/tests/functions.js | 244 ++++++ compiled/unit_test/tests/group_by.js | 32 + compiled/unit_test/tests/groups.js | 35 + compiled/unit_test/tests/order_by.js | 62 ++ compiled/unit_test/tests/selects.js | 60 ++ compiled/unit_test/tests/seperators.js | 50 ++ compiled/unit_test/tests/variable.js | 89 ++ 40 files changed, 4463 insertions(+) create mode 100644 compiled/get_caret_pos.js create mode 100644 compiled/pql/PQL.js create mode 100644 compiled/pql/config.js create mode 100644 compiled/pql/opcodes.js create mode 100644 compiled/pql/opcodes/and.js create mode 100644 compiled/pql/opcodes/comparitors/comparitor.js create mode 100644 compiled/pql/opcodes/comparitors/equal.js create mode 100644 compiled/pql/opcodes/comparitors/greater_than.js create mode 100644 compiled/pql/opcodes/comparitors/less_than.js create mode 100644 compiled/pql/opcodes/comparitors/like.js create mode 100644 compiled/pql/opcodes/comparitors/no_value.js create mode 100644 compiled/pql/opcodes/comparitors/not_equal.js create mode 100644 compiled/pql/opcodes/comparitors/not_like.js create mode 100644 compiled/pql/opcodes/constant.js create mode 100644 compiled/pql/opcodes/constants_array.js create mode 100644 compiled/pql/opcodes/field.js create mode 100644 compiled/pql/opcodes/function.js create mode 100644 compiled/pql/opcodes/group.js create mode 100644 compiled/pql/opcodes/null.js create mode 100644 compiled/pql/opcodes/opcode.js create mode 100644 compiled/pql/opcodes/or.js create mode 100644 compiled/pql/opcodes/seperator.js create mode 100644 compiled/pql/opcodes/seperators.js create mode 100644 compiled/pql/opcodes/variable.js create mode 100644 compiled/pql/parser.js create mode 100644 compiled/pql/parser/comparitors.js create mode 100644 compiled/pql/parser/sql_builder.js create mode 100644 compiled/pql/parser/table_ref.js create mode 100644 compiled/pql/pql_query.js create mode 100644 compiled/unit_test/test_config.js create mode 100644 compiled/unit_test/tests/compare.js create mode 100644 compiled/unit_test/tests/constants.js create mode 100644 compiled/unit_test/tests/cross_table.js create mode 100644 compiled/unit_test/tests/functions.js create mode 100644 compiled/unit_test/tests/group_by.js create mode 100644 compiled/unit_test/tests/groups.js create mode 100644 compiled/unit_test/tests/order_by.js create mode 100644 compiled/unit_test/tests/selects.js create mode 100644 compiled/unit_test/tests/seperators.js create mode 100644 compiled/unit_test/tests/variable.js diff --git a/compiled/get_caret_pos.js b/compiled/get_caret_pos.js new file mode 100644 index 0000000..8bee5e8 --- /dev/null +++ b/compiled/get_caret_pos.js @@ -0,0 +1,76 @@ +/* jshint browser: true */ + +// The properties that we copy into a mirrored div. +// Note that some browsers, such as Firefox, +// do not concatenate properties, i.e. padding-top, bottom etc. -> padding, +// so we have to do every single property specifically. +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.getCaretCoordinates = getCaretCoordinates; +var properties = ['direction', // RTL support +'boxSizing', 'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does +'height', 'overflowX', 'overflowY', // copy the scrollbar for IE + +'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderStyle', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', + +// https://developer.mozilla.org/en-US/docs/Web/CSS/font +'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch', 'fontSize', 'fontSizeAdjust', 'lineHeight', 'fontFamily', 'textAlign', 'textTransform', 'textIndent', 'textDecoration', // might not make a difference, but better be safe + +'letterSpacing', 'wordSpacing', 'tabSize', 'MozTabSize']; + +var isFirefox = window.mozInnerScreenX != null; + +function getCaretCoordinates(element, position) { + // mirrored div + var div = document.createElement('div'); + div.id = 'input-textarea-caret-position-mirror-div'; + document.body.appendChild(div); + + var style = div.style; + var computed = window.getComputedStyle ? getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9 + + // default textarea styles + style.whiteSpace = 'nowrap'; + if (element.nodeName !== 'INPUT') style.wordWrap = 'nowrap'; // only for textarea-s + + // position off-screen + style.position = 'absolute'; // required to return coordinates properly + style.visibility = 'hidden'; // not 'display: none' because we want rendering + + // transfer the element's properties to the div + properties.forEach(function (prop) { + style[prop] = computed[prop]; + }); + + if (isFirefox) { + // Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275 + if (element.scrollHeight > parseInt(computed.height)) style.overflowY = 'scroll'; + } else { + style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll' + } + + div.textContent = element.value.substring(0, position); + // the second special handling for input type="text" vs textarea: spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037 + if (element.nodeName === 'INPUT') div.textContent = div.textContent.replace(/\s/g, ' '); + + var span = document.createElement('span'); + // Wrapping must be replicated *exactly*, including when a long word gets + // onto the next line, with whitespace at the end of the line before (#7). + // The *only* reliable way to do that is to copy the *entire* rest of the + // textarea's content into the created at the caret position. + // for inputs, just '.' would be enough, but why bother? + span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all + div.appendChild(span); + + var coordinates = { + top: span.offsetTop + parseInt(computed['borderTopWidth']), + left: span.offsetLeft + parseInt(computed['borderLeftWidth']) + }; + + document.body.removeChild(div); + + return coordinates; +} \ No newline at end of file diff --git a/compiled/pql/PQL.js b/compiled/pql/PQL.js new file mode 100644 index 0000000..f6fc211 --- /dev/null +++ b/compiled/pql/PQL.js @@ -0,0 +1,115 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +var _parserJs = require('./parser.js'); + +var _parserSql_builderJs = require('./parser/sql_builder.js'); + +var PQL = (function () { + function PQL() { + _classCallCheck(this, PQL); + } + + _createClass(PQL, null, [{ + key: 'getSQL', + value: function getSQL(_ref) { + var _this = this; + + var query = _ref.query; + var table = _ref.table; + var group = _ref.group; + var selects = _ref.selects; + var orderBys = _ref.orderBys; + var variables = _ref.variables; + + var query_parser = new _parserJs.PARSER(query, table, false, this.defaultConfig, [], variables); + if (query_parser.hasError()) { + throw query_parser.getError(); + } + + if (group === undefined) { + group = 'id'; + } + var group_parser = new _parserJs.PARSER(group, table, true, this.defaultConfig, [], variables); + if (group_parser.hasError()) { + throw group_parser.getError(); + } + + var select_parsers = new Map(); + if (selects instanceof Map) { + selects.forEach(function (v, k) { + var val = new _parserJs.PARSER(v, table, false, _this.defaultConfig, [], variables); + if (val.hasError()) { + throw val.getError(); + } + select_parsers.set(k, val); + }); + } else { + for (var k in selects) { + if (selects.hasOwnProperty(k)) { + var v = new _parserJs.PARSER(selects[k], table, false, this.defaultConfig, [], variables); + if (v.hasError()) { + throw v.getError(); + } + select_parsers.set(k, v); + } + } + } + + var order_by_parsers = new Map(); + if (orderBys instanceof Map) { + orderBys.forEach(function (v, k) { + // This one is backwards... be warned that k is the string v is the [desc, asc] + var val = new _parserJs.PARSER(k, table, false, _this.defaultConfig, [], variables); + if (val.hasError()) { + throw val.getError(); + } + order_by_parsers.set(val, v); + }); + } else { + for (var k in orderBys) { + if (orderBys.hasOwnProperty(k)) { + var v = new _parserJs.PARSER(k, table, false, this.defaultConfig, [], variables); + if (v.hasError()) { + throw v.getError(); + } + order_by_parsers.set(v, orderBys[k]); + } + } + } + + var sb = new _parserSql_builderJs.SQL_BUILDER({ + query: query_parser, + table: table, + group: group_parser, + selects: select_parsers, + orderBys: order_by_parsers + }); + return sb.toString(); + } + }, { + key: 'setDefaultConfig', + value: function setDefaultConfig(config) { + PQL._defaultConfig = config; + } + }, { + key: 'defaultConfig', + get: function get() { + return PQL._defaultConfig; + }, + set: function set(v) { + PQL._defaultConfig = v; + } + }]); + + return PQL; +})(); + +exports.PQL = PQL; \ No newline at end of file diff --git a/compiled/pql/config.js b/compiled/pql/config.js new file mode 100644 index 0000000..8a68d7f --- /dev/null +++ b/compiled/pql/config.js @@ -0,0 +1,4 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _opcodesComparitorsEqualJs=require('./opcodes/comparitors/equal.js');var _opcodesComparitorsGreater_thanJs=require('./opcodes/comparitors/greater_than.js');var _opcodesComparitorsLess_thanJs=require('./opcodes/comparitors/less_than.js');var _opcodesComparitorsLikeJs=require('./opcodes/comparitors/like.js');var _opcodesComparitorsNo_valueJs=require('./opcodes/comparitors/no_value.js');var _opcodesComparitorsNot_equalJs=require('./opcodes/comparitors/not_equal.js');var _opcodesComparitorsNot_likeJs=require('./opcodes/comparitors/not_like.js');var _opcodesConstants_arrayJs=require('./opcodes/constants_array.js');var _opcodesNullJs=require('./opcodes/null.js');var Config=(function(){function Config(){_classCallCheck(this,Config);} /* Database types */_createClass(Config,null,[{key:"ALL_ARGS",value:function ALL_ARGS(args){return args.join(', ');}}]);return Config;})();exports.Config = Config;Config.NUMERIC = {is_numeric:true};Config.DATE = {is_numeric:false};Config.STRING = {is_numeric:false};Config.BOOLEAN = {is_numeric:true};Config.ANY_TYPE = {is_numeric:false}; /* These are to make it easier to read the code for the function definitions */Config.ARG1 = 0;Config.ARG2 = 1;Config.ARG3 = 2;Config.ARG4 = 3;Config.ARG5 = 4;Config.ARG6 = 5;Config.ARG7 = 6;Config.ARG8 = 7;Config.DB_MAP = {"bill":{"name":"bills","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"invoice_number":{"type":Config.STRING},"purchase_id":{"type":Config.NUMERIC},"invoice_date":{"type":Config.DATE},"notes":{"type":Config.STRING},"payment_status":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"due_date":{"type":Config.DATE},"accounting_system_id":{"type":Config.STRING},"vendor_id":{"type":Config.NUMERIC},"effective_date":{"type":Config.DATE},"invoice_amount":{"type":Config.NUMERIC},"shipping_cost":{"type":Config.NUMERIC},"discount_amount":{"type":Config.NUMERIC},"tax_amount":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"date_closed":{"type":Config.DATE},"currency":{"type":Config.STRING},"type":{"type":Config.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"}},"linkFrom":{"shipment":{"table":"shipment","pql":"eq(shipment.bill_id,id)"},"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.bill_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Bill\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Bill\")"}}},"booking":{"name":"bookings","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_attn":{"type":Config.STRING},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"brand_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"customer_po":{"type":Config.STRING},"sales_rep_id":{"type":Config.NUMERIC},"total":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Booking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Booking\")"}}},"brand":{"name":"brands","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"brand_names":{"type":Config.STRING},"parent_id":{"type":Config.NUMERIC},"active":{"type":Config.BOOLEAN},"website":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.NUMERIC},"warehouse_use_vendor_num":{"type":Config.BOOLEAN}},"linkTo":{"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"parent":{"table":"brand","pql":"eq(parent_id,parent.id)"}},"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.brand_id,id)"},"products":{"table":"product","pql":"eq(products.brand_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Brand\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Brand\")"}}},"carrier":{"name":"carriers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"scac_code":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"shipment_methods":{"table":"shipment_method","pql":"eq(shipment_methods.carrier_id,id)"}}},"contact":{"name":"contacts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"last_name":{"type":Config.STRING},"address1":{"type":Config.STRING},"address2":{"type":Config.STRING},"city":{"type":Config.STRING},"state":{"type":Config.STRING},"zip":{"type":Config.STRING},"country":{"type":Config.STRING},"email":{"type":Config.STRING},"phone":{"type":Config.STRING},"timezone_id":{"type":Config.NUMERIC},"contact_hours":{"type":Config.STRING},"notes":{"type":Config.STRING},"fax":{"type":Config.STRING},"alt_phone":{"type":Config.STRING},"fax_optout":{"type":Config.BOOLEAN},"email_optout":{"type":Config.BOOLEAN},"postal_optout":{"type":Config.BOOLEAN},"customer_id":{"type":Config.NUMERIC},"brand_id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"parent_contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"status":{"type":Config.NUMERIC}},"linkTo":{"timezone":{"table":"timezone","pql":"eq(timezone_id,timezone.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"parent_contact":{"table":"contact","pql":"eq(parent_contact_id,parent_contact.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.billing_contact_id,id)"},"customers_shipping":{"table":"customer","pql":"eq(customers_shipping.primary_shipping_contact_id,id)"},"customers_billing":{"table":"customer","pql":"eq(customers_billing.primary_billing_contact_id,id)"},"customers_primary":{"table":"customer","pql":"eq(customers_primary.primary_contact_id,id)"},"users":{"table":"user","pql":"eq(users.contact_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.contact_id,id)"},"brands":{"table":"brand","pql":"eq(brands.contact_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.primary_contact_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.contact_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Contact\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Contact\")"}}},"control_flag":{"name":"control_flags","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"control_key_id":{"type":Config.NUMERIC},"value":{"type":Config.STRING},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC}},"linkTo":{"control_key":{"table":"control_key","pql":"eq(control_key_id,control_key.id)"}},"linkFrom":[]},"control_key":{"name":"control_keys","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"key":{"type":Config.STRING},"module_flags":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"control_flags":{"table":"control_flag","pql":"eq(control_flags.control_key_id,id)"}}},"customer":{"name":"customers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"primary_rep_id":{"type":Config.NUMERIC},"current_credit":{"type":Config.NUMERIC},"max_credit_amount":{"type":Config.NUMERIC},"primary_contact_id":{"type":Config.NUMERIC},"primary_billing_contact_id":{"type":Config.NUMERIC},"primary_shipping_contact_id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"website":{"type":Config.STRING},"term_id":{"type":Config.NUMERIC},"resale_tax_number":{"type":Config.STRING},"territory_id":{"type":Config.NUMERIC},"federal_id":{"type":Config.STRING},"dunns":{"type":Config.STRING},"tax_code_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.STRING},"status":{"type":Config.NUMERIC},"parent_customer_id":{"type":Config.NUMERIC},"unpaid_invoice_amount":{"type":Config.NUMERIC},"primary_shipment_method_id":{"type":Config.NUMERIC},"primary_shipment_account_id":{"type":Config.NUMERIC}},"linkTo":{"rep":{"table":"user","pql":"eq(primary_rep_id,rep.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"billing_contact":{"table":"contact","pql":"eq(primary_billing_contact_id,billing_contact.id)"},"shipping_contact":{"table":"contact","pql":"eq(primary_shipping_contact_id,shipping_contact.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"territory":{"table":"territory","pql":"eq(territory_id,territory.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"parent_customer":{"table":"customer","pql":"eq(parent_customer_id,parent_customer.id)"},"primary_shipment_method":{"table":"shipment_method","pql":"eq(primary_shipment_method_id,primary_shipment_method.id)"},"primary_shipment_account":{"table":"shipment_account","pql":"eq(primary_shipment_account_id,primary_shipment_account.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.customer_id,id)"},"payments":{"table":"payment","pql":"eq(payments.customer_id,id)"},"invoices":{"table":"invoice","pql":"eq(invoices.customer_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.customer_id,id)"},"orders":{"table":"order","pql":"eq(orders.customer_id,id)"},"child_customers":{"table":"customer","pql":"eq(child_customers.parent_customer_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer\")"},"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.customer_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer\")"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.customer_id,id)"},"customer_notifications":{"table":"customers_notifications","pql":"eq(customer_notifications.customer_id,id)"}}},"customer_franchises":{"name":"customer_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"dont_purge":{"type":Config.BOOLEAN}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer_Franchises\")"}}},"customers_notifications":{"name":"customers_notifications","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING},"contact_method":{"type":Config.STRING},"contact_data":{"type":Config.STRING},"contact_name":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customers_Notifications\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customers_Notifications\")"}}},"cycle_count":{"name":"cycle_counts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"date_created":{"type":Config.DATE},"date_completed":{"type":Config.DATE},"active":{"type":Config.BOOLEAN}},"linkTo":[],"linkFrom":[]},"draft_item":{"name":"draft_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"order_draft_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"qty":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC}},"linkTo":{"order_draft":{"table":"order_draft","pql":"eq(order_draft_id,order_draft.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Draft_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Draft_Item\")"}}},"edi_term_code":{"name":"edi_term_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"term_code":{"type":Config.STRING},"description":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"terms":{"table":"term","pql":"eq(terms.edi_term_code_id,id)"}}},"edi_user":{"name":"edi_users","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"friendly_name":{"type":Config.STRING},"auth_qualifier":{"type":Config.STRING},"auth_info":{"type":Config.STRING},"security_qualifier":{"type":Config.STRING},"security_info":{"type":Config.STRING},"sender_qualifier":{"type":Config.STRING},"sender_id":{"type":Config.STRING},"receiver_qualifier":{"type":Config.STRING},"receiver_id":{"type":Config.STRING},"control_standard_id":{"type":Config.STRING},"control_version":{"type":Config.STRING},"ack_requested":{"type":Config.STRING},"is_test":{"type":Config.STRING},"sub_element_sep":{"type":Config.STRING},"func_id":{"type":Config.STRING},"application_sender_id":{"type":Config.STRING},"application_receiver_id":{"type":Config.STRING},"responsible_agency_code":{"type":Config.STRING},"version_id":{"type":Config.STRING},"transaction_set_id":{"type":Config.STRING},"element_seperator":{"type":Config.STRING},"tag_seperator":{"type":Config.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":[]},"employee":{"name":"employees","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"office_id":{"type":Config.NUMERIC},"work_area_location":{"type":Config.STRING},"computer_ip":{"type":Config.STRING},"position":{"type":Config.STRING},"actively_employed":{"type":Config.BOOLEAN},"extension":{"type":Config.STRING},"notes":{"type":Config.STRING}},"linkTo":{"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Employee\")"},"users":{"table":"user","pql":"eq(users.user_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Employee\")"}}},"event":{"name":"events","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"watch_id":{"type":Config.NUMERIC},"transaction_id":{"type":Config.NUMERIC},"message":{"type":Config.STRING},"date":{"type":Config.DATE},"has_read":{"type":Config.BOOLEAN},"module":{"type":Config.STRING}},"linkTo":{"watch":{"table":"watch","pql":"eq(watch_id,watch.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Event\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Event\")"}}},"franchise":{"name":"franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_brand_id":{"type":Config.NUMERIC},"is_exclude":{"type":Config.BOOLEAN},"is_public":{"type":Config.BOOLEAN},"legacy_id":{"type":Config.STRING},"formula":{"type":Config.STRING},"dealer_col":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(primary_brand_id,brand.id)"}},"linkFrom":{"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.franchise_id,id)"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.franchise_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise\")"}}},"franchise_products":{"name":"franchise_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"date_voided":{"type":Config.DATE},"date_created":{"type":Config.DATE},"rule_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"sugar_column":{"type":Config.STRING}},"linkTo":{"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise_Products\")"}}},"gateway_account":{"name":"gateway_accounts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"payment_gateway_id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"billing_contact_id":{"type":Config.NUMERIC},"gateway_ref":{"type":Config.STRING},"additional_ref":{"type":Config.STRING},"is_primary":{"type":Config.BOOLEAN},"last_updated":{"type":Config.DATE},"exp_date":{"type":Config.NUMERIC},"type":{"type":Config.STRING}},"linkTo":{"payment_gateway":{"table":"payment_gateway","pql":"eq(payment_gateway_id,payment_gateway.id)"},"billing_contact":{"table":"contact","pql":"eq(billing_contact_id,billing_contact.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"order_draft":{"table":"order_draft","pql":"eq(order_draft.gateway_account_id,id)"},"orders":{"table":"order","pql":"eq(orders.gateway_account_id,id)"},"remits":{"table":"remit","pql":"eq(remits.gateway_account_id,id)"},"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.gateway_account_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Gateway_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Gateway_Account\")"}}},"groupping_products":{"name":"groupping_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"parent_id":{"type":Config.NUMERIC},"child_id":{"type":Config.NUMERIC},"num_of_children_in_parent":{"type":Config.NUMERIC},"discount_percent":{"type":Config.NUMERIC}},"linkTo":{"parent":{"table":"product","pql":"eq(parent_id,parent.id)"},"child":{"table":"product","pql":"eq(child_id,child.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Groupping_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Groupping_Products\")"}}},"invoice":{"name":"invoices_view","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"invoice_date":{"type":Config.DATE},"invoice_status":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"invoice_sum":{"type":Config.NUMERIC},"amount_due":{"type":Config.NUMERIC},"amount_received":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"age":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"invoice_id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"retired_date":{"type":Config.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.invoice_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.invoice_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.invoice_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.invoice_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoice\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoice\")"}}},"invoices_payments":{"name":"invoices_payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"payment_id":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"applied_amount":{"type":Config.NUMERIC},"date_applied":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoices_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoices_Payments\")"}}},"item_exchange":{"name":"item_exchange","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"product_item_id":{"type":Config.NUMERIC},"from_status":{"type":Config.NUMERIC},"to_status":{"type":Config.NUMERIC},"from_warehouse_id":{"type":Config.NUMERIC},"to_warehouse_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"date":{"type":Config.DATE},"from_product_id":{"type":Config.NUMERIC},"to_product_id":{"type":Config.NUMERIC},"from_cost":{"type":Config.NUMERIC},"to_cost":{"type":Config.NUMERIC}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"from_warehouse":{"table":"office","pql":"eq(from_warehouse_id,from_warehouse.id)"},"to_warehouse":{"table":"office","pql":"eq(to_warehouse_id,to_warehouse.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Item_Exchange\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Item_Exchange\")"}}},"kit_item":{"name":"kit_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_item_order_kits":{"table":"product_item","pql":"eq(product_item_order_kits.order_kit_id,id)"},"product_item_purchase_kits":{"table":"product_item","pql":"eq(product_item_purchase_kits.purchase_kit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Kit_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Kit_Item\")"}}},"last_modified":{"name":"last_modifieds","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"memute":{"name":"memutes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"module":{"type":Config.STRING},"rule_id":{"type":Config.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Memute\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Memute\")"}}},"note":{"name":"notes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"note":{"type":Config.STRING},"date":{"type":Config.DATE},"public":{"type":Config.BOOLEAN},"module_flags":{"type":Config.NUMERIC},"module_priority":{"type":Config.NUMERIC},"category":{"type":Config.STRING},"code":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"important":{"type":Config.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.note_id,id)"}}},"notes_link":{"name":"notes_link","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"note_id":{"type":Config.NUMERIC},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"user_id":{"type":Config.NUMERIC},"void":{"type":Config.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"note":{"table":"note","pql":"eq(note_id,note.id)"},"bill":{"table":"$module","pql":"eq(item_id,bill.id)"},"booking":{"table":"$module","pql":"eq(item_id,booking.id)"},"brand":{"table":"$module","pql":"eq(item_id,brand.id)"},"contact":{"table":"$module","pql":"eq(item_id,contact.id)"},"customer":{"table":"$module","pql":"eq(item_id,customer.id)"},"employee":{"table":"$module","pql":"eq(item_id,employee.id)"},"event":{"table":"$module","pql":"eq(item_id,event.id)"},"franchise":{"table":"$module","pql":"eq(item_id,franchise.id)"},"groupping_products":{"table":"$module","pql":"eq(item_id,groupping_products.id)"},"invoice":{"table":"$module","pql":"eq(item_id,invoice.id)"},"invoices_payments":{"table":"$module","pql":"eq(item_id,invoices_payments.id)"},"kit_item":{"table":"$module","pql":"eq(item_id,kit_item.id)"},"memute":{"table":"$module","pql":"eq(item_id,memute.id)"},"message":{"table":"$module","pql":"eq(item_id,message.id)"},"office":{"table":"$module","pql":"eq(item_id,office.id)"},"order":{"table":"$module","pql":"eq(item_id,order.id)"},"order_draft":{"table":"$module","pql":"eq(item_id,order_draft.id)"},"payment":{"table":"$module","pql":"eq(item_id,payment.id)"},"product":{"table":"$module","pql":"eq(item_id,product.id)"},"product_bar_code":{"table":"$module","pql":"eq(item_id,product_bar_code.id)"},"product_item":{"table":"$module","pql":"eq(item_id,product_item.id)"},"product_item_report":{"table":"$module","pql":"eq(item_id,product_item_report.id)"},"product_item_return":{"table":"$module","pql":"eq(item_id,product_item_return.id)"},"product_items_bills":{"table":"$module","pql":"eq(item_id,product_items_bills.id)"},"products_vendors":{"table":"$module","pql":"eq(item_id,products_vendors.id)"},"program":{"table":"$module","pql":"eq(item_id,program.id)"},"programs_customers":{"table":"$module","pql":"eq(item_id,programs_customers.id)"},"promo":{"table":"$module","pql":"eq(item_id,promo.id)"},"promos_franchises":{"table":"$module","pql":"eq(item_id,promos_franchises.id)"},"promos_products":{"table":"$module","pql":"eq(item_id,promos_products.id)"},"purchase":{"table":"$module","pql":"eq(item_id,purchase.id)"},"purchase_tracking":{"table":"$module","pql":"eq(item_id,purchase_tracking.id)"},"purchase_tracking_item":{"table":"$module","pql":"eq(item_id,purchase_tracking_item.id)"},"return_product_due":{"table":"$module","pql":"eq(item_id,return_product_due.id)"},"rule":{"table":"$module","pql":"eq(item_id,rule.id)"},"sales_rep":{"table":"$module","pql":"eq(item_id,sales_rep.id)"},"shipment":{"table":"$module","pql":"eq(item_id,shipment.id)"},"shipment_in":{"table":"$module","pql":"eq(item_id,shipment_in.id)"},"shipment_method":{"table":"$module","pql":"eq(item_id,shipment_method.id)"},"spiff":{"table":"$module","pql":"eq(item_id,spiff.id)"},"spiffs_franchises":{"table":"$module","pql":"eq(item_id,spiffs_franchises.id)"},"spiffs_products":{"table":"$module","pql":"eq(item_id,spiffs_products.id)"},"tax_code":{"table":"$module","pql":"eq(item_id,tax_code.id)"},"term":{"table":"$module","pql":"eq(item_id,term.id)"},"territory":{"table":"$module","pql":"eq(item_id,territory.id)"},"timezone":{"table":"$module","pql":"eq(item_id,timezone.id)"}},"linkFrom":[]},"office":{"name":"offices","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"foreman_id":{"type":Config.NUMERIC},"address1":{"type":Config.STRING},"address2":{"type":Config.STRING},"city":{"type":Config.STRING},"state":{"type":Config.STRING},"zip":{"type":Config.STRING},"country":{"type":Config.STRING},"phone":{"type":Config.STRING},"private_name":{"type":Config.STRING},"is_primary":{"type":Config.BOOLEAN},"open_hours":{"type":Config.STRING},"is_warehouse":{"type":Config.BOOLEAN}},"linkTo":{"foreman":{"table":"user","pql":"eq(foreman_id,foreman.id)"},"user":{"table":"user","pql":"eq(foreman_id,user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.warehouse_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.warehouse_id,id)"},"employees":{"table":"employee","pql":"eq(employees.office_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"order":{"name":"orders","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"lead_user_id":{"type":Config.NUMERIC},"order_step":{"type":Config.NUMERIC},"order_created":{"type":Config.DATE},"order_modified":{"type":Config.DATE},"notes":{"type":Config.STRING},"term_id":{"type":Config.NUMERIC},"po_number":{"type":Config.STRING},"requested_delivery_date":{"type":Config.DATE},"requested_delivery_date_end":{"type":Config.DATE},"ship_on_date":{"type":Config.DATE},"tax_code_id":{"type":Config.NUMERIC},"notes_public":{"type":Config.STRING},"address_error":{"type":Config.BOOLEAN},"legacy_id":{"type":Config.STRING},"shipment_method_id":{"type":Config.NUMERIC},"shipment_addr_hash":{"type":Config.STRING},"ship_phone":{"type":Config.STRING},"ship_email":{"type":Config.STRING},"ship_attn":{"type":Config.STRING},"ship_id":{"type":Config.NUMERIC},"quote_id":{"type":Config.NUMERIC},"currency":{"type":Config.STRING},"billing_id":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"ship_quote_amount":{"type":Config.NUMERIC},"ship_flags":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"bill_override":{"table":"contact","pql":"eq(billing_id,bill_override.id)"},"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"order_draft":{"table":"order_draft","pql":"eq(quote_id,order_draft.id)"}},"linkFrom":{"invoices":{"table":"invoice","pql":"eq(invoices.order_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.order_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.order_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.order_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.order_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.order_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order\")"},"orders_product_items_void":{"table":"orders_product_items_void","pql":"eq(orders_product_items_void.order_id,id)"}}},"order_draft":{"name":"order_drafts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_attn":{"type":Config.STRING},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"lead_user_id":{"type":Config.NUMERIC},"order_step":{"type":Config.NUMERIC},"draft_created":{"type":Config.DATE},"term_id":{"type":Config.NUMERIC},"po_number":{"type":Config.STRING},"requested_delivery_date":{"type":Config.DATE},"requested_delivery_date_end":{"type":Config.DATE},"ship_on_date":{"type":Config.DATE},"tax_code_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"ship_phone":{"type":Config.STRING},"ship_email":{"type":Config.STRING},"ship_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"currency":{"type":Config.STRING},"billing_id":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC},"ship_flags":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"ship_quote_amount":{"type":Config.NUMERIC},"source":{"type":Config.STRING},"state":{"type":Config.STRING},"reserved_order_id":{"type":Config.NUMERIC},"cart_id":{"type":Config.STRING}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"reserved_order":{"table":"order","pql":"eq(reserved_order_id,reserved_order.id)"}},"linkFrom":{"orders":{"table":"order","pql":"eq(orders.quote_id,id)"},"draft_items":{"table":"draft_item","pql":"eq(draft_items.order_draft_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Draft\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order_Draft\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Draft\")"}}},"order_line":{"name":"order_lines","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_part_num":{"type":Config.STRING},"edi_customer_line_id":{"type":Config.STRING},"edi_entered_price":{"type":Config.NUMERIC},"edi_entered_qty":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.order_line_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.order_line_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.order_line_id,id)"}}},"order_return":{"name":"order_returns","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"date_entered":{"type":Config.DATE},"rma_number":{"type":Config.STRING},"notes":{"type":Config.STRING},"date_returned":{"type":Config.DATE},"payment_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING},"code":{"type":Config.STRING},"replacement_order_id":{"type":Config.NUMERIC},"vendor_rma_number":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"public_note":{"type":Config.STRING}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"replacement_order":{"table":"order","pql":"eq(replacement_order_id,replacement_order.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"shipments_ins":{"table":"shipment_in","pql":"eq(shipments_ins.order_return_id,id)"},"return_product_dues":{"table":"return_product_due","pql":"eq(return_product_dues.order_return_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.return_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Return\")"}}},"orders_product_items_void":{"name":"orders_product_items_void","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"void_sell_price":{"type":Config.NUMERIC},"order_kit_id":{"type":Config.NUMERIC},"date_canceled":{"type":Config.DATE},"moved_from_order_id":{"type":Config.NUMERIC}},"linkTo":{"order":{"table":"order","pql":"eq(order_id,order.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"orig_order":{"table":"order","pql":"eq(moved_from_order_id,orig_order.id)"}},"linkFrom":[]},"package":{"name":"packages","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"track_code":{"type":Config.STRING},"weight":{"type":Config.NUMERIC},"height":{"type":Config.NUMERIC},"width":{"type":Config.NUMERIC},"length":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"last_modified":{"type":Config.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.package_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.package_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.package_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Package\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Package\")"}}},"payment":{"name":"payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"reference_number":{"type":Config.STRING},"date_claimed":{"type":Config.DATE},"date_effective":{"type":Config.DATE},"amount_applied":{"type":Config.NUMERIC},"amount_received":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"payment_type":{"type":Config.STRING},"fee":{"type":Config.NUMERIC},"freight_refunded":{"type":Config.NUMERIC},"misc_refunded":{"type":Config.NUMERIC},"tax_refunded":{"type":Config.NUMERIC},"refunded_date":{"type":Config.DATE},"refunded_amount":{"type":Config.STRING},"refunded_method":{"type":Config.STRING},"refunded_notes":{"type":Config.STRING},"currency":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.payment_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.payment_id,id)"},"order_returns":{"table":"order_return","pql":"eq(order_returns.payment_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.payment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment\")"}}},"payment_gateway":{"name":"payment_gateways","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"class_name":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.payment_gateway_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment_Gateway\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment_Gateway\")"}}},"payment_gateway_request":{"name":"payment_gateway_requests","fields":{"id":{"type":Config.NUMERIC},"request_type":{"type":Config.STRING},"gateway_account_id":{"type":Config.NUMERIC},"reference":{"type":Config.STRING},"confirmation_num":{"type":Config.STRING},"payment_id":{"type":Config.NUMERIC},"amount":{"type":Config.NUMERIC},"request_date":{"type":Config.DATE},"request_by":{"type":Config.NUMERIC},"approved":{"type":Config.BOOLEAN},"deny_reason":{"type":Config.STRING},"full_request":{"type":Config.STRING},"full_response":{"type":Config.STRING},"deleted":{"type":Config.BOOLEAN}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"request_user":{"table":"user","pql":"eq(request_by,request_user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"product":{"name":"products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"date_created":{"type":Config.DATE},"description":{"type":Config.STRING},"item_code":{"type":Config.STRING},"brand_id":{"type":Config.NUMERIC},"category_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"weight":{"type":Config.NUMERIC},"dimension_h":{"type":Config.NUMERIC},"dimension_w":{"type":Config.NUMERIC},"dimension_l":{"type":Config.NUMERIC},"list_price":{"type":Config.NUMERIC},"map_price":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"vendor_part_number":{"type":Config.STRING},"primary_vendor_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"taxable":{"type":Config.BOOLEAN},"freight_only":{"type":Config.BOOLEAN},"upc_code":{"type":Config.STRING},"replacement_id":{"type":Config.NUMERIC},"bin_location":{"type":Config.STRING},"has_internal_serial":{"type":Config.BOOLEAN},"has_external_serial":{"type":Config.BOOLEAN},"ht_code":{"type":Config.STRING},"date_discontinued":{"type":Config.DATE},"master_pack_qty":{"type":Config.NUMERIC},"automation_flags":{"type":Config.NUMERIC},"primary_warehouse_id":{"type":Config.NUMERIC},"date_changed":{"type":Config.DATE},"default_stock_type":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"primary_vendor":{"table":"vendor","pql":"eq(primary_vendor_id,primary_vendor.id)"},"replacement":{"table":"product","pql":"eq(replacement_id,replacement.id)"},"primary_warehouse":{"table":"office","pql":"eq(primary_warehouse_id,primary_warehouse.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.product_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.product_id,id)"},"children":{"table":"groupping_products","pql":"eq(children.child_id,id)"},"parent":{"table":"groupping_products","pql":"eq(parent.parent_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.product_id,id)"},"product_bar_codes":{"table":"product_bar_code","pql":"eq(product_bar_codes.product_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product\")"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.product_id,id)"}}},"product_bar_code":{"name":"product_bar_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"bar_code":{"type":Config.STRING},"product_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Bar_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Bar_Code\")"}}},"product_item":{"name":"product_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"serial_number":{"type":Config.STRING},"warehouse_id":{"type":Config.NUMERIC},"warehouse_location":{"type":Config.STRING},"date_received":{"type":Config.DATE},"date_shipped":{"type":Config.DATE},"status":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"item_cost":{"type":Config.NUMERIC},"roi_cost":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"tax_amount":{"type":Config.NUMERIC},"temp_cust_id":{"type":Config.STRING},"shipment_in_id":{"type":Config.NUMERIC},"vendor_serial":{"type":Config.STRING},"override_date":{"type":Config.DATE},"order_kit_id":{"type":Config.NUMERIC},"purchase_kit_id":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"has_changed":{"type":Config.BOOLEAN},"order_warehouse_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING},"order_line_id":{"type":Config.NUMERIC},"purchase_tracking_item_id":{"type":Config.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.product_item_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.product_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_report":{"name":"product_items_reports","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"serial_number":{"type":Config.STRING},"warehouse_id":{"type":Config.NUMERIC},"warehouse_location":{"type":Config.STRING},"date_received":{"type":Config.DATE},"date_shipped":{"type":Config.DATE},"status":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"item_cost":{"type":Config.NUMERIC},"roi_cost":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"tax_amount":{"type":Config.NUMERIC},"temp_cust_id":{"type":Config.STRING},"shipment_in_id":{"type":Config.NUMERIC},"vendor_serial":{"type":Config.STRING},"return_id":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"order_kit_id":{"type":Config.NUMERIC},"purchase_kit_id":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"has_changed":{"type":Config.BOOLEAN},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC},"source":{"type":Config.STRING},"stock_type":{"type":Config.STRING},"purchase_tracking_item_id":{"type":Config.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,product_item_id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,product_item_id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_return":{"name":"product_items_returns","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"product_item_id":{"type":Config.NUMERIC},"return_id":{"type":Config.NUMERIC},"return_sell_price":{"type":Config.NUMERIC},"restock_fee":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"date_shipped":{"type":Config.DATE},"date_return_received":{"type":Config.DATE},"sort_order":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"tax_amount":{"type":Config.NUMERIC},"shipment_in_id":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"order_kit_id":{"type":Config.NUMERIC},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"order_return":{"table":"order_return","pql":"eq(return_id,order_return.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"sales_rep":{"table":"user","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Return\")"}}},"product_items_bills":{"name":"product_items_bills","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"bill_id":{"type":Config.NUMERIC},"item_cost":{"type":Config.NUMERIC}},"linkTo":{"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Bills\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Bills\")"}}},"products_vendors":{"name":"products_vendors","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"cost":{"type":Config.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Vendors\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Vendors\")"}}},"program":{"name":"programs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"brand_id":{"type":Config.NUMERIC},"rule_id":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.program_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.program_id,id)"},"product_item_returns":{"table":"product_item_returns","pql":"eq(product_item_returns.program_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Program\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Program\")"}}},"programs_customers":{"name":"programs_customers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"program_id":{"type":Config.STRING},"customer_id":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"parameters":{"type":Config.STRING}},"linkTo":{"program":{"table":"program","pql":"eq(program_id,program.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Programs_Customers\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Programs_Customers\")"}}},"promo":{"name":"promos","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"type":{"type":Config.STRING},"rule_id":{"type":Config.NUMERIC},"brand_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"promo_code":{"type":Config.STRING},"before_order_rule_id":{"type":Config.NUMERIC},"after_invoice_rule_id":{"type":Config.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"},"brand_id":{"table":"brand","pql":"eq(brand_id,brand_id.id)"}},"linkFrom":{"product_item_starin_promos":{"table":"product_item","pql":"eq(product_item_starin_promos.starin_promo_id,id)"},"product_item_vendor_promos":{"table":"product_item","pql":"eq(product_item_vendor_promos.vendor_promo_id,id)"},"product_item_return_starin_promos":{"table":"product_item_return","pql":"eq(product_item_return_starin_promos.starin_promo_id,id)"},"product_item_return_vendor_promos":{"table":"product_item_return","pql":"eq(product_item_return_vendor_promos.vendor_promo_id,id)"},"product_item_report_starin_promos":{"table":"product_item_report","pql":"eq(product_item_report_starin_promos.starin_promo_id,id)"},"product_item_report_vendor_promos":{"table":"product_item_report","pql":"eq(product_item_report_vendor_promos.vendor_promo_id,id)"},"promos_franchises":{"table":"promos_franchises","pql":"eq(promos_franchises.promo_id,id)"},"promos_products":{"table":"promos_products","pql":"eq(promos_products.promo_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promo\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promo\")"}}},"promos_franchises":{"name":"promos_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"promo_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Franchises\")"}}},"promos_products":{"name":"promos_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"promo_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"description":{"type":Config.STRING}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Products\")"}}},"purchase":{"name":"purchases","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"date_ordered":{"type":Config.DATE},"notes":{"type":Config.STRING},"status":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"assigned_user_id":{"type":Config.NUMERIC},"sub_total":{"type":Config.NUMERIC},"tax":{"type":Config.NUMERIC},"freight":{"type":Config.NUMERIC},"misc":{"type":Config.NUMERIC},"total":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"notes_public":{"type":Config.STRING},"ship_account_num":{"type":Config.STRING},"est_received_date":{"type":Config.DATE},"vendor_order_number":{"type":Config.STRING}},"linkTo":{"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_id,id)"},"bills":{"table":"bill","pql":"eq(bills.purchase_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Purchase\")"}}},"purchase_tracking":{"name":"purchase_tracking","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"estimated_receive_date":{"type":Config.DATE},"tracking_number":{"type":Config.STRING},"shipment_method_id":{"type":Config.NUMERIC},"last_updated":{"type":Config.DATE},"variance":{"type":Config.NUMERIC},"note":{"type":Config.STRING},"ref_number":{"type":Config.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"purchase_tracking_items":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_items.purchase_tracking_id,id)"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"PURCHASE_TRACKING\")"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking\")"}}},"purchase_tracking_item":{"name":"purchase_tracking_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"purchase_tracking_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING},"qty":{"type":Config.NUMERIC},"qty_received":{"type":Config.NUMERIC}},"linkTo":{"purchase_tracking":{"table":"purchase_tracking","pql":"eq(purchase_tracking_id,purchase_tracking.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_tracking_item_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_tracking_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking_Item\")"}}},"remit":{"name":"remits","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"paid":{"type":Config.BOOLEAN},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"amount_due":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"}},"linkFrom":{"shipments":{"table":"shipment","pql":"eq(shipments.remit_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.remit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remit\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remit\")"}}},"remits_payments":{"name":"remits_payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"remit_id":{"type":Config.NUMERIC},"payment_id":{"type":Config.NUMERIC},"amount":{"type":Config.NUMERIC},"date_applied":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remits_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remits_Payments\")"}}},"return_product_due":{"name":"return_product_due","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"order_return_id":{"type":Config.NUMERIC}},"linkTo":{"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":[]},"rule":{"name":"rules","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"code":{"type":Config.STRING},"file":{"type":Config.STRING}},"linkTo":[],"linkFrom":[]},"sales_rep":{"name":"sales_reps","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"contact_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"assigned_user_id":{"type":Config.NUMERIC},"is_distributor":{"type":Config.BOOLEAN},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.sales_rep_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Sales_Rep\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Sales_Rep\")"}}},"shipment":{"name":"shipments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"track_code":{"type":Config.STRING},"notes":{"type":Config.STRING},"actual_cost":{"type":Config.NUMERIC},"ship_date":{"type":Config.DATE},"date_due":{"type":Config.DATE},"shipment_fee":{"type":Config.NUMERIC},"handling_fee":{"type":Config.NUMERIC},"flags":{"type":Config.NUMERIC},"shipment_addr_hash":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"bill_id":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"backorder_hash":{"type":Config.STRING},"remit_id":{"type":Config.NUMERIC},"discount_amount":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"shipment_flags":{"type":Config.NUMERIC}},"linkTo":{"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.shipment_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.shipment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment\")"},"invoices":{"table":"invoice","pql":"eq(invoices.shipment_id,id)"}}},"shipment_account":{"name":"shipment_accounts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"ship_account_num":{"type":Config.STRING},"third_party_contact_id":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"third_party_contact":{"table":"contact","pql":"eq(third_party_contact_id,third_party_contact.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Account\")"}}},"shipment_in":{"name":"shipments_in","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"date_entered":{"type":Config.DATE},"purchase_id":{"type":Config.NUMERIC},"order_return_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"track_code":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_in_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_In\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_In\")"}}},"shipment_method":{"name":"shipment_methods","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"prepaid":{"type":Config.BOOLEAN},"carrier_code":{"type":Config.STRING},"carrier":{"type":Config.STRING},"parent_shipment_method_id":{"type":Config.NUMERIC},"carrier_id":{"type":Config.NUMERIC},"transportaion_method_code":{"type":Config.STRING},"is_freight":{"type":Config.BOOLEAN},"time_in_transit":{"type":Config.NUMERIC},"service_level_code":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"parent_shipment_method":{"table":"shipment_method","pql":"eq(parent_shipment_method_id,parent_shipment_method.id)"},"scac":{"table":"carrier","pql":"eq(carrier_id,scac.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.shipment_method_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.shipment_method_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Method\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Method\")"},"child_shipment_methods":{"table":"shipment_method","pql":"eq(child_shipment_methods.parent_shipment_method_id,id)"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.shipment_method_id,id)"}}},"spiff":{"name":"spiffs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"notes":{"type":Config.STRING},"max":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"spiffs_franchises":{"table":"spiffs_franchises","pql":"eq(spiffs_franchises.spiff_id,id)"},"spiffs_products":{"table":"spiffs_products","pql":"eq(spiffs_products.spiff_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.spiff_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.spiff_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.spiff_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff\")"}}},"spiffs_franchises":{"name":"spiffs_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff_Franchises\")"}}},"spiffs_products":{"name":"spiffs_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"qty":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiffs_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiffs_Products\")"}}},"tax_code":{"name":"tax_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"percentage":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"shipment_tax":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"orders":{"table":"order","pql":"eq(orders.tax_code_id,id)"},"customers":{"table":"customer","pql":"eq(customers.tax_code_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Tax_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Tax_Code\")"}}},"term":{"name":"terms","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"due_days":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"discount_days":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"order_override_flags":{"type":Config.NUMERIC},"classification":{"type":Config.STRING},"grace_days":{"type":Config.NUMERIC},"edi_term_code_id":{"type":Config.NUMERIC}},"linkTo":{"edi_term_code":{"table":"edi_term_code","pql":"eq(edi_term_code_id,edi_term_code.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.term_id,id)"},"bills":{"table":"bill","pql":"eq(bills.term_id,id)"},"customers":{"table":"customer","pql":"eq(customers.term_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.term_id,id)"},"orders":{"table":"order","pql":"eq(orders.term_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Term\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Term\")"}}},"territory":{"name":"territories","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"country":{"type":Config.STRING},"region":{"type":Config.STRING},"state_province":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"customers":{"table":"customer","pql":"eq(customers.territory_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Territory\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Territory\")"}}},"timezone":{"name":"timezones","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"utc":{"type":Config.STRING},"dst":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.timezone_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Timezone\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Timezone\")"}}},"user":{"name":"users_view","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"username":{"type":Config.STRING},"password":{"type":Config.STRING},"can_login":{"type":Config.BOOLEAN},"employee_id":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"wh_scan":{"type":Config.STRING}},"linkTo":{"employee":{"table":"employee","pql":"eq(employee_id,employee.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":{"user_historys":{"table":"user_history","pql":"eq(user_historys.user_id,id)"},"voided_gateway_requests":{"table":"payment_gateway_request","pql":"eq(voided_gateway_requests.void_by,id)"},"approved_gateway_requests":{"table":"payment_gateway_request","pql":"eq(approved_gateway_requests.approved_by,id)"},"requested_gateway_requests":{"table":"payment_gateway_request","pql":"eq(requested_gateway_requests.request_by,id)"},"offices":{"table":"office","pql":"eq(offices.foreman_id,id)"},"customers":{"table":"customer","pql":"eq(customers.primary_rep_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.assigned_user_id,id)"},"orders":{"table":"order","pql":"eq(orders.assigned_user_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.user_id,id)"},"assigned_sales_reps":{"table":"sales_rep","pql":"eq(assigned_sales_reps.assigned_user_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"User\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"User\")"}}},"user_history":{"name":"user_historys","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"method":{"type":Config.STRING},"args":{"type":Config.STRING},"window_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"vendor":{"name":"vendors","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_contact_id":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.STRING},"our_account_number":{"type":Config.STRING},"default_shipment_method_id":{"type":Config.NUMERIC},"default_office_id":{"type":Config.NUMERIC}},"linkTo":{"term":{"table":"term","pql":"eq(term_id,term.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"default_shipment_method":{"table":"shipment_method","pql":"eq(default_shipment_method_id,default_shipment_method.id)"},"default_office":{"table":"office","pql":"eq(default_office_id,default_office.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.vendor_id,id)"},"contacts":{"table":"contact","pql":"eq(contacts.vendor_id,id)"},"primary_products":{"table":"product","pql":"eq(primary_products.vendor_id,id)"},"bills":{"table":"bill","pql":"eq(bills.vendor_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.vendor_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Vendor\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Vendor\")"}}},"watch":{"name":"watchs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"record_id":{"type":Config.NUMERIC},"created":{"type":Config.DATE},"note":{"type":Config.STRING},"memute_id":{"type":Config.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"memute":{"table":"memute","pql":"eq(memute_id,memute.id)"}},"linkFrom":[]}};Config.FUNCTION_MAP = {eq:{description:'Compares two values',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsEqualJs.EQUAL(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},gt:{description:'Checks if first value is greater than second',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsGreater_thanJs.GREATER_THAN(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},lt:{description:'Checks if first value is less than second',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsLess_thanJs.LESS_THAN(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},ne:{description:'Checks if values are not equal',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsNot_equalJs.NOT_EQUAL(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},like:{description:'Checks if first value is like second. % sign is wild card character',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsLikeJs.LIKE(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},not_like:{description:'Checks if first value is not like second. % sign is wild card character',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsNot_likeJs.NOT_LIKE(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},'in':{description:'Checks if first value is any of the following values',min_args:2,max_args:Infinity,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var out_args=[];var obj=new _opcodesComparitorsEqualJs.EQUAL(pql);orig_args.splice(1).forEach(function(v){out_args.push(v);});obj.setLeft(orig_args[0]);obj.setRight(new _opcodesConstants_arrayJs.CONSTANTS_ARRAY(pql,out_args));return obj.getSQL(query_obj);}},not_in:{description:'Checks if first value is not any of the following values',min_args:2,max_args:Infinity,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var out_args=[];var obj=new _opcodesComparitorsNot_equalJs.NOT_EQUAL(pql);orig_args.splice(1).forEach(function(v){out_args.push(v);});obj.setLeft(orig_args[0]);obj.setRight(new _opcodesConstants_arrayJs.CONSTANTS_ARRAY(pql,out_args));return obj.getSQL(query_obj);}},'if':{description:'If first argument is truethy returns second argument otherwise returns third',min_args:3,max_args:3,return_type:Config.ANY,format:['IF(',Config.ALL_ARGS,')']}, /* Math functions */add:{description:'Adds values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' + ');}},sub:{description:'Subtracts values from eachother',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' - ');}},mul:{description:'Multiplies values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' * ');}},div:{description:'Divide values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' / ');}},mod:{description:'Modulus values together',min_args:2,max_args:2,return_type:Config.NUMBER,format:['MOD(',Config.ARG1,', ',Config.ARG2,')']},pow:{description:'Powers values together',min_args:2,max_args:2,return_type:Config.NUMBER,format:['POW(',Config.ARG1,', ',Config.ARG2,')']},sqrt:{description:'Square roots a value',min_args:1,max_args:1,return_type:Config.NUMBER,format:['SQRT(',Config.ARG1,')']}, /* Standard SQL functions */abs:{description:'Gets absolute value',min_args:1,max_args:1,arg_types:[Config.NUMERIC],return_type:Config.NUMERIC,format:['ABS(',Config.ARG1,')']},'char':{description:'Gets character from numerical ascii character',min_args:1,max_args:Infinity,arg_types:[Config.NUMERIC],return_type:Config.STRING,format:['CHAR(',Config.ALL_ARGS,')']},coalesce:{description:'Returns first non-null value from arguments',min_args:1,max_args:Infinity,return_type:Config.ANY_TYPE,format:['COALESCE(',Config.ALL_ARGS,')']},ifnull:{description:'Returns first argument if not null otherwise returns second argument',min_args:2,max_args:2,return_type:Config.ANY_TYPE,format:['IFNULL(',Config.ARG1,', ',Config.ARG2,')']},instr:{description:'Gets character position of argument two in argument one\'s string',min_args:2,max_args:2,return_type:Config.NUMERIC,arg_types:[Config.STRING,Config.STRING],format:['INSTR(',Config.ARG1,', ',Config.ARG2,')']},hex:{description:'Returns hex value of argument',min_args:1,max_args:1,return_type:Config.STRING,format:['HEX(',Config.ARG1,')']},length:{description:'Returns the string length',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.NUMERIC,format:['LENGTH(',Config.ARG1,')']},lower:{description:'Returns string converted to lower case',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['LOWER(',Config.ARG1,')']},ltrim:{description:'Returns left-trimmed string',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['LTRIM(',Config.ARG1,')']},nullif:{description:'Returns null if argument one equals argument two',min_args:2,max_args:2,return_type:Config.ANY_TYPE,format:['NULLIF(',Config.ARG1,', ',Config.ARG2,')']},random:{description:'Returns random number (platform dependent)',min_args:0,max_args:0,return_type:Config.NUMERIC,format:['RANDOM()']},replace:{description:'Searches for argument two and replaces matches with argument three in argument one',min_args:3,max_args:3,arg_types:[Config.STRING,Config.STRING,Config.STRING],return_type:Config.STRING,format:['REPLACE(',Config.ARG1,', ',Config.ARG2,', ',Config.ARG3,')']},round:{description:'Returns rounded value of argument one with decimal percision of argument two',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.NUMERIC],return_type:Config.NUMERIC,format:['ROUND(',Config.ALL_ARGS,')']},rtrim:{description:'Returns right-trimmed value',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['RTRIM(',Config.ARG1,')']},substr:{description:'Returns part of argument one string from argument two position with length of argument three',min_args:2,max_args:3,arg_types:[Config.STRING,Config.NUMERIC,Config.NUMERIC],return_type:Config.STRING,format:['SUBSTR(',Config.ALL_ARGS,')']},trim:{description:'Returns full trimmed string',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['TRIM(',Config.ARG1,')']},upper:{description:'Returns value converted to upper case',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['UPPER(',Config.ARG1,')']},concat:{description:'Returns multiple strings joined together',min_args:1,max_args:Infinity,arg_types:[Config.STRING],return_type:Config.STRING,format:['CONCAT(',Config.ALL_ARGS,')']}, /* Date Functions */date_format:{description:'Returns date converted converted using format of argument two',min_args:2,max_args:2,arg_types:[Config.DATE,Config.STRING],return_type:Config.STRING,format:['DATE_FORMAT(',Config.ARG1,', ',Config.ARG2,')']},date:{description:'Returns date porition of argument one',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.DATE,format:['DATE(',Config.ARG1,')']},day:{description:'Returns day number of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['DAY(',Config.ARG1,')']},from_unixtime:{description:'Returns date type from unix timestamp',min_args:1,max_args:1,arg_types:[Config.NUMERIC],return_type:Config.DATE,format:['FROM_UNIXTIME(',Config.ARG1,')']},hour:{description:'Returns hour portion of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['HOUR(',Config.ARG1,')']},minute:{description:'Returns minute porition of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['MINUTE(',Config.ARG1,')']},month:{description:'Returns month number porition of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['MONTH(',Config.ARG1,')']},now:{description:'Returns current time/date',min_args:0,max_args:0,return_type:Config.DATE,format:['NOW()']},second:{description:'Returns second porition of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['SECOND(',Config.ARG1,')']},time:{description:'Returns time porition of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.STRING,format:['TIME(',Config.ARG1,')']},unix_timestamp:{description:'Returns unix timestamp from date',min_args:0,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['UNIX_TIMESTAMP(',Config.ARG1,')']},year:{description:'Returns year porition from date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['YEAR(',Config.ARG1,')']}, /* Aggregate functions */avg:{description:'Returns average value',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['AVG(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "AVG(DISTINCT " + args[0];}return "AVG(" + args[0];}]}},count:{description:'Returns count of items',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['COUNT(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "COUNT(DISTINCT " + args[0];}return "COUNT(" + args[0];}]}}, // group_concat(expr[,distinct[,seperator[,order_by_expression,order_by_direction ...]]]); +group_concat:{description:'Returns the group concatinated string',min_args:1,max_args:Infinity,arg_types:[Config.STRING,Config.BOOLEAN,Config.STRING,Config.STRING,Config.STRING],return_type:Config.STRING,is_group_function:true,format:function format(args,orig_args){var distinct=orig_args.length >= 2 && Boolean(Number(orig_args[1].getValue()))?'DISTINCT ':'';var seperator='';if(orig_args.length >= 3){if(!orig_args[2].isConstant() && !orig_args[2].isInstanceOf(_opcodesNullJs.NULL)){throw "Third argument of \"group_concat\" function must be a constant type";}if(!orig_args[2].isInstanceOf(_opcodesNullJs.NULL)){seperator = " SEPARATOR " + args[2];}}var order_bys=new Set();if(orig_args.length > 3){ // Check to make sure there are always pairs of order_by_expression and order_by_direction +if(orig_args.length % 2 == 0){throw "GROUP_CONCAT function must have order_by_expression and order_by_direction in pairs";} // Inc in order of 2's +for(var i=3;i < args.length;i = i + 2) {var dir='ASC';if(orig_args[i + 1].isConstant()){dir = orig_args[i + 1].getValue().toString().toLowerCase() == 'desc'?'DESC':'ASC';}order_bys.add(args[i] + " " + dir);}}var order_by=undefined;if(order_bys.size){order_by = " ORDER BY " + Array.from(order_bys).join(',');}else {order_by = '';}return "GROUP_CONCAT(" + distinct + args[0] + order_by + seperator + ")";}},max:{description:'Returns maximum value',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['MAX(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "MAX(DISTINCT " + args[0];}return "MAX(" + args[0];}]}},min:{description:'Returns minimum value',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['MIN(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "MIN(DISTINCT " + args[0];}return "MIN(" + args[0];}]}},sum:{description:'Returns sum of values',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['SUM(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "SUM(DISTINCT " + args[0];}return "SUM(" + args[0];}]}},having:{description:'Forces item into having statment',min_args:1,max_args:1,return_type:Config.ANY,is_group_function:true,format:[Config.ARG1]}};Config.COMPARITORS = new Set([_opcodesComparitorsEqualJs.EQUAL,_opcodesComparitorsGreater_thanJs.GREATER_THAN,_opcodesComparitorsLess_thanJs.LESS_THAN,_opcodesComparitorsLikeJs.LIKE,_opcodesComparitorsNo_valueJs.NO_VALUE,_opcodesComparitorsNot_equalJs.NOT_EQUAL,_opcodesComparitorsNot_likeJs.NOT_LIKE]); \ No newline at end of file diff --git a/compiled/pql/opcodes.js b/compiled/pql/opcodes.js new file mode 100644 index 0000000..8f2aa0c --- /dev/null +++ b/compiled/pql/opcodes.js @@ -0,0 +1,3 @@ +"use strict"; +var PQL = window.PQL; +PQL.OPCODES = {}; \ No newline at end of file diff --git a/compiled/pql/opcodes/and.js b/compiled/pql/opcodes/and.js new file mode 100644 index 0000000..d5e36e6 --- /dev/null +++ b/compiled/pql/opcodes/and.js @@ -0,0 +1,36 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _seperatorsJs = require('./seperators.js'); + +var AND = (function (_SEPERATORS) { + _inherits(AND, _SEPERATORS); + + function AND() { + _classCallCheck(this, AND); + + _get(Object.getPrototypeOf(AND.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(AND, [{ + key: 'getSQL', + value: function getSQL() { + return 'AND'; + } + }]); + + return AND; +})(_seperatorsJs.SEPERATORS); + +exports.AND = AND; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/comparitor.js b/compiled/pql/opcodes/comparitors/comparitor.js new file mode 100644 index 0000000..d21c526 --- /dev/null +++ b/compiled/pql/opcodes/comparitors/comparitor.js @@ -0,0 +1,82 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _opcodeJs = require('./../opcode.js'); + +var COMPARITOR = (function (_OPCODE) { + _inherits(COMPARITOR, _OPCODE); + + function COMPARITOR() { + _classCallCheck(this, COMPARITOR); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _get(Object.getPrototypeOf(COMPARITOR.prototype), 'constructor', this).apply(this, args); + this._needs_group_cache = null; + } + + _createClass(COMPARITOR, [{ + key: 'setLeft', + value: function setLeft(v) { + this.left = v; + return this; + } + }, { + key: 'setRight', + value: function setRight(v) { + this.right = v; + return this; + } + }, { + key: 'needsGroup', + value: function needsGroup() { + if (this._needs_group_cache !== null) { + return this._needs_group_cache; + } + if (this.left) { + if (this.left.needsGroup()) { + return this._needs_group_cache = true; + } + } + if (this.right) { + if (this.right.needsGroup()) { + return this._needs_group_cache = true; + } + } + return this._needs_group_cache = false; + } + }, { + key: 'left', + get: function get() { + return this._left; + }, + set: function set(v) { + return this._left = v; + } + }, { + key: 'right', + get: function get() { + return this._right; + }, + set: function set(v) { + return this._right = v; + } + }]); + + return COMPARITOR; +})(_opcodeJs.OPCODE); + +exports.COMPARITOR = COMPARITOR; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/equal.js b/compiled/pql/opcodes/comparitors/equal.js new file mode 100644 index 0000000..bd978ca --- /dev/null +++ b/compiled/pql/opcodes/comparitors/equal.js @@ -0,0 +1,73 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _comparitorJs = require('./comparitor.js'); + +var _nullJs = require('./../null.js'); + +var _constants_arrayJs = require('./../constants_array.js'); + +var EQUAL = (function (_COMPARITOR) { + _inherits(EQUAL, _COMPARITOR); + + function EQUAL() { + _classCallCheck(this, EQUAL); + + _get(Object.getPrototypeOf(EQUAL.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(EQUAL, [{ + key: 'getSQL', + value: function getSQL(query_object) { + var _this = this; + + var left_type = undefined; + var right_type = undefined; + if (this.left.getType) { + left_type = this.left.getType(); + } + if (this.right.getType) { + right_type = this.right.getType(); + } + if (this.right.isInstanceOf(_nullJs.NULL)) { + return this.left.getSQL(query_object, right_type) + ' IS NULL'; + } else if (this.right.isInstanceOf(_constants_arrayJs.CONSTANTS_ARRAY)) { + var _ret = (function () { + var right_values = _this.right.getValue(); + var sql_safe_values = []; + right_values.forEach(function (v) { + sql_safe_values.push(v.getSQL(query_object, left_type)); + }); + return { + v: _this.left.getSQL(query_object, right_type) + ' IN (' + sql_safe_values.join(', ') + ')' + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + return this.left.getSQL(query_object, right_type) + ' = ' + this.right.getSQL(query_object, left_type); + } + } + }], [{ + key: 'comparitors', + set: function set(v) {}, + get: function get() { + return ['=', ':']; + } + }]); + + return EQUAL; +})(_comparitorJs.COMPARITOR); + +exports.EQUAL = EQUAL; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/greater_than.js b/compiled/pql/opcodes/comparitors/greater_than.js new file mode 100644 index 0000000..dac77e8 --- /dev/null +++ b/compiled/pql/opcodes/comparitors/greater_than.js @@ -0,0 +1,71 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _comparitorJs = require('./comparitor.js'); + +var _constants_arrayJs = require('./../constants_array.js'); + +var GREATER_THAN = (function (_COMPARITOR) { + _inherits(GREATER_THAN, _COMPARITOR); + + function GREATER_THAN() { + _classCallCheck(this, GREATER_THAN); + + _get(Object.getPrototypeOf(GREATER_THAN.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(GREATER_THAN, [{ + key: 'getSQL', + value: function getSQL(query_object) { + var _this = this; + + var left_type = undefined; + var right_type = undefined; + if (this.left.getType) { + left_type = this.left.getType(); + } + if (this.right.getType) { + right_type = this.right.getType(); + } + if (this.right.isInstanceOf(_constants_arrayJs.CONSTANTS_ARRAY)) { + var _ret = (function () { + var right_values = _this.right.getValue(); + var sql_safe_values = []; + var left_sql = _this.left.getSQL(query_object, right_type); + right_values.forEach(function (v) { + sql_safe_values.push(left_sql + ' > ' + v.getSQL(query_object, left_type)); + }); + + return { + v: '(' + sql_safe_values.join(' AND ') + ')' + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + return this.left.getSQL(query_object, right_type) + ' > ' + this.right.getSQL(query_object, left_type); + } + } + }], [{ + key: 'comparitors', + set: function set(v) {}, + get: function get() { + return ['>']; + } + }]); + + return GREATER_THAN; +})(_comparitorJs.COMPARITOR); + +exports.GREATER_THAN = GREATER_THAN; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/less_than.js b/compiled/pql/opcodes/comparitors/less_than.js new file mode 100644 index 0000000..b63a743 --- /dev/null +++ b/compiled/pql/opcodes/comparitors/less_than.js @@ -0,0 +1,71 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _comparitorJs = require('./comparitor.js'); + +var _constants_arrayJs = require('./../constants_array.js'); + +var LESS_THAN = (function (_COMPARITOR) { + _inherits(LESS_THAN, _COMPARITOR); + + function LESS_THAN() { + _classCallCheck(this, LESS_THAN); + + _get(Object.getPrototypeOf(LESS_THAN.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(LESS_THAN, [{ + key: 'getSQL', + value: function getSQL(query_object) { + var _this = this; + + var left_type = undefined; + var right_type = undefined; + if (this.left.getType) { + left_type = this.left.getType(); + } + if (this.right.getType) { + right_type = this.right.getType(); + } + if (this.right.isInstanceOf(_constants_arrayJs.CONSTANTS_ARRAY)) { + var _ret = (function () { + var right_values = _this.right.getValue(); + var sql_safe_values = []; + var left_sql = _this.left.getSQL(query_object, right_type); + right_values.forEach(function (v) { + sql_safe_values.push(left_sql + ' < ' + v.getSQL(query_object, left_type)); + }); + + return { + v: '(' + sql_safe_values.join(' AND ') + ')' + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + return this.left.getSQL(query_object, right_type) + ' < ' + this.right.getSQL(query_object, left_type); + } + } + }], [{ + key: 'comparitors', + set: function set(v) {}, + get: function get() { + return ['<']; + } + }]); + + return LESS_THAN; +})(_comparitorJs.COMPARITOR); + +exports.LESS_THAN = LESS_THAN; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/like.js b/compiled/pql/opcodes/comparitors/like.js new file mode 100644 index 0000000..515b211 --- /dev/null +++ b/compiled/pql/opcodes/comparitors/like.js @@ -0,0 +1,94 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _comparitorJs = require('./comparitor.js'); + +var _nullJs = require('./../null.js'); + +var _constantJs = require('./../constant.js'); + +var _constants_arrayJs = require('./../constants_array.js'); + +var LIKE = (function (_COMPARITOR) { + _inherits(LIKE, _COMPARITOR); + + function LIKE() { + _classCallCheck(this, LIKE); + + _get(Object.getPrototypeOf(LIKE.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(LIKE, [{ + key: 'getSQL', + value: function getSQL(query_object) { + var _this = this; + + if (this.right.isInstanceOf(_constants_arrayJs.CONSTANTS_ARRAY)) { + var _ret = (function () { + var right_values = _this.right.getValue(); + var sql_safe_values = []; + var left_sql = _this.left.getSQL(query_object); + right_values.forEach(function (v) { + sql_safe_values.push(_this.constructor._getSQLHelper(query_object, left_sql, v)); + }); + + return { + v: '(' + sql_safe_values.join(' OR ') + ')' + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + return this.constructor._getSQLHelper(query_object, this.left, this.right); + } + } + }], [{ + key: '_getSQLHelper', + value: function _getSQLHelper(query_object, left, right) { + var val; + var left_sql; + if (typeof left === 'string') { + left_sql = left; + } else { + left_sql = left.getSQL(query_object); + } + // Hack used to add the wild card char + if (right.isInstanceOf(_constantJs.CONSTANT)) { + val = right.getValue(); + right.setValue(val + '%'); + } + var ret_val; + if (right.isInstanceOf(_nullJs.NULL)) { + ret_val = left_sql + ' IS NULL'; + } else { + ret_val = left_sql + ' LIKE ' + right.getSQL(query_object); + } + // Continue hack from above hack + if (right.isInstanceOf(_constantJs.CONSTANT)) { + right.setValue(val); + } + return ret_val; + } + }, { + key: 'comparitors', + set: function set(v) {}, + get: function get() { + return ['~']; + } + }]); + + return LIKE; +})(_comparitorJs.COMPARITOR); + +exports.LIKE = LIKE; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/no_value.js b/compiled/pql/opcodes/comparitors/no_value.js new file mode 100644 index 0000000..b6a655a --- /dev/null +++ b/compiled/pql/opcodes/comparitors/no_value.js @@ -0,0 +1,42 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _comparitorJs = require('./comparitor.js'); + +var NO_VALUE = (function (_COMPARITOR) { + _inherits(NO_VALUE, _COMPARITOR); + + function NO_VALUE() { + _classCallCheck(this, NO_VALUE); + + _get(Object.getPrototypeOf(NO_VALUE.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(NO_VALUE, [{ + key: 'getSQL', + value: function getSQL(query_object) { + return this.left.getSQL(query_object); + } + }], [{ + key: 'comparitors', + set: function set(v) {}, + get: function get() { + return [';']; + } + }]); + + return NO_VALUE; +})(_comparitorJs.COMPARITOR); + +exports.NO_VALUE = NO_VALUE; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/not_equal.js b/compiled/pql/opcodes/comparitors/not_equal.js new file mode 100644 index 0000000..d5feb48 --- /dev/null +++ b/compiled/pql/opcodes/comparitors/not_equal.js @@ -0,0 +1,74 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _comparitorJs = require('./comparitor.js'); + +var _nullJs = require('./../null.js'); + +var _constants_arrayJs = require('./../constants_array.js'); + +var NOT_EQUAL = (function (_COMPARITOR) { + _inherits(NOT_EQUAL, _COMPARITOR); + + function NOT_EQUAL() { + _classCallCheck(this, NOT_EQUAL); + + _get(Object.getPrototypeOf(NOT_EQUAL.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(NOT_EQUAL, [{ + key: 'getSQL', + value: function getSQL(query_object) { + var _this = this; + + var left_type = undefined; + var right_type = undefined; + if (this.left.getType) { + left_type = this.left.getType(); + } + if (this.right.getType) { + right_type = this.right.getType(); + } + + if (this.right.isInstanceOf(_nullJs.NULL)) { + return this.left.getSQL(query_object, right_type) + ' IS NOT NULL'; + } else if (this.right.isInstanceOf(_constants_arrayJs.CONSTANTS_ARRAY)) { + var _ret = (function () { + var right_values = _this.right.getValue(); + var sql_safe_values = []; + right_values.forEach(function (v) { + sql_safe_values.push(v.getSQL(query_object, left_type)); + }); + return { + v: _this.left.getSQL(query_object, right_type) + ' NOT IN (' + sql_safe_values.join(', ') + ')' + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + return this.left.getSQL(query_object, right_type) + ' != ' + this.right.getSQL(query_object, left_type); + } + } + }], [{ + key: 'comparitors', + set: function set(v) {}, + get: function get() { + return ['!=', '!:']; + } + }]); + + return NOT_EQUAL; +})(_comparitorJs.COMPARITOR); + +exports.NOT_EQUAL = NOT_EQUAL; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/not_like.js b/compiled/pql/opcodes/comparitors/not_like.js new file mode 100644 index 0000000..d8f3381 --- /dev/null +++ b/compiled/pql/opcodes/comparitors/not_like.js @@ -0,0 +1,94 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _comparitorJs = require('./comparitor.js'); + +var _nullJs = require('./../null.js'); + +var _constantJs = require('./../constant.js'); + +var _constants_arrayJs = require('./../constants_array.js'); + +var NOT_LIKE = (function (_COMPARITOR) { + _inherits(NOT_LIKE, _COMPARITOR); + + function NOT_LIKE() { + _classCallCheck(this, NOT_LIKE); + + _get(Object.getPrototypeOf(NOT_LIKE.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(NOT_LIKE, [{ + key: 'getSQL', + value: function getSQL(query_object) { + var _this = this; + + if (this.right.isInstanceOf(_constants_arrayJs.CONSTANTS_ARRAY)) { + var _ret = (function () { + var right_values = _this.right.getValue(); + var sql_safe_values = []; + var left_sql = _this.left.getSQL(query_object); + right_values.forEach(function (v) { + sql_safe_values.push(_this.constructor._getSQLHelper(query_object, left_sql, v)); + }); + + return { + v: '(' + sql_safe_values.join(' AND ') + ')' + }; + })(); + + if (typeof _ret === 'object') return _ret.v; + } else { + return this.constructor._getSQLHelper(query_object, this.left, this.right); + } + } + }], [{ + key: '_getSQLHelper', + value: function _getSQLHelper(query_object, left, right) { + var val; + var left_sql; + if (typeof left === 'string') { + left_sql = left; + } else { + left_sql = left.getSQL(query_object); + } + // Hack used to add the wild card char + if (right.isInstanceOf(_constantJs.CONSTANT)) { + val = right.getValue(); + right.setValue(val + '%'); + } + var ret_val; + if (right.isInstanceOf(_nullJs.NULL)) { + ret_val = left_sql + ' IS NOT NULL'; + } else { + ret_val = left_sql + ' NOT LIKE ' + right.getSQL(query_object); + } + // Continue hack from above hack + if (right.isInstanceOf(_constantJs.CONSTANT)) { + right.setValue(val); + } + return ret_val; + } + }, { + key: 'comparitors', + set: function set(v) {}, + get: function get() { + return ['!~', '!']; + } + }]); + + return NOT_LIKE; +})(_comparitorJs.COMPARITOR); + +exports.NOT_LIKE = NOT_LIKE; \ No newline at end of file diff --git a/compiled/pql/opcodes/constant.js b/compiled/pql/opcodes/constant.js new file mode 100644 index 0000000..f6133fe --- /dev/null +++ b/compiled/pql/opcodes/constant.js @@ -0,0 +1,71 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _opcodeJs = require('./opcode.js'); + +var CONSTANT = (function (_OPCODE) { + _inherits(CONSTANT, _OPCODE); + + function CONSTANT(pql_obj, val) { + _classCallCheck(this, CONSTANT); + + _get(Object.getPrototypeOf(CONSTANT.prototype), 'constructor', this).call(this, pql_obj, val); + + this._force_numeric = false; + this.setValue(val); + } + + _createClass(CONSTANT, [{ + key: 'setValue', + value: function setValue(val) { + this._value = val; + return this; + } + }, { + key: 'setForceNumeric', + value: function setForceNumeric(force) { + this._force_numeric = !!force; + } + }, { + key: 'getValue', + value: function getValue() { + return this._value; + } + }, { + key: 'getSQL', + value: function getSQL(query_object, type_ref) { + var value = this.getValue(); + if ((this._force_numeric || type_ref && type_ref.is_numeric) && this.constructor.canBeNumeric(value)) { + return value.toString().replace(/[^0-9.\-]+/g, ''); + } else { + return query_object.constructor.escapeDBString(value.toString(), true); + } + } + }, { + key: 'isConstant', + value: function isConstant() { + return true; + } + }], [{ + key: 'canBeNumeric', + value: function canBeNumeric(value) { + return (/^-?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)$/.test(value) + ); + } + }]); + + return CONSTANT; +})(_opcodeJs.OPCODE); + +exports.CONSTANT = CONSTANT; \ No newline at end of file diff --git a/compiled/pql/opcodes/constants_array.js b/compiled/pql/opcodes/constants_array.js new file mode 100644 index 0000000..c02f8dd --- /dev/null +++ b/compiled/pql/opcodes/constants_array.js @@ -0,0 +1,36 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _constantJs = require('./constant.js'); + +var CONSTANTS_ARRAY = (function (_CONSTANT) { + _inherits(CONSTANTS_ARRAY, _CONSTANT); + + function CONSTANTS_ARRAY() { + _classCallCheck(this, CONSTANTS_ARRAY); + + _get(Object.getPrototypeOf(CONSTANTS_ARRAY.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(CONSTANTS_ARRAY, [{ + key: 'getSQL', + value: function getSQL(query_object, type_ref) { + throw 'Cannot call getSQL of CONSTANTS_ARRAY'; + } + }]); + + return CONSTANTS_ARRAY; +})(_constantJs.CONSTANT); + +exports.CONSTANTS_ARRAY = CONSTANTS_ARRAY; \ No newline at end of file diff --git a/compiled/pql/opcodes/field.js b/compiled/pql/opcodes/field.js new file mode 100644 index 0000000..80710ab --- /dev/null +++ b/compiled/pql/opcodes/field.js @@ -0,0 +1,91 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _opcodeJs = require('./opcode.js'); + +var FIELD = (function (_OPCODE) { + _inherits(FIELD, _OPCODE); + + function FIELD(pql_obj, field, table_ref) { + _classCallCheck(this, FIELD); + + _get(Object.getPrototypeOf(FIELD.prototype), 'constructor', this).call(this, pql_obj, field, table_ref); + + this.setTableRef(table_ref); + this.setField(field); + } + + _createClass(FIELD, [{ + key: 'setField', + value: function setField(field) { + var map_obj = undefined; + var table_ref = this.getTableRef(); + var pql_obj = this.getPqlObj(); + var config = pql_obj.getConfig(); + + if (table_ref) { + map_obj = table_ref.getCurTableObj(); + } else { + map_obj = config.DB_MAP[pql_obj.getRefTable()]; + } + + if (!map_obj.fields[field]) { + throw 'Could not find field \'' + field + '\' in table \'' + map_obj.name + '\''; + } + this._field = field; + this.setFieldConfig(map_obj.fields[field]); + return this; + } + }, { + key: 'getField', + value: function getField() { + return this._field; + } + }, { + key: 'getTableRef', + value: function getTableRef() { + return this._table_ref; + } + }, { + key: 'setTableRef', + value: function setTableRef(table_ref) { + this._table_ref = table_ref || null; + } + }, { + key: 'setFieldConfig', + value: function setFieldConfig(v) { + this._field_config = v; + return this; + } + }, { + key: 'getFieldConfig', + value: function getFieldConfig() { + return this._field_config; + } + }, { + key: 'getType', + value: function getType() { + return this.getFieldConfig().type; + } + }, { + key: 'getSQL', + value: function getSQL(query_obj) { + return (this.getTableRef() ? this.getTableRef().getSQL(query_obj) : query_obj.constructor.escapeDBIdentifier(this.getPqlObj().getConfig().DB_MAP[this.getPqlObj().getRefTable()].name, true)) + '.' + query_obj.constructor.escapeDBColumnName(this.getField(), true); + } + }]); + + return FIELD; +})(_opcodeJs.OPCODE); + +exports.FIELD = FIELD; \ No newline at end of file diff --git a/compiled/pql/opcodes/function.js b/compiled/pql/opcodes/function.js new file mode 100644 index 0000000..5e9eeb7 --- /dev/null +++ b/compiled/pql/opcodes/function.js @@ -0,0 +1,200 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _opcodeJs = require('./opcode.js'); + +var FUNCTION = (function (_OPCODE) { + _inherits(FUNCTION, _OPCODE); + + function FUNCTION(pql_obj, fn_name) { + _classCallCheck(this, FUNCTION); + + _get(Object.getPrototypeOf(FUNCTION.prototype), 'constructor', this).call(this, pql_obj, fn_name); + + this._needs_group_cache = null; + this.setFunctionName(fn_name); + } + + _createClass(FUNCTION, [{ + key: 'setArgs', + value: function setArgs(args) { + this._needs_group_cache = null; + this._arguments = args; + return this; + } + }, { + key: 'getMinArgs', + value: function getMinArgs() { + return this._fn_settings.min_args; + } + }, { + key: 'getMaxArgs', + value: function getMaxArgs() { + return this._fn_settings.max_args; + } + }, { + key: 'getFuncName', + value: function getFuncName() { + return this._fn_name; + } + }, { + key: 'getFormat', + value: function getFormat() { + return this._fn_settings.format; + } + }, { + key: 'setFunctionName', + value: function setFunctionName(fn_name) { + this._needs_group_cache = null; + fn_name = fn_name.toLowerCase(); + if (!this.getPqlObj().getConfig().FUNCTION_MAP || !this.getPqlObj().getConfig().FUNCTION_MAP[fn_name]) { + throw 'Function \'' + fn_name + '\' is not allowed or not defined'; + } + this._fn_settings = this.getPqlObj().getConfig().FUNCTION_MAP[fn_name]; + this._fn_name = fn_name; + } + }, { + key: 'getFunctionSettings', + value: function getFunctionSettings() { + return this._fn_settings; + } + }, { + key: 'getSQL', + value: function getSQL(query_obj) { + var args = []; + + this._arguments.forEach(function (v) { + args.push(v.getSQL(query_obj)); + }); + return this.buildFromFormat(this.getFormat(), args, this._arguments, query_obj); + } + }, { + key: 'needsGroup', + value: function needsGroup() { + if (this._needs_group_cache !== null) { + return this._needs_group_cache; + } + if (this.getFunctionSettings().is_group_function) { + return this._needs_group_cache = true; + } + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = this._arguments[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var op_code = _step.value; + + if (op_code.needsGroup()) { + return this._needs_group_cache = true; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return this._needs_group_cache = false; + } + }, { + key: 'buildFromFormat', + value: function buildFromFormat(format_arg, args, orig_args, query_obj) { + var out = []; + + switch (typeof format_arg) { + case 'function': + return format_arg.call(this, args, orig_args, query_obj); + break; + case 'string': + // Break does not need to go here because it needs to continue to 'object' section + format_arg = [format_arg]; + case 'object': + // Check if is not array type + if (!(format_arg instanceof Array)) { + if (format_arg[args.length] !== undefined) { + return this.buildFromFormat(format_arg[args.length], args, orig_args, query_obj); + } else { + throw 'Could not find ' + format_arg[args.length] + ' in format config for function'; + } + } + + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = format_arg[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var format = _step2.value; + + switch (typeof format) { + case 'string': + out.push(format); + break; + case 'number': + if (args.length > format && format >= 0) { + out.push(args[format]); + } else { + throw 'Format \'' + format.join('') + '\' tried to use argument with number out of range'; + } + break; + case 'function': + out.push(format.call(this, args, orig_args, query_obj)); + break; + case 'object': + if (format[args.length]) { + return this.buildFromFormat(format[args.length], args, orig_args, query_obj); + } else { + throw 'Format \'' + JSON.stringify(format) + '\' does not have key of \'' + args.length + '\''; + } + break; + default: + throw 'Format \'' + JSON.stringify(format) + '\' does not have a valid type'; + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2['return']) { + _iterator2['return'](); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + return out.join(''); + default: + throw 'Format \'' + JSON.stringify(format_arg) + '\' is of unhandleable type'; + } + } + }]); + + return FUNCTION; +})(_opcodeJs.OPCODE); + +exports.FUNCTION = FUNCTION; \ No newline at end of file diff --git a/compiled/pql/opcodes/group.js b/compiled/pql/opcodes/group.js new file mode 100644 index 0000000..42ba931 --- /dev/null +++ b/compiled/pql/opcodes/group.js @@ -0,0 +1,131 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _opcodeJs = require('./opcode.js'); + +var GROUP = (function (_OPCODE) { + _inherits(GROUP, _OPCODE); + + function GROUP(pql_obj, op_codes) { + _classCallCheck(this, GROUP); + + _get(Object.getPrototypeOf(GROUP.prototype), 'constructor', this).call(this, pql_obj, op_codes); + + this._needs_group_cache = null; + this._needs_wrap = true; + this.setOpCodes(op_codes); + } + + _createClass(GROUP, [{ + key: 'setNeedWrap', + value: function setNeedWrap(val) { + this._needs_group_cache = null; + this._needs_wrap = !!val; + return this; + } + }, { + key: 'setOpCodes', + value: function setOpCodes(op_codes) { + this._needs_group_cache = null; + this._op_codes = op_codes; + return this; + } + }, { + key: 'getOpCodes', + value: function getOpCodes() { + return this._op_codes; + } + }, { + key: 'getOpCodeLen', + value: function getOpCodeLen() { + return this._op_codes.length; + } + }, { + key: 'getSQL', + value: function getSQL(query_obj) { + var outs = []; + if (this._needs_wrap) { + outs.push('('); + } + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = this._op_codes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var op_code = _step.value; + + outs.push(op_code.getSQL(query_obj)); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + if (this._needs_wrap) { + outs.push(')'); + } + return outs.join(' '); + } + }, { + key: 'needsGroup', + value: function needsGroup() { + if (this._needs_group_cache !== null) { + return this._needs_group_cache; + } + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = this._op_codes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var op_code = _step2.value; + + if (op_code.needsGroup()) { + return this._needs_group_cache = true; + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2['return']) { + _iterator2['return'](); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + return this._needs_group_cache = false; + } + }]); + + return GROUP; +})(_opcodeJs.OPCODE); + +exports.GROUP = GROUP; \ No newline at end of file diff --git a/compiled/pql/opcodes/null.js b/compiled/pql/opcodes/null.js new file mode 100644 index 0000000..f2839f2 --- /dev/null +++ b/compiled/pql/opcodes/null.js @@ -0,0 +1,36 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _opcodeJs = require('./opcode.js'); + +var NULL = (function (_OPCODE) { + _inherits(NULL, _OPCODE); + + function NULL() { + _classCallCheck(this, NULL); + + _get(Object.getPrototypeOf(NULL.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(NULL, [{ + key: 'getSQL', + value: function getSQL() { + return 'NULL'; + } + }]); + + return NULL; +})(_opcodeJs.OPCODE); + +exports.NULL = NULL; \ No newline at end of file diff --git a/compiled/pql/opcodes/opcode.js b/compiled/pql/opcodes/opcode.js new file mode 100644 index 0000000..afc95d2 --- /dev/null +++ b/compiled/pql/opcodes/opcode.js @@ -0,0 +1,57 @@ +/* + * Interface class to all OPCODES + */ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var OPCODE = (function () { + function OPCODE(pql_obj) { + _classCallCheck(this, OPCODE); + + this.setPqlObj(pql_obj); + } + + _createClass(OPCODE, [{ + key: "setPqlObj", + value: function setPqlObj(v) { + this._pql_obj = v; + return this; + } + }, { + key: "getPqlObj", + value: function getPqlObj() { + return this._pql_obj; + } + }, { + key: "isConstant", + value: function isConstant() { + return false; + } + }, { + key: "getValue", + value: function getValue() { + return null; + } + }, { + key: "needsGroup", + value: function needsGroup() { + return false; + } + }, { + key: "isInstanceOf", + value: function isInstanceOf(chk_class) { + return this instanceof chk_class; + } + }]); + + return OPCODE; +})(); + +exports.OPCODE = OPCODE; \ No newline at end of file diff --git a/compiled/pql/opcodes/or.js b/compiled/pql/opcodes/or.js new file mode 100644 index 0000000..b71882d --- /dev/null +++ b/compiled/pql/opcodes/or.js @@ -0,0 +1,36 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _seperatorsJs = require('./seperators.js'); + +var OR = (function (_SEPERATORS) { + _inherits(OR, _SEPERATORS); + + function OR() { + _classCallCheck(this, OR); + + _get(Object.getPrototypeOf(OR.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(OR, [{ + key: 'getSQL', + value: function getSQL() { + return 'OR'; + } + }]); + + return OR; +})(_seperatorsJs.SEPERATORS); + +exports.OR = OR; \ No newline at end of file diff --git a/compiled/pql/opcodes/seperator.js b/compiled/pql/opcodes/seperator.js new file mode 100644 index 0000000..33afbd4 --- /dev/null +++ b/compiled/pql/opcodes/seperator.js @@ -0,0 +1,36 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _seperatorsJs = require('./seperators.js'); + +var SEPERATOR = (function (_SEPERATORS) { + _inherits(SEPERATOR, _SEPERATORS); + + function SEPERATOR() { + _classCallCheck(this, SEPERATOR); + + _get(Object.getPrototypeOf(SEPERATOR.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(SEPERATOR, [{ + key: 'getSQL', + value: function getSQL() { + return ','; + } + }]); + + return SEPERATOR; +})(_seperatorsJs.SEPERATORS); + +exports.SEPERATOR = SEPERATOR; \ No newline at end of file diff --git a/compiled/pql/opcodes/seperators.js b/compiled/pql/opcodes/seperators.js new file mode 100644 index 0000000..412f676 --- /dev/null +++ b/compiled/pql/opcodes/seperators.js @@ -0,0 +1,36 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _opcodeJs = require('./opcode.js'); + +var SEPERATORS = (function (_OPCODE) { + _inherits(SEPERATORS, _OPCODE); + + function SEPERATORS() { + _classCallCheck(this, SEPERATORS); + + _get(Object.getPrototypeOf(SEPERATORS.prototype), 'constructor', this).apply(this, arguments); + } + + _createClass(SEPERATORS, [{ + key: 'getSQL', + value: function getSQL() { + return 'UNKNOWN'; + } + }]); + + return SEPERATORS; +})(_opcodeJs.OPCODE); + +exports.SEPERATORS = SEPERATORS; \ No newline at end of file diff --git a/compiled/pql/opcodes/variable.js b/compiled/pql/opcodes/variable.js new file mode 100644 index 0000000..a2566ec --- /dev/null +++ b/compiled/pql/opcodes/variable.js @@ -0,0 +1,94 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var _constantJs = require('./constant.js'); + +var _nullJs = require('./null.js'); + +var VARIABLE = (function (_CONSTANT) { + _inherits(VARIABLE, _CONSTANT); + + function VARIABLE(pql_obj, var_name) { + _classCallCheck(this, VARIABLE); + + _get(Object.getPrototypeOf(VARIABLE.prototype), 'constructor', this).call(this, pql_obj, null); + + pql_obj.addVariable(var_name, this); + + this._force_numeric = false; + this.setVarName(var_name); + } + + _createClass(VARIABLE, [{ + key: 'setVarName', + value: function setVarName(var_name) { + this._var_name = var_name; + } + }, { + key: 'getVarName', + value: function getVarName() { + return this._var_name; + } + }, { + key: 'setValue', + value: function setValue(val) { + this._value = val; + return this; + } + }, { + key: 'getValue', + value: function getValue() { + return this._value; + } + }, { + key: 'getSQL', + value: function getSQL(query_object, type_ref) { + var value = this.getValue(); + if (value === null || value === undefined) { + return new _nullJs.NULL(query_object).getSQL(query_object); + } else if ((this._force_numeric || type_ref && type_ref.is_numeric) && this.constructor.canBeNumeric(value)) { + return value.toString().replace(/[^0-9.\-]+/g, ''); + } else { + return query_object.constructor.escapeDBString(value.toString(), true); + } + } + }, { + key: 'isInstanceOf', + value: function isInstanceOf(class_obj) { + var value = this.getValue(); + if (value === null || value === undefined) { + return class_obj === _nullJs.NULL; + } + return this instanceof class_obj; + } + }, { + key: 'isConstant', + value: function isConstant() { + return true; + } + }], [{ + key: 'canBeNumeric', + value: function canBeNumeric(value) { + if (value === null || value === undefined) { + return false; + } + return (/^-?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)$/.test(value) + ); + } + }]); + + return VARIABLE; +})(_constantJs.CONSTANT); + +exports.VARIABLE = VARIABLE; \ No newline at end of file diff --git a/compiled/pql/parser.js b/compiled/pql/parser.js new file mode 100644 index 0000000..7268435 --- /dev/null +++ b/compiled/pql/parser.js @@ -0,0 +1,761 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +var _parserComparitorsJs = require('./parser/comparitors.js'); + +var _opcodesAndJs = require('./opcodes/and.js'); + +var _opcodesConstantJs = require('./opcodes/constant.js'); + +var _opcodesFieldJs = require('./opcodes/field.js'); + +var _opcodesFunctionJs = require('./opcodes/function.js'); + +var _opcodesGroupJs = require('./opcodes/group.js'); + +var _opcodesNullJs = require('./opcodes/null.js'); + +var _opcodesOrJs = require('./opcodes/or.js'); + +var _opcodesSeperatorJs = require('./opcodes/seperator.js'); + +var _opcodesSeperatorsJs = require('./opcodes/seperators.js'); + +var _opcodesComparitorsNo_valueJs = require('./opcodes/comparitors/no_value.js'); + +var _opcodesVariableJs = require('./opcodes/variable.js'); + +var _opcodesConstants_arrayJs = require('./opcodes/constants_array.js'); + +var _parserTable_refJs = require('./parser/table_ref.js'); + +var PARSER = (function () { + function PARSER(query, ref_table) { + var allow_seperator = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; + var config = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; + var table_refs = arguments.length <= 4 || arguments[4] === undefined ? [] : arguments[4]; + var variables = arguments.length <= 5 || arguments[5] === undefined ? {} : arguments[5]; + + _classCallCheck(this, PARSER); + + this._hasError = false; + this._error = null; + this._codes = []; + this._comparitors = new _parserComparitorsJs.COMPARITORS(config.COMPARITORS); + this._table_refs = table_refs; + this._variables = {}; + + // Defaults to false + allow_seperator = !!allow_seperator; + + if (config !== undefined) { + this._config = config; + } else { + this._config = PARSER.getDefaultConfig(); + } + + this._ref_table = ref_table; + + if (query === null || query === undefined || !query.length) { + var group = new _opcodesGroupJs.GROUP(this, []); + group.setNeedWrap(false); + this.setCodes(group); + this.assignVariables(variables); + } else { + try { + var general = this.T_GENERAL(query, allow_seperator); + if (general === false) { + throw ["Unknown character", query.length]; + } + if (general[0] != query.length) { + throw ["Unknown character", query.length - general[0]]; + } + if (general[1].isInstanceOf(_opcodesGroupJs.GROUP)) { + general[1].setNeedWrap(false); + } + this.setCodes(general[1]); + } catch (e) { + if (e instanceof Array) { + this.setError([e[0] + ' at character ' + (query.length - e[1]).toString(), query.length - e[1], query], true); + } else { + this.setError(e.message || e, true); + } + } finally { + this.assignVariables(variables); + } + } + } + + _createClass(PARSER, [{ + key: 'assignVariables', + value: function assignVariables(var_list_obj) { + for (var var_name in var_list_obj) { + if (var_list_obj.hasOwnProperty(var_name)) { + this.assignVariable(var_name, var_list_obj[var_name]); + } + } + } + }, { + key: 'assignVariable', + value: function assignVariable(var_name, val) { + if (this._variables[var_name]) { + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = this._variables[var_name][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var obj = _step.value; + + obj.setValue(val); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + } + } + }, { + key: 'addVariable', + value: function addVariable(var_name, obj) { + if (this._variables[var_name] === undefined) { + this._variables[var_name] = []; + } + this._variables[var_name].push(obj); + } + }, { + key: 'getRefTable', + value: function getRefTable() { + return this._ref_table; + } + }, { + key: '_getCodesOfGroup', + value: function _getCodesOfGroup(need_group) { + var codes = this._codes; + + if (codes && codes.isInstanceOf(_opcodesGroupJs.GROUP)) { + var group_codes = codes.getOpCodes(); + var new_codes = []; + var has_or = false; + var has_needs_group = false; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = group_codes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var code = _step2.value; + + // If it has an OR just return all of them if in where + if (code.isInstanceOf(_opcodesOrJs.OR)) { + has_or = true; + } + if (code.needsGroup()) { + has_needs_group = true; + } + if (has_or && has_needs_group) { + if (need_group) { + return codes; + } else { + return new _opcodesGroupJs.GROUP(this, []).setNeedWrap(false); + } + } + if (!!need_group === code.needsGroup()) { + new_codes.push(code); + } + } + // Trims off any comparitors (ANDs and ORs) from beginning and end of codes + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2['return']) { + _iterator2['return'](); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + while (new_codes.length) { + if (new_codes[0] && new_codes[0].isInstanceOf(_opcodesSeperatorsJs.SEPERATORS)) { + new_codes.shift(); + } else { + break; + } + } + while (new_codes.length) { + if (new_codes[new_codes.length - 1] && new_codes[new_codes.length - 1].isInstanceOf(_opcodesSeperatorsJs.SEPERATORS)) { + new_codes.pop(); + } else { + break; + } + } + return new _opcodesGroupJs.GROUP(this, new_codes).setNeedWrap(false); + } else { + if (need_group !== codes.needsGroup()) { + return new _opcodesGroupJs.GROUP(this, []).setNeedWrap(false); + } else { + return codes; + } + } + } + }, { + key: 'getWhereCodes', + value: function getWhereCodes() { + return this._getCodesOfGroup(false); + } + }, { + key: 'getHavingCodes', + value: function getHavingCodes() { + return this._getCodesOfGroup(true); + } + }, { + key: 'getCodes', + value: function getCodes() { + return this._codes; + } + }, { + key: 'setCodes', + value: function setCodes(v) { + this._codes = v; + return this; + } + }, { + key: 'setError', + value: function setError(error, noThrow) { + this._error = error; + this._hasError = true; + if (!noThrow) { + throw error; + } + } + }, { + key: 'getError', + value: function getError() { + return this._error; + } + }, { + key: 'hasError', + value: function hasError() { + return this._hasError; + } + }, { + key: 'getConfig', + value: function getConfig() { + return this._config; + } + }, { + key: 'T_COMPARITOR', + + // Checks if any of the comparitor operators persist here + value: function T_COMPARITOR(str) { + var start_pos = 0; + var next_char; + while ((next_char = str.substr(start_pos, 1)) && (next_char === ' ' || next_char === "\r" || next_char === "\n" || next_char === "\t")) { + // Ignore spaces + start_pos++; + } + var max_comp_len = this._comparitors.getComparitorMaxLength(); + + // 0 because it 0 is not to be counted... 1 is the max + for (var i = max_comp_len; i > 0; i--) { + if (this._comparitors.comparitors.has(i)) { + var chrs = str.substr(start_pos, i); + var cmps = this._comparitors.comparitors.get(i); + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = cmps[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var c = _step3.value; + + if (c[0] === chrs) { + return [i + start_pos, new c[1](this)]; + } + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3['return']) { + _iterator3['return'](); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } + } + } + return false; + } + + /* + * When a table reference is specified. + */ + }, { + key: 'T_TABLE_REF', + value: function T_TABLE_REF(str, table_ref) { + var match = str.match(/^\s*([a-zA-Z_][a-zA-Z0-9_]*)\./); + if (!match) { + return false; + } + str = str.substring(match[0].length); + if (!table_ref) { + var refs = this._table_refs.slice(0); + refs.push(match[1]); + table_ref = new _parserTable_refJs.TABLE_REF(this, refs[0]); + // Start at one because first one already done + for (var i = 1; i < refs.length; i++) { + table_ref.appendRef(refs[i]); + } + } else { + table_ref.appendRef(match[1]); + } + + // Will recrusively loop until no more table refs exist + // Will also modify the table_ref with any additional tables in this + var sub_ref = this.T_TABLE_REF(str, table_ref); + if (!sub_ref) { + var field = this.T_FIELD(str, table_ref); + if (!field) { + throw ["Expected T_FIELD", str.length, [_opcodesFieldJs.FIELD]]; + } + return [match[0].length + field[0], field[1]]; + } + return [match[0].length + sub_ref[0], sub_ref[1]]; + } + + /* + * Is the value that comes after a comparitor. + */ + }, { + key: 'T_COMPARE_VALUE', + value: function T_COMPARE_VALUE(str) { + var ret_const = this.T_CONSTANT(str); + if (ret_const) { + return ret_const; + } + var match = str.match(/^\s*([a-zA-Z0-9_\-.]+)/); + if (match) { + return [match[0].length, new _opcodesConstantJs.CONSTANT(this, match[1])]; + } + var ret_array = this.T_ARRAY_VALUE(str); + if (ret_array) { + return ret_array; + } + return false; + } + }, { + key: 'T_ARRAY_VALUE', + value: function T_ARRAY_VALUE(str) { + var tries = 0; + var next_char = undefined; + // Ignore spaces + while ((next_char = str.substr(tries, 1)) && (next_char === ' ' || next_char === "\r" || next_char === "\n" || next_char === "\t")) { + tries++; + } + if (next_char === '[') { + var array_values = []; + var s = str.substr(tries + 1); + do { + var c = this.T_COMPARE_VALUE(s); + if (!c) { + throw ['Expected T_COMPARE_VALUE', s.length]; + } + s = s.substr(c[0]); + array_values.push(c[1]); + var sep = this.T_SEPERATOR(s); + if (!sep) { + var term = s.match(/^\s*\]/); + if (term) { + return [str.length - s.length + term[0].length, new _opcodesConstants_arrayJs.CONSTANTS_ARRAY(this, array_values)]; + } else { + throw ['Expected T_CONSTANT, T_SEPERATOR or closing array "]" character', s.length]; + } + } else { + s = s.substr(sep[0]); + } + } while (true); + } + return false; + } + + /* + * Is a field in a table + */ + }, { + key: 'T_FIELD', + value: function T_FIELD(str, table_ref) { + var match = str.match(/^\s*([a-zA-Z_][a-zA-Z0-9_]*)/); + if (!match) { + return false; + } + if (!table_ref) { + if (this._table_refs.length) { + table_ref = new _parserTable_refJs.TABLE_REF(this, this._table_refs[0]); + // Start at one because first one already done + for (var i = 1; i < this._table_refs.length; i++) { + table_ref.appendRef(this._table_refs[i]); + } + } + } + + try { + var field = new _opcodesFieldJs.FIELD(this, match[1], table_ref); + } catch (e) { + throw [e, str.length, [_opcodesFieldJs.FIELD]]; + } + str = str.substring(match[0].length); + + var comparitor = this.T_COMPARITOR(str); + if (!comparitor) { + return [match[0].length, field]; + //throw ["Expected T_COMPARITOR", str.length]; + } + if (comparitor[1].isInstanceOf(_opcodesComparitorsNo_valueJs.NO_VALUE)) { + return [match[0].length + comparitor[0], field]; + } + + str = str.substring(comparitor[0]); + var value = this.T_COMPARE_VALUE(str); + if (!value) { + throw ["Expected T_COMPARE_VALUE", str.length, [_opcodesConstantJs.CONSTANT, _opcodesNullJs.NULL]]; + } + comparitor[1].setLeft(field).setRight(value[1]); + + return [match[0].length + comparitor[0] + value[0], comparitor[1]]; + } + + /* + * Is a function in sql + */ + }, { + key: 'T_FUNCTION', + value: function T_FUNCTION(str) { + var match = str.match(/^\s*([a-zA-Z0-9_]+)\(/); + if (!match) { + return false; + } + try { + var func = new _opcodesFunctionJs.FUNCTION(this, match[1]); + } catch (e) { + throw [e, str.length, [_opcodesFunctionJs.FUNCTION]]; + } + var max_args = func.getMaxArgs(); + var min_args = func.getMinArgs(); + var sum_length = 0; + var found_args = []; + + str = str.substring(match[0].length); + for (var i = 0; true; i++) { + if (found_args.length >= max_args) { + throw ['Function \'' + func.getFuncName() + '\' cannot have more than ' + max_args.toString() + ' args', str.length, []]; + } + var general = this.T_GENERAL(str); + if (!general && found_args.length < min_args) { + throw ['Function \'' + func.getFuncName() + '\' expected ' + min_args.toString() + ' but got ' + found_args.length.toString() + ' args', str.length, []]; + } + if (!general) { + break; + } + sum_length += general[0]; + if (general[1].isInstanceOf(_opcodesGroupJs.GROUP)) { + general.setNeedWrap(false); + } + found_args.push(general[1]); + str = str.substring(general[0]); + + var seperator = this.T_SEPERATOR(str); + if (!seperator) { + break; + } + str = str.substring(seperator[0]); + sum_length += seperator[0]; + } + var closer = this.T_FUNCTION_CLOSER(str); + if (!closer) { + throw ["Open function group tag without close tag", str.length]; + } + func.setArgs(found_args); + str = str.substring(closer[0]); + + var comparitor = this.T_COMPARITOR(str); + if (!comparitor) { + return [match[0].length + sum_length + closer[0], func]; + //throw ["Expected T_COMPARITOR", str.length]; + } + if (comparitor[1].isInstanceOf(_opcodesComparitorsNo_valueJs.NO_VALUE)) { + return [match[0].length + sum_length + closer[0] + comparitor[0], func]; + } + str = str.substring(comparitor[0]); + var value = this.T_COMPARE_VALUE(str); + comparitor[1].setLeft(func); + comparitor[1].setRight(value[1]); + + return [match[0].length + sum_length + closer[0] + comparitor[0] + value[0], comparitor[1]]; + } + + /* + * Is a string constant. The matching string will be exactly sent as is. Also good for binary data. + */ + }, { + key: 'T_CONSTANT', + value: function T_CONSTANT(str) { + var tries = 0; + var next_char = undefined; + // Ignore spaces + while ((next_char = str.substr(tries, 1)) && (next_char === ' ' || next_char === "\r" || next_char === "\n" || next_char === "\t")) { + tries++; + } + var match = undefined; + switch (next_char) { + case '"': + match = str.match(/^\s*"((?:[^"\\]?(?:\\[\x00-\xFF])?)*)"/); + // Make sure we have data + if (match && match.length && match[1].length) { + match[1] = match[1].replace(/((?:^|[^\\])(\\\.)*)\\n/g, "$1\n"); + match[1] = match[1].replace(/((?:^|[^\\])(\\\\)*)\\r/g, "$1\r"); + match[1] = match[1].replace(/((?:^|[^\\])(\\\\)*)\\t/g, "$1\t"); + match[1] = match[1].replace(/\\([\x00-\xFF])/g, '$1'); + } + break; + case "'": + match = str.match(/^\s*'((?:[^'\\]?(?:\\[\x00-\xFF])?)*)'/); + // Make sure we have data + if (match && match.length && match[1].length) { + match[1] = match[1].replace(/((?:^|[^\\])(\\\.)*)\\n/g, "$1\n"); + match[1] = match[1].replace(/((?:^|[^\\])(\\\\)*)\\r/g, "$1\r"); + match[1] = match[1].replace(/((?:^|[^\\])(\\\\)*)\\t/g, "$1\t"); + match[1] = match[1].replace(/\\([\x00-\xFF])/g, '$1'); + } + break; + case '@': + match = str.match(/\s*@([a-zA-Z0-9\-_]+)/); + if (match) { + return [match[0].length, new _opcodesVariableJs.VARIABLE(this, match[1])]; + } + break; + case '-': + if (!/[0-9]/.test(str.substr(tries + 1, 1))) { + return [1 + tries, new _opcodesNullJs.NULL(this)]; + } + } + if (!match) { + // see if it's a constant numeric + match = str.match(/^\s*(-?[0-9]+(\.[0-9]+)?)/); + if (!match) { + return false; + } + } + return [match[0].length, new _opcodesConstantJs.CONSTANT(this, match[1])]; + } + }, { + key: 'T_GENERAL', + value: function T_GENERAL(str, allow_seperator) { + var op_order = [this.T_TABLE_REF, this.T_FUNCTION, this.T_CONSTANT, this.T_FIELD, this.T_GROUP_OPENER]; + + /*this.T_SUBQUERY_OPENER*/ + var op_len = op_order.length; + var used_str_len = 0; + var op_codes = []; + var found = undefined; + + do { + for (var i = 0; i < op_len; i++) { + found = op_order[i].call(this, str); + if (found) { + break; + } + } + if (found) { + var sep = undefined; + str = str.substring(found[0]); + used_str_len += found[0]; + if (op_codes.length && !op_codes[op_codes.length - 1].isInstanceOf(_opcodesSeperatorsJs.SEPERATORS)) { + throw ['Expected space, "|"' + (allow_seperator ? ' or ","' : ''), str.length + found[0]]; + } + op_codes.push(found[1]); + + // This is a simple trick to keep from many ifs from being needed. + switch (allow_seperator) { + case true: + if (sep = this.T_SEPERATOR(str)) { + break; + } + default: + if ((sep = this.T_OR(str)) || (sep = this.T_AND(str))) { + break; + } + } + if (sep) { + str = str.substring(sep[0]); + used_str_len += sep[0]; + op_codes.push(sep[1]); + } + } + } while (found && str.length !== 0); + + // Removes any trailing ANDs + while (op_codes.length) { + if (op_codes[op_codes.length - 1] && op_codes[op_codes.length - 1].isInstanceOf(_opcodesAndJs.AND)) { + op_codes.pop(); + } else { + break; + } + } + + if (op_codes.length && op_codes[op_codes.length - 1].isInstanceOf(_opcodesSeperatorsJs.SEPERATORS)) { + throw ["Cannot terminate this section with a seperator", str.length]; + } + + if (op_codes.length && op_codes.length > 1) { + return [used_str_len, new _opcodesGroupJs.GROUP(this, op_codes)]; + } else if (op_codes.length == 1) { + return [used_str_len, op_codes[0]]; + } + return false; + } + + /* + * Represents an open prenthesis "(" + */ + }, { + key: 'T_GROUP_OPENER', + value: function T_GROUP_OPENER(str) { + var match = str.match(/^\s*\(\s*/); + if (!match) { + return false; + } + str = str.substring(match[0].length); + var general = this.T_GENERAL(str); + if (!general) { + throw ["Group cannot be empty", str.length]; + } + str = str.substring(general[0]); + var closer = this.T_GROUP_CLOSER(str); + if (!closer) { + throw ["Open group tag without close tag", str.length]; + } + return [match[0].length + general[0] + closer[0], general[1]]; + } + }, { + key: 'T_FUNCTION_CLOSER', + value: function T_FUNCTION_CLOSER(str) { + var match = str.match(/^\s*\)/); + if (!match) { + return false; + } + return [match[0].length, true]; + } + + /* + * Represents a closed prenthesis ")" + */ + }, { + key: 'T_GROUP_CLOSER', + value: function T_GROUP_CLOSER(str) { + var match = str.match(/^\s*\)/); + if (!match) { + return false; + } + return [match[0].length, true]; + } + + /* + * Represents an open prenthesis "{". The data inside will be parsed as a subquery. + */ + }, { + key: 'T_SUBQUERY_OPENER', + value: function T_SUBQUERY_OPENER(str) {} + // TODO: this + + /* + * Represents a closed prenthesis "}" + */ + + }, { + key: 'T_SUBQUERY_CLOSER', + value: function T_SUBQUERY_CLOSER(str) {} + // TODO: this + + /* + * Is the space character + */ + + }, { + key: 'T_AND', + value: function T_AND(str) { + var match = str.match(/^\s+/); + if (!match) { + return false; + } + return [match[0].length, new _opcodesAndJs.AND(this)]; + } + + /* + * Is the pipe "|" character + */ + }, { + key: 'T_OR', + value: function T_OR(str) { + var match = str.match(/^\s*\|/); + if (!match) { + return false; + } + return [match[0].length, new _opcodesOrJs.OR(this)]; + } + + /* + * Is the comma "," character + */ + }, { + key: 'T_SEPERATOR', + value: function T_SEPERATOR(str) { + var match = str.match(/^\s*,/); + if (!match) { + return false; + } + return [match[0].length, new _opcodesSeperatorJs.SEPERATOR(this)]; + } + }], [{ + key: 'setDefaultConfig', + value: function setDefaultConfig(config) { + PARSER._config = config; + return this; + } + }, { + key: 'getDefaultConfig', + value: function getDefaultConfig() { + return PARSER._config; + } + }]); + + return PARSER; +})(); + +exports.PARSER = PARSER; \ No newline at end of file diff --git a/compiled/pql/parser/comparitors.js b/compiled/pql/parser/comparitors.js new file mode 100644 index 0000000..b9f462b --- /dev/null +++ b/compiled/pql/parser/comparitors.js @@ -0,0 +1,87 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var COMPARITORS = (function () { + function COMPARITORS(comparitors) { + _classCallCheck(this, COMPARITORS); + + this._comparitors = new Map(); + this._comparitorMaxLength = 0; + + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = comparitors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var comparitor = _step.value; + + this.addComparitor(comparitor.comparitors, comparitor); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator["return"]) { + _iterator["return"](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + } + + _createClass(COMPARITORS, [{ + key: "clearComparitors", + value: function clearComparitors() { + this._comparitors = new Map(); + this._comparitorMaxLength = 0; + return this; + } + }, { + key: "addComparitor", + value: function addComparitor(comparitors, cls) { + var _this = this; + + // Add each item into a multi-dimentional array for faster? processing in the parser + if (!Array.isArray(comparitors)) { + comparitors = [comparitors]; + } + comparitors.forEach(function (item) { + if (!_this._comparitors.has(item.length)) { + if (_this._comparitorMaxLength < item.length) { + _this._comparitorMaxLength = item.length; + } + _this._comparitors.set(item.length, new Map()); + } + _this._comparitors.get(item.length).set(item, cls); + }); + return this; + } + }, { + key: "getComparitorMaxLength", + value: function getComparitorMaxLength() { + return this._comparitorMaxLength; + } + }, { + key: "comparitors", + get: function get() { + return this._comparitors; + }, + set: function set(v) {} + }]); + + return COMPARITORS; +})(); + +exports.COMPARITORS = COMPARITORS; \ No newline at end of file diff --git a/compiled/pql/parser/sql_builder.js b/compiled/pql/parser/sql_builder.js new file mode 100644 index 0000000..d6b0058 --- /dev/null +++ b/compiled/pql/parser/sql_builder.js @@ -0,0 +1,304 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +var _parserJs = require('./../parser.js'); + +var SQL_BUILDER = (function () { + function SQL_BUILDER(_ref) { + var query = _ref.query; + var table = _ref.table; + var group = _ref.group; + var selects = _ref.selects; + var orderBys = _ref.orderBys; + + _classCallCheck(this, SQL_BUILDER); + + this._query = query; + this._table = table; + this._group = group; + this._selects = selects; + this._orderBys = orderBys; + + this._table_refs = new Map(); + this._linked_tables = []; + this._next_i = 0; + } + + _createClass(SQL_BUILDER, [{ + key: 'getQuery', + value: function getQuery() { + return this._query; + } + }, { + key: 'getTable', + value: function getTable() { + return this._table; + } + }, { + key: 'getGroup', + value: function getGroup() { + return this._group; + } + }, { + key: 'getSelects', + value: function getSelects() { + return this._selects; + } + }, { + key: 'getOrderBys', + value: function getOrderBys() { + return this._orderBys; + } + }, { + key: 'getTableName', + value: function getTableName() { + return this.getQuery().getConfig().DB_MAP[this.getTable()].name; + } + }, { + key: 'toString', + value: function toString() { + var _this = this; + + var query_str = this.getQuery().getWhereCodes().getSQL(this); + if (query_str) { + query_str = '\nWHERE\n\t' + query_str; + } + var having_str = this.getQuery().getHavingCodes().getSQL(this); + if (having_str) { + having_str = '\nHAVING\n\t' + having_str; + } + var group_str = this.getGroup().getCodes().getSQL(this); + if (group_str) { + group_str = '\nGROUP BY\n\t' + group_str; + } + var selects = []; + this.getSelects().forEach(function (v, k) { + var val = v.getCodes().getSQL(_this) + (k ? ' AS ' + _this.constructor.escapeDBIdentifier(k, true) : ''); + if (val) { + selects.push(val); + } + }); + if (!selects.length) { + selects.push('*'); + } + var orders = []; + this.getOrderBys().forEach(function (v, k) { + var code = k.getCodes().getSQL(_this); + if (code) { + orders.push(code + (v !== null && v !== undefined && v.toLowerCase() === 'desc' ? ' DESC' : ' ASC')); + } + }); + var order_by_str = ''; + if (orders.length) { + order_by_str = '\nORDER BY\n\t' + orders.join(','); + } + + var join_str = ''; + if (this._table_refs.size) { + var join_ary = []; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = this._linked_tables[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var table_ref = _step.value; + + join_ary.push('LEFT JOIN ' + this.constructor.escapeDBTableName(table_ref.table_obj.name, true) + ' AS ' + this.constructor.escapeDBIdentifier(table_ref.alias, true) + ' ON ' + table_ref.parser.getCodes().getSQL(this)); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + if (join_ary.length) { + join_str = '\n\t' + join_ary.join('\n\t'); + } + } + return 'SELECT\n\t' + selects.join(',\n\t') + '\nFROM ' + this.constructor.escapeDBTableName(this.getTableName(), true) + join_str + query_str + group_str + having_str + order_by_str; + } + }, { + key: '_addTableLink', + value: function _addTableLink(table_ary) { + var table_str = this.constructor.tableArrayToString(table_ary); + if (this._table_refs.has(table_str)) { + return false; + } + + var config = this.getQuery().getConfig(); + var start_table = this.getTable(); + + var accum_table_ary = []; + var trimmed_table_ary = table_ary.slice(0, table_ary.length - 1); + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = trimmed_table_ary[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var ref = _step2.value; + + accum_table_ary.push(ref); + var ary_copy = [].concat(accum_table_ary); + if (!this._table_refs.has(this.constructor.tableArrayToString(ary_copy))) { + this._addTableLink(ary_copy); + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2['return']) { + _iterator2['return'](); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + var link_obj = this.getLinkObj(table_ary); + var link_info = { + alias: this.getNextRefName(), + table_ary: table_ary, + table_str: table_str, + parser: null, + table_obj: config.DB_MAP[link_obj.table] + }; + + // Because this function may be recusive it needs to set this field here even though + // all fields may not be available yet. + if (!this._table_refs.has(link_info.table_str)) { + this._table_refs.set(link_info.table_str, link_info); + } + + // Pop last item off the array and clone it so it doesn't count itself + var parser = new _parserJs.PARSER(link_obj.pql, this.getTable(), false, this.getQuery().getConfig(), table_ary.slice(0, table_ary.length - 1)); + // This needs to happen here to ensure the tables get added in the proper order + parser.getCodes().getSQL(this); + + link_info.parser = parser; + + this._linked_tables.push(link_info); + + return link_info.alias; + } + }, { + key: 'getLinkObj', + value: function getLinkObj(table_ary) { + var tb_ary = [].concat(_toConsumableArray(table_ary)); + var db_map = this.getQuery().getConfig().DB_MAP; + var cur_obj = db_map[this.getTable()]; + var cur_link_obj = undefined; + table_ary.forEach(function (v) { + if (cur_obj.linkTo && cur_obj.linkTo.hasOwnProperty(v)) { + cur_link_obj = cur_obj.linkTo[v]; + } else if (cur_obj.linkFrom && cur_obj.linkFrom.hasOwnProperty(v)) { + cur_link_obj = cur_obj.linkFrom[v]; + } else { + throw 'No table link from "' + cur_obj.name + '" to table "' + v + '"'; + } + cur_obj = db_map[cur_link_obj.table]; + }); + return cur_link_obj; + } + }, { + key: 'getNextRefName', + value: function getNextRefName() { + // Using base 36 just because it will recude the total size of the query... Really it's just for the hell of it. + // Using 'a' because.... Why not? + var ref = 'a' + this._next_i.toString(36); + this._next_i++; + return ref; + } + }, { + key: 'setJoin', + value: function setJoin(table_ary) { + var table_str = this.constructor.tableArrayToString([].concat(_toConsumableArray(table_ary))); + if (this._table_refs.has(table_str)) { + return this._table_refs.get(table_str).alias; + } + return this._addTableLink(table_ary); + } + }], [{ + key: 'tableArrayToString', + value: function tableArrayToString(table_ary) { + return table_ary.join("\0"); + } + }, { + key: 'escapeDBString', + value: function escapeDBString(value) { + var include_wrapper = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + + value = value.replace("\\", "\\\\").replace("\0", "\\0").replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t").replace("'", "\\'").replace(String.fromCharCode(26), '\\Z').replace('\b', '\\b'); + if (include_wrapper) { + return '\'' + value + '\''; + } + return value; + } + }, { + key: 'escapeDBTableName', + value: function escapeDBTableName(value) { + var include_wrapper = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + + if (/[\0\\\/:*<>|."%?]/.test(value)) { + throw "The following characters may not be used for table or column names: \\/:*<>|.\"%?"; + } + if (include_wrapper) { + return '"' + value.replace('"', '""') + '"'; + } + return value.replace('"', '""'); + } + }, { + key: 'escapeDBColumnName', + value: function escapeDBColumnName(value) { + var include_wrapper = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + + if (/[\0\\\/:*<>|."%?]/.test(value)) { + throw "The following characters may not be used for table or column names: \\/:*<>|.\"%?"; + } + if (/^-?[0-9]+$/.test(value)) { + throw "Column name cannot match [-][0-9...]"; + } + if (include_wrapper) { + return '"' + value.replace('"', '""') + '"'; + } + return value.replace('"', '""'); + } + }, { + key: 'escapeDBIdentifier', + value: function escapeDBIdentifier(value) { + var include_wrapper = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + + if (include_wrapper) { + return '"' + value.replace('"', '""') + '"'; + } + return value.replace('"', '""'); + } + }]); + + return SQL_BUILDER; +})(); + +exports.SQL_BUILDER = SQL_BUILDER; \ No newline at end of file diff --git a/compiled/pql/parser/table_ref.js b/compiled/pql/parser/table_ref.js new file mode 100644 index 0000000..e057b93 --- /dev/null +++ b/compiled/pql/parser/table_ref.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var TABLE_REF = (function () { + function TABLE_REF(pql_obj) { + var table = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; + + _classCallCheck(this, TABLE_REF); + + this._refs = []; + this._pql_obj = pql_obj; + this._cur_table_obj = null; + if (table) { + this.appendRef(table); + } + } + + _createClass(TABLE_REF, [{ + key: "appendRef", + value: function appendRef(table) { + var db_map = this._pql_obj.getConfig().DB_MAP; + if (!this._cur_table_obj) { + this._cur_table_obj = db_map[this._pql_obj.getRefTable()]; + } + if (this._cur_table_obj.linkTo && this._cur_table_obj.linkTo[table]) { + this._cur_table_obj = db_map[this._cur_table_obj.linkTo[table].table]; + } else if (this._cur_table_obj.linkFrom && this._cur_table_obj.linkFrom[table]) { + this._cur_table_obj = db_map[this._cur_table_obj.linkFrom[table].table]; + } else { + throw "Link \"" + table + "\" does not exist in table \"" + this._cur_table_obj.name + "\""; + } + this._refs.push(table); + return this; + } + }, { + key: "getCurTableObj", + value: function getCurTableObj() { + return this._cur_table_obj; + } + }, { + key: "getRefs", + value: function getRefs() { + return this._refs; + } + }, { + key: "getSQL", + value: function getSQL(query_obj) { + return query_obj.constructor.escapeDBIdentifier(query_obj.setJoin(this.getRefs()), true); + } + }]); + + return TABLE_REF; +})(); + +exports.TABLE_REF = TABLE_REF; \ No newline at end of file diff --git a/compiled/pql/pql_query.js b/compiled/pql/pql_query.js new file mode 100644 index 0000000..b010d19 --- /dev/null +++ b/compiled/pql/pql_query.js @@ -0,0 +1,25 @@ +"use strict"; + +function PQL_QUERY(module, query_string) { + this._select_data = []; + this._query_data = []; + this._group_data = []; + this._order_data = []; + this._limit = 100; + this._offset = 0; +} +PQL_QUERY.prototype.select = function (select_query_ary) { + if (!select_query_ary instanceof Array) { + throw "First parameter of PQL_QUERY.select must be an array of Strings."; + } + var i = 0, + len = select_query_ary.length, + str; + this._select_data = []; + for (; i < len; i++) { + str = select_query_ary[i]; + if (str instanceof String) { + this._select_data.push(new PQL_OPERATION(str)); + } + } +}; \ No newline at end of file diff --git a/compiled/unit_test/test_config.js b/compiled/unit_test/test_config.js new file mode 100644 index 0000000..4c98ba3 --- /dev/null +++ b/compiled/unit_test/test_config.js @@ -0,0 +1,699 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + +var _pqlOpcodesComparitorsEqualJs = require('./../pql/opcodes/comparitors/equal.js'); + +var _pqlOpcodesComparitorsGreater_thanJs = require('./../pql/opcodes/comparitors/greater_than.js'); + +var _pqlOpcodesComparitorsLess_thanJs = require('./../pql/opcodes/comparitors/less_than.js'); + +var _pqlOpcodesComparitorsLikeJs = require('./../pql/opcodes/comparitors/like.js'); + +var _pqlOpcodesComparitorsNo_valueJs = require('./../pql/opcodes/comparitors/no_value.js'); + +var _pqlOpcodesComparitorsNot_equalJs = require('./../pql/opcodes/comparitors/not_equal.js'); + +var _pqlOpcodesComparitorsNot_likeJs = require('./../pql/opcodes/comparitors/not_like.js'); + +var _pqlOpcodesConstants_arrayJs = require('./../pql/opcodes/constants_array.js'); + +var _pqlOpcodesNullJs = require('./../pql/opcodes/null.js'); + +var Config = (function () { + function Config() { + _classCallCheck(this, Config); + } + + /* Database types */ + + _createClass(Config, null, [{ + key: 'ALL_ARGS', + value: function ALL_ARGS(args) { + return args.join(', '); + } + }]); + + return Config; +})(); + +exports.Config = Config; +Config.NUMERIC = { + is_numeric: true +}; +Config.DATE = { + is_numeric: false +}; +Config.STRING = { + is_numeric: false +}; +Config.BOOLEAN = { + is_numeric: true +}; +Config.ANY_TYPE = { + is_numeric: false +}; + +/* These are to make it easier to read the code for the function definitions */ +Config.ARG1 = 0; +Config.ARG2 = 1; +Config.ARG3 = 2; +Config.ARG4 = 3; +Config.ARG5 = 4; +Config.ARG6 = 5; +Config.ARG7 = 6; +Config.ARG8 = 7; +Config.DB_MAP = { + table1: { + name: 'TablE1', + fields: { + id: { + type: Config.NUMERIC + }, + name: { + type: Config.STRING + }, + linkField1: { + type: Config.NUMERIC + } + }, + linkTo: { + link1: { + table: 'linkTo1', + pql: 'eq(linkField1,link1.id)' + } + }, + linkFrom: { + link2: { + table: 'linkFrom2', + pql: 'eq(id, link2.linkId)' + } + } + }, + linkTo1: { + name: 'linkTB1', + fields: { + id: { + type: Config.NUMERIC + }, + name: { + type: Config.STRING + } + }, + linkFrom: { + linkTable1: { + table: 'table1', + pql: 'eq(id, linkTable1.linkField1)' + } + } + }, + linkFrom2: { + name: 'linkTB2', + fields: { + id: { + type: Config.NUMERIC + }, + linkId: { + type: Config.NUMERIC + }, + name: { + type: Config.STRING + } + }, + linkTo: { + linkTable1: { + table: 'table1', + pql: 'eq(linkId, linkTable1.id)' + } + } + } +}; + +Config.FUNCTION_MAP = { + eq: { + description: 'Compares two values', + min_args: 2, + max_args: 2, + return_type: Config.BOOLEAN, + format: function format(args, orig_args, query_obj) { + var pql = this.getPqlObj(); + var obj = new _pqlOpcodesComparitorsEqualJs.EQUAL(pql); + obj.setLeft(orig_args[0]); + obj.setRight(orig_args[1]); + return obj.getSQL(query_obj); + } + }, + gt: { + description: 'Checks if first value is greater than second', + min_args: 2, + max_args: 2, + return_type: Config.BOOLEAN, + format: function format(args, orig_args, query_obj) { + var pql = this.getPqlObj(); + var obj = new _pqlOpcodesComparitorsGreater_thanJs.GREATER_THAN(pql); + obj.setLeft(orig_args[0]); + obj.setRight(orig_args[1]); + return obj.getSQL(query_obj); + } + }, + lt: { + description: 'Checks if first value is less than second', + min_args: 2, + max_args: 2, + return_type: Config.BOOLEAN, + format: function format(args, orig_args, query_obj) { + var pql = this.getPqlObj(); + var obj = new _pqlOpcodesComparitorsLess_thanJs.LESS_THAN(pql); + obj.setLeft(orig_args[0]); + obj.setRight(orig_args[1]); + return obj.getSQL(query_obj); + } + }, + ne: { + description: 'Checks if values are not equal', + min_args: 2, + max_args: 2, + return_type: Config.BOOLEAN, + format: function format(args, orig_args, query_obj) { + var pql = this.getPqlObj(); + var obj = new _pqlOpcodesComparitorsNot_equalJs.NOT_EQUAL(pql); + obj.setLeft(orig_args[0]); + obj.setRight(orig_args[1]); + return obj.getSQL(query_obj); + } + }, + like: { + description: 'Checks if first value is like second. % sign is wild card character', + min_args: 2, + max_args: 2, + return_type: Config.BOOLEAN, + format: function format(args, orig_args, query_obj) { + var pql = this.getPqlObj(); + var obj = new _pqlOpcodesComparitorsLikeJs.LIKE(pql); + obj.setLeft(orig_args[0]); + obj.setRight(orig_args[1]); + return obj.getSQL(query_obj); + } + }, + not_like: { + description: 'Checks if first value is not like second. % sign is wild card character', + min_args: 2, + max_args: 2, + return_type: Config.BOOLEAN, + format: function format(args, orig_args, query_obj) { + var pql = this.getPqlObj(); + var obj = new _pqlOpcodesComparitorsNot_likeJs.NOT_LIKE(pql); + obj.setLeft(orig_args[0]); + obj.setRight(orig_args[1]); + return obj.getSQL(query_obj); + } + }, + 'in': { + description: 'Checks if first value is any of the following values', + min_args: 2, + max_args: Infinity, + return_type: Config.BOOLEAN, + format: function format(args, orig_args, query_obj) { + var pql = this.getPqlObj(); + var out_args = []; + var obj = new _pqlOpcodesComparitorsEqualJs.EQUAL(pql); + orig_args.splice(1).forEach(function (v) { + out_args.push(v); + }); + obj.setLeft(orig_args[0]); + obj.setRight(new _pqlOpcodesConstants_arrayJs.CONSTANTS_ARRAY(pql, out_args)); + return obj.getSQL(query_obj); + } + }, + not_in: { + description: 'Checks if first value is not any of the following values', + min_args: 2, + max_args: Infinity, + return_type: Config.BOOLEAN, + format: function format(args, orig_args, query_obj) { + var pql = this.getPqlObj(); + var out_args = []; + var obj = new _pqlOpcodesComparitorsNot_equalJs.NOT_EQUAL(pql); + orig_args.splice(1).forEach(function (v) { + out_args.push(v); + }); + obj.setLeft(orig_args[0]); + obj.setRight(new _pqlOpcodesConstants_arrayJs.CONSTANTS_ARRAY(pql, out_args)); + return obj.getSQL(query_obj); + } + }, + 'if': { + description: 'If first argument is truethy returns second argument otherwise returns third', + min_args: 3, + max_args: 3, + return_type: Config.ANY, + format: ['IF(', Config.ALL_ARGS, ')'] + }, + /* Math functions */ + add: { + description: 'Adds values together', + min_args: 2, + max_args: Infinity, + return_type: Config.NUMBER, + format: function format(args, orig_args, query_obj) { + return args.join(' + '); + } + }, + sub: { + description: 'Subtracts values from eachother', + min_args: 2, + max_args: Infinity, + return_type: Config.NUMBER, + format: function format(args, orig_args, query_obj) { + return args.join(' - '); + } + }, + mul: { + description: 'Multiplies values together', + min_args: 2, + max_args: Infinity, + return_type: Config.NUMBER, + format: function format(args, orig_args, query_obj) { + return args.join(' * '); + } + }, + div: { + description: 'Divide values together', + min_args: 2, + max_args: Infinity, + return_type: Config.NUMBER, + format: function format(args, orig_args, query_obj) { + return args.join(' / '); + } + }, + mod: { + description: 'Modulus values together', + min_args: 2, + max_args: 2, + return_type: Config.NUMBER, + format: ['MOD(', Config.ARG1, ', ', Config.ARG2, ')'] + }, + pow: { + description: 'Powers values together', + min_args: 2, + max_args: 2, + return_type: Config.NUMBER, + format: ['POW(', Config.ARG1, ', ', Config.ARG2, ')'] + }, + sqrt: { + description: 'Square roots a value', + min_args: 1, + max_args: 1, + return_type: Config.NUMBER, + format: ['SQRT(', Config.ARG1, ')'] + }, + + /* Standard SQL functions */ + abs: { + description: 'Gets absolute value', + min_args: 1, + max_args: 1, + arg_types: [Config.NUMERIC], + return_type: Config.NUMERIC, + format: ['ABS(', Config.ARG1, ')'] + }, + 'char': { + description: 'Gets character from numerical ascii character', + min_args: 1, + max_args: Infinity, + arg_types: [Config.NUMERIC], + return_type: Config.STRING, + format: ['CHAR(', Config.ALL_ARGS, ')'] + }, + coalesce: { + description: 'Returns first non-null value from arguments', + min_args: 1, + max_args: Infinity, + return_type: Config.ANY_TYPE, + format: ['COALESCE(', Config.ALL_ARGS, ')'] + }, + ifnull: { + description: 'Returns first argument if not null otherwise returns second argument', + min_args: 2, + max_args: 2, + return_type: Config.ANY_TYPE, + format: ['IFNULL(', Config.ARG1, ', ', Config.ARG2, ')'] + }, + instr: { + description: 'Gets character position of argument two in argument one\'s string', + min_args: 2, + max_args: 2, + return_type: Config.NUMERIC, + arg_types: [Config.STRING, Config.STRING], + format: ['INSTR(', Config.ARG1, ', ', Config.ARG2, ')'] + }, + hex: { + description: 'Returns hex value of argument', + min_args: 1, + max_args: 1, + return_type: Config.STRING, + format: ['HEX(', Config.ARG1, ')'] + }, + length: { + description: 'Returns the string length', + min_args: 1, + max_args: 1, + arg_types: [Config.STRING], + return_type: Config.NUMERIC, + format: ['LENGTH(', Config.ARG1, ')'] + }, + lower: { + description: 'Returns string converted to lower case', + min_args: 1, + max_args: 1, + arg_types: [Config.STRING], + return_type: Config.STRING, + format: ['LOWER(', Config.ARG1, ')'] + }, + ltrim: { + description: 'Returns left-trimmed string', + min_args: 1, + max_args: 1, + arg_types: [Config.STRING], + return_type: Config.STRING, + format: ['LTRIM(', Config.ARG1, ')'] + }, + nullif: { + description: 'Returns null if argument one equals argument two', + min_args: 2, + max_args: 2, + return_type: Config.ANY_TYPE, + format: ['NULLIF(', Config.ARG1, ', ', Config.ARG2, ')'] + }, + random: { + description: 'Returns random number (platform dependent)', + min_args: 0, + max_args: 0, + return_type: Config.NUMERIC, + format: ['RANDOM()'] + }, + replace: { + description: 'Searches for argument two and replaces matches with argument three in argument one', + min_args: 3, + max_args: 3, + arg_types: [Config.STRING, Config.STRING, Config.STRING], + return_type: Config.STRING, + format: ['REPLACE(', Config.ARG1, ', ', Config.ARG2, ', ', Config.ARG3, ')'] + }, + round: { + description: 'Returns rounded value of argument one with decimal percision of argument two', + min_args: 1, + max_args: 2, + arg_types: [Config.NUMERIC, Config.NUMERIC], + return_type: Config.NUMERIC, + format: ['ROUND(', Config.ALL_ARGS, ')'] + }, + rtrim: { + description: 'Returns right-trimmed value', + min_args: 1, + max_args: 1, + arg_types: [Config.STRING], + return_type: Config.STRING, + format: ['RTRIM(', Config.ARG1, ')'] + }, + substr: { + description: 'Returns part of argument one string from argument two position with length of argument three', + min_args: 2, + max_args: 3, + arg_types: [Config.STRING, Config.NUMERIC, Config.NUMERIC], + return_type: Config.STRING, + format: ['SUBSTR(', Config.ALL_ARGS, ')'] + }, + trim: { + description: 'Returns full trimmed string', + min_args: 1, + max_args: 1, + arg_types: [Config.STRING], + return_type: Config.STRING, + format: ['TRIM(', Config.ARG1, ')'] + }, + upper: { + description: 'Returns value converted to upper case', + min_args: 1, + max_args: 1, + arg_types: [Config.STRING], + return_type: Config.STRING, + format: ['UPPER(', Config.ARG1, ')'] + }, + concat: { + description: 'Returns multiple strings joined together', + min_args: 1, + max_args: Infinity, + arg_types: [Config.STRING], + return_type: Config.STRING, + format: ['CONCAT(', Config.ALL_ARGS, ')'] + }, + + /* Date Functions */ + date_format: { + description: 'Returns date converted converted using format of argument two', + min_args: 2, + max_args: 2, + arg_types: [Config.DATE, Config.STRING], + return_type: Config.STRING, + format: ['DATE_FORMAT(', Config.ARG1, ', ', Config.ARG2, ')'] + }, + date: { + description: 'Returns date porition of argument one', + min_args: 1, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.DATE, + format: ['DATE(', Config.ARG1, ')'] + }, + day: { + description: 'Returns day number of date', + min_args: 1, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.NUMERIC, + format: ['DAY(', Config.ARG1, ')'] + }, + from_unixtime: { + description: 'Returns date type from unix timestamp', + min_args: 1, + max_args: 1, + arg_types: [Config.NUMERIC], + return_type: Config.DATE, + format: ['FROM_UNIXTIME(', Config.ARG1, ')'] + }, + hour: { + description: 'Returns hour portion of date', + min_args: 1, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.NUMERIC, + format: ['HOUR(', Config.ARG1, ')'] + }, + minute: { + description: 'Returns minute porition of date', + min_args: 1, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.NUMERIC, + format: ['MINUTE(', Config.ARG1, ')'] + }, + month: { + description: 'Returns month number porition of date', + min_args: 1, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.NUMERIC, + format: ['MONTH(', Config.ARG1, ')'] + }, + now: { + description: 'Returns current time/date', + min_args: 0, + max_args: 0, + return_type: Config.DATE, + format: ['NOW()'] + }, + second: { + description: 'Returns second porition of date', + min_args: 1, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.NUMERIC, + format: ['SECOND(', Config.ARG1, ')'] + }, + time: { + description: 'Returns time porition of date', + min_args: 1, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.STRING, + format: ['TIME(', Config.ARG1, ')'] + }, + unix_timestamp: { + description: 'Returns unix timestamp from date', + min_args: 0, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.NUMERIC, + format: ['UNIX_TIMESTAMP(', Config.ARG1, ')'] + }, + year: { + description: 'Returns year porition from date', + min_args: 1, + max_args: 1, + arg_types: [Config.DATE], + return_type: Config.NUMERIC, + format: ['YEAR(', Config.ARG1, ')'] + }, + + /* Aggregate functions */ + avg: { + description: 'Returns average value', + min_args: 1, + max_args: 2, + arg_types: [Config.NUMERIC, Config.BOOLEAN], + return_type: Config.NUMERIC, + is_group_function: true, + format: { + 1: ['AVG(', Config.ARG1, ')'], + 2: [function (args, orig_args) { + var distinct = Boolean(Number(orig_args[1].getValue())); + if (distinct) { + return 'AVG(DISTINCT ' + args[0]; + } + return 'AVG(' + args[0]; + }] + } + }, + count: { + description: 'Returns count of items', + min_args: 1, + max_args: 2, + arg_types: [Config.NUMERIC, Config.BOOLEAN], + return_type: Config.NUMERIC, + is_group_function: true, + format: { + 1: ['COUNT(', Config.ARG1, ')'], + 2: [function (args, orig_args) { + var distinct = Boolean(Number(orig_args[1].getValue())); + if (distinct) { + return 'COUNT(DISTINCT ' + args[0]; + } + return 'COUNT(' + args[0]; + }] + } + }, + // group_concat(expr[,distinct[,seperator[,order_by_expression,order_by_direction ...]]]); + group_concat: { + description: 'Returns the group concatinated string', + min_args: 1, + max_args: Infinity, + arg_types: [Config.STRING, Config.BOOLEAN, Config.STRING, Config.STRING, Config.STRING], + return_type: Config.STRING, + is_group_function: true, + format: function format(args, orig_args) { + var distinct = orig_args.length >= 2 && Boolean(Number(orig_args[1].getValue())) ? 'DISTINCT ' : ''; + var seperator = ''; + if (orig_args.length >= 3) { + if (!orig_args[2].isConstant() && !orig_args[2].isInstanceOf(_pqlOpcodesNullJs.NULL)) { + throw 'Third argument of "group_concat" function must be a constant type'; + } + if (!orig_args[2].isInstanceOf(_pqlOpcodesNullJs.NULL)) { + seperator = ' SEPARATOR ' + args[2]; + } + } + var order_bys = new Set(); + if (orig_args.length > 3) { + // Check to make sure there are always pairs of order_by_expression and order_by_direction + if (orig_args.length % 2 == 0) { + throw 'GROUP_CONCAT function must have order_by_expression and order_by_direction in pairs'; + } + // Inc in order of 2's + for (var i = 3; i < args.length; i = i + 2) { + var dir = 'ASC'; + if (orig_args[i + 1].isConstant()) { + dir = orig_args[i + 1].getValue().toString().toLowerCase() == 'desc' ? 'DESC' : 'ASC'; + } + order_bys.add(args[i] + ' ' + dir); + } + } + var order_by = undefined; + if (order_bys.size) { + order_by = ' ORDER BY ' + Array.from(order_bys).join(','); + } else { + order_by = ''; + } + return 'GROUP_CONCAT(' + distinct + args[0] + order_by + seperator + ')'; + } + }, + max: { + description: 'Returns maximum value', + min_args: 1, + max_args: 2, + arg_types: [Config.NUMERIC, Config.BOOLEAN], + return_type: Config.NUMERIC, + is_group_function: true, + format: { + 1: ['MAX(', Config.ARG1, ')'], + 2: [function (args, orig_args) { + var distinct = Boolean(Number(orig_args[1].getValue())); + if (distinct) { + return 'MAX(DISTINCT ' + args[0]; + } + return 'MAX(' + args[0]; + }] + } + }, + min: { + description: 'Returns minimum value', + min_args: 1, + max_args: 2, + arg_types: [Config.NUMERIC, Config.BOOLEAN], + return_type: Config.NUMERIC, + is_group_function: true, + format: { + 1: ['MIN(', Config.ARG1, ')'], + 2: [function (args, orig_args) { + var distinct = Boolean(Number(orig_args[1].getValue())); + if (distinct) { + return 'MIN(DISTINCT ' + args[0]; + } + return 'MIN(' + args[0]; + }] + } + }, + sum: { + description: 'Returns sum of values', + min_args: 1, + max_args: 2, + arg_types: [Config.NUMERIC, Config.BOOLEAN], + return_type: Config.NUMERIC, + is_group_function: true, + format: { + 1: ['SUM(', Config.ARG1, ')'], + 2: [function (args, orig_args) { + var distinct = Boolean(Number(orig_args[1].getValue())); + if (distinct) { + return 'SUM(DISTINCT ' + args[0]; + } + return 'SUM(' + args[0]; + }] + } + }, + having: { + description: 'Forces item into having statment', + min_args: 1, + max_args: 1, + return_type: Config.ANY, + is_group_function: true, + format: [Config.ARG1] + } +}; + +Config.COMPARITORS = new Set([_pqlOpcodesComparitorsEqualJs.EQUAL, _pqlOpcodesComparitorsGreater_thanJs.GREATER_THAN, _pqlOpcodesComparitorsLess_thanJs.LESS_THAN, _pqlOpcodesComparitorsLikeJs.LIKE, _pqlOpcodesComparitorsNo_valueJs.NO_VALUE, _pqlOpcodesComparitorsNot_equalJs.NOT_EQUAL, _pqlOpcodesComparitorsNot_likeJs.NOT_LIKE]); \ No newline at end of file diff --git a/compiled/unit_test/tests/compare.js b/compiled/unit_test/tests/compare.js new file mode 100644 index 0000000..697c2d7 --- /dev/null +++ b/compiled/unit_test/tests/compare.js @@ -0,0 +1,211 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Compare Equal - Number', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:5', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = 5 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Equal - String', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:hello', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = \'hello\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Equal - Caps String', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:hEll0e', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = \'hEll0e\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Equal - Double Quote', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:"H\\"el\'l\\"-\x00"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = \'H"el\\\'l"-\\0\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Equal - Single Quote', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: " id : 'J0\\\'h\"n Smith' ", + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = \'J0\\\'h"n Smith\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Not Equal - Number', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id!:5', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" != 5 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Not Equal - String', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id!:hello', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" != \'hello\' GROUP BY "TablE1"."id"', "Passed!"); +}); + +window.QUnit.test('Compare Like - Number', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id~5', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" LIKE \'5%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Like - String', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id~Hello45.4', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" LIKE \'Hello45.4%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare NOT Like - Number', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id !~ -983.493', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" NOT LIKE \'-983.493%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare NOT Like - String', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id !~ JOOOOe', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" NOT LIKE \'JOOOOe%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Greater Than - Number Negative w/ Decimal', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id > -493.44', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" > -493.44 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Greater Than - String', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id > "HOSH\\".5"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" > \'HOSH".5\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Less Than - String', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id < "HOSH\\".35"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" < \'HOSH".35\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Less Than - Number', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id < 3', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" < 3 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare No Value - Basic', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare No Value - Spacer', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: ' id ', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Equal - NULL', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:-', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IS NULL GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Not Equal - NULL', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id!:-', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IS NOT NULL GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Not Like - NULL', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id!~-', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IS NOT NULL GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Like - NULL', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id~-', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IS NULL GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Like - NULL', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id~-', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IS NULL GROUP BY "TablE1"."id"', "Passed!"); +}); + +window.QUnit.test('Compare In List - Numbers', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:[4,3,43,33]', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IN (4, 3, 43, 33) GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Not In List - Numbers', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id!:[14,3,43,33]', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" NOT IN (14, 3, 43, 33) GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare In List - Numbers w/ Strings', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:[5,3, 4, "Hi\\"o", \'33\']', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IN (5, 3, 4, \'Hi"o\', 33) GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare In List - Negative Numbers w/ Decimal', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:[-5,3 , -44.33]', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IN (-5, 3, -44.33) GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Like In List - Strings', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id~[hI,l0w]', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE ("TablE1"."id" LIKE \'hI%\' OR "TablE1"."id" LIKE \'l0w%\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare NOT Like In List - Strings', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id!~[hI,l0w]', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE ("TablE1"."id" NOT LIKE \'hI%\' AND "TablE1"."id" NOT LIKE \'l0w%\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Compare Like In List - Numbers/Strings/Negative', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: ' id ~ [ foo, -1, 1.5, .3 , bar] ', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE ("TablE1"."id" LIKE \'foo%\' OR "TablE1"."id" LIKE \'-1%\' OR "TablE1"."id" LIKE \'1.5%\' OR "TablE1"."id" LIKE \'.3%\' OR "TablE1"."id" LIKE \'bar%\') GROUP BY "TablE1"."id"', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/constants.js b/compiled/unit_test/tests/constants.js new file mode 100644 index 0000000..ca61396 --- /dev/null +++ b/compiled/unit_test/tests/constants.js @@ -0,0 +1,48 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Constants 1 - Strings', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '"id"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'id\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Constants 2 - Strings', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '"id" \'id\'', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'id\' AND \'id\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Constants 3 - Numbers', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '54', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'54\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Constants 4 - Negative Numbers', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '-54', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'-54\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Constants 5 - Negative Numbers Decimal', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '-54.1234', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'-54.1234\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Constants 6 - Positive Numbers Decimal', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '154.1234', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'154.1234\' GROUP BY "TablE1"."id"', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/cross_table.js b/compiled/unit_test/tests/cross_table.js new file mode 100644 index 0000000..ad1bf15 --- /dev/null +++ b/compiled/unit_test/tests/cross_table.js @@ -0,0 +1,35 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Cross Table - Compare', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'link1.id:5', + table: 'table1' + }); + + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" WHERE "a0"."id" = 5 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Cross Table2 - Compare', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'link2.id:5', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB2" AS "a0" ON "TablE1"."id" = "a0"."linkId" WHERE "a0"."id" = 5 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Cross Table - Multi Tables 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'link1.linkTable1.link2.name~"foobar"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" LEFT JOIN "TablE1" AS "a1" ON "a0"."id" = "a1"."linkField1" LEFT JOIN "linkTB2" AS "a2" ON "a1"."id" = "a2"."linkId" WHERE "a2"."name" LIKE \'foobar%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Cross Table - Multi Tables 2', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: ' link2.linkTable1.link1.name ~ "foobar"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB2" AS "a0" ON "TablE1"."id" = "a0"."linkId" LEFT JOIN "TablE1" AS "a1" ON "a0"."linkId" = "a1"."id" LEFT JOIN "linkTB1" AS "a2" ON "a1"."linkField1" = "a2"."id" WHERE "a2"."name" LIKE \'foobar%\' GROUP BY "TablE1"."id"', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/functions.js b/compiled/unit_test/tests/functions.js new file mode 100644 index 0000000..1ac723e --- /dev/null +++ b/compiled/unit_test/tests/functions.js @@ -0,0 +1,244 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Functions - eq', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'eq(id,name)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = "TablE1"."name" GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - ne', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'ne(id, name)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" != "TablE1"."name" GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - lt', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'lt(5, 3)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'5\' < \'3\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - gt', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'gt(-5.11, 31)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'-5.11\' > \'31\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - like', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'LIKE(id, "foodbar")', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" LIKE \'foodbar%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - not_like', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'NoT_LikE(id, "%foodbar")', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" NOT LIKE \'%foodbar%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - in', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'in(id, name, 5, 3, 4, 1)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IN ("TablE1"."name", 5, 3, 4, 1) GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - not_in', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'not_in(name, concat("Foo", "BAR + ", id), 5, 3, 4, 1)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."name" NOT IN (CONCAT(\'Foo\', \'BAR + \', "TablE1"."id"), \'5\', \'3\', \'4\', \'1\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - if', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'IF(LIKE(CONCAT(id, "-", name), CONCAT(link1.id, "-", link2.id, "%")), -, 1)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" LEFT JOIN "linkTB2" AS "a1" ON "TablE1"."id" = "a1"."linkId" WHERE IF(CONCAT("TablE1"."id", \'-\', "TablE1"."name") LIKE CONCAT("a0"."id", \'-\', "a1"."id", \'%\'), NULL, \'1\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - add', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'add(4, id, 2)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'4\' + "TablE1"."id" + \'2\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - sub', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'sub(4, 2)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'4\' - \'2\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - mul', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'MuL(4, 2)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'4\' * \'2\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - div', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'DIV(4, 2)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE \'4\' / \'2\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - mod', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'MOD(4, 2)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE MOD(\'4\', \'2\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - pow', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'pow(4, 2)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE POW(\'4\', \'2\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - sqrt', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'sqrt(4)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE SQRT(\'4\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - abs', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'abs(4)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE ABS(\'4\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - char', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'char(4):1', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE CHAR(\'4\') = \'1\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - coalesce', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'coalesce(4,-):1', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE COALESCE(\'4\', NULL) = \'1\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - ifnull', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'ifnull(id, "foobar")', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE IFNULL("TablE1"."id", \'foobar\') GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Functions - avg', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'avg(id)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING AVG("TablE1"."id")', "Passed!"); +}); +window.QUnit.test('Functions - count', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'count(id) > 21', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING COUNT("TablE1"."id") > \'21\'', "Passed!"); +}); +window.QUnit.test('Functions - group_concat 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT("TablE1"."name")', "Passed!"); +}); +window.QUnit.test('Functions - group_concat distinct', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name, 1)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT(DISTINCT "TablE1"."name")', "Passed!"); +}); +window.QUnit.test('Functions - group_concat non distinct 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name, 0)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT("TablE1"."name")', "Passed!"); +}); +window.QUnit.test('Functions - group_concat non distinct 2', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name, -)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT("TablE1"."name")', "Passed!"); +}); +window.QUnit.test('Functions - group_concat distinct separator', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name, 1, "-")', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT(DISTINCT "TablE1"."name" SEPARATOR \'-\')', "Passed!"); +}); +window.QUnit.test('Functions - group_concat distinct null separator', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name, 1, -)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT(DISTINCT "TablE1"."name")', "Passed!"); +}); +window.QUnit.test('Functions - group_concat distinct separator w/ sort desc', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name, 1, "!", id, "desc")', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT(DISTINCT "TablE1"."name" ORDER BY "TablE1"."id" DESC SEPARATOR \'!\')', "Passed!"); +}); +window.QUnit.test('Functions - group_concat distinct separator w/ sort asc', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name, 1, "!", id, "asc")', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT(DISTINCT "TablE1"."name" ORDER BY "TablE1"."id" ASC SEPARATOR \'!\')', "Passed!"); +}); +window.QUnit.test('Functions - group_concat distinct separator w/ sort null', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'group_concat(name, 1, "!", id, -)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING GROUP_CONCAT(DISTINCT "TablE1"."name" ORDER BY "TablE1"."id" ASC SEPARATOR \'!\')', "Passed!"); +}); +window.QUnit.test('Functions - max', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'max(id)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING MAX("TablE1"."id")', "Passed!"); +}); +window.QUnit.test('Functions - min', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'MIN(id)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING MIN("TablE1"."id")', "Passed!"); +}); +window.QUnit.test('Functions - min', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'having(id) > 5', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING "TablE1"."id" > \'5\'', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/group_by.js b/compiled/unit_test/tests/group_by.js new file mode 100644 index 0000000..b0692c7 --- /dev/null +++ b/compiled/unit_test/tests/group_by.js @@ -0,0 +1,32 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Group By 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(link1.id:5 | link2.name~foo)', + group: 'id,name,4,5', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" LEFT JOIN "linkTB2" AS "a1" ON "TablE1"."id" = "a1"."linkId" WHERE "a0"."id" = 5 OR "a1"."name" LIKE \'foo%\' GROUP BY "TablE1"."id" , "TablE1"."name" , \'4\' , \'5\'', "Passed!"); +}); +window.QUnit.test('Group By 2', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + group: '@testVar,@testVarStr,id', + table: 'table1', + variables: { + testVar: 1, + testVarStr: "hi" + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY \'1\' , \'hi\' , "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Group By 3', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + group: '"h0Ei"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY \'h0Ei\'', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/groups.js b/compiled/unit_test/tests/groups.js new file mode 100644 index 0000000..bbb7e8d --- /dev/null +++ b/compiled/unit_test/tests/groups.js @@ -0,0 +1,35 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Group OR', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(link1.id:5 | link2.name~foo)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" LEFT JOIN "linkTB2" AS "a1" ON "TablE1"."id" = "a1"."linkId" WHERE "a0"."id" = 5 OR "a1"."name" LIKE \'foo%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Group Multi', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(link1.id:5 | link2.name~foo) id:4', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" LEFT JOIN "linkTB2" AS "a1" ON "TablE1"."id" = "a1"."linkId" WHERE ( "a0"."id" = 5 OR "a1"."name" LIKE \'foo%\' ) AND "TablE1"."id" = 4 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Group Multi-Multi 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(link1.id:5 | link2.name~foo) (id:4)', + table: 'table1' + }); + // If only 1 item in group it does not wrap it + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" LEFT JOIN "linkTB2" AS "a1" ON "TablE1"."id" = "a1"."linkId" WHERE ( "a0"."id" = 5 OR "a1"."name" LIKE \'foo%\' ) AND "TablE1"."id" = 4 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Group Multi-Multi 2', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(link1.id:5 | link2.name~foo) (id:4 name!:3)', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" LEFT JOIN "linkTB2" AS "a1" ON "TablE1"."id" = "a1"."linkId" WHERE ( "a0"."id" = 5 OR "a1"."name" LIKE \'foo%\' ) AND ( "TablE1"."id" = 4 AND "TablE1"."name" != \'3\' ) GROUP BY "TablE1"."id"', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/order_by.js b/compiled/unit_test/tests/order_by.js new file mode 100644 index 0000000..8735532 --- /dev/null +++ b/compiled/unit_test/tests/order_by.js @@ -0,0 +1,62 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Order By DESC w/ GroupFn', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + orderBys: { + 'count(id)': 'desc' + }, + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" ORDER BY COUNT("TablE1"."id") DESC', "Passed!"); +}); +window.QUnit.test('Order By ASC w/ GroupFn', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + orderBys: { + 'count(id)': 'asc' + }, + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" ORDER BY COUNT("TablE1"."id") ASC', "Passed!"); +}); +window.QUnit.test('Order By ASC (unknown by) w/ GroupFn', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + orderBys: { + 'count(id)': '' + }, + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" ORDER BY COUNT("TablE1"."id") ASC', "Passed!"); +}); +window.QUnit.test('Order By ASC (null by) w/ GroupFn', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + orderBys: { + 'count(id)': null + }, + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" ORDER BY COUNT("TablE1"."id") ASC', "Passed!"); +}); +window.QUnit.test('Order By ASC (undefined by) w/ GroupFn', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + orderBys: { + 'count(id)': undefined + }, + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" ORDER BY COUNT("TablE1"."id") ASC', "Passed!"); +}); +window.QUnit.test('Order By Multi', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + orderBys: { + 'count(id)': undefined, + id: 'asc', + name: 'desc' + }, + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" ORDER BY COUNT("TablE1"."id") ASC,"TablE1"."id" ASC,"TablE1"."name" DESC', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/selects.js b/compiled/unit_test/tests/selects.js new file mode 100644 index 0000000..6330a2f --- /dev/null +++ b/compiled/unit_test/tests/selects.js @@ -0,0 +1,60 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Select 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:@id', + table: 'table1', + selects: { + jo: 'count(id)' + }, + variables: { + id: 3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT COUNT("TablE1"."id") AS "jo" FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Select 2', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:@id', + table: 'table1', + selects: { + jo: 'count(id)', + jo: 'count(name)' + }, + variables: { + id: 3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT COUNT("TablE1"."name") AS "jo" FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Select 3', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:@id', + table: 'table1', + selects: { + '"test"': 'count(@id)' + }, + variables: { + id: 3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT COUNT(\'3\') AS """test"" FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Select 4', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:@id', + table: 'table1', + selects: { + '': 'count(@id)', + '*': '"blah"' + }, + variables: { + id: 3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT COUNT(\'3\'), \'blah\' AS "*" FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id"', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/seperators.js b/compiled/unit_test/tests/seperators.js new file mode 100644 index 0000000..2d84992 --- /dev/null +++ b/compiled/unit_test/tests/seperators.js @@ -0,0 +1,50 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Seperators - AND 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'link1.id:5 link1.id~"FOO BAR"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" WHERE "a0"."id" = 5 AND "a0"."id" LIKE \'FOO BAR%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Seperators - AND 2', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: ' link1.id: -504.1 link2.id~"FOO BAR" id!:44', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" LEFT JOIN "linkTB2" AS "a1" ON "TablE1"."id" = "a1"."linkId" WHERE "a0"."id" = -504.1 AND "a1"."id" LIKE \'FOO BAR%\' AND "TablE1"."id" != 44 GROUP BY "TablE1"."id"', "Passed!"); +}); + +window.QUnit.test('Seperators - AND 3', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id: yo id!:-', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = \'yo\' AND "TablE1"."id" IS NOT NULL GROUP BY "TablE1"."id"', "Passed!"); +}); + +window.QUnit.test('Seperators - OR 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id | name!"FOO"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" OR "TablE1"."name" NOT LIKE \'FOO%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Seperators - OR 2', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id | name!"FOO" | link1.id~"FOO BAR"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" WHERE "TablE1"."id" OR "TablE1"."name" NOT LIKE \'FOO%\' OR "a0"."id" LIKE \'FOO BAR%\' GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Seperators - Mix', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id | name!"FOO" link1.id~"FOO BAR"', + table: 'table1' + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" LEFT JOIN "linkTB1" AS "a0" ON "TablE1"."linkField1" = "a0"."id" WHERE "TablE1"."id" OR "TablE1"."name" NOT LIKE \'FOO%\' AND "a0"."id" LIKE \'FOO BAR%\' GROUP BY "TablE1"."id"', "Passed!"); +}); \ No newline at end of file diff --git a/compiled/unit_test/tests/variable.js b/compiled/unit_test/tests/variable.js new file mode 100644 index 0000000..4921960 --- /dev/null +++ b/compiled/unit_test/tests/variable.js @@ -0,0 +1,89 @@ +'use strict'; + +var _pqlPQLJs = require('./../../pql/PQL.js'); + +var _test_configJs = require('./../test_config.js'); + +window.QUnit.test('Variable 1', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:@id', + table: 'table1', + variables: { + id: 3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Variable 2', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:@no_value', + table: 'table1', + variables: { + id: 3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IS NULL GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Variable 3', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:@no_value|id:@id', + table: 'table1', + variables: { + id: -3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" IS NULL OR "TablE1"."id" = -3 GROUP BY "TablE1"."id"', "Passed!"); +}); +window.QUnit.test('Variable 4', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: 'id:@no_value|count(ifnull(id,@val))>@amt', + table: 'table1', + variables: { + val: "1", + amt: 3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > \'3\'', "Passed!"); +}); +window.QUnit.test('Variable 5', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(id:@no_value|count(ifnull(id,@val))>@amt) if(count(@id) > -009, @amt, - )', + table: 'table1', + variables: { + id: 4, + val: "1", + amt: 3 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING ( "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > \'3\' ) IF(COUNT(\'4\') > \'-009\', \'3\', NULL)', "Passed!"); +}); +window.QUnit.test('Variable 6', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(id:3 eq(7,count(@id)))', + table: 'table1', + variables: { + id: 0 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id" HAVING \'7\' = COUNT(\'0\')', "Passed!"); +}); +window.QUnit.test('Variable 7', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(id:3|eq(7,ifnull(count(@id),1)))', + table: 'table1', + variables: { + id: 0 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING "TablE1"."id" = 3 OR \'7\' = IFNULL(COUNT(\'0\'), \'1\')', "Passed!"); +}); +window.QUnit.test('Variable 8', function (assert) { + var query = _pqlPQLJs.PQL.getSQL({ + query: '(id:3 | eq(7,ifnull(count(@id),1))) id < -', + table: 'table1', + variables: { + id: 0 + } + }); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" < NULL GROUP BY "TablE1"."id" HAVING ( "TablE1"."id" = 3 OR \'7\' = IFNULL(COUNT(\'0\'), \'1\') )', "Passed!"); +}); \ No newline at end of file From e933042fc100309a388422c3fb10ec8b396020a0 Mon Sep 17 00:00:00 2001 From: Nathan Bruer Date: Tue, 27 Oct 2015 15:58:14 -0500 Subject: [PATCH 2/6] added limit and offset --- pql/PQL.js | 4 +++- pql/parser/sql_builder.js | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/pql/PQL.js b/pql/PQL.js index a5ef96d..c925613 100644 --- a/pql/PQL.js +++ b/pql/PQL.js @@ -9,7 +9,7 @@ export class PQL { PQL._defaultConfig = v; } - static getSQL ({ query, table, group, selects, orderBys, variables }) { + static getSQL ({ query, table, group, selects, orderBys, variables, limit, offset }) { var query_parser = new PARSER(query, table, false, this.defaultConfig, [], variables); if (query_parser.hasError()) { throw query_parser.getError(); @@ -72,6 +72,8 @@ export class PQL { group: group_parser, selects: select_parsers, orderBys: order_by_parsers, + limit: limit, + offset: offset, }); return sb.toString(); } diff --git a/pql/parser/sql_builder.js b/pql/parser/sql_builder.js index 7e79ddc..361461f 100644 --- a/pql/parser/sql_builder.js +++ b/pql/parser/sql_builder.js @@ -1,11 +1,13 @@ import { PARSER } from './../parser.js'; export class SQL_BUILDER { - constructor ({ query, table, group, selects, orderBys }) { + constructor ({ query, table, group, selects, orderBys, limit, offset }) { this._query = query; this._table = table; this._group = group; this._selects = selects; this._orderBys = orderBys; + this._limit = limit; + this._offset = offset; this._table_refs = new Map; this._linked_tables = []; @@ -29,6 +31,12 @@ export class SQL_BUILDER { getTableName () { return this.getQuery().getConfig().DB_MAP[this.getTable()].name; } + getLimit () { + return this._limit; + } + getOfffset () { + return this._offset; + } toString () { let query_str = this.getQuery().getWhereCodes().getSQL(this); if (query_str) { @@ -74,7 +82,22 @@ export class SQL_BUILDER { join_str = '\n\t' + join_ary.join('\n\t'); } } - return 'SELECT\n\t' + selects.join(',\n\t') + '\nFROM ' + this.constructor.escapeDBTableName(this.getTableName(), true) + join_str + query_str + group_str + having_str + order_by_str; + + let limit = this.getLimit(); + let offset = this.getOffset(); + if (limit !== undefined && limit !== null) { + limit = '\nLIMIT ' + parseInt(limit); + if (offset !== undefined && offset !== null) { + offset = ' OFFSET ' + parseInt(offset); + } else { + offset = ''; + } + } else { + limit = ''; + offset = ''; + } + + return 'SELECT\n\t' + selects.join(',\n\t') + '\nFROM ' + this.constructor.escapeDBTableName(this.getTableName(), true) + join_str + query_str + group_str + having_str + order_by_str + limit + offset; } _addTableLink (table_ary) { let table_str = this.constructor.tableArrayToString(table_ary); From b7f9eda16a1cbe207599910fc2804ddcd4934357 Mon Sep 17 00:00:00 2001 From: Nathan Bruer Date: Tue, 27 Oct 2015 16:18:03 -0500 Subject: [PATCH 3/6] fixed typo --- pql/parser/sql_builder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pql/parser/sql_builder.js b/pql/parser/sql_builder.js index 361461f..df4111e 100644 --- a/pql/parser/sql_builder.js +++ b/pql/parser/sql_builder.js @@ -34,7 +34,7 @@ export class SQL_BUILDER { getLimit () { return this._limit; } - getOfffset () { + getOffset () { return this._offset; } toString () { @@ -219,4 +219,4 @@ export class SQL_BUILDER { } return value.replace('"', '""'); } -} \ No newline at end of file +} From cd3bb43f7a4d46bcba5cad178b4106a3cbf78f3e Mon Sep 17 00:00:00 2001 From: Nathan Bruer Date: Tue, 27 Oct 2015 16:20:24 -0500 Subject: [PATCH 4/6] Update compiled version --- compiled/pql/PQL.js | 6 +++++- compiled/pql/parser/sql_builder.js | 31 +++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/compiled/pql/PQL.js b/compiled/pql/PQL.js index f6fc211..dc996b3 100644 --- a/compiled/pql/PQL.js +++ b/compiled/pql/PQL.js @@ -28,6 +28,8 @@ var PQL = (function () { var selects = _ref.selects; var orderBys = _ref.orderBys; var variables = _ref.variables; + var limit = _ref.limit; + var offset = _ref.offset; var query_parser = new _parserJs.PARSER(query, table, false, this.defaultConfig, [], variables); if (query_parser.hasError()) { @@ -90,7 +92,9 @@ var PQL = (function () { table: table, group: group_parser, selects: select_parsers, - orderBys: order_by_parsers + orderBys: order_by_parsers, + limit: limit, + offset: offset }); return sb.toString(); } diff --git a/compiled/pql/parser/sql_builder.js b/compiled/pql/parser/sql_builder.js index d6b0058..9edf7cb 100644 --- a/compiled/pql/parser/sql_builder.js +++ b/compiled/pql/parser/sql_builder.js @@ -19,6 +19,8 @@ var SQL_BUILDER = (function () { var group = _ref.group; var selects = _ref.selects; var orderBys = _ref.orderBys; + var limit = _ref.limit; + var offset = _ref.offset; _classCallCheck(this, SQL_BUILDER); @@ -27,6 +29,8 @@ var SQL_BUILDER = (function () { this._group = group; this._selects = selects; this._orderBys = orderBys; + this._limit = limit; + this._offset = offset; this._table_refs = new Map(); this._linked_tables = []; @@ -63,6 +67,16 @@ var SQL_BUILDER = (function () { value: function getTableName() { return this.getQuery().getConfig().DB_MAP[this.getTable()].name; } + }, { + key: 'getLimit', + value: function getLimit() { + return this._limit; + } + }, { + key: 'getOffset', + value: function getOffset() { + return this._offset; + } }, { key: 'toString', value: function toString() { @@ -134,7 +148,22 @@ var SQL_BUILDER = (function () { join_str = '\n\t' + join_ary.join('\n\t'); } } - return 'SELECT\n\t' + selects.join(',\n\t') + '\nFROM ' + this.constructor.escapeDBTableName(this.getTableName(), true) + join_str + query_str + group_str + having_str + order_by_str; + + var limit = this.getLimit(); + var offset = this.getOffset(); + if (limit !== undefined && limit !== null) { + limit = '\nLIMIT ' + parseInt(limit); + if (offset !== undefined && offset !== null) { + offset = ' OFFSET ' + parseInt(offset); + } else { + offset = ''; + } + } else { + limit = ''; + offset = ''; + } + + return 'SELECT\n\t' + selects.join(',\n\t') + '\nFROM ' + this.constructor.escapeDBTableName(this.getTableName(), true) + join_str + query_str + group_str + having_str + order_by_str + limit + offset; } }, { key: '_addTableLink', From dfd1e55e6f17f6947fc5cb65af50b8ed3010d3d1 Mon Sep 17 00:00:00 2001 From: Nathan Bruer Date: Thu, 3 Dec 2015 18:44:19 -0600 Subject: [PATCH 5/6] updated to support oracle better --- pql/PQL.js | 13 +- pql/config.js | 205 ++++++++++++-------------- pql/data_types.js | 18 +++ pql/opcodes/comparitors/comparitor.js | 4 + pql/opcodes/constant.js | 1 + pql/opcodes/function.js | 10 ++ pql/parser.js | 31 +++- pql/parser/sql_builder.js | 8 +- unit_test/tests/functions.js | 2 +- unit_test/tests/variable.js | 6 +- 10 files changed, 175 insertions(+), 123 deletions(-) create mode 100644 pql/data_types.js diff --git a/pql/PQL.js b/pql/PQL.js index c925613..3f18674 100644 --- a/pql/PQL.js +++ b/pql/PQL.js @@ -10,7 +10,7 @@ export class PQL { } static getSQL ({ query, table, group, selects, orderBys, variables, limit, offset }) { - var query_parser = new PARSER(query, table, false, this.defaultConfig, [], variables); + var query_parser = new PARSER(query, table, false, this.defaultConfig, [], variables, true); if (query_parser.hasError()) { throw query_parser.getError(); } @@ -18,7 +18,7 @@ export class PQL { if (group === undefined) { group = 'id'; } - var group_parser = new PARSER(group, table, true, this.defaultConfig, [], variables); + var group_parser = new PARSER(group, table, true, this.defaultConfig, [], variables, false); if (group_parser.hasError()) { throw group_parser.getError(); } @@ -26,7 +26,7 @@ export class PQL { let select_parsers = new Map(); if (selects instanceof Map) { selects.forEach((v, k) => { - let val = new PARSER(v, table, false, this.defaultConfig, [], variables); + let val = new PARSER(v, table, false, this.defaultConfig, [], variables, false); if (val.hasError()) { throw val.getError(); } @@ -35,7 +35,7 @@ export class PQL { } else { for (let k in selects) { if (selects.hasOwnProperty(k)) { - let v = new PARSER(selects[k], table, false, this.defaultConfig, [], variables); + let v = new PARSER(selects[k], table, false, this.defaultConfig, [], variables, false); if (v.hasError()) { throw v.getError(); } @@ -48,7 +48,7 @@ export class PQL { if (orderBys instanceof Map) { orderBys.forEach((v, k) => { // This one is backwards... be warned that k is the string v is the [desc, asc] - let val = new PARSER(k, table, false, this.defaultConfig, [], variables); + let val = new PARSER(k, table, false, this.defaultConfig, [], variables, false); if (val.hasError()) { throw val.getError(); } @@ -57,7 +57,7 @@ export class PQL { } else { for (let k in orderBys) { if (orderBys.hasOwnProperty(k)) { - let v = new PARSER(k, table, false, this.defaultConfig, [], variables); + let v = new PARSER(k, table, false, this.defaultConfig, [], variables, false); if (v.hasError()) { throw v.getError(); } @@ -74,6 +74,7 @@ export class PQL { orderBys: order_by_parsers, limit: limit, offset: offset, + variables: variables, }); return sb.toString(); } diff --git a/pql/config.js b/pql/config.js index 4126b53..9956194 100644 --- a/pql/config.js +++ b/pql/config.js @@ -1,24 +1,9 @@ +import { DATA_TYPES } from './data_types.js'; export class Config { static ALL_ARGS (args) { return args.join(', '); }; } -/* Database types */ -Config.NUMERIC = { - is_numeric: true, -}; -Config.DATE = { - is_numeric: false, -}; -Config.STRING = { - is_numeric: false, -}; -Config.BOOLEAN = { - is_numeric: true, -}; -Config.ANY_TYPE = { - is_numeric: false, -}; /* These are to make it easier to read the code for the function definitions */ Config.ARG1 = 0; @@ -30,7 +15,7 @@ Config.ARG6 = 5; Config.ARG7 = 6; Config.ARG8 = 7; Config.DB_MAP = -{"bill":{"name":"bills","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"invoice_number":{"type":Config.STRING},"purchase_id":{"type":Config.NUMERIC},"invoice_date":{"type":Config.DATE},"notes":{"type":Config.STRING},"payment_status":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"due_date":{"type":Config.DATE},"accounting_system_id":{"type":Config.STRING},"vendor_id":{"type":Config.NUMERIC},"effective_date":{"type":Config.DATE},"invoice_amount":{"type":Config.NUMERIC},"shipping_cost":{"type":Config.NUMERIC},"discount_amount":{"type":Config.NUMERIC},"tax_amount":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"date_closed":{"type":Config.DATE},"currency":{"type":Config.STRING},"type":{"type":Config.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"}},"linkFrom":{"shipment":{"table":"shipment","pql":"eq(shipment.bill_id,id)"},"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.bill_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Bill\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Bill\")"}}},"booking":{"name":"bookings","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_attn":{"type":Config.STRING},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"brand_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"customer_po":{"type":Config.STRING},"sales_rep_id":{"type":Config.NUMERIC},"total":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Booking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Booking\")"}}},"brand":{"name":"brands","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"brand_names":{"type":Config.STRING},"parent_id":{"type":Config.NUMERIC},"active":{"type":Config.BOOLEAN},"website":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.NUMERIC},"warehouse_use_vendor_num":{"type":Config.BOOLEAN}},"linkTo":{"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"parent":{"table":"brand","pql":"eq(parent_id,parent.id)"}},"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.brand_id,id)"},"products":{"table":"product","pql":"eq(products.brand_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Brand\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Brand\")"}}},"carrier":{"name":"carriers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"scac_code":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"shipment_methods":{"table":"shipment_method","pql":"eq(shipment_methods.carrier_id,id)"}}},"contact":{"name":"contacts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"last_name":{"type":Config.STRING},"address1":{"type":Config.STRING},"address2":{"type":Config.STRING},"city":{"type":Config.STRING},"state":{"type":Config.STRING},"zip":{"type":Config.STRING},"country":{"type":Config.STRING},"email":{"type":Config.STRING},"phone":{"type":Config.STRING},"timezone_id":{"type":Config.NUMERIC},"contact_hours":{"type":Config.STRING},"notes":{"type":Config.STRING},"fax":{"type":Config.STRING},"alt_phone":{"type":Config.STRING},"fax_optout":{"type":Config.BOOLEAN},"email_optout":{"type":Config.BOOLEAN},"postal_optout":{"type":Config.BOOLEAN},"customer_id":{"type":Config.NUMERIC},"brand_id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"parent_contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"status":{"type":Config.NUMERIC}},"linkTo":{"timezone":{"table":"timezone","pql":"eq(timezone_id,timezone.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"parent_contact":{"table":"contact","pql":"eq(parent_contact_id,parent_contact.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.billing_contact_id,id)"},"customers_shipping":{"table":"customer","pql":"eq(customers_shipping.primary_shipping_contact_id,id)"},"customers_billing":{"table":"customer","pql":"eq(customers_billing.primary_billing_contact_id,id)"},"customers_primary":{"table":"customer","pql":"eq(customers_primary.primary_contact_id,id)"},"users":{"table":"user","pql":"eq(users.contact_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.contact_id,id)"},"brands":{"table":"brand","pql":"eq(brands.contact_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.primary_contact_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.contact_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Contact\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Contact\")"}}},"control_flag":{"name":"control_flags","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"control_key_id":{"type":Config.NUMERIC},"value":{"type":Config.STRING},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC}},"linkTo":{"control_key":{"table":"control_key","pql":"eq(control_key_id,control_key.id)"}},"linkFrom":[]},"control_key":{"name":"control_keys","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"key":{"type":Config.STRING},"module_flags":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"control_flags":{"table":"control_flag","pql":"eq(control_flags.control_key_id,id)"}}},"customer":{"name":"customers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"primary_rep_id":{"type":Config.NUMERIC},"current_credit":{"type":Config.NUMERIC},"max_credit_amount":{"type":Config.NUMERIC},"primary_contact_id":{"type":Config.NUMERIC},"primary_billing_contact_id":{"type":Config.NUMERIC},"primary_shipping_contact_id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"website":{"type":Config.STRING},"term_id":{"type":Config.NUMERIC},"resale_tax_number":{"type":Config.STRING},"territory_id":{"type":Config.NUMERIC},"federal_id":{"type":Config.STRING},"dunns":{"type":Config.STRING},"tax_code_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.STRING},"status":{"type":Config.NUMERIC},"parent_customer_id":{"type":Config.NUMERIC},"unpaid_invoice_amount":{"type":Config.NUMERIC},"primary_shipment_method_id":{"type":Config.NUMERIC},"primary_shipment_account_id":{"type":Config.NUMERIC}},"linkTo":{"rep":{"table":"user","pql":"eq(primary_rep_id,rep.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"billing_contact":{"table":"contact","pql":"eq(primary_billing_contact_id,billing_contact.id)"},"shipping_contact":{"table":"contact","pql":"eq(primary_shipping_contact_id,shipping_contact.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"territory":{"table":"territory","pql":"eq(territory_id,territory.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"parent_customer":{"table":"customer","pql":"eq(parent_customer_id,parent_customer.id)"},"primary_shipment_method":{"table":"shipment_method","pql":"eq(primary_shipment_method_id,primary_shipment_method.id)"},"primary_shipment_account":{"table":"shipment_account","pql":"eq(primary_shipment_account_id,primary_shipment_account.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.customer_id,id)"},"payments":{"table":"payment","pql":"eq(payments.customer_id,id)"},"invoices":{"table":"invoice","pql":"eq(invoices.customer_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.customer_id,id)"},"orders":{"table":"order","pql":"eq(orders.customer_id,id)"},"child_customers":{"table":"customer","pql":"eq(child_customers.parent_customer_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer\")"},"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.customer_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer\")"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.customer_id,id)"},"customer_notifications":{"table":"customers_notifications","pql":"eq(customer_notifications.customer_id,id)"}}},"customer_franchises":{"name":"customer_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"dont_purge":{"type":Config.BOOLEAN}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer_Franchises\")"}}},"customers_notifications":{"name":"customers_notifications","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING},"contact_method":{"type":Config.STRING},"contact_data":{"type":Config.STRING},"contact_name":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customers_Notifications\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customers_Notifications\")"}}},"cycle_count":{"name":"cycle_counts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"date_created":{"type":Config.DATE},"date_completed":{"type":Config.DATE},"active":{"type":Config.BOOLEAN}},"linkTo":[],"linkFrom":[]},"draft_item":{"name":"draft_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"order_draft_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"qty":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC}},"linkTo":{"order_draft":{"table":"order_draft","pql":"eq(order_draft_id,order_draft.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Draft_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Draft_Item\")"}}},"edi_term_code":{"name":"edi_term_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"term_code":{"type":Config.STRING},"description":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"terms":{"table":"term","pql":"eq(terms.edi_term_code_id,id)"}}},"edi_user":{"name":"edi_users","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"friendly_name":{"type":Config.STRING},"auth_qualifier":{"type":Config.STRING},"auth_info":{"type":Config.STRING},"security_qualifier":{"type":Config.STRING},"security_info":{"type":Config.STRING},"sender_qualifier":{"type":Config.STRING},"sender_id":{"type":Config.STRING},"receiver_qualifier":{"type":Config.STRING},"receiver_id":{"type":Config.STRING},"control_standard_id":{"type":Config.STRING},"control_version":{"type":Config.STRING},"ack_requested":{"type":Config.STRING},"is_test":{"type":Config.STRING},"sub_element_sep":{"type":Config.STRING},"func_id":{"type":Config.STRING},"application_sender_id":{"type":Config.STRING},"application_receiver_id":{"type":Config.STRING},"responsible_agency_code":{"type":Config.STRING},"version_id":{"type":Config.STRING},"transaction_set_id":{"type":Config.STRING},"element_seperator":{"type":Config.STRING},"tag_seperator":{"type":Config.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":[]},"employee":{"name":"employees","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"office_id":{"type":Config.NUMERIC},"work_area_location":{"type":Config.STRING},"computer_ip":{"type":Config.STRING},"position":{"type":Config.STRING},"actively_employed":{"type":Config.BOOLEAN},"extension":{"type":Config.STRING},"notes":{"type":Config.STRING}},"linkTo":{"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Employee\")"},"users":{"table":"user","pql":"eq(users.user_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Employee\")"}}},"event":{"name":"events","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"watch_id":{"type":Config.NUMERIC},"transaction_id":{"type":Config.NUMERIC},"message":{"type":Config.STRING},"date":{"type":Config.DATE},"has_read":{"type":Config.BOOLEAN},"module":{"type":Config.STRING}},"linkTo":{"watch":{"table":"watch","pql":"eq(watch_id,watch.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Event\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Event\")"}}},"franchise":{"name":"franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_brand_id":{"type":Config.NUMERIC},"is_exclude":{"type":Config.BOOLEAN},"is_public":{"type":Config.BOOLEAN},"legacy_id":{"type":Config.STRING},"formula":{"type":Config.STRING},"dealer_col":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(primary_brand_id,brand.id)"}},"linkFrom":{"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.franchise_id,id)"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.franchise_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise\")"}}},"franchise_products":{"name":"franchise_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"date_voided":{"type":Config.DATE},"date_created":{"type":Config.DATE},"rule_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"sugar_column":{"type":Config.STRING}},"linkTo":{"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise_Products\")"}}},"gateway_account":{"name":"gateway_accounts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"payment_gateway_id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"billing_contact_id":{"type":Config.NUMERIC},"gateway_ref":{"type":Config.STRING},"additional_ref":{"type":Config.STRING},"is_primary":{"type":Config.BOOLEAN},"last_updated":{"type":Config.DATE},"exp_date":{"type":Config.NUMERIC},"type":{"type":Config.STRING}},"linkTo":{"payment_gateway":{"table":"payment_gateway","pql":"eq(payment_gateway_id,payment_gateway.id)"},"billing_contact":{"table":"contact","pql":"eq(billing_contact_id,billing_contact.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"order_draft":{"table":"order_draft","pql":"eq(order_draft.gateway_account_id,id)"},"orders":{"table":"order","pql":"eq(orders.gateway_account_id,id)"},"remits":{"table":"remit","pql":"eq(remits.gateway_account_id,id)"},"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.gateway_account_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Gateway_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Gateway_Account\")"}}},"groupping_products":{"name":"groupping_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"parent_id":{"type":Config.NUMERIC},"child_id":{"type":Config.NUMERIC},"num_of_children_in_parent":{"type":Config.NUMERIC},"discount_percent":{"type":Config.NUMERIC}},"linkTo":{"parent":{"table":"product","pql":"eq(parent_id,parent.id)"},"child":{"table":"product","pql":"eq(child_id,child.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Groupping_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Groupping_Products\")"}}},"invoice":{"name":"invoices_view","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"invoice_date":{"type":Config.DATE},"invoice_status":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"invoice_sum":{"type":Config.NUMERIC},"amount_due":{"type":Config.NUMERIC},"amount_received":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"age":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"invoice_id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"retired_date":{"type":Config.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.invoice_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.invoice_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.invoice_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.invoice_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoice\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoice\")"}}},"invoices_payments":{"name":"invoices_payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"payment_id":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"applied_amount":{"type":Config.NUMERIC},"date_applied":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoices_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoices_Payments\")"}}},"item_exchange":{"name":"item_exchange","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"product_item_id":{"type":Config.NUMERIC},"from_status":{"type":Config.NUMERIC},"to_status":{"type":Config.NUMERIC},"from_warehouse_id":{"type":Config.NUMERIC},"to_warehouse_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"date":{"type":Config.DATE},"from_product_id":{"type":Config.NUMERIC},"to_product_id":{"type":Config.NUMERIC},"from_cost":{"type":Config.NUMERIC},"to_cost":{"type":Config.NUMERIC}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"from_warehouse":{"table":"office","pql":"eq(from_warehouse_id,from_warehouse.id)"},"to_warehouse":{"table":"office","pql":"eq(to_warehouse_id,to_warehouse.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Item_Exchange\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Item_Exchange\")"}}},"kit_item":{"name":"kit_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_item_order_kits":{"table":"product_item","pql":"eq(product_item_order_kits.order_kit_id,id)"},"product_item_purchase_kits":{"table":"product_item","pql":"eq(product_item_purchase_kits.purchase_kit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Kit_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Kit_Item\")"}}},"last_modified":{"name":"last_modifieds","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"memute":{"name":"memutes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"module":{"type":Config.STRING},"rule_id":{"type":Config.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Memute\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Memute\")"}}},"note":{"name":"notes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"note":{"type":Config.STRING},"date":{"type":Config.DATE},"public":{"type":Config.BOOLEAN},"module_flags":{"type":Config.NUMERIC},"module_priority":{"type":Config.NUMERIC},"category":{"type":Config.STRING},"code":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"important":{"type":Config.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.note_id,id)"}}},"notes_link":{"name":"notes_link","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"note_id":{"type":Config.NUMERIC},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"user_id":{"type":Config.NUMERIC},"void":{"type":Config.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"note":{"table":"note","pql":"eq(note_id,note.id)"},"bill":{"table":"$module","pql":"eq(item_id,bill.id)"},"booking":{"table":"$module","pql":"eq(item_id,booking.id)"},"brand":{"table":"$module","pql":"eq(item_id,brand.id)"},"contact":{"table":"$module","pql":"eq(item_id,contact.id)"},"customer":{"table":"$module","pql":"eq(item_id,customer.id)"},"employee":{"table":"$module","pql":"eq(item_id,employee.id)"},"event":{"table":"$module","pql":"eq(item_id,event.id)"},"franchise":{"table":"$module","pql":"eq(item_id,franchise.id)"},"groupping_products":{"table":"$module","pql":"eq(item_id,groupping_products.id)"},"invoice":{"table":"$module","pql":"eq(item_id,invoice.id)"},"invoices_payments":{"table":"$module","pql":"eq(item_id,invoices_payments.id)"},"kit_item":{"table":"$module","pql":"eq(item_id,kit_item.id)"},"memute":{"table":"$module","pql":"eq(item_id,memute.id)"},"message":{"table":"$module","pql":"eq(item_id,message.id)"},"office":{"table":"$module","pql":"eq(item_id,office.id)"},"order":{"table":"$module","pql":"eq(item_id,order.id)"},"order_draft":{"table":"$module","pql":"eq(item_id,order_draft.id)"},"payment":{"table":"$module","pql":"eq(item_id,payment.id)"},"product":{"table":"$module","pql":"eq(item_id,product.id)"},"product_bar_code":{"table":"$module","pql":"eq(item_id,product_bar_code.id)"},"product_item":{"table":"$module","pql":"eq(item_id,product_item.id)"},"product_item_report":{"table":"$module","pql":"eq(item_id,product_item_report.id)"},"product_item_return":{"table":"$module","pql":"eq(item_id,product_item_return.id)"},"product_items_bills":{"table":"$module","pql":"eq(item_id,product_items_bills.id)"},"products_vendors":{"table":"$module","pql":"eq(item_id,products_vendors.id)"},"program":{"table":"$module","pql":"eq(item_id,program.id)"},"programs_customers":{"table":"$module","pql":"eq(item_id,programs_customers.id)"},"promo":{"table":"$module","pql":"eq(item_id,promo.id)"},"promos_franchises":{"table":"$module","pql":"eq(item_id,promos_franchises.id)"},"promos_products":{"table":"$module","pql":"eq(item_id,promos_products.id)"},"purchase":{"table":"$module","pql":"eq(item_id,purchase.id)"},"purchase_tracking":{"table":"$module","pql":"eq(item_id,purchase_tracking.id)"},"purchase_tracking_item":{"table":"$module","pql":"eq(item_id,purchase_tracking_item.id)"},"return_product_due":{"table":"$module","pql":"eq(item_id,return_product_due.id)"},"rule":{"table":"$module","pql":"eq(item_id,rule.id)"},"sales_rep":{"table":"$module","pql":"eq(item_id,sales_rep.id)"},"shipment":{"table":"$module","pql":"eq(item_id,shipment.id)"},"shipment_in":{"table":"$module","pql":"eq(item_id,shipment_in.id)"},"shipment_method":{"table":"$module","pql":"eq(item_id,shipment_method.id)"},"spiff":{"table":"$module","pql":"eq(item_id,spiff.id)"},"spiffs_franchises":{"table":"$module","pql":"eq(item_id,spiffs_franchises.id)"},"spiffs_products":{"table":"$module","pql":"eq(item_id,spiffs_products.id)"},"tax_code":{"table":"$module","pql":"eq(item_id,tax_code.id)"},"term":{"table":"$module","pql":"eq(item_id,term.id)"},"territory":{"table":"$module","pql":"eq(item_id,territory.id)"},"timezone":{"table":"$module","pql":"eq(item_id,timezone.id)"}},"linkFrom":[]},"office":{"name":"offices","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"foreman_id":{"type":Config.NUMERIC},"address1":{"type":Config.STRING},"address2":{"type":Config.STRING},"city":{"type":Config.STRING},"state":{"type":Config.STRING},"zip":{"type":Config.STRING},"country":{"type":Config.STRING},"phone":{"type":Config.STRING},"private_name":{"type":Config.STRING},"is_primary":{"type":Config.BOOLEAN},"open_hours":{"type":Config.STRING},"is_warehouse":{"type":Config.BOOLEAN}},"linkTo":{"foreman":{"table":"user","pql":"eq(foreman_id,foreman.id)"},"user":{"table":"user","pql":"eq(foreman_id,user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.warehouse_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.warehouse_id,id)"},"employees":{"table":"employee","pql":"eq(employees.office_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"order":{"name":"orders","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"lead_user_id":{"type":Config.NUMERIC},"order_step":{"type":Config.NUMERIC},"order_created":{"type":Config.DATE},"order_modified":{"type":Config.DATE},"notes":{"type":Config.STRING},"term_id":{"type":Config.NUMERIC},"po_number":{"type":Config.STRING},"requested_delivery_date":{"type":Config.DATE},"requested_delivery_date_end":{"type":Config.DATE},"ship_on_date":{"type":Config.DATE},"tax_code_id":{"type":Config.NUMERIC},"notes_public":{"type":Config.STRING},"address_error":{"type":Config.BOOLEAN},"legacy_id":{"type":Config.STRING},"shipment_method_id":{"type":Config.NUMERIC},"shipment_addr_hash":{"type":Config.STRING},"ship_phone":{"type":Config.STRING},"ship_email":{"type":Config.STRING},"ship_attn":{"type":Config.STRING},"ship_id":{"type":Config.NUMERIC},"quote_id":{"type":Config.NUMERIC},"currency":{"type":Config.STRING},"billing_id":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"ship_quote_amount":{"type":Config.NUMERIC},"ship_flags":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"bill_override":{"table":"contact","pql":"eq(billing_id,bill_override.id)"},"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"order_draft":{"table":"order_draft","pql":"eq(quote_id,order_draft.id)"}},"linkFrom":{"invoices":{"table":"invoice","pql":"eq(invoices.order_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.order_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.order_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.order_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.order_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.order_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order\")"},"orders_product_items_void":{"table":"orders_product_items_void","pql":"eq(orders_product_items_void.order_id,id)"}}},"order_draft":{"name":"order_drafts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_attn":{"type":Config.STRING},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"lead_user_id":{"type":Config.NUMERIC},"order_step":{"type":Config.NUMERIC},"draft_created":{"type":Config.DATE},"term_id":{"type":Config.NUMERIC},"po_number":{"type":Config.STRING},"requested_delivery_date":{"type":Config.DATE},"requested_delivery_date_end":{"type":Config.DATE},"ship_on_date":{"type":Config.DATE},"tax_code_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"ship_phone":{"type":Config.STRING},"ship_email":{"type":Config.STRING},"ship_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"currency":{"type":Config.STRING},"billing_id":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC},"ship_flags":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"ship_quote_amount":{"type":Config.NUMERIC},"source":{"type":Config.STRING},"state":{"type":Config.STRING},"reserved_order_id":{"type":Config.NUMERIC},"cart_id":{"type":Config.STRING}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"reserved_order":{"table":"order","pql":"eq(reserved_order_id,reserved_order.id)"}},"linkFrom":{"orders":{"table":"order","pql":"eq(orders.quote_id,id)"},"draft_items":{"table":"draft_item","pql":"eq(draft_items.order_draft_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Draft\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order_Draft\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Draft\")"}}},"order_line":{"name":"order_lines","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_part_num":{"type":Config.STRING},"edi_customer_line_id":{"type":Config.STRING},"edi_entered_price":{"type":Config.NUMERIC},"edi_entered_qty":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.order_line_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.order_line_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.order_line_id,id)"}}},"order_return":{"name":"order_returns","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"date_entered":{"type":Config.DATE},"rma_number":{"type":Config.STRING},"notes":{"type":Config.STRING},"date_returned":{"type":Config.DATE},"payment_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING},"code":{"type":Config.STRING},"replacement_order_id":{"type":Config.NUMERIC},"vendor_rma_number":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"public_note":{"type":Config.STRING}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"replacement_order":{"table":"order","pql":"eq(replacement_order_id,replacement_order.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"shipments_ins":{"table":"shipment_in","pql":"eq(shipments_ins.order_return_id,id)"},"return_product_dues":{"table":"return_product_due","pql":"eq(return_product_dues.order_return_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.return_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Return\")"}}},"orders_product_items_void":{"name":"orders_product_items_void","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"void_sell_price":{"type":Config.NUMERIC},"order_kit_id":{"type":Config.NUMERIC},"date_canceled":{"type":Config.DATE},"moved_from_order_id":{"type":Config.NUMERIC}},"linkTo":{"order":{"table":"order","pql":"eq(order_id,order.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"orig_order":{"table":"order","pql":"eq(moved_from_order_id,orig_order.id)"}},"linkFrom":[]},"package":{"name":"packages","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"track_code":{"type":Config.STRING},"weight":{"type":Config.NUMERIC},"height":{"type":Config.NUMERIC},"width":{"type":Config.NUMERIC},"length":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"last_modified":{"type":Config.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.package_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.package_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.package_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Package\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Package\")"}}},"payment":{"name":"payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"reference_number":{"type":Config.STRING},"date_claimed":{"type":Config.DATE},"date_effective":{"type":Config.DATE},"amount_applied":{"type":Config.NUMERIC},"amount_received":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"payment_type":{"type":Config.STRING},"fee":{"type":Config.NUMERIC},"freight_refunded":{"type":Config.NUMERIC},"misc_refunded":{"type":Config.NUMERIC},"tax_refunded":{"type":Config.NUMERIC},"refunded_date":{"type":Config.DATE},"refunded_amount":{"type":Config.STRING},"refunded_method":{"type":Config.STRING},"refunded_notes":{"type":Config.STRING},"currency":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.payment_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.payment_id,id)"},"order_returns":{"table":"order_return","pql":"eq(order_returns.payment_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.payment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment\")"}}},"payment_gateway":{"name":"payment_gateways","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"class_name":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.payment_gateway_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment_Gateway\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment_Gateway\")"}}},"payment_gateway_request":{"name":"payment_gateway_requests","fields":{"id":{"type":Config.NUMERIC},"request_type":{"type":Config.STRING},"gateway_account_id":{"type":Config.NUMERIC},"reference":{"type":Config.STRING},"confirmation_num":{"type":Config.STRING},"payment_id":{"type":Config.NUMERIC},"amount":{"type":Config.NUMERIC},"request_date":{"type":Config.DATE},"request_by":{"type":Config.NUMERIC},"approved":{"type":Config.BOOLEAN},"deny_reason":{"type":Config.STRING},"full_request":{"type":Config.STRING},"full_response":{"type":Config.STRING},"deleted":{"type":Config.BOOLEAN}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"request_user":{"table":"user","pql":"eq(request_by,request_user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"product":{"name":"products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"date_created":{"type":Config.DATE},"description":{"type":Config.STRING},"item_code":{"type":Config.STRING},"brand_id":{"type":Config.NUMERIC},"category_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"weight":{"type":Config.NUMERIC},"dimension_h":{"type":Config.NUMERIC},"dimension_w":{"type":Config.NUMERIC},"dimension_l":{"type":Config.NUMERIC},"list_price":{"type":Config.NUMERIC},"map_price":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"vendor_part_number":{"type":Config.STRING},"primary_vendor_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"taxable":{"type":Config.BOOLEAN},"freight_only":{"type":Config.BOOLEAN},"upc_code":{"type":Config.STRING},"replacement_id":{"type":Config.NUMERIC},"bin_location":{"type":Config.STRING},"has_internal_serial":{"type":Config.BOOLEAN},"has_external_serial":{"type":Config.BOOLEAN},"ht_code":{"type":Config.STRING},"date_discontinued":{"type":Config.DATE},"master_pack_qty":{"type":Config.NUMERIC},"automation_flags":{"type":Config.NUMERIC},"primary_warehouse_id":{"type":Config.NUMERIC},"date_changed":{"type":Config.DATE},"default_stock_type":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"primary_vendor":{"table":"vendor","pql":"eq(primary_vendor_id,primary_vendor.id)"},"replacement":{"table":"product","pql":"eq(replacement_id,replacement.id)"},"primary_warehouse":{"table":"office","pql":"eq(primary_warehouse_id,primary_warehouse.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.product_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.product_id,id)"},"children":{"table":"groupping_products","pql":"eq(children.child_id,id)"},"parent":{"table":"groupping_products","pql":"eq(parent.parent_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.product_id,id)"},"product_bar_codes":{"table":"product_bar_code","pql":"eq(product_bar_codes.product_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product\")"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.product_id,id)"}}},"product_bar_code":{"name":"product_bar_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"bar_code":{"type":Config.STRING},"product_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Bar_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Bar_Code\")"}}},"product_item":{"name":"product_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"serial_number":{"type":Config.STRING},"warehouse_id":{"type":Config.NUMERIC},"warehouse_location":{"type":Config.STRING},"date_received":{"type":Config.DATE},"date_shipped":{"type":Config.DATE},"status":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"item_cost":{"type":Config.NUMERIC},"roi_cost":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"tax_amount":{"type":Config.NUMERIC},"temp_cust_id":{"type":Config.STRING},"shipment_in_id":{"type":Config.NUMERIC},"vendor_serial":{"type":Config.STRING},"override_date":{"type":Config.DATE},"order_kit_id":{"type":Config.NUMERIC},"purchase_kit_id":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"has_changed":{"type":Config.BOOLEAN},"order_warehouse_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING},"order_line_id":{"type":Config.NUMERIC},"purchase_tracking_item_id":{"type":Config.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.product_item_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.product_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_report":{"name":"product_items_reports","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"serial_number":{"type":Config.STRING},"warehouse_id":{"type":Config.NUMERIC},"warehouse_location":{"type":Config.STRING},"date_received":{"type":Config.DATE},"date_shipped":{"type":Config.DATE},"status":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"item_cost":{"type":Config.NUMERIC},"roi_cost":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"tax_amount":{"type":Config.NUMERIC},"temp_cust_id":{"type":Config.STRING},"shipment_in_id":{"type":Config.NUMERIC},"vendor_serial":{"type":Config.STRING},"return_id":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"order_kit_id":{"type":Config.NUMERIC},"purchase_kit_id":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"has_changed":{"type":Config.BOOLEAN},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC},"source":{"type":Config.STRING},"stock_type":{"type":Config.STRING},"purchase_tracking_item_id":{"type":Config.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,product_item_id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,product_item_id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_return":{"name":"product_items_returns","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"product_item_id":{"type":Config.NUMERIC},"return_id":{"type":Config.NUMERIC},"return_sell_price":{"type":Config.NUMERIC},"restock_fee":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"date_shipped":{"type":Config.DATE},"date_return_received":{"type":Config.DATE},"sort_order":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"tax_amount":{"type":Config.NUMERIC},"shipment_in_id":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"order_kit_id":{"type":Config.NUMERIC},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"order_return":{"table":"order_return","pql":"eq(return_id,order_return.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"sales_rep":{"table":"user","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Return\")"}}},"product_items_bills":{"name":"product_items_bills","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"bill_id":{"type":Config.NUMERIC},"item_cost":{"type":Config.NUMERIC}},"linkTo":{"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Bills\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Bills\")"}}},"products_vendors":{"name":"products_vendors","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"cost":{"type":Config.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Vendors\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Vendors\")"}}},"program":{"name":"programs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"brand_id":{"type":Config.NUMERIC},"rule_id":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.program_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.program_id,id)"},"product_item_returns":{"table":"product_item_returns","pql":"eq(product_item_returns.program_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Program\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Program\")"}}},"programs_customers":{"name":"programs_customers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"program_id":{"type":Config.STRING},"customer_id":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"parameters":{"type":Config.STRING}},"linkTo":{"program":{"table":"program","pql":"eq(program_id,program.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Programs_Customers\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Programs_Customers\")"}}},"promo":{"name":"promos","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"type":{"type":Config.STRING},"rule_id":{"type":Config.NUMERIC},"brand_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"promo_code":{"type":Config.STRING},"before_order_rule_id":{"type":Config.NUMERIC},"after_invoice_rule_id":{"type":Config.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"},"brand_id":{"table":"brand","pql":"eq(brand_id,brand_id.id)"}},"linkFrom":{"product_item_starin_promos":{"table":"product_item","pql":"eq(product_item_starin_promos.starin_promo_id,id)"},"product_item_vendor_promos":{"table":"product_item","pql":"eq(product_item_vendor_promos.vendor_promo_id,id)"},"product_item_return_starin_promos":{"table":"product_item_return","pql":"eq(product_item_return_starin_promos.starin_promo_id,id)"},"product_item_return_vendor_promos":{"table":"product_item_return","pql":"eq(product_item_return_vendor_promos.vendor_promo_id,id)"},"product_item_report_starin_promos":{"table":"product_item_report","pql":"eq(product_item_report_starin_promos.starin_promo_id,id)"},"product_item_report_vendor_promos":{"table":"product_item_report","pql":"eq(product_item_report_vendor_promos.vendor_promo_id,id)"},"promos_franchises":{"table":"promos_franchises","pql":"eq(promos_franchises.promo_id,id)"},"promos_products":{"table":"promos_products","pql":"eq(promos_products.promo_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promo\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promo\")"}}},"promos_franchises":{"name":"promos_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"promo_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Franchises\")"}}},"promos_products":{"name":"promos_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"promo_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"description":{"type":Config.STRING}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Products\")"}}},"purchase":{"name":"purchases","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"date_ordered":{"type":Config.DATE},"notes":{"type":Config.STRING},"status":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"assigned_user_id":{"type":Config.NUMERIC},"sub_total":{"type":Config.NUMERIC},"tax":{"type":Config.NUMERIC},"freight":{"type":Config.NUMERIC},"misc":{"type":Config.NUMERIC},"total":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"notes_public":{"type":Config.STRING},"ship_account_num":{"type":Config.STRING},"est_received_date":{"type":Config.DATE},"vendor_order_number":{"type":Config.STRING}},"linkTo":{"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_id,id)"},"bills":{"table":"bill","pql":"eq(bills.purchase_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Purchase\")"}}},"purchase_tracking":{"name":"purchase_tracking","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"estimated_receive_date":{"type":Config.DATE},"tracking_number":{"type":Config.STRING},"shipment_method_id":{"type":Config.NUMERIC},"last_updated":{"type":Config.DATE},"variance":{"type":Config.NUMERIC},"note":{"type":Config.STRING},"ref_number":{"type":Config.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"purchase_tracking_items":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_items.purchase_tracking_id,id)"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"PURCHASE_TRACKING\")"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking\")"}}},"purchase_tracking_item":{"name":"purchase_tracking_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"purchase_tracking_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING},"qty":{"type":Config.NUMERIC},"qty_received":{"type":Config.NUMERIC}},"linkTo":{"purchase_tracking":{"table":"purchase_tracking","pql":"eq(purchase_tracking_id,purchase_tracking.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_tracking_item_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_tracking_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking_Item\")"}}},"remit":{"name":"remits","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"paid":{"type":Config.BOOLEAN},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"amount_due":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"}},"linkFrom":{"shipments":{"table":"shipment","pql":"eq(shipments.remit_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.remit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remit\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remit\")"}}},"remits_payments":{"name":"remits_payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"remit_id":{"type":Config.NUMERIC},"payment_id":{"type":Config.NUMERIC},"amount":{"type":Config.NUMERIC},"date_applied":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remits_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remits_Payments\")"}}},"return_product_due":{"name":"return_product_due","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"order_return_id":{"type":Config.NUMERIC}},"linkTo":{"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":[]},"rule":{"name":"rules","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"code":{"type":Config.STRING},"file":{"type":Config.STRING}},"linkTo":[],"linkFrom":[]},"sales_rep":{"name":"sales_reps","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"contact_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"assigned_user_id":{"type":Config.NUMERIC},"is_distributor":{"type":Config.BOOLEAN},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.sales_rep_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Sales_Rep\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Sales_Rep\")"}}},"shipment":{"name":"shipments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"track_code":{"type":Config.STRING},"notes":{"type":Config.STRING},"actual_cost":{"type":Config.NUMERIC},"ship_date":{"type":Config.DATE},"date_due":{"type":Config.DATE},"shipment_fee":{"type":Config.NUMERIC},"handling_fee":{"type":Config.NUMERIC},"flags":{"type":Config.NUMERIC},"shipment_addr_hash":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"bill_id":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"backorder_hash":{"type":Config.STRING},"remit_id":{"type":Config.NUMERIC},"discount_amount":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"shipment_flags":{"type":Config.NUMERIC}},"linkTo":{"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.shipment_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.shipment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment\")"},"invoices":{"table":"invoice","pql":"eq(invoices.shipment_id,id)"}}},"shipment_account":{"name":"shipment_accounts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"ship_account_num":{"type":Config.STRING},"third_party_contact_id":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"third_party_contact":{"table":"contact","pql":"eq(third_party_contact_id,third_party_contact.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Account\")"}}},"shipment_in":{"name":"shipments_in","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"date_entered":{"type":Config.DATE},"purchase_id":{"type":Config.NUMERIC},"order_return_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"track_code":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_in_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_In\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_In\")"}}},"shipment_method":{"name":"shipment_methods","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"prepaid":{"type":Config.BOOLEAN},"carrier_code":{"type":Config.STRING},"carrier":{"type":Config.STRING},"parent_shipment_method_id":{"type":Config.NUMERIC},"carrier_id":{"type":Config.NUMERIC},"transportaion_method_code":{"type":Config.STRING},"is_freight":{"type":Config.BOOLEAN},"time_in_transit":{"type":Config.NUMERIC},"service_level_code":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"parent_shipment_method":{"table":"shipment_method","pql":"eq(parent_shipment_method_id,parent_shipment_method.id)"},"scac":{"table":"carrier","pql":"eq(carrier_id,scac.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.shipment_method_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.shipment_method_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Method\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Method\")"},"child_shipment_methods":{"table":"shipment_method","pql":"eq(child_shipment_methods.parent_shipment_method_id,id)"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.shipment_method_id,id)"}}},"spiff":{"name":"spiffs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"notes":{"type":Config.STRING},"max":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"spiffs_franchises":{"table":"spiffs_franchises","pql":"eq(spiffs_franchises.spiff_id,id)"},"spiffs_products":{"table":"spiffs_products","pql":"eq(spiffs_products.spiff_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.spiff_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.spiff_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.spiff_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff\")"}}},"spiffs_franchises":{"name":"spiffs_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff_Franchises\")"}}},"spiffs_products":{"name":"spiffs_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"qty":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiffs_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiffs_Products\")"}}},"tax_code":{"name":"tax_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"percentage":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"shipment_tax":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"orders":{"table":"order","pql":"eq(orders.tax_code_id,id)"},"customers":{"table":"customer","pql":"eq(customers.tax_code_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Tax_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Tax_Code\")"}}},"term":{"name":"terms","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"due_days":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"discount_days":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"order_override_flags":{"type":Config.NUMERIC},"classification":{"type":Config.STRING},"grace_days":{"type":Config.NUMERIC},"edi_term_code_id":{"type":Config.NUMERIC}},"linkTo":{"edi_term_code":{"table":"edi_term_code","pql":"eq(edi_term_code_id,edi_term_code.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.term_id,id)"},"bills":{"table":"bill","pql":"eq(bills.term_id,id)"},"customers":{"table":"customer","pql":"eq(customers.term_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.term_id,id)"},"orders":{"table":"order","pql":"eq(orders.term_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Term\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Term\")"}}},"territory":{"name":"territories","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"country":{"type":Config.STRING},"region":{"type":Config.STRING},"state_province":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"customers":{"table":"customer","pql":"eq(customers.territory_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Territory\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Territory\")"}}},"timezone":{"name":"timezones","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"utc":{"type":Config.STRING},"dst":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.timezone_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Timezone\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Timezone\")"}}},"user":{"name":"users_view","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"username":{"type":Config.STRING},"password":{"type":Config.STRING},"can_login":{"type":Config.BOOLEAN},"employee_id":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"wh_scan":{"type":Config.STRING}},"linkTo":{"employee":{"table":"employee","pql":"eq(employee_id,employee.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":{"user_historys":{"table":"user_history","pql":"eq(user_historys.user_id,id)"},"voided_gateway_requests":{"table":"payment_gateway_request","pql":"eq(voided_gateway_requests.void_by,id)"},"approved_gateway_requests":{"table":"payment_gateway_request","pql":"eq(approved_gateway_requests.approved_by,id)"},"requested_gateway_requests":{"table":"payment_gateway_request","pql":"eq(requested_gateway_requests.request_by,id)"},"offices":{"table":"office","pql":"eq(offices.foreman_id,id)"},"customers":{"table":"customer","pql":"eq(customers.primary_rep_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.assigned_user_id,id)"},"orders":{"table":"order","pql":"eq(orders.assigned_user_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.user_id,id)"},"assigned_sales_reps":{"table":"sales_rep","pql":"eq(assigned_sales_reps.assigned_user_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"User\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"User\")"}}},"user_history":{"name":"user_historys","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"method":{"type":Config.STRING},"args":{"type":Config.STRING},"window_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"vendor":{"name":"vendors","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_contact_id":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.STRING},"our_account_number":{"type":Config.STRING},"default_shipment_method_id":{"type":Config.NUMERIC},"default_office_id":{"type":Config.NUMERIC}},"linkTo":{"term":{"table":"term","pql":"eq(term_id,term.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"default_shipment_method":{"table":"shipment_method","pql":"eq(default_shipment_method_id,default_shipment_method.id)"},"default_office":{"table":"office","pql":"eq(default_office_id,default_office.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.vendor_id,id)"},"contacts":{"table":"contact","pql":"eq(contacts.vendor_id,id)"},"primary_products":{"table":"product","pql":"eq(primary_products.vendor_id,id)"},"bills":{"table":"bill","pql":"eq(bills.vendor_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.vendor_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Vendor\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Vendor\")"}}},"watch":{"name":"watchs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"record_id":{"type":Config.NUMERIC},"created":{"type":Config.DATE},"note":{"type":Config.STRING},"memute_id":{"type":Config.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"memute":{"table":"memute","pql":"eq(memute_id,memute.id)"}},"linkFrom":[]}}; +{"bill":{"name":"bills","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"invoice_number":{"type":DATA_TYPES.STRING},"purchase_id":{"type":DATA_TYPES.NUMERIC},"invoice_date":{"type":DATA_TYPES.DATE},"notes":{"type":DATA_TYPES.STRING},"payment_status":{"type":DATA_TYPES.NUMERIC},"term_id":{"type":DATA_TYPES.NUMERIC},"due_date":{"type":DATA_TYPES.DATE},"accounting_system_id":{"type":DATA_TYPES.STRING},"vendor_id":{"type":DATA_TYPES.NUMERIC},"effective_date":{"type":DATA_TYPES.DATE},"invoice_amount":{"type":DATA_TYPES.NUMERIC},"shipping_cost":{"type":DATA_TYPES.NUMERIC},"discount_amount":{"type":DATA_TYPES.NUMERIC},"tax_amount":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"date_closed":{"type":DATA_TYPES.DATE},"currency":{"type":DATA_TYPES.STRING},"type":{"type":DATA_TYPES.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"}},"linkFrom":{"shipment":{"table":"shipment","pql":"eq(shipment.bill_id,id)"},"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.bill_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Bill\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Bill\")"}}},"booking":{"name":"bookings","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"customer_id":{"type":DATA_TYPES.NUMERIC},"ship_attn":{"type":DATA_TYPES.STRING},"ship_name":{"type":DATA_TYPES.STRING},"ship_address1":{"type":DATA_TYPES.STRING},"ship_address2":{"type":DATA_TYPES.STRING},"ship_city":{"type":DATA_TYPES.STRING},"ship_state":{"type":DATA_TYPES.STRING},"ship_zip":{"type":DATA_TYPES.STRING},"ship_country":{"type":DATA_TYPES.STRING},"brand_id":{"type":DATA_TYPES.NUMERIC},"date":{"type":DATA_TYPES.DATE},"customer_po":{"type":DATA_TYPES.STRING},"sales_rep_id":{"type":DATA_TYPES.NUMERIC},"total":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Booking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Booking\")"}}},"brand":{"name":"brands","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING},"primary_contact_id":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"brand_names":{"type":DATA_TYPES.STRING},"parent_id":{"type":DATA_TYPES.NUMERIC},"active":{"type":DATA_TYPES.BOOLEAN},"website":{"type":DATA_TYPES.STRING},"temp_mybooks_id":{"type":DATA_TYPES.NUMERIC},"warehouse_use_vendor_num":{"type":DATA_TYPES.BOOLEAN}},"linkTo":{"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"parent":{"table":"brand","pql":"eq(parent_id,parent.id)"}},"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.brand_id,id)"},"products":{"table":"product","pql":"eq(products.brand_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Brand\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Brand\")"}}},"carrier":{"name":"carriers","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"scac_code":{"type":DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"shipment_methods":{"table":"shipment_method","pql":"eq(shipment_methods.carrier_id,id)"}}},"contact":{"name":"contacts","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"last_name":{"type":DATA_TYPES.STRING},"address1":{"type":DATA_TYPES.STRING},"address2":{"type":DATA_TYPES.STRING},"city":{"type":DATA_TYPES.STRING},"state":{"type":DATA_TYPES.STRING},"zip":{"type":DATA_TYPES.STRING},"country":{"type":DATA_TYPES.STRING},"email":{"type":DATA_TYPES.STRING},"phone":{"type":DATA_TYPES.STRING},"timezone_id":{"type":DATA_TYPES.NUMERIC},"contact_hours":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING},"fax":{"type":DATA_TYPES.STRING},"alt_phone":{"type":DATA_TYPES.STRING},"fax_optout":{"type":DATA_TYPES.BOOLEAN},"email_optout":{"type":DATA_TYPES.BOOLEAN},"postal_optout":{"type":DATA_TYPES.BOOLEAN},"customer_id":{"type":DATA_TYPES.NUMERIC},"brand_id":{"type":DATA_TYPES.NUMERIC},"vendor_id":{"type":DATA_TYPES.NUMERIC},"parent_contact_id":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"status":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"timezone":{"table":"timezone","pql":"eq(timezone_id,timezone.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"parent_contact":{"table":"contact","pql":"eq(parent_contact_id,parent_contact.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.billing_contact_id,id)"},"customers_shipping":{"table":"customer","pql":"eq(customers_shipping.primary_shipping_contact_id,id)"},"customers_billing":{"table":"customer","pql":"eq(customers_billing.primary_billing_contact_id,id)"},"customers_primary":{"table":"customer","pql":"eq(customers_primary.primary_contact_id,id)"},"users":{"table":"user","pql":"eq(users.contact_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.contact_id,id)"},"brands":{"table":"brand","pql":"eq(brands.contact_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.primary_contact_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.contact_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Contact\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Contact\")"}}},"control_flag":{"name":"control_flags","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"control_key_id":{"type":DATA_TYPES.NUMERIC},"value":{"type":DATA_TYPES.STRING},"module":{"type":DATA_TYPES.STRING},"item_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"control_key":{"table":"control_key","pql":"eq(control_key_id,control_key.id)"}},"linkFrom":[]},"control_key":{"name":"control_keys","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"key":{"type":DATA_TYPES.STRING},"module_flags":{"type":DATA_TYPES.NUMERIC}},"linkTo":[],"linkFrom":{"control_flags":{"table":"control_flag","pql":"eq(control_flags.control_key_id,id)"}}},"customer":{"name":"customers","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"primary_rep_id":{"type":DATA_TYPES.NUMERIC},"current_credit":{"type":DATA_TYPES.NUMERIC},"max_credit_amount":{"type":DATA_TYPES.NUMERIC},"primary_contact_id":{"type":DATA_TYPES.NUMERIC},"primary_billing_contact_id":{"type":DATA_TYPES.NUMERIC},"primary_shipping_contact_id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING},"website":{"type":DATA_TYPES.STRING},"term_id":{"type":DATA_TYPES.NUMERIC},"resale_tax_number":{"type":DATA_TYPES.STRING},"territory_id":{"type":DATA_TYPES.NUMERIC},"federal_id":{"type":DATA_TYPES.STRING},"dunns":{"type":DATA_TYPES.STRING},"tax_code_id":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"temp_mybooks_id":{"type":DATA_TYPES.STRING},"status":{"type":DATA_TYPES.NUMERIC},"parent_customer_id":{"type":DATA_TYPES.NUMERIC},"unpaid_invoice_amount":{"type":DATA_TYPES.NUMERIC},"primary_shipment_method_id":{"type":DATA_TYPES.NUMERIC},"primary_shipment_account_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"rep":{"table":"user","pql":"eq(primary_rep_id,rep.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"billing_contact":{"table":"contact","pql":"eq(primary_billing_contact_id,billing_contact.id)"},"shipping_contact":{"table":"contact","pql":"eq(primary_shipping_contact_id,shipping_contact.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"territory":{"table":"territory","pql":"eq(territory_id,territory.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"parent_customer":{"table":"customer","pql":"eq(parent_customer_id,parent_customer.id)"},"primary_shipment_method":{"table":"shipment_method","pql":"eq(primary_shipment_method_id,primary_shipment_method.id)"},"primary_shipment_account":{"table":"shipment_account","pql":"eq(primary_shipment_account_id,primary_shipment_account.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.customer_id,id)"},"payments":{"table":"payment","pql":"eq(payments.customer_id,id)"},"invoices":{"table":"invoice","pql":"eq(invoices.customer_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.customer_id,id)"},"orders":{"table":"order","pql":"eq(orders.customer_id,id)"},"child_customers":{"table":"customer","pql":"eq(child_customers.parent_customer_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer\")"},"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.customer_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer\")"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.customer_id,id)"},"customer_notifications":{"table":"customers_notifications","pql":"eq(customer_notifications.customer_id,id)"}}},"customer_franchises":{"name":"customer_franchises","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"customer_id":{"type":DATA_TYPES.NUMERIC},"franchise_id":{"type":DATA_TYPES.NUMERIC},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE},"dont_purge":{"type":DATA_TYPES.BOOLEAN}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer_Franchises\")"}}},"customers_notifications":{"name":"customers_notifications","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"customer_id":{"type":DATA_TYPES.NUMERIC},"type":{"type":DATA_TYPES.STRING},"contact_method":{"type":DATA_TYPES.STRING},"contact_data":{"type":DATA_TYPES.STRING},"contact_name":{"type":DATA_TYPES.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customers_Notifications\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customers_Notifications\")"}}},"cycle_count":{"name":"cycle_counts","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"date_created":{"type":DATA_TYPES.DATE},"date_completed":{"type":DATA_TYPES.DATE},"active":{"type":DATA_TYPES.BOOLEAN}},"linkTo":[],"linkFrom":[]},"draft_item":{"name":"draft_items","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"order_draft_id":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"status":{"type":DATA_TYPES.NUMERIC},"qty":{"type":DATA_TYPES.NUMERIC},"sell_price":{"type":DATA_TYPES.NUMERIC},"discount":{"type":DATA_TYPES.NUMERIC},"sort_order":{"type":DATA_TYPES.NUMERIC},"starin_promo_id":{"type":DATA_TYPES.NUMERIC},"vendor_promo_id":{"type":DATA_TYPES.NUMERIC},"spiff_id":{"type":DATA_TYPES.NUMERIC},"program_id":{"type":DATA_TYPES.NUMERIC},"order_warehouse_id":{"type":DATA_TYPES.NUMERIC},"order_line_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"order_draft":{"table":"order_draft","pql":"eq(order_draft_id,order_draft.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Draft_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Draft_Item\")"}}},"edi_term_code":{"name":"edi_term_codes","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"term_code":{"type":DATA_TYPES.STRING},"description":{"type":DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"terms":{"table":"term","pql":"eq(terms.edi_term_code_id,id)"}}},"edi_user":{"name":"edi_users","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"contact_id":{"type":DATA_TYPES.NUMERIC},"friendly_name":{"type":DATA_TYPES.STRING},"auth_qualifier":{"type":DATA_TYPES.STRING},"auth_info":{"type":DATA_TYPES.STRING},"security_qualifier":{"type":DATA_TYPES.STRING},"security_info":{"type":DATA_TYPES.STRING},"sender_qualifier":{"type":DATA_TYPES.STRING},"sender_id":{"type":DATA_TYPES.STRING},"receiver_qualifier":{"type":DATA_TYPES.STRING},"receiver_id":{"type":DATA_TYPES.STRING},"control_standard_id":{"type":DATA_TYPES.STRING},"control_version":{"type":DATA_TYPES.STRING},"ack_requested":{"type":DATA_TYPES.STRING},"is_test":{"type":DATA_TYPES.STRING},"sub_element_sep":{"type":DATA_TYPES.STRING},"func_id":{"type":DATA_TYPES.STRING},"application_sender_id":{"type":DATA_TYPES.STRING},"application_receiver_id":{"type":DATA_TYPES.STRING},"responsible_agency_code":{"type":DATA_TYPES.STRING},"version_id":{"type":DATA_TYPES.STRING},"transaction_set_id":{"type":DATA_TYPES.STRING},"element_seperator":{"type":DATA_TYPES.STRING},"tag_seperator":{"type":DATA_TYPES.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":[]},"employee":{"name":"employees","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"office_id":{"type":DATA_TYPES.NUMERIC},"work_area_location":{"type":DATA_TYPES.STRING},"computer_ip":{"type":DATA_TYPES.STRING},"position":{"type":DATA_TYPES.STRING},"actively_employed":{"type":DATA_TYPES.BOOLEAN},"extension":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING}},"linkTo":{"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Employee\")"},"users":{"table":"user","pql":"eq(users.user_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Employee\")"}}},"event":{"name":"events","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"watch_id":{"type":DATA_TYPES.NUMERIC},"transaction_id":{"type":DATA_TYPES.NUMERIC},"message":{"type":DATA_TYPES.STRING},"date":{"type":DATA_TYPES.DATE},"has_read":{"type":DATA_TYPES.BOOLEAN},"module":{"type":DATA_TYPES.STRING}},"linkTo":{"watch":{"table":"watch","pql":"eq(watch_id,watch.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Event\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Event\")"}}},"franchise":{"name":"franchises","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING},"primary_brand_id":{"type":DATA_TYPES.NUMERIC},"is_exclude":{"type":DATA_TYPES.BOOLEAN},"is_public":{"type":DATA_TYPES.BOOLEAN},"legacy_id":{"type":DATA_TYPES.STRING},"formula":{"type":DATA_TYPES.STRING},"dealer_col":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(primary_brand_id,brand.id)"}},"linkFrom":{"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.franchise_id,id)"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.franchise_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise\")"}}},"franchise_products":{"name":"franchise_products","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"franchise_id":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"date_voided":{"type":DATA_TYPES.DATE},"date_created":{"type":DATA_TYPES.DATE},"rule_id":{"type":DATA_TYPES.NUMERIC},"sell_price":{"type":DATA_TYPES.NUMERIC},"sugar_column":{"type":DATA_TYPES.STRING}},"linkTo":{"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise_Products\")"}}},"gateway_account":{"name":"gateway_accounts","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"payment_gateway_id":{"type":DATA_TYPES.NUMERIC},"customer_id":{"type":DATA_TYPES.NUMERIC},"billing_contact_id":{"type":DATA_TYPES.NUMERIC},"gateway_ref":{"type":DATA_TYPES.STRING},"additional_ref":{"type":DATA_TYPES.STRING},"is_primary":{"type":DATA_TYPES.BOOLEAN},"last_updated":{"type":DATA_TYPES.DATE},"exp_date":{"type":DATA_TYPES.NUMERIC},"type":{"type":DATA_TYPES.STRING}},"linkTo":{"payment_gateway":{"table":"payment_gateway","pql":"eq(payment_gateway_id,payment_gateway.id)"},"billing_contact":{"table":"contact","pql":"eq(billing_contact_id,billing_contact.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"order_draft":{"table":"order_draft","pql":"eq(order_draft.gateway_account_id,id)"},"orders":{"table":"order","pql":"eq(orders.gateway_account_id,id)"},"remits":{"table":"remit","pql":"eq(remits.gateway_account_id,id)"},"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.gateway_account_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Gateway_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Gateway_Account\")"}}},"groupping_products":{"name":"groupping_products","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"parent_id":{"type":DATA_TYPES.NUMERIC},"child_id":{"type":DATA_TYPES.NUMERIC},"num_of_children_in_parent":{"type":DATA_TYPES.NUMERIC},"discount_percent":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"parent":{"table":"product","pql":"eq(parent_id,parent.id)"},"child":{"table":"product","pql":"eq(child_id,child.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Groupping_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Groupping_Products\")"}}},"invoice":{"name":"invoices_view","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"invoice_date":{"type":DATA_TYPES.DATE},"invoice_status":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"legacy_id":{"type":DATA_TYPES.STRING},"invoice_sum":{"type":DATA_TYPES.NUMERIC},"amount_due":{"type":DATA_TYPES.NUMERIC},"amount_received":{"type":DATA_TYPES.NUMERIC},"shipment_id":{"type":DATA_TYPES.NUMERIC},"age":{"type":DATA_TYPES.NUMERIC},"override_date":{"type":DATA_TYPES.DATE},"invoice_id":{"type":DATA_TYPES.NUMERIC},"customer_id":{"type":DATA_TYPES.NUMERIC},"retired_date":{"type":DATA_TYPES.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.invoice_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.invoice_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.invoice_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.invoice_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoice\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoice\")"}}},"invoices_payments":{"name":"invoices_payments","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"payment_id":{"type":DATA_TYPES.NUMERIC},"invoice_id":{"type":DATA_TYPES.NUMERIC},"applied_amount":{"type":DATA_TYPES.NUMERIC},"date_applied":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoices_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoices_Payments\")"}}},"item_exchange":{"name":"item_exchange","fields":{"id":{"type":DATA_TYPES.NUMERIC},"deleted":{"type":DATA_TYPES.BOOLEAN},"product_item_id":{"type":DATA_TYPES.NUMERIC},"from_status":{"type":DATA_TYPES.NUMERIC},"to_status":{"type":DATA_TYPES.NUMERIC},"from_warehouse_id":{"type":DATA_TYPES.NUMERIC},"to_warehouse_id":{"type":DATA_TYPES.NUMERIC},"user_id":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"date":{"type":DATA_TYPES.DATE},"from_product_id":{"type":DATA_TYPES.NUMERIC},"to_product_id":{"type":DATA_TYPES.NUMERIC},"from_cost":{"type":DATA_TYPES.NUMERIC},"to_cost":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"from_warehouse":{"table":"office","pql":"eq(from_warehouse_id,from_warehouse.id)"},"to_warehouse":{"table":"office","pql":"eq(to_warehouse_id,to_warehouse.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Item_Exchange\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Item_Exchange\")"}}},"kit_item":{"name":"kit_items","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"sort_order":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_item_order_kits":{"table":"product_item","pql":"eq(product_item_order_kits.order_kit_id,id)"},"product_item_purchase_kits":{"table":"product_item","pql":"eq(product_item_purchase_kits.purchase_kit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Kit_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Kit_Item\")"}}},"last_modified":{"name":"last_modifieds","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"date":{"type":DATA_TYPES.DATE},"module":{"type":DATA_TYPES.STRING},"item_id":{"type":DATA_TYPES.NUMERIC},"user_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"memute":{"name":"memutes","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"module":{"type":DATA_TYPES.STRING},"rule_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Memute\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Memute\")"}}},"note":{"name":"notes","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"user_id":{"type":DATA_TYPES.NUMERIC},"note":{"type":DATA_TYPES.STRING},"date":{"type":DATA_TYPES.DATE},"public":{"type":DATA_TYPES.BOOLEAN},"module_flags":{"type":DATA_TYPES.NUMERIC},"module_priority":{"type":DATA_TYPES.NUMERIC},"category":{"type":DATA_TYPES.STRING},"code":{"type":DATA_TYPES.STRING},"legacy_id":{"type":DATA_TYPES.STRING},"important":{"type":DATA_TYPES.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.note_id,id)"}}},"notes_link":{"name":"notes_link","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"note_id":{"type":DATA_TYPES.NUMERIC},"module":{"type":DATA_TYPES.STRING},"item_id":{"type":DATA_TYPES.NUMERIC},"date":{"type":DATA_TYPES.DATE},"user_id":{"type":DATA_TYPES.NUMERIC},"void":{"type":DATA_TYPES.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"note":{"table":"note","pql":"eq(note_id,note.id)"},"bill":{"table":"$module","pql":"eq(item_id,bill.id)"},"booking":{"table":"$module","pql":"eq(item_id,booking.id)"},"brand":{"table":"$module","pql":"eq(item_id,brand.id)"},"contact":{"table":"$module","pql":"eq(item_id,contact.id)"},"customer":{"table":"$module","pql":"eq(item_id,customer.id)"},"employee":{"table":"$module","pql":"eq(item_id,employee.id)"},"event":{"table":"$module","pql":"eq(item_id,event.id)"},"franchise":{"table":"$module","pql":"eq(item_id,franchise.id)"},"groupping_products":{"table":"$module","pql":"eq(item_id,groupping_products.id)"},"invoice":{"table":"$module","pql":"eq(item_id,invoice.id)"},"invoices_payments":{"table":"$module","pql":"eq(item_id,invoices_payments.id)"},"kit_item":{"table":"$module","pql":"eq(item_id,kit_item.id)"},"memute":{"table":"$module","pql":"eq(item_id,memute.id)"},"message":{"table":"$module","pql":"eq(item_id,message.id)"},"office":{"table":"$module","pql":"eq(item_id,office.id)"},"order":{"table":"$module","pql":"eq(item_id,order.id)"},"order_draft":{"table":"$module","pql":"eq(item_id,order_draft.id)"},"payment":{"table":"$module","pql":"eq(item_id,payment.id)"},"product":{"table":"$module","pql":"eq(item_id,product.id)"},"product_bar_code":{"table":"$module","pql":"eq(item_id,product_bar_code.id)"},"product_item":{"table":"$module","pql":"eq(item_id,product_item.id)"},"product_item_report":{"table":"$module","pql":"eq(item_id,product_item_report.id)"},"product_item_return":{"table":"$module","pql":"eq(item_id,product_item_return.id)"},"product_items_bills":{"table":"$module","pql":"eq(item_id,product_items_bills.id)"},"products_vendors":{"table":"$module","pql":"eq(item_id,products_vendors.id)"},"program":{"table":"$module","pql":"eq(item_id,program.id)"},"programs_customers":{"table":"$module","pql":"eq(item_id,programs_customers.id)"},"promo":{"table":"$module","pql":"eq(item_id,promo.id)"},"promos_franchises":{"table":"$module","pql":"eq(item_id,promos_franchises.id)"},"promos_products":{"table":"$module","pql":"eq(item_id,promos_products.id)"},"purchase":{"table":"$module","pql":"eq(item_id,purchase.id)"},"purchase_tracking":{"table":"$module","pql":"eq(item_id,purchase_tracking.id)"},"purchase_tracking_item":{"table":"$module","pql":"eq(item_id,purchase_tracking_item.id)"},"return_product_due":{"table":"$module","pql":"eq(item_id,return_product_due.id)"},"rule":{"table":"$module","pql":"eq(item_id,rule.id)"},"sales_rep":{"table":"$module","pql":"eq(item_id,sales_rep.id)"},"shipment":{"table":"$module","pql":"eq(item_id,shipment.id)"},"shipment_in":{"table":"$module","pql":"eq(item_id,shipment_in.id)"},"shipment_method":{"table":"$module","pql":"eq(item_id,shipment_method.id)"},"spiff":{"table":"$module","pql":"eq(item_id,spiff.id)"},"spiffs_franchises":{"table":"$module","pql":"eq(item_id,spiffs_franchises.id)"},"spiffs_products":{"table":"$module","pql":"eq(item_id,spiffs_products.id)"},"tax_code":{"table":"$module","pql":"eq(item_id,tax_code.id)"},"term":{"table":"$module","pql":"eq(item_id,term.id)"},"territory":{"table":"$module","pql":"eq(item_id,territory.id)"},"timezone":{"table":"$module","pql":"eq(item_id,timezone.id)"}},"linkFrom":[]},"office":{"name":"offices","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"foreman_id":{"type":DATA_TYPES.NUMERIC},"address1":{"type":DATA_TYPES.STRING},"address2":{"type":DATA_TYPES.STRING},"city":{"type":DATA_TYPES.STRING},"state":{"type":DATA_TYPES.STRING},"zip":{"type":DATA_TYPES.STRING},"country":{"type":DATA_TYPES.STRING},"phone":{"type":DATA_TYPES.STRING},"private_name":{"type":DATA_TYPES.STRING},"is_primary":{"type":DATA_TYPES.BOOLEAN},"open_hours":{"type":DATA_TYPES.STRING},"is_warehouse":{"type":DATA_TYPES.BOOLEAN}},"linkTo":{"foreman":{"table":"user","pql":"eq(foreman_id,foreman.id)"},"user":{"table":"user","pql":"eq(foreman_id,user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.warehouse_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.warehouse_id,id)"},"employees":{"table":"employee","pql":"eq(employees.office_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"order":{"name":"orders","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"customer_id":{"type":DATA_TYPES.NUMERIC},"ship_name":{"type":DATA_TYPES.STRING},"ship_address1":{"type":DATA_TYPES.STRING},"ship_address2":{"type":DATA_TYPES.STRING},"ship_city":{"type":DATA_TYPES.STRING},"ship_state":{"type":DATA_TYPES.STRING},"ship_zip":{"type":DATA_TYPES.STRING},"ship_country":{"type":DATA_TYPES.STRING},"lead_user_id":{"type":DATA_TYPES.NUMERIC},"order_step":{"type":DATA_TYPES.NUMERIC},"order_created":{"type":DATA_TYPES.DATE},"order_modified":{"type":DATA_TYPES.DATE},"notes":{"type":DATA_TYPES.STRING},"term_id":{"type":DATA_TYPES.NUMERIC},"po_number":{"type":DATA_TYPES.STRING},"requested_delivery_date":{"type":DATA_TYPES.DATE},"requested_delivery_date_end":{"type":DATA_TYPES.DATE},"ship_on_date":{"type":DATA_TYPES.DATE},"tax_code_id":{"type":DATA_TYPES.NUMERIC},"notes_public":{"type":DATA_TYPES.STRING},"address_error":{"type":DATA_TYPES.BOOLEAN},"legacy_id":{"type":DATA_TYPES.STRING},"shipment_method_id":{"type":DATA_TYPES.NUMERIC},"shipment_addr_hash":{"type":DATA_TYPES.STRING},"ship_phone":{"type":DATA_TYPES.STRING},"ship_email":{"type":DATA_TYPES.STRING},"ship_attn":{"type":DATA_TYPES.STRING},"ship_id":{"type":DATA_TYPES.NUMERIC},"quote_id":{"type":DATA_TYPES.NUMERIC},"currency":{"type":DATA_TYPES.STRING},"billing_id":{"type":DATA_TYPES.NUMERIC},"gateway_account_id":{"type":DATA_TYPES.NUMERIC},"shipment_account_id":{"type":DATA_TYPES.NUMERIC},"ship_quote_amount":{"type":DATA_TYPES.NUMERIC},"ship_flags":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"bill_override":{"table":"contact","pql":"eq(billing_id,bill_override.id)"},"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"order_draft":{"table":"order_draft","pql":"eq(quote_id,order_draft.id)"}},"linkFrom":{"invoices":{"table":"invoice","pql":"eq(invoices.order_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.order_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.order_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.order_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.order_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.order_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order\")"},"orders_product_items_void":{"table":"orders_product_items_void","pql":"eq(orders_product_items_void.order_id,id)"}}},"order_draft":{"name":"order_drafts","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"customer_id":{"type":DATA_TYPES.NUMERIC},"ship_attn":{"type":DATA_TYPES.STRING},"ship_name":{"type":DATA_TYPES.STRING},"ship_address1":{"type":DATA_TYPES.STRING},"ship_address2":{"type":DATA_TYPES.STRING},"ship_city":{"type":DATA_TYPES.STRING},"ship_state":{"type":DATA_TYPES.STRING},"ship_zip":{"type":DATA_TYPES.STRING},"ship_country":{"type":DATA_TYPES.STRING},"lead_user_id":{"type":DATA_TYPES.NUMERIC},"order_step":{"type":DATA_TYPES.NUMERIC},"draft_created":{"type":DATA_TYPES.DATE},"term_id":{"type":DATA_TYPES.NUMERIC},"po_number":{"type":DATA_TYPES.STRING},"requested_delivery_date":{"type":DATA_TYPES.DATE},"requested_delivery_date_end":{"type":DATA_TYPES.DATE},"ship_on_date":{"type":DATA_TYPES.DATE},"tax_code_id":{"type":DATA_TYPES.NUMERIC},"shipment_method_id":{"type":DATA_TYPES.NUMERIC},"ship_phone":{"type":DATA_TYPES.STRING},"ship_email":{"type":DATA_TYPES.STRING},"ship_id":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"currency":{"type":DATA_TYPES.STRING},"billing_id":{"type":DATA_TYPES.NUMERIC},"gateway_account_id":{"type":DATA_TYPES.NUMERIC},"ship_flags":{"type":DATA_TYPES.NUMERIC},"shipment_account_id":{"type":DATA_TYPES.NUMERIC},"ship_quote_amount":{"type":DATA_TYPES.NUMERIC},"source":{"type":DATA_TYPES.STRING},"state":{"type":DATA_TYPES.STRING},"reserved_order_id":{"type":DATA_TYPES.NUMERIC},"cart_id":{"type":DATA_TYPES.STRING}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"reserved_order":{"table":"order","pql":"eq(reserved_order_id,reserved_order.id)"}},"linkFrom":{"orders":{"table":"order","pql":"eq(orders.quote_id,id)"},"draft_items":{"table":"draft_item","pql":"eq(draft_items.order_draft_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Draft\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order_Draft\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Draft\")"}}},"order_line":{"name":"order_lines","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"customer_part_num":{"type":DATA_TYPES.STRING},"edi_customer_line_id":{"type":DATA_TYPES.STRING},"edi_entered_price":{"type":DATA_TYPES.NUMERIC},"edi_entered_qty":{"type":DATA_TYPES.NUMERIC}},"linkTo":[],"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.order_line_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.order_line_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.order_line_id,id)"}}},"order_return":{"name":"order_returns","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"date_entered":{"type":DATA_TYPES.DATE},"rma_number":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING},"date_returned":{"type":DATA_TYPES.DATE},"payment_id":{"type":DATA_TYPES.NUMERIC},"order_id":{"type":DATA_TYPES.NUMERIC},"status":{"type":DATA_TYPES.NUMERIC},"contact_id":{"type":DATA_TYPES.NUMERIC},"type":{"type":DATA_TYPES.STRING},"code":{"type":DATA_TYPES.STRING},"replacement_order_id":{"type":DATA_TYPES.NUMERIC},"vendor_rma_number":{"type":DATA_TYPES.STRING},"office_id":{"type":DATA_TYPES.NUMERIC},"public_note":{"type":DATA_TYPES.STRING}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"replacement_order":{"table":"order","pql":"eq(replacement_order_id,replacement_order.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"shipments_ins":{"table":"shipment_in","pql":"eq(shipments_ins.order_return_id,id)"},"return_product_dues":{"table":"return_product_due","pql":"eq(return_product_dues.order_return_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.return_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Return\")"}}},"orders_product_items_void":{"name":"orders_product_items_void","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"order_id":{"type":DATA_TYPES.NUMERIC},"product_item_id":{"type":DATA_TYPES.NUMERIC},"void_sell_price":{"type":DATA_TYPES.NUMERIC},"order_kit_id":{"type":DATA_TYPES.NUMERIC},"date_canceled":{"type":DATA_TYPES.DATE},"moved_from_order_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"order":{"table":"order","pql":"eq(order_id,order.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"orig_order":{"table":"order","pql":"eq(moved_from_order_id,orig_order.id)"}},"linkFrom":[]},"package":{"name":"packages","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"track_code":{"type":DATA_TYPES.STRING},"weight":{"type":DATA_TYPES.NUMERIC},"height":{"type":DATA_TYPES.NUMERIC},"width":{"type":DATA_TYPES.NUMERIC},"length":{"type":DATA_TYPES.NUMERIC},"shipment_id":{"type":DATA_TYPES.NUMERIC},"last_modified":{"type":DATA_TYPES.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.package_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.package_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.package_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Package\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Package\")"}}},"payment":{"name":"payments","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"reference_number":{"type":DATA_TYPES.STRING},"date_claimed":{"type":DATA_TYPES.DATE},"date_effective":{"type":DATA_TYPES.DATE},"amount_applied":{"type":DATA_TYPES.NUMERIC},"amount_received":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"legacy_id":{"type":DATA_TYPES.STRING},"customer_id":{"type":DATA_TYPES.NUMERIC},"status":{"type":DATA_TYPES.NUMERIC},"date_created":{"type":DATA_TYPES.DATE},"payment_type":{"type":DATA_TYPES.STRING},"fee":{"type":DATA_TYPES.NUMERIC},"freight_refunded":{"type":DATA_TYPES.NUMERIC},"misc_refunded":{"type":DATA_TYPES.NUMERIC},"tax_refunded":{"type":DATA_TYPES.NUMERIC},"refunded_date":{"type":DATA_TYPES.DATE},"refunded_amount":{"type":DATA_TYPES.STRING},"refunded_method":{"type":DATA_TYPES.STRING},"refunded_notes":{"type":DATA_TYPES.STRING},"currency":{"type":DATA_TYPES.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.payment_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.payment_id,id)"},"order_returns":{"table":"order_return","pql":"eq(order_returns.payment_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.payment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment\")"}}},"payment_gateway":{"name":"payment_gateways","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"class_name":{"type":DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.payment_gateway_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment_Gateway\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment_Gateway\")"}}},"payment_gateway_request":{"name":"payment_gateway_requests","fields":{"id":{"type":DATA_TYPES.NUMERIC},"request_type":{"type":DATA_TYPES.STRING},"gateway_account_id":{"type":DATA_TYPES.NUMERIC},"reference":{"type":DATA_TYPES.STRING},"confirmation_num":{"type":DATA_TYPES.STRING},"payment_id":{"type":DATA_TYPES.NUMERIC},"amount":{"type":DATA_TYPES.NUMERIC},"request_date":{"type":DATA_TYPES.DATE},"request_by":{"type":DATA_TYPES.NUMERIC},"approved":{"type":DATA_TYPES.BOOLEAN},"deny_reason":{"type":DATA_TYPES.STRING},"full_request":{"type":DATA_TYPES.STRING},"full_response":{"type":DATA_TYPES.STRING},"deleted":{"type":DATA_TYPES.BOOLEAN}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"request_user":{"table":"user","pql":"eq(request_by,request_user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"product":{"name":"products","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"date_created":{"type":DATA_TYPES.DATE},"description":{"type":DATA_TYPES.STRING},"item_code":{"type":DATA_TYPES.STRING},"brand_id":{"type":DATA_TYPES.NUMERIC},"category_id":{"type":DATA_TYPES.NUMERIC},"sort_order":{"type":DATA_TYPES.NUMERIC},"weight":{"type":DATA_TYPES.NUMERIC},"dimension_h":{"type":DATA_TYPES.NUMERIC},"dimension_w":{"type":DATA_TYPES.NUMERIC},"dimension_l":{"type":DATA_TYPES.NUMERIC},"list_price":{"type":DATA_TYPES.NUMERIC},"map_price":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"vendor_part_number":{"type":DATA_TYPES.STRING},"primary_vendor_id":{"type":DATA_TYPES.NUMERIC},"status":{"type":DATA_TYPES.NUMERIC},"taxable":{"type":DATA_TYPES.BOOLEAN},"freight_only":{"type":DATA_TYPES.BOOLEAN},"upc_code":{"type":DATA_TYPES.STRING},"replacement_id":{"type":DATA_TYPES.NUMERIC},"bin_location":{"type":DATA_TYPES.STRING},"has_internal_serial":{"type":DATA_TYPES.BOOLEAN},"has_external_serial":{"type":DATA_TYPES.BOOLEAN},"ht_code":{"type":DATA_TYPES.STRING},"date_discontinued":{"type":DATA_TYPES.DATE},"master_pack_qty":{"type":DATA_TYPES.NUMERIC},"automation_flags":{"type":DATA_TYPES.NUMERIC},"primary_warehouse_id":{"type":DATA_TYPES.NUMERIC},"date_changed":{"type":DATA_TYPES.DATE},"default_stock_type":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"primary_vendor":{"table":"vendor","pql":"eq(primary_vendor_id,primary_vendor.id)"},"replacement":{"table":"product","pql":"eq(replacement_id,replacement.id)"},"primary_warehouse":{"table":"office","pql":"eq(primary_warehouse_id,primary_warehouse.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.product_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.product_id,id)"},"children":{"table":"groupping_products","pql":"eq(children.child_id,id)"},"parent":{"table":"groupping_products","pql":"eq(parent.parent_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.product_id,id)"},"product_bar_codes":{"table":"product_bar_code","pql":"eq(product_bar_codes.product_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product\")"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.product_id,id)"}}},"product_bar_code":{"name":"product_bar_codes","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"bar_code":{"type":DATA_TYPES.STRING},"product_id":{"type":DATA_TYPES.NUMERIC},"type":{"type":DATA_TYPES.STRING}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Bar_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Bar_Code\")"}}},"product_item":{"name":"product_items","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"serial_number":{"type":DATA_TYPES.STRING},"warehouse_id":{"type":DATA_TYPES.NUMERIC},"warehouse_location":{"type":DATA_TYPES.STRING},"date_received":{"type":DATA_TYPES.DATE},"date_shipped":{"type":DATA_TYPES.DATE},"status":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"item_cost":{"type":DATA_TYPES.NUMERIC},"roi_cost":{"type":DATA_TYPES.NUMERIC},"purchase_id":{"type":DATA_TYPES.NUMERIC},"order_id":{"type":DATA_TYPES.NUMERIC},"sell_price":{"type":DATA_TYPES.NUMERIC},"invoice_id":{"type":DATA_TYPES.NUMERIC},"shipment_id":{"type":DATA_TYPES.NUMERIC},"sales_rep_id":{"type":DATA_TYPES.NUMERIC},"sort_order":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"tax_amount":{"type":DATA_TYPES.NUMERIC},"temp_cust_id":{"type":DATA_TYPES.STRING},"shipment_in_id":{"type":DATA_TYPES.NUMERIC},"vendor_serial":{"type":DATA_TYPES.STRING},"override_date":{"type":DATA_TYPES.DATE},"order_kit_id":{"type":DATA_TYPES.NUMERIC},"purchase_kit_id":{"type":DATA_TYPES.NUMERIC},"discount":{"type":DATA_TYPES.NUMERIC},"starin_promo_id":{"type":DATA_TYPES.NUMERIC},"vendor_promo_id":{"type":DATA_TYPES.NUMERIC},"spiff_id":{"type":DATA_TYPES.NUMERIC},"program_id":{"type":DATA_TYPES.NUMERIC},"package_id":{"type":DATA_TYPES.NUMERIC},"has_changed":{"type":DATA_TYPES.BOOLEAN},"order_warehouse_id":{"type":DATA_TYPES.NUMERIC},"stock_type":{"type":DATA_TYPES.STRING},"order_line_id":{"type":DATA_TYPES.NUMERIC},"purchase_tracking_item_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.product_item_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.product_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_report":{"name":"product_items_reports","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"serial_number":{"type":DATA_TYPES.STRING},"warehouse_id":{"type":DATA_TYPES.NUMERIC},"warehouse_location":{"type":DATA_TYPES.STRING},"date_received":{"type":DATA_TYPES.DATE},"date_shipped":{"type":DATA_TYPES.DATE},"status":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"item_cost":{"type":DATA_TYPES.NUMERIC},"roi_cost":{"type":DATA_TYPES.NUMERIC},"purchase_id":{"type":DATA_TYPES.NUMERIC},"order_id":{"type":DATA_TYPES.NUMERIC},"sell_price":{"type":DATA_TYPES.NUMERIC},"invoice_id":{"type":DATA_TYPES.NUMERIC},"shipment_id":{"type":DATA_TYPES.NUMERIC},"sales_rep_id":{"type":DATA_TYPES.NUMERIC},"sort_order":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"tax_amount":{"type":DATA_TYPES.NUMERIC},"temp_cust_id":{"type":DATA_TYPES.STRING},"shipment_in_id":{"type":DATA_TYPES.NUMERIC},"vendor_serial":{"type":DATA_TYPES.STRING},"return_id":{"type":DATA_TYPES.NUMERIC},"override_date":{"type":DATA_TYPES.DATE},"order_kit_id":{"type":DATA_TYPES.NUMERIC},"purchase_kit_id":{"type":DATA_TYPES.NUMERIC},"discount":{"type":DATA_TYPES.NUMERIC},"starin_promo_id":{"type":DATA_TYPES.NUMERIC},"vendor_promo_id":{"type":DATA_TYPES.NUMERIC},"spiff_id":{"type":DATA_TYPES.NUMERIC},"program_id":{"type":DATA_TYPES.NUMERIC},"package_id":{"type":DATA_TYPES.NUMERIC},"has_changed":{"type":DATA_TYPES.BOOLEAN},"order_warehouse_id":{"type":DATA_TYPES.NUMERIC},"order_line_id":{"type":DATA_TYPES.NUMERIC},"source":{"type":DATA_TYPES.STRING},"stock_type":{"type":DATA_TYPES.STRING},"purchase_tracking_item_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,product_item_id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,product_item_id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_return":{"name":"product_items_returns","fields":{"id":{"type":DATA_TYPES.NUMERIC},"deleted":{"type":DATA_TYPES.BOOLEAN},"product_item_id":{"type":DATA_TYPES.NUMERIC},"return_id":{"type":DATA_TYPES.NUMERIC},"return_sell_price":{"type":DATA_TYPES.NUMERIC},"restock_fee":{"type":DATA_TYPES.NUMERIC},"invoice_id":{"type":DATA_TYPES.NUMERIC},"shipment_id":{"type":DATA_TYPES.NUMERIC},"order_id":{"type":DATA_TYPES.NUMERIC},"status":{"type":DATA_TYPES.NUMERIC},"date_shipped":{"type":DATA_TYPES.DATE},"date_return_received":{"type":DATA_TYPES.DATE},"sort_order":{"type":DATA_TYPES.NUMERIC},"sales_rep_id":{"type":DATA_TYPES.NUMERIC},"sell_price":{"type":DATA_TYPES.NUMERIC},"tax_amount":{"type":DATA_TYPES.NUMERIC},"shipment_in_id":{"type":DATA_TYPES.NUMERIC},"override_date":{"type":DATA_TYPES.DATE},"discount":{"type":DATA_TYPES.NUMERIC},"starin_promo_id":{"type":DATA_TYPES.NUMERIC},"vendor_promo_id":{"type":DATA_TYPES.NUMERIC},"spiff_id":{"type":DATA_TYPES.NUMERIC},"program_id":{"type":DATA_TYPES.NUMERIC},"package_id":{"type":DATA_TYPES.NUMERIC},"order_kit_id":{"type":DATA_TYPES.NUMERIC},"order_warehouse_id":{"type":DATA_TYPES.NUMERIC},"order_line_id":{"type":DATA_TYPES.NUMERIC},"stock_type":{"type":DATA_TYPES.STRING}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"order_return":{"table":"order_return","pql":"eq(return_id,order_return.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"sales_rep":{"table":"user","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Return\")"}}},"product_items_bills":{"name":"product_items_bills","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"product_item_id":{"type":DATA_TYPES.NUMERIC},"bill_id":{"type":DATA_TYPES.NUMERIC},"item_cost":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Bills\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Bills\")"}}},"products_vendors":{"name":"products_vendors","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"vendor_id":{"type":DATA_TYPES.NUMERIC},"cost":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Vendors\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Vendors\")"}}},"program":{"name":"programs","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"start_date":{"type":DATA_TYPES.DATE},"end_date":{"type":DATA_TYPES.DATE},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE},"brand_id":{"type":DATA_TYPES.NUMERIC},"rule_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.program_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.program_id,id)"},"product_item_returns":{"table":"product_item_returns","pql":"eq(product_item_returns.program_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Program\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Program\")"}}},"programs_customers":{"name":"programs_customers","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"program_id":{"type":DATA_TYPES.STRING},"customer_id":{"type":DATA_TYPES.DATE},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE},"parameters":{"type":DATA_TYPES.STRING}},"linkTo":{"program":{"table":"program","pql":"eq(program_id,program.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Programs_Customers\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Programs_Customers\")"}}},"promo":{"name":"promos","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"start_date":{"type":DATA_TYPES.DATE},"end_date":{"type":DATA_TYPES.DATE},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE},"type":{"type":DATA_TYPES.STRING},"rule_id":{"type":DATA_TYPES.NUMERIC},"brand_id":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"promo_code":{"type":DATA_TYPES.STRING},"before_order_rule_id":{"type":DATA_TYPES.NUMERIC},"after_invoice_rule_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"},"brand_id":{"table":"brand","pql":"eq(brand_id,brand_id.id)"}},"linkFrom":{"product_item_starin_promos":{"table":"product_item","pql":"eq(product_item_starin_promos.starin_promo_id,id)"},"product_item_vendor_promos":{"table":"product_item","pql":"eq(product_item_vendor_promos.vendor_promo_id,id)"},"product_item_return_starin_promos":{"table":"product_item_return","pql":"eq(product_item_return_starin_promos.starin_promo_id,id)"},"product_item_return_vendor_promos":{"table":"product_item_return","pql":"eq(product_item_return_vendor_promos.vendor_promo_id,id)"},"product_item_report_starin_promos":{"table":"product_item_report","pql":"eq(product_item_report_starin_promos.starin_promo_id,id)"},"product_item_report_vendor_promos":{"table":"product_item_report","pql":"eq(product_item_report_vendor_promos.vendor_promo_id,id)"},"promos_franchises":{"table":"promos_franchises","pql":"eq(promos_franchises.promo_id,id)"},"promos_products":{"table":"promos_products","pql":"eq(promos_products.promo_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promo\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promo\")"}}},"promos_franchises":{"name":"promos_franchises","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"promo_id":{"type":DATA_TYPES.NUMERIC},"franchise_id":{"type":DATA_TYPES.NUMERIC},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Franchises\")"}}},"promos_products":{"name":"promos_products","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"promo_id":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE},"description":{"type":DATA_TYPES.STRING}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Products\")"}}},"purchase":{"name":"purchases","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"vendor_id":{"type":DATA_TYPES.NUMERIC},"date_ordered":{"type":DATA_TYPES.DATE},"notes":{"type":DATA_TYPES.STRING},"status":{"type":DATA_TYPES.NUMERIC},"term_id":{"type":DATA_TYPES.NUMERIC},"shipment_method_id":{"type":DATA_TYPES.NUMERIC},"assigned_user_id":{"type":DATA_TYPES.NUMERIC},"sub_total":{"type":DATA_TYPES.NUMERIC},"tax":{"type":DATA_TYPES.NUMERIC},"freight":{"type":DATA_TYPES.NUMERIC},"misc":{"type":DATA_TYPES.NUMERIC},"total":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"office_id":{"type":DATA_TYPES.NUMERIC},"order_id":{"type":DATA_TYPES.NUMERIC},"notes_public":{"type":DATA_TYPES.STRING},"ship_account_num":{"type":DATA_TYPES.STRING},"est_received_date":{"type":DATA_TYPES.DATE},"vendor_order_number":{"type":DATA_TYPES.STRING}},"linkTo":{"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_id,id)"},"bills":{"table":"bill","pql":"eq(bills.purchase_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Purchase\")"}}},"purchase_tracking":{"name":"purchase_tracking","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"purchase_id":{"type":DATA_TYPES.NUMERIC},"estimated_receive_date":{"type":DATA_TYPES.DATE},"tracking_number":{"type":DATA_TYPES.STRING},"shipment_method_id":{"type":DATA_TYPES.NUMERIC},"last_updated":{"type":DATA_TYPES.DATE},"variance":{"type":DATA_TYPES.NUMERIC},"note":{"type":DATA_TYPES.STRING},"ref_number":{"type":DATA_TYPES.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"purchase_tracking_items":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_items.purchase_tracking_id,id)"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"PURCHASE_TRACKING\")"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking\")"}}},"purchase_tracking_item":{"name":"purchase_tracking_items","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"purchase_tracking_id":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"stock_type":{"type":DATA_TYPES.STRING},"qty":{"type":DATA_TYPES.NUMERIC},"qty_received":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"purchase_tracking":{"table":"purchase_tracking","pql":"eq(purchase_tracking_id,purchase_tracking.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_tracking_item_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_tracking_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking_Item\")"}}},"remit":{"name":"remits","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"paid":{"type":DATA_TYPES.BOOLEAN},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE},"amount_due":{"type":DATA_TYPES.NUMERIC},"gateway_account_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"}},"linkFrom":{"shipments":{"table":"shipment","pql":"eq(shipments.remit_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.remit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remit\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remit\")"}}},"remits_payments":{"name":"remits_payments","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"remit_id":{"type":DATA_TYPES.NUMERIC},"payment_id":{"type":DATA_TYPES.NUMERIC},"amount":{"type":DATA_TYPES.NUMERIC},"date_applied":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remits_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remits_Payments\")"}}},"return_product_due":{"name":"return_product_due","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"product_item_id":{"type":DATA_TYPES.NUMERIC},"order_return_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":[]},"rule":{"name":"rules","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"code":{"type":DATA_TYPES.STRING},"file":{"type":DATA_TYPES.STRING}},"linkTo":[],"linkFrom":[]},"sales_rep":{"name":"sales_reps","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"contact_id":{"type":DATA_TYPES.NUMERIC},"user_id":{"type":DATA_TYPES.NUMERIC},"assigned_user_id":{"type":DATA_TYPES.NUMERIC},"is_distributor":{"type":DATA_TYPES.BOOLEAN},"notes":{"type":DATA_TYPES.STRING},"legacy_id":{"type":DATA_TYPES.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.sales_rep_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Sales_Rep\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Sales_Rep\")"}}},"shipment":{"name":"shipments","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"shipment_method_id":{"type":DATA_TYPES.NUMERIC},"track_code":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING},"actual_cost":{"type":DATA_TYPES.NUMERIC},"ship_date":{"type":DATA_TYPES.DATE},"date_due":{"type":DATA_TYPES.DATE},"shipment_fee":{"type":DATA_TYPES.NUMERIC},"handling_fee":{"type":DATA_TYPES.NUMERIC},"flags":{"type":DATA_TYPES.NUMERIC},"shipment_addr_hash":{"type":DATA_TYPES.STRING},"customer_id":{"type":DATA_TYPES.NUMERIC},"bill_id":{"type":DATA_TYPES.NUMERIC},"term_id":{"type":DATA_TYPES.NUMERIC},"backorder_hash":{"type":DATA_TYPES.STRING},"remit_id":{"type":DATA_TYPES.NUMERIC},"discount_amount":{"type":DATA_TYPES.NUMERIC},"shipment_account_id":{"type":DATA_TYPES.NUMERIC},"shipment_flags":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.shipment_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.shipment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment\")"},"invoices":{"table":"invoice","pql":"eq(invoices.shipment_id,id)"}}},"shipment_account":{"name":"shipment_accounts","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"customer_id":{"type":DATA_TYPES.NUMERIC},"shipment_method_id":{"type":DATA_TYPES.NUMERIC},"ship_account_num":{"type":DATA_TYPES.STRING},"third_party_contact_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"third_party_contact":{"table":"contact","pql":"eq(third_party_contact_id,third_party_contact.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Account\")"}}},"shipment_in":{"name":"shipments_in","fields":{"id":{"type":DATA_TYPES.NUMERIC},"deleted":{"type":DATA_TYPES.BOOLEAN},"date_entered":{"type":DATA_TYPES.DATE},"purchase_id":{"type":DATA_TYPES.NUMERIC},"order_return_id":{"type":DATA_TYPES.NUMERIC},"notes":{"type":DATA_TYPES.STRING},"track_code":{"type":DATA_TYPES.STRING},"office_id":{"type":DATA_TYPES.NUMERIC},"shipment_method_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_in_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_In\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_In\")"}}},"shipment_method":{"name":"shipment_methods","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"customer_id":{"type":DATA_TYPES.NUMERIC},"prepaid":{"type":DATA_TYPES.BOOLEAN},"carrier_code":{"type":DATA_TYPES.STRING},"carrier":{"type":DATA_TYPES.STRING},"parent_shipment_method_id":{"type":DATA_TYPES.NUMERIC},"carrier_id":{"type":DATA_TYPES.NUMERIC},"transportaion_method_code":{"type":DATA_TYPES.STRING},"is_freight":{"type":DATA_TYPES.BOOLEAN},"time_in_transit":{"type":DATA_TYPES.NUMERIC},"service_level_code":{"type":DATA_TYPES.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"parent_shipment_method":{"table":"shipment_method","pql":"eq(parent_shipment_method_id,parent_shipment_method.id)"},"scac":{"table":"carrier","pql":"eq(carrier_id,scac.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.shipment_method_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.shipment_method_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Method\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Method\")"},"child_shipment_methods":{"table":"shipment_method","pql":"eq(child_shipment_methods.parent_shipment_method_id,id)"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.shipment_method_id,id)"}}},"spiff":{"name":"spiffs","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"start_date":{"type":DATA_TYPES.DATE},"end_date":{"type":DATA_TYPES.DATE},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE},"notes":{"type":DATA_TYPES.STRING},"max":{"type":DATA_TYPES.NUMERIC}},"linkTo":[],"linkFrom":{"spiffs_franchises":{"table":"spiffs_franchises","pql":"eq(spiffs_franchises.spiff_id,id)"},"spiffs_products":{"table":"spiffs_products","pql":"eq(spiffs_products.spiff_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.spiff_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.spiff_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.spiff_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff\")"}}},"spiffs_franchises":{"name":"spiffs_franchises","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"spiff_id":{"type":DATA_TYPES.NUMERIC},"franchise_id":{"type":DATA_TYPES.NUMERIC},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff_Franchises\")"}}},"spiffs_products":{"name":"spiffs_products","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"spiff_id":{"type":DATA_TYPES.NUMERIC},"product_id":{"type":DATA_TYPES.NUMERIC},"qty":{"type":DATA_TYPES.NUMERIC},"date_created":{"type":DATA_TYPES.DATE},"date_voided":{"type":DATA_TYPES.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiffs_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiffs_Products\")"}}},"tax_code":{"name":"tax_codes","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"percentage":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"shipment_tax":{"type":DATA_TYPES.NUMERIC}},"linkTo":[],"linkFrom":{"orders":{"table":"order","pql":"eq(orders.tax_code_id,id)"},"customers":{"table":"customer","pql":"eq(customers.tax_code_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Tax_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Tax_Code\")"}}},"term":{"name":"terms","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"due_days":{"type":DATA_TYPES.NUMERIC},"discount":{"type":DATA_TYPES.NUMERIC},"discount_days":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"order_override_flags":{"type":DATA_TYPES.NUMERIC},"classification":{"type":DATA_TYPES.STRING},"grace_days":{"type":DATA_TYPES.NUMERIC},"edi_term_code_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"edi_term_code":{"table":"edi_term_code","pql":"eq(edi_term_code_id,edi_term_code.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.term_id,id)"},"bills":{"table":"bill","pql":"eq(bills.term_id,id)"},"customers":{"table":"customer","pql":"eq(customers.term_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.term_id,id)"},"orders":{"table":"order","pql":"eq(orders.term_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Term\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Term\")"}}},"territory":{"name":"territories","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING},"legacy_id":{"type":DATA_TYPES.STRING},"country":{"type":DATA_TYPES.STRING},"region":{"type":DATA_TYPES.STRING},"state_province":{"type":DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"customers":{"table":"customer","pql":"eq(customers.territory_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Territory\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Territory\")"}}},"timezone":{"name":"timezones","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"utc":{"type":DATA_TYPES.STRING},"dst":{"type":DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.timezone_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Timezone\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Timezone\")"}}},"user":{"name":"users_view","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"username":{"type":DATA_TYPES.STRING},"password":{"type":DATA_TYPES.STRING},"can_login":{"type":DATA_TYPES.BOOLEAN},"employee_id":{"type":DATA_TYPES.NUMERIC},"contact_id":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"wh_scan":{"type":DATA_TYPES.STRING}},"linkTo":{"employee":{"table":"employee","pql":"eq(employee_id,employee.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":{"user_historys":{"table":"user_history","pql":"eq(user_historys.user_id,id)"},"voided_gateway_requests":{"table":"payment_gateway_request","pql":"eq(voided_gateway_requests.void_by,id)"},"approved_gateway_requests":{"table":"payment_gateway_request","pql":"eq(approved_gateway_requests.approved_by,id)"},"requested_gateway_requests":{"table":"payment_gateway_request","pql":"eq(requested_gateway_requests.request_by,id)"},"offices":{"table":"office","pql":"eq(offices.foreman_id,id)"},"customers":{"table":"customer","pql":"eq(customers.primary_rep_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.assigned_user_id,id)"},"orders":{"table":"order","pql":"eq(orders.assigned_user_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.user_id,id)"},"assigned_sales_reps":{"table":"sales_rep","pql":"eq(assigned_sales_reps.assigned_user_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"User\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"User\")"}}},"user_history":{"name":"user_historys","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"user_id":{"type":DATA_TYPES.NUMERIC},"method":{"type":DATA_TYPES.STRING},"args":{"type":DATA_TYPES.STRING},"window_id":{"type":DATA_TYPES.NUMERIC},"date":{"type":DATA_TYPES.DATE}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"vendor":{"name":"vendors","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"name":{"type":DATA_TYPES.STRING},"notes":{"type":DATA_TYPES.STRING},"primary_contact_id":{"type":DATA_TYPES.NUMERIC},"term_id":{"type":DATA_TYPES.NUMERIC},"legacy_id":{"type":DATA_TYPES.STRING},"temp_mybooks_id":{"type":DATA_TYPES.STRING},"our_account_number":{"type":DATA_TYPES.STRING},"default_shipment_method_id":{"type":DATA_TYPES.NUMERIC},"default_office_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"term":{"table":"term","pql":"eq(term_id,term.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"default_shipment_method":{"table":"shipment_method","pql":"eq(default_shipment_method_id,default_shipment_method.id)"},"default_office":{"table":"office","pql":"eq(default_office_id,default_office.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.vendor_id,id)"},"contacts":{"table":"contact","pql":"eq(contacts.vendor_id,id)"},"primary_products":{"table":"product","pql":"eq(primary_products.vendor_id,id)"},"bills":{"table":"bill","pql":"eq(bills.vendor_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.vendor_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Vendor\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Vendor\")"}}},"watch":{"name":"watchs","fields":{"deleted":{"type":DATA_TYPES.BOOLEAN},"id":{"type":DATA_TYPES.NUMERIC},"user_id":{"type":DATA_TYPES.NUMERIC},"record_id":{"type":DATA_TYPES.NUMERIC},"created":{"type":DATA_TYPES.DATE},"note":{"type":DATA_TYPES.STRING},"memute_id":{"type":DATA_TYPES.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"memute":{"table":"memute","pql":"eq(memute_id,memute.id)"}},"linkFrom":[]}}; import { EQUAL } from './opcodes/comparitors/equal.js'; @@ -49,7 +34,7 @@ Config.FUNCTION_MAP = { description: 'Compares two values', min_args: 2, max_args: 2, - return_type: Config.BOOLEAN, + return_type: DATA_TYPES.BOOLEAN, format: function (args, orig_args, query_obj){ var pql = this.getPqlObj(); var obj = new EQUAL(pql); @@ -62,7 +47,7 @@ Config.FUNCTION_MAP = { description: 'Checks if first value is greater than second', min_args: 2, max_args: 2, - return_type: Config.BOOLEAN, + return_type: DATA_TYPES.BOOLEAN, format: function (args, orig_args, query_obj){ var pql = this.getPqlObj(); var obj = new GREATER_THAN(pql); @@ -75,7 +60,7 @@ Config.FUNCTION_MAP = { description: 'Checks if first value is less than second', min_args: 2, max_args: 2, - return_type: Config.BOOLEAN, + return_type: DATA_TYPES.BOOLEAN, format: function (args, orig_args, query_obj){ var pql = this.getPqlObj(); var obj = new LESS_THAN(pql); @@ -88,7 +73,7 @@ Config.FUNCTION_MAP = { description: 'Checks if values are not equal', min_args: 2, max_args: 2, - return_type: Config.BOOLEAN, + return_type: DATA_TYPES.BOOLEAN, format: function (args, orig_args, query_obj){ var pql = this.getPqlObj(); var obj = new NOT_EQUAL(pql); @@ -101,7 +86,7 @@ Config.FUNCTION_MAP = { description: 'Checks if first value is like second. % sign is wild card character', min_args: 2, max_args: 2, - return_type: Config.BOOLEAN, + return_type: DATA_TYPES.BOOLEAN, format: function (args, orig_args, query_obj){ var pql = this.getPqlObj(); var obj = new LIKE(pql); @@ -114,7 +99,7 @@ Config.FUNCTION_MAP = { description: 'Checks if first value is not like second. % sign is wild card character', min_args: 2, max_args: 2, - return_type: Config.BOOLEAN, + return_type: DATA_TYPES.BOOLEAN, format: function (args, orig_args, query_obj){ var pql = this.getPqlObj(); var obj = new NOT_LIKE(pql); @@ -127,7 +112,7 @@ Config.FUNCTION_MAP = { description: 'Checks if first value is any of the following values', min_args: 2, max_args: Infinity, - return_type: Config.BOOLEAN, + return_type: DATA_TYPES.BOOLEAN, format: function (args, orig_args, query_obj){ var pql = this.getPqlObj(); var out_args = []; @@ -144,7 +129,7 @@ Config.FUNCTION_MAP = { description: 'Checks if first value is not any of the following values', min_args: 2, max_args: Infinity, - return_type: Config.BOOLEAN, + return_type: DATA_TYPES.BOOLEAN, format: function (args, orig_args, query_obj){ var pql = this.getPqlObj(); var out_args = []; @@ -161,8 +146,8 @@ Config.FUNCTION_MAP = { description: 'If first argument is truethy returns second argument otherwise returns third', min_args: 3, max_args: 3, - return_type: Config.ANY, - format: ['IF(', Config.ALL_ARGS, ')'], + return_type: DATA_TYPES.ANY, + format: ['(CASE WHEN ', Config.ARG1, ' THEN ', Config.ARG2, ' ELSE ', Config.ARG3, ' END)'], }, /* Math functions */ add: { @@ -229,9 +214,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.NUMERIC, + DATA_TYPES.NUMERIC, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['ABS(', Config.ARG1, ')'], }, 'char': { @@ -239,33 +224,33 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: Infinity, arg_types: [ - Config.NUMERIC, + DATA_TYPES.NUMERIC, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['CHAR(', Config.ALL_ARGS, ')'], }, coalesce: { description: 'Returns first non-null value from arguments', min_args: 1, max_args: Infinity, - return_type: Config.ANY_TYPE, + return_type: DATA_TYPES.ANY_TYPE, format: ['COALESCE(', Config.ALL_ARGS, ')'], }, ifnull: { description: 'Returns first argument if not null otherwise returns second argument', min_args: 2, max_args: 2, - return_type: Config.ANY_TYPE, + return_type: DATA_TYPES.ANY_TYPE, format: ['IFNULL(', Config.ARG1, ', ', Config.ARG2, ')'], }, instr: { description: 'Gets character position of argument two in argument one\'s string', min_args: 2, max_args: 2, - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, arg_types: [ - Config.STRING, - Config.STRING, + DATA_TYPES.STRING, + DATA_TYPES.STRING, ], format: ['INSTR(', Config.ARG1, ', ', Config.ARG2, ')'], }, @@ -273,7 +258,7 @@ Config.FUNCTION_MAP = { description: 'Returns hex value of argument', min_args: 1, max_args: 1, - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['HEX(', Config.ARG1, ')'], }, length: { @@ -281,9 +266,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.STRING, + DATA_TYPES.STRING, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['LENGTH(', Config.ARG1, ')'], }, lower: { @@ -291,9 +276,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.STRING, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['LOWER(', Config.ARG1, ')'], }, ltrim: { @@ -301,23 +286,23 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.STRING, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['LTRIM(', Config.ARG1, ')'], }, nullif: { description: 'Returns null if argument one equals argument two', min_args: 2, max_args: 2, - return_type: Config.ANY_TYPE, + return_type: DATA_TYPES.ANY_TYPE, format: ['NULLIF(', Config.ARG1, ', ', Config.ARG2, ')'], }, random: { description: 'Returns random number (platform dependent)', min_args: 0, max_args: 0, - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['RANDOM()'], }, replace: { @@ -325,11 +310,11 @@ Config.FUNCTION_MAP = { min_args: 3, max_args: 3, arg_types: [ - Config.STRING, - Config.STRING, - Config.STRING, + DATA_TYPES.STRING, + DATA_TYPES.STRING, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['REPLACE(', Config.ARG1, ', ', Config.ARG2, ', ', Config.ARG3, ')'], }, round: { @@ -337,10 +322,10 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 2, arg_types: [ - Config.NUMERIC, - Config.NUMERIC, + DATA_TYPES.NUMERIC, + DATA_TYPES.NUMERIC, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['ROUND(', Config.ALL_ARGS, ')'], }, rtrim: { @@ -348,9 +333,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.STRING, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['RTRIM(', Config.ARG1, ')'], }, substr: { @@ -358,11 +343,11 @@ Config.FUNCTION_MAP = { min_args: 2, max_args: 3, arg_types: [ - Config.STRING, - Config.NUMERIC, - Config.NUMERIC, + DATA_TYPES.STRING, + DATA_TYPES.NUMERIC, + DATA_TYPES.NUMERIC, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['SUBSTR(', Config.ALL_ARGS, ')'], }, trim: { @@ -370,9 +355,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.STRING, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['TRIM(', Config.ARG1, ')'], }, upper: { @@ -380,9 +365,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.STRING, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['UPPER(', Config.ARG1, ')'], }, concat: { @@ -390,9 +375,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: Infinity, arg_types: [ - Config.STRING, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['CONCAT(', Config.ALL_ARGS, ')'], }, @@ -402,10 +387,10 @@ Config.FUNCTION_MAP = { min_args: 2, max_args: 2, arg_types: [ - Config.DATE, - Config.STRING, + DATA_TYPES.DATE, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['DATE_FORMAT(', Config.ARG1, ', ', Config.ARG2,')'], }, date: { @@ -413,9 +398,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.DATE, + return_type: DATA_TYPES.DATE, format: ['DATE(', Config.ARG1, ')'], }, day: { @@ -423,9 +408,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['DAY(', Config.ARG1, ')'], }, from_unixtime: { @@ -433,9 +418,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.NUMERIC, + DATA_TYPES.NUMERIC, ], - return_type: Config.DATE, + return_type: DATA_TYPES.DATE, format: ['FROM_UNIXTIME(', Config.ARG1, ')'], }, hour: { @@ -443,9 +428,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['HOUR(', Config.ARG1, ')'], }, minute: { @@ -453,9 +438,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['MINUTE(', Config.ARG1, ')'], }, month: { @@ -463,16 +448,16 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['MONTH(', Config.ARG1, ')'], }, now: { description: 'Returns current time/date', min_args: 0, max_args: 0, - return_type: Config.DATE, + return_type: DATA_TYPES.DATE, format: ['NOW()'], }, second: { @@ -480,9 +465,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['SECOND(', Config.ARG1, ')'], }, time: { @@ -490,9 +475,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, format: ['TIME(', Config.ARG1, ')'], }, unix_timestamp: { @@ -500,9 +485,9 @@ Config.FUNCTION_MAP = { min_args: 0, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['UNIX_TIMESTAMP(', Config.ARG1, ')'], }, year: { @@ -510,9 +495,9 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 1, arg_types: [ - Config.DATE, + DATA_TYPES.DATE, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, format: ['YEAR(', Config.ARG1, ')'], }, @@ -522,10 +507,10 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 2, arg_types: [ - Config.NUMERIC, - Config.BOOLEAN, + DATA_TYPES.NUMERIC, + DATA_TYPES.BOOLEAN, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, is_group_function: true, format: { 1: ['AVG(', Config.ARG1, ')'], @@ -543,10 +528,10 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 2, arg_types: [ - Config.NUMERIC, - Config.BOOLEAN, + DATA_TYPES.NUMERIC, + DATA_TYPES.BOOLEAN, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, is_group_function: true, format: { 1: ['COUNT(', Config.ARG1, ')'], @@ -565,13 +550,13 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: Infinity, arg_types: [ - Config.STRING, - Config.BOOLEAN, - Config.STRING, - Config.STRING, - Config.STRING, + DATA_TYPES.STRING, + DATA_TYPES.BOOLEAN, + DATA_TYPES.STRING, + DATA_TYPES.STRING, + DATA_TYPES.STRING, ], - return_type: Config.STRING, + return_type: DATA_TYPES.STRING, is_group_function: true, format: (args, orig_args) => { let distinct = (orig_args.length >= 2) && Boolean(Number(orig_args[1].getValue())) ? 'DISTINCT ' : ''; @@ -613,10 +598,10 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 2, arg_types: [ - Config.NUMERIC, - Config.BOOLEAN, + DATA_TYPES.NUMERIC, + DATA_TYPES.BOOLEAN, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, is_group_function: true, format: { 1: ['MAX(', Config.ARG1, ')'], @@ -634,10 +619,10 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 2, arg_types: [ - Config.NUMERIC, - Config.BOOLEAN, + DATA_TYPES.NUMERIC, + DATA_TYPES.BOOLEAN, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, is_group_function: true, format: { 1: ['MIN(', Config.ARG1, ')'], @@ -655,10 +640,10 @@ Config.FUNCTION_MAP = { min_args: 1, max_args: 2, arg_types: [ - Config.NUMERIC, - Config.BOOLEAN, + DATA_TYPES.NUMERIC, + DATA_TYPES.BOOLEAN, ], - return_type: Config.NUMERIC, + return_type: DATA_TYPES.NUMERIC, is_group_function: true, format: { 1: ['SUM(', Config.ARG1, ')'], @@ -675,7 +660,7 @@ Config.FUNCTION_MAP = { description: 'Forces item into having statment', min_args: 1, max_args: 1, - return_type: Config.ANY, + return_type: DATA_TYPES.ANY, is_group_function: true, format: [Config.ARG1], } diff --git a/pql/data_types.js b/pql/data_types.js new file mode 100644 index 0000000..8d6a9bc --- /dev/null +++ b/pql/data_types.js @@ -0,0 +1,18 @@ +export class DATA_TYPES { + +}; +DATA_TYPES.NUMERIC = { + is_numeric: true, +}; +DATA_TYPES.DATE = { + is_numeric: false, +}; +DATA_TYPES.STRING = { + is_numeric: false, +}; +DATA_TYPES.BOOLEAN = { + is_numeric: true, +}; +DATA_TYPES.ANY = { + is_numeric: false, +}; \ No newline at end of file diff --git a/pql/opcodes/comparitors/comparitor.js b/pql/opcodes/comparitors/comparitor.js index 194b3e7..c71e414 100644 --- a/pql/opcodes/comparitors/comparitor.js +++ b/pql/opcodes/comparitors/comparitor.js @@ -26,6 +26,10 @@ export class COMPARITOR extends OPCODE { this.right = v; return this; } + setNeedsWrapped (val) { + this._needs_wrapped = val; + return this; + } needsGroup () { if (this._needs_group_cache !== null) { return this._needs_group_cache; diff --git a/pql/opcodes/constant.js b/pql/opcodes/constant.js index e8de395..c71a773 100644 --- a/pql/opcodes/constant.js +++ b/pql/opcodes/constant.js @@ -13,6 +13,7 @@ export class CONSTANT extends OPCODE { } setForceNumeric (force) { this._force_numeric = !!force; + return this; } getValue () { return this._value; diff --git a/pql/opcodes/function.js b/pql/opcodes/function.js index 8f0aa1d..ebd2fce 100644 --- a/pql/opcodes/function.js +++ b/pql/opcodes/function.js @@ -1,10 +1,12 @@ import { OPCODE } from './opcode.js'; +import { DATA_TYPES } from '../data_types.js'; export class FUNCTION extends OPCODE { constructor (pql_obj, fn_name) { super(pql_obj, fn_name); this._needs_group_cache = null; + this._return_type = null; this.setFunctionName(fn_name); } setArgs (args) { @@ -31,6 +33,7 @@ export class FUNCTION extends OPCODE { throw `Function '${fn_name}' is not allowed or not defined`; } this._fn_settings = this.getPqlObj().getConfig().FUNCTION_MAP[fn_name]; + this.setType(this._fn_settings.return_type || DATA_TYPES.ANY); this._fn_name = fn_name; } getFunctionSettings () { @@ -44,6 +47,13 @@ export class FUNCTION extends OPCODE { }); return this.buildFromFormat(this.getFormat(), args, this._arguments, query_obj); } + setType (type) { + this._return_type = type; + return this; + } + getType () { + return this._return_type; + } needsGroup () { if (this._needs_group_cache !== null) { return this._needs_group_cache; diff --git a/pql/parser.js b/pql/parser.js index 5463964..c0577b2 100644 --- a/pql/parser.js +++ b/pql/parser.js @@ -12,15 +12,17 @@ import { NO_VALUE } from './opcodes/comparitors/no_value.js'; import { VARIABLE } from './opcodes/variable.js'; import { CONSTANTS_ARRAY } from './opcodes/constants_array.js'; import { TABLE_REF } from './parser/table_ref.js'; +import { DATA_TYPES } from './data_types.js'; export class PARSER { - constructor (query, ref_table, allow_seperator = false, config = null, table_refs = [], variables = {}) { + constructor (query, ref_table, allow_seperator = false, config = null, table_refs = [], variables = {}, allow_compares = false) { this._hasError = false; this._error = null; this._codes = []; this._comparitors = new COMPARITORS(config.COMPARITORS); this._table_refs = table_refs; this._variables = {}; + this._allow_compares= !!allow_compares; // Defaults to false allow_seperator = !!allow_seperator; @@ -62,6 +64,9 @@ export class PARSER { } } } + getAllowCompares () { + return this._allow_compares; + } assignVariables (var_list_obj) { for (let var_name in var_list_obj) { if (var_list_obj.hasOwnProperty(var_name)) { @@ -332,6 +337,7 @@ export class PARSER { ]; //throw ["Expected T_COMPARITOR", str.length]; } + if (comparitor[1].isInstanceOf(NO_VALUE)) { return [ match[0].length + comparitor[0], @@ -348,6 +354,17 @@ export class PARSER { .setLeft(field) .setRight(value[1]); + if (!this.getAllowCompares()) { + let func = new FUNCTION(this, 'if'); + func.setArgs([ + comparitor[1], + (new CONSTANT(this, '1')).setForceNumeric(true), + (new CONSTANT(this, '0')).setForceNumeric(true), + ]); + func.setType(DATA_TYPES.BOOLEAN); + comparitor[1] = func; + } + return [ match[0].length + comparitor[0] + value[0], comparitor[1] @@ -413,6 +430,7 @@ export class PARSER { ]; //throw ["Expected T_COMPARITOR", str.length]; } + if (comparitor[1].isInstanceOf(NO_VALUE)) { return [ match[0].length + sum_length + closer[0] + comparitor[0], @@ -424,6 +442,17 @@ export class PARSER { comparitor[1].setLeft(func); comparitor[1].setRight(value[1]); + if (!this.getAllowCompares()) { + let func = new FUNCTION(this, 'if'); + func.setArgs([ + comparitor[1], + new CONSTANT(this, '1'), + new CONSTANT(this, '0'), + ]); + func.setType(DATA_TYPES.BOOLEAN); + comparitor[1] = func; + } + return [ match[0].length + sum_length + closer[0] + comparitor[0] + value[0], comparitor[1] diff --git a/pql/parser/sql_builder.js b/pql/parser/sql_builder.js index df4111e..f2ecf44 100644 --- a/pql/parser/sql_builder.js +++ b/pql/parser/sql_builder.js @@ -1,6 +1,6 @@ import { PARSER } from './../parser.js'; export class SQL_BUILDER { - constructor ({ query, table, group, selects, orderBys, limit, offset }) { + constructor ({ query, table, group, selects, orderBys, limit, offset, variables }) { this._query = query; this._table = table; this._group = group; @@ -8,6 +8,7 @@ export class SQL_BUILDER { this._orderBys = orderBys; this._limit = limit; this._offset = offset; + this._variables = variables; this._table_refs = new Map; this._linked_tables = []; @@ -37,6 +38,9 @@ export class SQL_BUILDER { getOffset () { return this._offset; } + getVariables () { + return this._variables; + } toString () { let query_str = this.getQuery().getWhereCodes().getSQL(this); if (query_str) { @@ -133,7 +137,7 @@ export class SQL_BUILDER { } // Pop last item off the array and clone it so it doesn't count itself - let parser = new PARSER(link_obj.pql, this.getTable(), false, this.getQuery().getConfig(), table_ary.slice(0, table_ary.length - 1)); + let parser = new PARSER(link_obj.pql, this.getTable(), false, this.getQuery().getConfig(), table_ary.slice(0, table_ary.length - 1), this.getVariables(), true); // This needs to happen here to ensure the tables get added in the proper order parser.getCodes().getSQL(this); diff --git a/unit_test/tests/functions.js b/unit_test/tests/functions.js index 7162796..ab70b91 100644 --- a/unit_test/tests/functions.js +++ b/unit_test/tests/functions.js @@ -153,7 +153,7 @@ window.QUnit.test('Functions - count', function (assert) { query: 'count(id) > 21', table: 'table1', }); - assert.ok(query.replace (/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING COUNT("TablE1"."id") > \'21\'', "Passed!"); + assert.ok(query.replace (/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING COUNT("TablE1"."id") > 21', "Passed!"); }); window.QUnit.test('Functions - group_concat 1', function (assert) { var query = PQL.getSQL({ diff --git a/unit_test/tests/variable.js b/unit_test/tests/variable.js index bfd6a7b..d977213 100644 --- a/unit_test/tests/variable.js +++ b/unit_test/tests/variable.js @@ -40,7 +40,7 @@ window.QUnit.test('Variable 4', function (assert) { amt: 3, }, }); - assert.ok(query.replace (/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > \'3\'', "Passed!"); + assert.ok(query.replace (/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > 3', "Passed!"); }); window.QUnit.test('Variable 5', function (assert) { var query = PQL.getSQL({ @@ -52,7 +52,7 @@ window.QUnit.test('Variable 5', function (assert) { amt: 3, }, }); - assert.ok(query.replace (/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING ( "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > \'3\' ) IF(COUNT(\'4\') > \'-009\', \'3\', NULL)', "Passed!"); + assert.ok(query.replace (/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING ( "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > 3 ) IF(COUNT(\'4\') > -009, \'3\', NULL)', "Passed!"); }); window.QUnit.test('Variable 6', function (assert) { var query = PQL.getSQL({ @@ -62,7 +62,7 @@ window.QUnit.test('Variable 6', function (assert) { id: 0, }, }); - assert.ok(query.replace (/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id" HAVING \'7\' = COUNT(\'0\')', "Passed!"); + assert.ok(query.replace (/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id" HAVING 7 = COUNT(\'0\')', "Passed!"); }); window.QUnit.test('Variable 7', function (assert) { var query = PQL.getSQL({ From a08a3dd13245c0a49a97406e36dc6b85ab3ae447 Mon Sep 17 00:00:00 2001 From: Nathan Bruer Date: Thu, 3 Dec 2015 18:46:07 -0600 Subject: [PATCH 6/6] updated compiled directory --- compiled/pql/PQL.js | 15 +++++----- compiled/pql/config.js | 8 ++--- compiled/pql/data_types.js | 29 +++++++++++++++++++ .../pql/opcodes/comparitors/comparitor.js | 6 ++++ compiled/pql/opcodes/constant.js | 1 + compiled/pql/opcodes/function.js | 15 ++++++++++ compiled/pql/parser.js | 25 ++++++++++++++++ compiled/pql/parser/sql_builder.js | 9 +++++- compiled/unit_test/tests/functions.js | 2 +- compiled/unit_test/tests/variable.js | 6 ++-- 10 files changed, 100 insertions(+), 16 deletions(-) create mode 100644 compiled/pql/data_types.js diff --git a/compiled/pql/PQL.js b/compiled/pql/PQL.js index dc996b3..54ff66a 100644 --- a/compiled/pql/PQL.js +++ b/compiled/pql/PQL.js @@ -31,7 +31,7 @@ var PQL = (function () { var limit = _ref.limit; var offset = _ref.offset; - var query_parser = new _parserJs.PARSER(query, table, false, this.defaultConfig, [], variables); + var query_parser = new _parserJs.PARSER(query, table, false, this.defaultConfig, [], variables, true); if (query_parser.hasError()) { throw query_parser.getError(); } @@ -39,7 +39,7 @@ var PQL = (function () { if (group === undefined) { group = 'id'; } - var group_parser = new _parserJs.PARSER(group, table, true, this.defaultConfig, [], variables); + var group_parser = new _parserJs.PARSER(group, table, true, this.defaultConfig, [], variables, false); if (group_parser.hasError()) { throw group_parser.getError(); } @@ -47,7 +47,7 @@ var PQL = (function () { var select_parsers = new Map(); if (selects instanceof Map) { selects.forEach(function (v, k) { - var val = new _parserJs.PARSER(v, table, false, _this.defaultConfig, [], variables); + var val = new _parserJs.PARSER(v, table, false, _this.defaultConfig, [], variables, false); if (val.hasError()) { throw val.getError(); } @@ -56,7 +56,7 @@ var PQL = (function () { } else { for (var k in selects) { if (selects.hasOwnProperty(k)) { - var v = new _parserJs.PARSER(selects[k], table, false, this.defaultConfig, [], variables); + var v = new _parserJs.PARSER(selects[k], table, false, this.defaultConfig, [], variables, false); if (v.hasError()) { throw v.getError(); } @@ -69,7 +69,7 @@ var PQL = (function () { if (orderBys instanceof Map) { orderBys.forEach(function (v, k) { // This one is backwards... be warned that k is the string v is the [desc, asc] - var val = new _parserJs.PARSER(k, table, false, _this.defaultConfig, [], variables); + var val = new _parserJs.PARSER(k, table, false, _this.defaultConfig, [], variables, false); if (val.hasError()) { throw val.getError(); } @@ -78,7 +78,7 @@ var PQL = (function () { } else { for (var k in orderBys) { if (orderBys.hasOwnProperty(k)) { - var v = new _parserJs.PARSER(k, table, false, this.defaultConfig, [], variables); + var v = new _parserJs.PARSER(k, table, false, this.defaultConfig, [], variables, false); if (v.hasError()) { throw v.getError(); } @@ -94,7 +94,8 @@ var PQL = (function () { selects: select_parsers, orderBys: order_by_parsers, limit: limit, - offset: offset + offset: offset, + variables: variables }); return sb.toString(); } diff --git a/compiled/pql/config.js b/compiled/pql/config.js index 8a68d7f..15f5491 100644 --- a/compiled/pql/config.js +++ b/compiled/pql/config.js @@ -1,4 +1,4 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _opcodesComparitorsEqualJs=require('./opcodes/comparitors/equal.js');var _opcodesComparitorsGreater_thanJs=require('./opcodes/comparitors/greater_than.js');var _opcodesComparitorsLess_thanJs=require('./opcodes/comparitors/less_than.js');var _opcodesComparitorsLikeJs=require('./opcodes/comparitors/like.js');var _opcodesComparitorsNo_valueJs=require('./opcodes/comparitors/no_value.js');var _opcodesComparitorsNot_equalJs=require('./opcodes/comparitors/not_equal.js');var _opcodesComparitorsNot_likeJs=require('./opcodes/comparitors/not_like.js');var _opcodesConstants_arrayJs=require('./opcodes/constants_array.js');var _opcodesNullJs=require('./opcodes/null.js');var Config=(function(){function Config(){_classCallCheck(this,Config);} /* Database types */_createClass(Config,null,[{key:"ALL_ARGS",value:function ALL_ARGS(args){return args.join(', ');}}]);return Config;})();exports.Config = Config;Config.NUMERIC = {is_numeric:true};Config.DATE = {is_numeric:false};Config.STRING = {is_numeric:false};Config.BOOLEAN = {is_numeric:true};Config.ANY_TYPE = {is_numeric:false}; /* These are to make it easier to read the code for the function definitions */Config.ARG1 = 0;Config.ARG2 = 1;Config.ARG3 = 2;Config.ARG4 = 3;Config.ARG5 = 4;Config.ARG6 = 5;Config.ARG7 = 6;Config.ARG8 = 7;Config.DB_MAP = {"bill":{"name":"bills","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"invoice_number":{"type":Config.STRING},"purchase_id":{"type":Config.NUMERIC},"invoice_date":{"type":Config.DATE},"notes":{"type":Config.STRING},"payment_status":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"due_date":{"type":Config.DATE},"accounting_system_id":{"type":Config.STRING},"vendor_id":{"type":Config.NUMERIC},"effective_date":{"type":Config.DATE},"invoice_amount":{"type":Config.NUMERIC},"shipping_cost":{"type":Config.NUMERIC},"discount_amount":{"type":Config.NUMERIC},"tax_amount":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"date_closed":{"type":Config.DATE},"currency":{"type":Config.STRING},"type":{"type":Config.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"}},"linkFrom":{"shipment":{"table":"shipment","pql":"eq(shipment.bill_id,id)"},"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.bill_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Bill\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Bill\")"}}},"booking":{"name":"bookings","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_attn":{"type":Config.STRING},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"brand_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"customer_po":{"type":Config.STRING},"sales_rep_id":{"type":Config.NUMERIC},"total":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Booking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Booking\")"}}},"brand":{"name":"brands","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"brand_names":{"type":Config.STRING},"parent_id":{"type":Config.NUMERIC},"active":{"type":Config.BOOLEAN},"website":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.NUMERIC},"warehouse_use_vendor_num":{"type":Config.BOOLEAN}},"linkTo":{"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"parent":{"table":"brand","pql":"eq(parent_id,parent.id)"}},"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.brand_id,id)"},"products":{"table":"product","pql":"eq(products.brand_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Brand\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Brand\")"}}},"carrier":{"name":"carriers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"scac_code":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"shipment_methods":{"table":"shipment_method","pql":"eq(shipment_methods.carrier_id,id)"}}},"contact":{"name":"contacts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"last_name":{"type":Config.STRING},"address1":{"type":Config.STRING},"address2":{"type":Config.STRING},"city":{"type":Config.STRING},"state":{"type":Config.STRING},"zip":{"type":Config.STRING},"country":{"type":Config.STRING},"email":{"type":Config.STRING},"phone":{"type":Config.STRING},"timezone_id":{"type":Config.NUMERIC},"contact_hours":{"type":Config.STRING},"notes":{"type":Config.STRING},"fax":{"type":Config.STRING},"alt_phone":{"type":Config.STRING},"fax_optout":{"type":Config.BOOLEAN},"email_optout":{"type":Config.BOOLEAN},"postal_optout":{"type":Config.BOOLEAN},"customer_id":{"type":Config.NUMERIC},"brand_id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"parent_contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"status":{"type":Config.NUMERIC}},"linkTo":{"timezone":{"table":"timezone","pql":"eq(timezone_id,timezone.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"parent_contact":{"table":"contact","pql":"eq(parent_contact_id,parent_contact.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.billing_contact_id,id)"},"customers_shipping":{"table":"customer","pql":"eq(customers_shipping.primary_shipping_contact_id,id)"},"customers_billing":{"table":"customer","pql":"eq(customers_billing.primary_billing_contact_id,id)"},"customers_primary":{"table":"customer","pql":"eq(customers_primary.primary_contact_id,id)"},"users":{"table":"user","pql":"eq(users.contact_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.contact_id,id)"},"brands":{"table":"brand","pql":"eq(brands.contact_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.primary_contact_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.contact_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Contact\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Contact\")"}}},"control_flag":{"name":"control_flags","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"control_key_id":{"type":Config.NUMERIC},"value":{"type":Config.STRING},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC}},"linkTo":{"control_key":{"table":"control_key","pql":"eq(control_key_id,control_key.id)"}},"linkFrom":[]},"control_key":{"name":"control_keys","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"key":{"type":Config.STRING},"module_flags":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"control_flags":{"table":"control_flag","pql":"eq(control_flags.control_key_id,id)"}}},"customer":{"name":"customers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"primary_rep_id":{"type":Config.NUMERIC},"current_credit":{"type":Config.NUMERIC},"max_credit_amount":{"type":Config.NUMERIC},"primary_contact_id":{"type":Config.NUMERIC},"primary_billing_contact_id":{"type":Config.NUMERIC},"primary_shipping_contact_id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"website":{"type":Config.STRING},"term_id":{"type":Config.NUMERIC},"resale_tax_number":{"type":Config.STRING},"territory_id":{"type":Config.NUMERIC},"federal_id":{"type":Config.STRING},"dunns":{"type":Config.STRING},"tax_code_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.STRING},"status":{"type":Config.NUMERIC},"parent_customer_id":{"type":Config.NUMERIC},"unpaid_invoice_amount":{"type":Config.NUMERIC},"primary_shipment_method_id":{"type":Config.NUMERIC},"primary_shipment_account_id":{"type":Config.NUMERIC}},"linkTo":{"rep":{"table":"user","pql":"eq(primary_rep_id,rep.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"billing_contact":{"table":"contact","pql":"eq(primary_billing_contact_id,billing_contact.id)"},"shipping_contact":{"table":"contact","pql":"eq(primary_shipping_contact_id,shipping_contact.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"territory":{"table":"territory","pql":"eq(territory_id,territory.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"parent_customer":{"table":"customer","pql":"eq(parent_customer_id,parent_customer.id)"},"primary_shipment_method":{"table":"shipment_method","pql":"eq(primary_shipment_method_id,primary_shipment_method.id)"},"primary_shipment_account":{"table":"shipment_account","pql":"eq(primary_shipment_account_id,primary_shipment_account.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.customer_id,id)"},"payments":{"table":"payment","pql":"eq(payments.customer_id,id)"},"invoices":{"table":"invoice","pql":"eq(invoices.customer_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.customer_id,id)"},"orders":{"table":"order","pql":"eq(orders.customer_id,id)"},"child_customers":{"table":"customer","pql":"eq(child_customers.parent_customer_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer\")"},"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.customer_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer\")"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.customer_id,id)"},"customer_notifications":{"table":"customers_notifications","pql":"eq(customer_notifications.customer_id,id)"}}},"customer_franchises":{"name":"customer_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"dont_purge":{"type":Config.BOOLEAN}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer_Franchises\")"}}},"customers_notifications":{"name":"customers_notifications","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING},"contact_method":{"type":Config.STRING},"contact_data":{"type":Config.STRING},"contact_name":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customers_Notifications\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customers_Notifications\")"}}},"cycle_count":{"name":"cycle_counts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"date_created":{"type":Config.DATE},"date_completed":{"type":Config.DATE},"active":{"type":Config.BOOLEAN}},"linkTo":[],"linkFrom":[]},"draft_item":{"name":"draft_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"order_draft_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"qty":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC}},"linkTo":{"order_draft":{"table":"order_draft","pql":"eq(order_draft_id,order_draft.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Draft_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Draft_Item\")"}}},"edi_term_code":{"name":"edi_term_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"term_code":{"type":Config.STRING},"description":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"terms":{"table":"term","pql":"eq(terms.edi_term_code_id,id)"}}},"edi_user":{"name":"edi_users","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"friendly_name":{"type":Config.STRING},"auth_qualifier":{"type":Config.STRING},"auth_info":{"type":Config.STRING},"security_qualifier":{"type":Config.STRING},"security_info":{"type":Config.STRING},"sender_qualifier":{"type":Config.STRING},"sender_id":{"type":Config.STRING},"receiver_qualifier":{"type":Config.STRING},"receiver_id":{"type":Config.STRING},"control_standard_id":{"type":Config.STRING},"control_version":{"type":Config.STRING},"ack_requested":{"type":Config.STRING},"is_test":{"type":Config.STRING},"sub_element_sep":{"type":Config.STRING},"func_id":{"type":Config.STRING},"application_sender_id":{"type":Config.STRING},"application_receiver_id":{"type":Config.STRING},"responsible_agency_code":{"type":Config.STRING},"version_id":{"type":Config.STRING},"transaction_set_id":{"type":Config.STRING},"element_seperator":{"type":Config.STRING},"tag_seperator":{"type":Config.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":[]},"employee":{"name":"employees","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"office_id":{"type":Config.NUMERIC},"work_area_location":{"type":Config.STRING},"computer_ip":{"type":Config.STRING},"position":{"type":Config.STRING},"actively_employed":{"type":Config.BOOLEAN},"extension":{"type":Config.STRING},"notes":{"type":Config.STRING}},"linkTo":{"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Employee\")"},"users":{"table":"user","pql":"eq(users.user_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Employee\")"}}},"event":{"name":"events","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"watch_id":{"type":Config.NUMERIC},"transaction_id":{"type":Config.NUMERIC},"message":{"type":Config.STRING},"date":{"type":Config.DATE},"has_read":{"type":Config.BOOLEAN},"module":{"type":Config.STRING}},"linkTo":{"watch":{"table":"watch","pql":"eq(watch_id,watch.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Event\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Event\")"}}},"franchise":{"name":"franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_brand_id":{"type":Config.NUMERIC},"is_exclude":{"type":Config.BOOLEAN},"is_public":{"type":Config.BOOLEAN},"legacy_id":{"type":Config.STRING},"formula":{"type":Config.STRING},"dealer_col":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(primary_brand_id,brand.id)"}},"linkFrom":{"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.franchise_id,id)"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.franchise_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise\")"}}},"franchise_products":{"name":"franchise_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"date_voided":{"type":Config.DATE},"date_created":{"type":Config.DATE},"rule_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"sugar_column":{"type":Config.STRING}},"linkTo":{"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise_Products\")"}}},"gateway_account":{"name":"gateway_accounts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"payment_gateway_id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"billing_contact_id":{"type":Config.NUMERIC},"gateway_ref":{"type":Config.STRING},"additional_ref":{"type":Config.STRING},"is_primary":{"type":Config.BOOLEAN},"last_updated":{"type":Config.DATE},"exp_date":{"type":Config.NUMERIC},"type":{"type":Config.STRING}},"linkTo":{"payment_gateway":{"table":"payment_gateway","pql":"eq(payment_gateway_id,payment_gateway.id)"},"billing_contact":{"table":"contact","pql":"eq(billing_contact_id,billing_contact.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"order_draft":{"table":"order_draft","pql":"eq(order_draft.gateway_account_id,id)"},"orders":{"table":"order","pql":"eq(orders.gateway_account_id,id)"},"remits":{"table":"remit","pql":"eq(remits.gateway_account_id,id)"},"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.gateway_account_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Gateway_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Gateway_Account\")"}}},"groupping_products":{"name":"groupping_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"parent_id":{"type":Config.NUMERIC},"child_id":{"type":Config.NUMERIC},"num_of_children_in_parent":{"type":Config.NUMERIC},"discount_percent":{"type":Config.NUMERIC}},"linkTo":{"parent":{"table":"product","pql":"eq(parent_id,parent.id)"},"child":{"table":"product","pql":"eq(child_id,child.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Groupping_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Groupping_Products\")"}}},"invoice":{"name":"invoices_view","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"invoice_date":{"type":Config.DATE},"invoice_status":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"invoice_sum":{"type":Config.NUMERIC},"amount_due":{"type":Config.NUMERIC},"amount_received":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"age":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"invoice_id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"retired_date":{"type":Config.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.invoice_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.invoice_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.invoice_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.invoice_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoice\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoice\")"}}},"invoices_payments":{"name":"invoices_payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"payment_id":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"applied_amount":{"type":Config.NUMERIC},"date_applied":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoices_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoices_Payments\")"}}},"item_exchange":{"name":"item_exchange","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"product_item_id":{"type":Config.NUMERIC},"from_status":{"type":Config.NUMERIC},"to_status":{"type":Config.NUMERIC},"from_warehouse_id":{"type":Config.NUMERIC},"to_warehouse_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"date":{"type":Config.DATE},"from_product_id":{"type":Config.NUMERIC},"to_product_id":{"type":Config.NUMERIC},"from_cost":{"type":Config.NUMERIC},"to_cost":{"type":Config.NUMERIC}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"from_warehouse":{"table":"office","pql":"eq(from_warehouse_id,from_warehouse.id)"},"to_warehouse":{"table":"office","pql":"eq(to_warehouse_id,to_warehouse.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Item_Exchange\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Item_Exchange\")"}}},"kit_item":{"name":"kit_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_item_order_kits":{"table":"product_item","pql":"eq(product_item_order_kits.order_kit_id,id)"},"product_item_purchase_kits":{"table":"product_item","pql":"eq(product_item_purchase_kits.purchase_kit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Kit_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Kit_Item\")"}}},"last_modified":{"name":"last_modifieds","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"memute":{"name":"memutes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"module":{"type":Config.STRING},"rule_id":{"type":Config.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Memute\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Memute\")"}}},"note":{"name":"notes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"note":{"type":Config.STRING},"date":{"type":Config.DATE},"public":{"type":Config.BOOLEAN},"module_flags":{"type":Config.NUMERIC},"module_priority":{"type":Config.NUMERIC},"category":{"type":Config.STRING},"code":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"important":{"type":Config.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.note_id,id)"}}},"notes_link":{"name":"notes_link","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"note_id":{"type":Config.NUMERIC},"module":{"type":Config.STRING},"item_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE},"user_id":{"type":Config.NUMERIC},"void":{"type":Config.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"note":{"table":"note","pql":"eq(note_id,note.id)"},"bill":{"table":"$module","pql":"eq(item_id,bill.id)"},"booking":{"table":"$module","pql":"eq(item_id,booking.id)"},"brand":{"table":"$module","pql":"eq(item_id,brand.id)"},"contact":{"table":"$module","pql":"eq(item_id,contact.id)"},"customer":{"table":"$module","pql":"eq(item_id,customer.id)"},"employee":{"table":"$module","pql":"eq(item_id,employee.id)"},"event":{"table":"$module","pql":"eq(item_id,event.id)"},"franchise":{"table":"$module","pql":"eq(item_id,franchise.id)"},"groupping_products":{"table":"$module","pql":"eq(item_id,groupping_products.id)"},"invoice":{"table":"$module","pql":"eq(item_id,invoice.id)"},"invoices_payments":{"table":"$module","pql":"eq(item_id,invoices_payments.id)"},"kit_item":{"table":"$module","pql":"eq(item_id,kit_item.id)"},"memute":{"table":"$module","pql":"eq(item_id,memute.id)"},"message":{"table":"$module","pql":"eq(item_id,message.id)"},"office":{"table":"$module","pql":"eq(item_id,office.id)"},"order":{"table":"$module","pql":"eq(item_id,order.id)"},"order_draft":{"table":"$module","pql":"eq(item_id,order_draft.id)"},"payment":{"table":"$module","pql":"eq(item_id,payment.id)"},"product":{"table":"$module","pql":"eq(item_id,product.id)"},"product_bar_code":{"table":"$module","pql":"eq(item_id,product_bar_code.id)"},"product_item":{"table":"$module","pql":"eq(item_id,product_item.id)"},"product_item_report":{"table":"$module","pql":"eq(item_id,product_item_report.id)"},"product_item_return":{"table":"$module","pql":"eq(item_id,product_item_return.id)"},"product_items_bills":{"table":"$module","pql":"eq(item_id,product_items_bills.id)"},"products_vendors":{"table":"$module","pql":"eq(item_id,products_vendors.id)"},"program":{"table":"$module","pql":"eq(item_id,program.id)"},"programs_customers":{"table":"$module","pql":"eq(item_id,programs_customers.id)"},"promo":{"table":"$module","pql":"eq(item_id,promo.id)"},"promos_franchises":{"table":"$module","pql":"eq(item_id,promos_franchises.id)"},"promos_products":{"table":"$module","pql":"eq(item_id,promos_products.id)"},"purchase":{"table":"$module","pql":"eq(item_id,purchase.id)"},"purchase_tracking":{"table":"$module","pql":"eq(item_id,purchase_tracking.id)"},"purchase_tracking_item":{"table":"$module","pql":"eq(item_id,purchase_tracking_item.id)"},"return_product_due":{"table":"$module","pql":"eq(item_id,return_product_due.id)"},"rule":{"table":"$module","pql":"eq(item_id,rule.id)"},"sales_rep":{"table":"$module","pql":"eq(item_id,sales_rep.id)"},"shipment":{"table":"$module","pql":"eq(item_id,shipment.id)"},"shipment_in":{"table":"$module","pql":"eq(item_id,shipment_in.id)"},"shipment_method":{"table":"$module","pql":"eq(item_id,shipment_method.id)"},"spiff":{"table":"$module","pql":"eq(item_id,spiff.id)"},"spiffs_franchises":{"table":"$module","pql":"eq(item_id,spiffs_franchises.id)"},"spiffs_products":{"table":"$module","pql":"eq(item_id,spiffs_products.id)"},"tax_code":{"table":"$module","pql":"eq(item_id,tax_code.id)"},"term":{"table":"$module","pql":"eq(item_id,term.id)"},"territory":{"table":"$module","pql":"eq(item_id,territory.id)"},"timezone":{"table":"$module","pql":"eq(item_id,timezone.id)"}},"linkFrom":[]},"office":{"name":"offices","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"foreman_id":{"type":Config.NUMERIC},"address1":{"type":Config.STRING},"address2":{"type":Config.STRING},"city":{"type":Config.STRING},"state":{"type":Config.STRING},"zip":{"type":Config.STRING},"country":{"type":Config.STRING},"phone":{"type":Config.STRING},"private_name":{"type":Config.STRING},"is_primary":{"type":Config.BOOLEAN},"open_hours":{"type":Config.STRING},"is_warehouse":{"type":Config.BOOLEAN}},"linkTo":{"foreman":{"table":"user","pql":"eq(foreman_id,foreman.id)"},"user":{"table":"user","pql":"eq(foreman_id,user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.warehouse_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.warehouse_id,id)"},"employees":{"table":"employee","pql":"eq(employees.office_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"order":{"name":"orders","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"lead_user_id":{"type":Config.NUMERIC},"order_step":{"type":Config.NUMERIC},"order_created":{"type":Config.DATE},"order_modified":{"type":Config.DATE},"notes":{"type":Config.STRING},"term_id":{"type":Config.NUMERIC},"po_number":{"type":Config.STRING},"requested_delivery_date":{"type":Config.DATE},"requested_delivery_date_end":{"type":Config.DATE},"ship_on_date":{"type":Config.DATE},"tax_code_id":{"type":Config.NUMERIC},"notes_public":{"type":Config.STRING},"address_error":{"type":Config.BOOLEAN},"legacy_id":{"type":Config.STRING},"shipment_method_id":{"type":Config.NUMERIC},"shipment_addr_hash":{"type":Config.STRING},"ship_phone":{"type":Config.STRING},"ship_email":{"type":Config.STRING},"ship_attn":{"type":Config.STRING},"ship_id":{"type":Config.NUMERIC},"quote_id":{"type":Config.NUMERIC},"currency":{"type":Config.STRING},"billing_id":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"ship_quote_amount":{"type":Config.NUMERIC},"ship_flags":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"bill_override":{"table":"contact","pql":"eq(billing_id,bill_override.id)"},"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"order_draft":{"table":"order_draft","pql":"eq(quote_id,order_draft.id)"}},"linkFrom":{"invoices":{"table":"invoice","pql":"eq(invoices.order_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.order_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.order_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.order_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.order_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.order_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order\")"},"orders_product_items_void":{"table":"orders_product_items_void","pql":"eq(orders_product_items_void.order_id,id)"}}},"order_draft":{"name":"order_drafts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"ship_attn":{"type":Config.STRING},"ship_name":{"type":Config.STRING},"ship_address1":{"type":Config.STRING},"ship_address2":{"type":Config.STRING},"ship_city":{"type":Config.STRING},"ship_state":{"type":Config.STRING},"ship_zip":{"type":Config.STRING},"ship_country":{"type":Config.STRING},"lead_user_id":{"type":Config.NUMERIC},"order_step":{"type":Config.NUMERIC},"draft_created":{"type":Config.DATE},"term_id":{"type":Config.NUMERIC},"po_number":{"type":Config.STRING},"requested_delivery_date":{"type":Config.DATE},"requested_delivery_date_end":{"type":Config.DATE},"ship_on_date":{"type":Config.DATE},"tax_code_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"ship_phone":{"type":Config.STRING},"ship_email":{"type":Config.STRING},"ship_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"currency":{"type":Config.STRING},"billing_id":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC},"ship_flags":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"ship_quote_amount":{"type":Config.NUMERIC},"source":{"type":Config.STRING},"state":{"type":Config.STRING},"reserved_order_id":{"type":Config.NUMERIC},"cart_id":{"type":Config.STRING}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"reserved_order":{"table":"order","pql":"eq(reserved_order_id,reserved_order.id)"}},"linkFrom":{"orders":{"table":"order","pql":"eq(orders.quote_id,id)"},"draft_items":{"table":"draft_item","pql":"eq(draft_items.order_draft_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Draft\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order_Draft\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Draft\")"}}},"order_line":{"name":"order_lines","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_part_num":{"type":Config.STRING},"edi_customer_line_id":{"type":Config.STRING},"edi_entered_price":{"type":Config.NUMERIC},"edi_entered_qty":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.order_line_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.order_line_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.order_line_id,id)"}}},"order_return":{"name":"order_returns","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"date_entered":{"type":Config.DATE},"rma_number":{"type":Config.STRING},"notes":{"type":Config.STRING},"date_returned":{"type":Config.DATE},"payment_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING},"code":{"type":Config.STRING},"replacement_order_id":{"type":Config.NUMERIC},"vendor_rma_number":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"public_note":{"type":Config.STRING}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"replacement_order":{"table":"order","pql":"eq(replacement_order_id,replacement_order.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"shipments_ins":{"table":"shipment_in","pql":"eq(shipments_ins.order_return_id,id)"},"return_product_dues":{"table":"return_product_due","pql":"eq(return_product_dues.order_return_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.return_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Return\")"}}},"orders_product_items_void":{"name":"orders_product_items_void","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"void_sell_price":{"type":Config.NUMERIC},"order_kit_id":{"type":Config.NUMERIC},"date_canceled":{"type":Config.DATE},"moved_from_order_id":{"type":Config.NUMERIC}},"linkTo":{"order":{"table":"order","pql":"eq(order_id,order.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"orig_order":{"table":"order","pql":"eq(moved_from_order_id,orig_order.id)"}},"linkFrom":[]},"package":{"name":"packages","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"track_code":{"type":Config.STRING},"weight":{"type":Config.NUMERIC},"height":{"type":Config.NUMERIC},"width":{"type":Config.NUMERIC},"length":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"last_modified":{"type":Config.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.package_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.package_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.package_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Package\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Package\")"}}},"payment":{"name":"payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"reference_number":{"type":Config.STRING},"date_claimed":{"type":Config.DATE},"date_effective":{"type":Config.DATE},"amount_applied":{"type":Config.NUMERIC},"amount_received":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"payment_type":{"type":Config.STRING},"fee":{"type":Config.NUMERIC},"freight_refunded":{"type":Config.NUMERIC},"misc_refunded":{"type":Config.NUMERIC},"tax_refunded":{"type":Config.NUMERIC},"refunded_date":{"type":Config.DATE},"refunded_amount":{"type":Config.STRING},"refunded_method":{"type":Config.STRING},"refunded_notes":{"type":Config.STRING},"currency":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.payment_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.payment_id,id)"},"order_returns":{"table":"order_return","pql":"eq(order_returns.payment_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.payment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment\")"}}},"payment_gateway":{"name":"payment_gateways","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"class_name":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.payment_gateway_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment_Gateway\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment_Gateway\")"}}},"payment_gateway_request":{"name":"payment_gateway_requests","fields":{"id":{"type":Config.NUMERIC},"request_type":{"type":Config.STRING},"gateway_account_id":{"type":Config.NUMERIC},"reference":{"type":Config.STRING},"confirmation_num":{"type":Config.STRING},"payment_id":{"type":Config.NUMERIC},"amount":{"type":Config.NUMERIC},"request_date":{"type":Config.DATE},"request_by":{"type":Config.NUMERIC},"approved":{"type":Config.BOOLEAN},"deny_reason":{"type":Config.STRING},"full_request":{"type":Config.STRING},"full_response":{"type":Config.STRING},"deleted":{"type":Config.BOOLEAN}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"request_user":{"table":"user","pql":"eq(request_by,request_user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"product":{"name":"products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"date_created":{"type":Config.DATE},"description":{"type":Config.STRING},"item_code":{"type":Config.STRING},"brand_id":{"type":Config.NUMERIC},"category_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"weight":{"type":Config.NUMERIC},"dimension_h":{"type":Config.NUMERIC},"dimension_w":{"type":Config.NUMERIC},"dimension_l":{"type":Config.NUMERIC},"list_price":{"type":Config.NUMERIC},"map_price":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"vendor_part_number":{"type":Config.STRING},"primary_vendor_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"taxable":{"type":Config.BOOLEAN},"freight_only":{"type":Config.BOOLEAN},"upc_code":{"type":Config.STRING},"replacement_id":{"type":Config.NUMERIC},"bin_location":{"type":Config.STRING},"has_internal_serial":{"type":Config.BOOLEAN},"has_external_serial":{"type":Config.BOOLEAN},"ht_code":{"type":Config.STRING},"date_discontinued":{"type":Config.DATE},"master_pack_qty":{"type":Config.NUMERIC},"automation_flags":{"type":Config.NUMERIC},"primary_warehouse_id":{"type":Config.NUMERIC},"date_changed":{"type":Config.DATE},"default_stock_type":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"primary_vendor":{"table":"vendor","pql":"eq(primary_vendor_id,primary_vendor.id)"},"replacement":{"table":"product","pql":"eq(replacement_id,replacement.id)"},"primary_warehouse":{"table":"office","pql":"eq(primary_warehouse_id,primary_warehouse.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.product_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.product_id,id)"},"children":{"table":"groupping_products","pql":"eq(children.child_id,id)"},"parent":{"table":"groupping_products","pql":"eq(parent.parent_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.product_id,id)"},"product_bar_codes":{"table":"product_bar_code","pql":"eq(product_bar_codes.product_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product\")"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.product_id,id)"}}},"product_bar_code":{"name":"product_bar_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"bar_code":{"type":Config.STRING},"product_id":{"type":Config.NUMERIC},"type":{"type":Config.STRING}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Bar_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Bar_Code\")"}}},"product_item":{"name":"product_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"serial_number":{"type":Config.STRING},"warehouse_id":{"type":Config.NUMERIC},"warehouse_location":{"type":Config.STRING},"date_received":{"type":Config.DATE},"date_shipped":{"type":Config.DATE},"status":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"item_cost":{"type":Config.NUMERIC},"roi_cost":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"tax_amount":{"type":Config.NUMERIC},"temp_cust_id":{"type":Config.STRING},"shipment_in_id":{"type":Config.NUMERIC},"vendor_serial":{"type":Config.STRING},"override_date":{"type":Config.DATE},"order_kit_id":{"type":Config.NUMERIC},"purchase_kit_id":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"has_changed":{"type":Config.BOOLEAN},"order_warehouse_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING},"order_line_id":{"type":Config.NUMERIC},"purchase_tracking_item_id":{"type":Config.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.product_item_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.product_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_report":{"name":"product_items_reports","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"serial_number":{"type":Config.STRING},"warehouse_id":{"type":Config.NUMERIC},"warehouse_location":{"type":Config.STRING},"date_received":{"type":Config.DATE},"date_shipped":{"type":Config.DATE},"status":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"item_cost":{"type":Config.NUMERIC},"roi_cost":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sort_order":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"tax_amount":{"type":Config.NUMERIC},"temp_cust_id":{"type":Config.STRING},"shipment_in_id":{"type":Config.NUMERIC},"vendor_serial":{"type":Config.STRING},"return_id":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"order_kit_id":{"type":Config.NUMERIC},"purchase_kit_id":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"has_changed":{"type":Config.BOOLEAN},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC},"source":{"type":Config.STRING},"stock_type":{"type":Config.STRING},"purchase_tracking_item_id":{"type":Config.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,product_item_id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,product_item_id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_return":{"name":"product_items_returns","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"product_item_id":{"type":Config.NUMERIC},"return_id":{"type":Config.NUMERIC},"return_sell_price":{"type":Config.NUMERIC},"restock_fee":{"type":Config.NUMERIC},"invoice_id":{"type":Config.NUMERIC},"shipment_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"status":{"type":Config.NUMERIC},"date_shipped":{"type":Config.DATE},"date_return_received":{"type":Config.DATE},"sort_order":{"type":Config.NUMERIC},"sales_rep_id":{"type":Config.NUMERIC},"sell_price":{"type":Config.NUMERIC},"tax_amount":{"type":Config.NUMERIC},"shipment_in_id":{"type":Config.NUMERIC},"override_date":{"type":Config.DATE},"discount":{"type":Config.NUMERIC},"starin_promo_id":{"type":Config.NUMERIC},"vendor_promo_id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"program_id":{"type":Config.NUMERIC},"package_id":{"type":Config.NUMERIC},"order_kit_id":{"type":Config.NUMERIC},"order_warehouse_id":{"type":Config.NUMERIC},"order_line_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"order_return":{"table":"order_return","pql":"eq(return_id,order_return.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"sales_rep":{"table":"user","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Return\")"}}},"product_items_bills":{"name":"product_items_bills","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"bill_id":{"type":Config.NUMERIC},"item_cost":{"type":Config.NUMERIC}},"linkTo":{"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Bills\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Bills\")"}}},"products_vendors":{"name":"products_vendors","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"cost":{"type":Config.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Vendors\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Vendors\")"}}},"program":{"name":"programs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"brand_id":{"type":Config.NUMERIC},"rule_id":{"type":Config.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.program_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.program_id,id)"},"product_item_returns":{"table":"product_item_returns","pql":"eq(product_item_returns.program_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Program\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Program\")"}}},"programs_customers":{"name":"programs_customers","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"program_id":{"type":Config.STRING},"customer_id":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"parameters":{"type":Config.STRING}},"linkTo":{"program":{"table":"program","pql":"eq(program_id,program.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Programs_Customers\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Programs_Customers\")"}}},"promo":{"name":"promos","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"type":{"type":Config.STRING},"rule_id":{"type":Config.NUMERIC},"brand_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"promo_code":{"type":Config.STRING},"before_order_rule_id":{"type":Config.NUMERIC},"after_invoice_rule_id":{"type":Config.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"},"brand_id":{"table":"brand","pql":"eq(brand_id,brand_id.id)"}},"linkFrom":{"product_item_starin_promos":{"table":"product_item","pql":"eq(product_item_starin_promos.starin_promo_id,id)"},"product_item_vendor_promos":{"table":"product_item","pql":"eq(product_item_vendor_promos.vendor_promo_id,id)"},"product_item_return_starin_promos":{"table":"product_item_return","pql":"eq(product_item_return_starin_promos.starin_promo_id,id)"},"product_item_return_vendor_promos":{"table":"product_item_return","pql":"eq(product_item_return_vendor_promos.vendor_promo_id,id)"},"product_item_report_starin_promos":{"table":"product_item_report","pql":"eq(product_item_report_starin_promos.starin_promo_id,id)"},"product_item_report_vendor_promos":{"table":"product_item_report","pql":"eq(product_item_report_vendor_promos.vendor_promo_id,id)"},"promos_franchises":{"table":"promos_franchises","pql":"eq(promos_franchises.promo_id,id)"},"promos_products":{"table":"promos_products","pql":"eq(promos_products.promo_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promo\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promo\")"}}},"promos_franchises":{"name":"promos_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"promo_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Franchises\")"}}},"promos_products":{"name":"promos_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"promo_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"description":{"type":Config.STRING}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Products\")"}}},"purchase":{"name":"purchases","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"vendor_id":{"type":Config.NUMERIC},"date_ordered":{"type":Config.DATE},"notes":{"type":Config.STRING},"status":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"assigned_user_id":{"type":Config.NUMERIC},"sub_total":{"type":Config.NUMERIC},"tax":{"type":Config.NUMERIC},"freight":{"type":Config.NUMERIC},"misc":{"type":Config.NUMERIC},"total":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"order_id":{"type":Config.NUMERIC},"notes_public":{"type":Config.STRING},"ship_account_num":{"type":Config.STRING},"est_received_date":{"type":Config.DATE},"vendor_order_number":{"type":Config.STRING}},"linkTo":{"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_id,id)"},"bills":{"table":"bill","pql":"eq(bills.purchase_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Purchase\")"}}},"purchase_tracking":{"name":"purchase_tracking","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"purchase_id":{"type":Config.NUMERIC},"estimated_receive_date":{"type":Config.DATE},"tracking_number":{"type":Config.STRING},"shipment_method_id":{"type":Config.NUMERIC},"last_updated":{"type":Config.DATE},"variance":{"type":Config.NUMERIC},"note":{"type":Config.STRING},"ref_number":{"type":Config.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"purchase_tracking_items":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_items.purchase_tracking_id,id)"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"PURCHASE_TRACKING\")"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking\")"}}},"purchase_tracking_item":{"name":"purchase_tracking_items","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"purchase_tracking_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"stock_type":{"type":Config.STRING},"qty":{"type":Config.NUMERIC},"qty_received":{"type":Config.NUMERIC}},"linkTo":{"purchase_tracking":{"table":"purchase_tracking","pql":"eq(purchase_tracking_id,purchase_tracking.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_tracking_item_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_tracking_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking_Item\")"}}},"remit":{"name":"remits","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"paid":{"type":Config.BOOLEAN},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"amount_due":{"type":Config.NUMERIC},"gateway_account_id":{"type":Config.NUMERIC}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"}},"linkFrom":{"shipments":{"table":"shipment","pql":"eq(shipments.remit_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.remit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remit\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remit\")"}}},"remits_payments":{"name":"remits_payments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"remit_id":{"type":Config.NUMERIC},"payment_id":{"type":Config.NUMERIC},"amount":{"type":Config.NUMERIC},"date_applied":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remits_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remits_Payments\")"}}},"return_product_due":{"name":"return_product_due","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"product_item_id":{"type":Config.NUMERIC},"order_return_id":{"type":Config.NUMERIC}},"linkTo":{"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":[]},"rule":{"name":"rules","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"code":{"type":Config.STRING},"file":{"type":Config.STRING}},"linkTo":[],"linkFrom":[]},"sales_rep":{"name":"sales_reps","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"contact_id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"assigned_user_id":{"type":Config.NUMERIC},"is_distributor":{"type":Config.BOOLEAN},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.sales_rep_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Sales_Rep\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Sales_Rep\")"}}},"shipment":{"name":"shipments","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"track_code":{"type":Config.STRING},"notes":{"type":Config.STRING},"actual_cost":{"type":Config.NUMERIC},"ship_date":{"type":Config.DATE},"date_due":{"type":Config.DATE},"shipment_fee":{"type":Config.NUMERIC},"handling_fee":{"type":Config.NUMERIC},"flags":{"type":Config.NUMERIC},"shipment_addr_hash":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"bill_id":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"backorder_hash":{"type":Config.STRING},"remit_id":{"type":Config.NUMERIC},"discount_amount":{"type":Config.NUMERIC},"shipment_account_id":{"type":Config.NUMERIC},"shipment_flags":{"type":Config.NUMERIC}},"linkTo":{"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.shipment_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.shipment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment\")"},"invoices":{"table":"invoice","pql":"eq(invoices.shipment_id,id)"}}},"shipment_account":{"name":"shipment_accounts","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"customer_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC},"ship_account_num":{"type":Config.STRING},"third_party_contact_id":{"type":Config.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"third_party_contact":{"table":"contact","pql":"eq(third_party_contact_id,third_party_contact.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Account\")"}}},"shipment_in":{"name":"shipments_in","fields":{"id":{"type":Config.NUMERIC},"deleted":{"type":Config.BOOLEAN},"date_entered":{"type":Config.DATE},"purchase_id":{"type":Config.NUMERIC},"order_return_id":{"type":Config.NUMERIC},"notes":{"type":Config.STRING},"track_code":{"type":Config.STRING},"office_id":{"type":Config.NUMERIC},"shipment_method_id":{"type":Config.NUMERIC}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_in_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_In\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_In\")"}}},"shipment_method":{"name":"shipment_methods","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"customer_id":{"type":Config.NUMERIC},"prepaid":{"type":Config.BOOLEAN},"carrier_code":{"type":Config.STRING},"carrier":{"type":Config.STRING},"parent_shipment_method_id":{"type":Config.NUMERIC},"carrier_id":{"type":Config.NUMERIC},"transportaion_method_code":{"type":Config.STRING},"is_freight":{"type":Config.BOOLEAN},"time_in_transit":{"type":Config.NUMERIC},"service_level_code":{"type":Config.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"parent_shipment_method":{"table":"shipment_method","pql":"eq(parent_shipment_method_id,parent_shipment_method.id)"},"scac":{"table":"carrier","pql":"eq(carrier_id,scac.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.shipment_method_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.shipment_method_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Method\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Method\")"},"child_shipment_methods":{"table":"shipment_method","pql":"eq(child_shipment_methods.parent_shipment_method_id,id)"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.shipment_method_id,id)"}}},"spiff":{"name":"spiffs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"start_date":{"type":Config.DATE},"end_date":{"type":Config.DATE},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE},"notes":{"type":Config.STRING},"max":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"spiffs_franchises":{"table":"spiffs_franchises","pql":"eq(spiffs_franchises.spiff_id,id)"},"spiffs_products":{"table":"spiffs_products","pql":"eq(spiffs_products.spiff_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.spiff_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.spiff_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.spiff_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff\")"}}},"spiffs_franchises":{"name":"spiffs_franchises","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"franchise_id":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff_Franchises\")"}}},"spiffs_products":{"name":"spiffs_products","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"spiff_id":{"type":Config.NUMERIC},"product_id":{"type":Config.NUMERIC},"qty":{"type":Config.NUMERIC},"date_created":{"type":Config.DATE},"date_voided":{"type":Config.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiffs_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiffs_Products\")"}}},"tax_code":{"name":"tax_codes","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"percentage":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"shipment_tax":{"type":Config.NUMERIC}},"linkTo":[],"linkFrom":{"orders":{"table":"order","pql":"eq(orders.tax_code_id,id)"},"customers":{"table":"customer","pql":"eq(customers.tax_code_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Tax_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Tax_Code\")"}}},"term":{"name":"terms","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"due_days":{"type":Config.NUMERIC},"discount":{"type":Config.NUMERIC},"discount_days":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"order_override_flags":{"type":Config.NUMERIC},"classification":{"type":Config.STRING},"grace_days":{"type":Config.NUMERIC},"edi_term_code_id":{"type":Config.NUMERIC}},"linkTo":{"edi_term_code":{"table":"edi_term_code","pql":"eq(edi_term_code_id,edi_term_code.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.term_id,id)"},"bills":{"table":"bill","pql":"eq(bills.term_id,id)"},"customers":{"table":"customer","pql":"eq(customers.term_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.term_id,id)"},"orders":{"table":"order","pql":"eq(orders.term_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Term\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Term\")"}}},"territory":{"name":"territories","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"legacy_id":{"type":Config.STRING},"country":{"type":Config.STRING},"region":{"type":Config.STRING},"state_province":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"customers":{"table":"customer","pql":"eq(customers.territory_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Territory\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Territory\")"}}},"timezone":{"name":"timezones","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"utc":{"type":Config.STRING},"dst":{"type":Config.STRING}},"linkTo":[],"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.timezone_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Timezone\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Timezone\")"}}},"user":{"name":"users_view","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"username":{"type":Config.STRING},"password":{"type":Config.STRING},"can_login":{"type":Config.BOOLEAN},"employee_id":{"type":Config.NUMERIC},"contact_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"wh_scan":{"type":Config.STRING}},"linkTo":{"employee":{"table":"employee","pql":"eq(employee_id,employee.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":{"user_historys":{"table":"user_history","pql":"eq(user_historys.user_id,id)"},"voided_gateway_requests":{"table":"payment_gateway_request","pql":"eq(voided_gateway_requests.void_by,id)"},"approved_gateway_requests":{"table":"payment_gateway_request","pql":"eq(approved_gateway_requests.approved_by,id)"},"requested_gateway_requests":{"table":"payment_gateway_request","pql":"eq(requested_gateway_requests.request_by,id)"},"offices":{"table":"office","pql":"eq(offices.foreman_id,id)"},"customers":{"table":"customer","pql":"eq(customers.primary_rep_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.assigned_user_id,id)"},"orders":{"table":"order","pql":"eq(orders.assigned_user_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.user_id,id)"},"assigned_sales_reps":{"table":"sales_rep","pql":"eq(assigned_sales_reps.assigned_user_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"User\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"User\")"}}},"user_history":{"name":"user_historys","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"method":{"type":Config.STRING},"args":{"type":Config.STRING},"window_id":{"type":Config.NUMERIC},"date":{"type":Config.DATE}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"vendor":{"name":"vendors","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"name":{"type":Config.STRING},"notes":{"type":Config.STRING},"primary_contact_id":{"type":Config.NUMERIC},"term_id":{"type":Config.NUMERIC},"legacy_id":{"type":Config.STRING},"temp_mybooks_id":{"type":Config.STRING},"our_account_number":{"type":Config.STRING},"default_shipment_method_id":{"type":Config.NUMERIC},"default_office_id":{"type":Config.NUMERIC}},"linkTo":{"term":{"table":"term","pql":"eq(term_id,term.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"default_shipment_method":{"table":"shipment_method","pql":"eq(default_shipment_method_id,default_shipment_method.id)"},"default_office":{"table":"office","pql":"eq(default_office_id,default_office.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.vendor_id,id)"},"contacts":{"table":"contact","pql":"eq(contacts.vendor_id,id)"},"primary_products":{"table":"product","pql":"eq(primary_products.vendor_id,id)"},"bills":{"table":"bill","pql":"eq(bills.vendor_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.vendor_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Vendor\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Vendor\")"}}},"watch":{"name":"watchs","fields":{"deleted":{"type":Config.BOOLEAN},"id":{"type":Config.NUMERIC},"user_id":{"type":Config.NUMERIC},"record_id":{"type":Config.NUMERIC},"created":{"type":Config.DATE},"note":{"type":Config.STRING},"memute_id":{"type":Config.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"memute":{"table":"memute","pql":"eq(memute_id,memute.id)"}},"linkFrom":[]}};Config.FUNCTION_MAP = {eq:{description:'Compares two values',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsEqualJs.EQUAL(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},gt:{description:'Checks if first value is greater than second',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsGreater_thanJs.GREATER_THAN(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},lt:{description:'Checks if first value is less than second',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsLess_thanJs.LESS_THAN(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},ne:{description:'Checks if values are not equal',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsNot_equalJs.NOT_EQUAL(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},like:{description:'Checks if first value is like second. % sign is wild card character',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsLikeJs.LIKE(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},not_like:{description:'Checks if first value is not like second. % sign is wild card character',min_args:2,max_args:2,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsNot_likeJs.NOT_LIKE(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},'in':{description:'Checks if first value is any of the following values',min_args:2,max_args:Infinity,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var out_args=[];var obj=new _opcodesComparitorsEqualJs.EQUAL(pql);orig_args.splice(1).forEach(function(v){out_args.push(v);});obj.setLeft(orig_args[0]);obj.setRight(new _opcodesConstants_arrayJs.CONSTANTS_ARRAY(pql,out_args));return obj.getSQL(query_obj);}},not_in:{description:'Checks if first value is not any of the following values',min_args:2,max_args:Infinity,return_type:Config.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var out_args=[];var obj=new _opcodesComparitorsNot_equalJs.NOT_EQUAL(pql);orig_args.splice(1).forEach(function(v){out_args.push(v);});obj.setLeft(orig_args[0]);obj.setRight(new _opcodesConstants_arrayJs.CONSTANTS_ARRAY(pql,out_args));return obj.getSQL(query_obj);}},'if':{description:'If first argument is truethy returns second argument otherwise returns third',min_args:3,max_args:3,return_type:Config.ANY,format:['IF(',Config.ALL_ARGS,')']}, /* Math functions */add:{description:'Adds values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' + ');}},sub:{description:'Subtracts values from eachother',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' - ');}},mul:{description:'Multiplies values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' * ');}},div:{description:'Divide values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' / ');}},mod:{description:'Modulus values together',min_args:2,max_args:2,return_type:Config.NUMBER,format:['MOD(',Config.ARG1,', ',Config.ARG2,')']},pow:{description:'Powers values together',min_args:2,max_args:2,return_type:Config.NUMBER,format:['POW(',Config.ARG1,', ',Config.ARG2,')']},sqrt:{description:'Square roots a value',min_args:1,max_args:1,return_type:Config.NUMBER,format:['SQRT(',Config.ARG1,')']}, /* Standard SQL functions */abs:{description:'Gets absolute value',min_args:1,max_args:1,arg_types:[Config.NUMERIC],return_type:Config.NUMERIC,format:['ABS(',Config.ARG1,')']},'char':{description:'Gets character from numerical ascii character',min_args:1,max_args:Infinity,arg_types:[Config.NUMERIC],return_type:Config.STRING,format:['CHAR(',Config.ALL_ARGS,')']},coalesce:{description:'Returns first non-null value from arguments',min_args:1,max_args:Infinity,return_type:Config.ANY_TYPE,format:['COALESCE(',Config.ALL_ARGS,')']},ifnull:{description:'Returns first argument if not null otherwise returns second argument',min_args:2,max_args:2,return_type:Config.ANY_TYPE,format:['IFNULL(',Config.ARG1,', ',Config.ARG2,')']},instr:{description:'Gets character position of argument two in argument one\'s string',min_args:2,max_args:2,return_type:Config.NUMERIC,arg_types:[Config.STRING,Config.STRING],format:['INSTR(',Config.ARG1,', ',Config.ARG2,')']},hex:{description:'Returns hex value of argument',min_args:1,max_args:1,return_type:Config.STRING,format:['HEX(',Config.ARG1,')']},length:{description:'Returns the string length',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.NUMERIC,format:['LENGTH(',Config.ARG1,')']},lower:{description:'Returns string converted to lower case',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['LOWER(',Config.ARG1,')']},ltrim:{description:'Returns left-trimmed string',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['LTRIM(',Config.ARG1,')']},nullif:{description:'Returns null if argument one equals argument two',min_args:2,max_args:2,return_type:Config.ANY_TYPE,format:['NULLIF(',Config.ARG1,', ',Config.ARG2,')']},random:{description:'Returns random number (platform dependent)',min_args:0,max_args:0,return_type:Config.NUMERIC,format:['RANDOM()']},replace:{description:'Searches for argument two and replaces matches with argument three in argument one',min_args:3,max_args:3,arg_types:[Config.STRING,Config.STRING,Config.STRING],return_type:Config.STRING,format:['REPLACE(',Config.ARG1,', ',Config.ARG2,', ',Config.ARG3,')']},round:{description:'Returns rounded value of argument one with decimal percision of argument two',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.NUMERIC],return_type:Config.NUMERIC,format:['ROUND(',Config.ALL_ARGS,')']},rtrim:{description:'Returns right-trimmed value',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['RTRIM(',Config.ARG1,')']},substr:{description:'Returns part of argument one string from argument two position with length of argument three',min_args:2,max_args:3,arg_types:[Config.STRING,Config.NUMERIC,Config.NUMERIC],return_type:Config.STRING,format:['SUBSTR(',Config.ALL_ARGS,')']},trim:{description:'Returns full trimmed string',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['TRIM(',Config.ARG1,')']},upper:{description:'Returns value converted to upper case',min_args:1,max_args:1,arg_types:[Config.STRING],return_type:Config.STRING,format:['UPPER(',Config.ARG1,')']},concat:{description:'Returns multiple strings joined together',min_args:1,max_args:Infinity,arg_types:[Config.STRING],return_type:Config.STRING,format:['CONCAT(',Config.ALL_ARGS,')']}, /* Date Functions */date_format:{description:'Returns date converted converted using format of argument two',min_args:2,max_args:2,arg_types:[Config.DATE,Config.STRING],return_type:Config.STRING,format:['DATE_FORMAT(',Config.ARG1,', ',Config.ARG2,')']},date:{description:'Returns date porition of argument one',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.DATE,format:['DATE(',Config.ARG1,')']},day:{description:'Returns day number of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['DAY(',Config.ARG1,')']},from_unixtime:{description:'Returns date type from unix timestamp',min_args:1,max_args:1,arg_types:[Config.NUMERIC],return_type:Config.DATE,format:['FROM_UNIXTIME(',Config.ARG1,')']},hour:{description:'Returns hour portion of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['HOUR(',Config.ARG1,')']},minute:{description:'Returns minute porition of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['MINUTE(',Config.ARG1,')']},month:{description:'Returns month number porition of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['MONTH(',Config.ARG1,')']},now:{description:'Returns current time/date',min_args:0,max_args:0,return_type:Config.DATE,format:['NOW()']},second:{description:'Returns second porition of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['SECOND(',Config.ARG1,')']},time:{description:'Returns time porition of date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.STRING,format:['TIME(',Config.ARG1,')']},unix_timestamp:{description:'Returns unix timestamp from date',min_args:0,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['UNIX_TIMESTAMP(',Config.ARG1,')']},year:{description:'Returns year porition from date',min_args:1,max_args:1,arg_types:[Config.DATE],return_type:Config.NUMERIC,format:['YEAR(',Config.ARG1,')']}, /* Aggregate functions */avg:{description:'Returns average value',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['AVG(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "AVG(DISTINCT " + args[0];}return "AVG(" + args[0];}]}},count:{description:'Returns count of items',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['COUNT(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "COUNT(DISTINCT " + args[0];}return "COUNT(" + args[0];}]}}, // group_concat(expr[,distinct[,seperator[,order_by_expression,order_by_direction ...]]]); -group_concat:{description:'Returns the group concatinated string',min_args:1,max_args:Infinity,arg_types:[Config.STRING,Config.BOOLEAN,Config.STRING,Config.STRING,Config.STRING],return_type:Config.STRING,is_group_function:true,format:function format(args,orig_args){var distinct=orig_args.length >= 2 && Boolean(Number(orig_args[1].getValue()))?'DISTINCT ':'';var seperator='';if(orig_args.length >= 3){if(!orig_args[2].isConstant() && !orig_args[2].isInstanceOf(_opcodesNullJs.NULL)){throw "Third argument of \"group_concat\" function must be a constant type";}if(!orig_args[2].isInstanceOf(_opcodesNullJs.NULL)){seperator = " SEPARATOR " + args[2];}}var order_bys=new Set();if(orig_args.length > 3){ // Check to make sure there are always pairs of order_by_expression and order_by_direction -if(orig_args.length % 2 == 0){throw "GROUP_CONCAT function must have order_by_expression and order_by_direction in pairs";} // Inc in order of 2's -for(var i=3;i < args.length;i = i + 2) {var dir='ASC';if(orig_args[i + 1].isConstant()){dir = orig_args[i + 1].getValue().toString().toLowerCase() == 'desc'?'DESC':'ASC';}order_bys.add(args[i] + " " + dir);}}var order_by=undefined;if(order_bys.size){order_by = " ORDER BY " + Array.from(order_bys).join(',');}else {order_by = '';}return "GROUP_CONCAT(" + distinct + args[0] + order_by + seperator + ")";}},max:{description:'Returns maximum value',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['MAX(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "MAX(DISTINCT " + args[0];}return "MAX(" + args[0];}]}},min:{description:'Returns minimum value',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['MIN(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "MIN(DISTINCT " + args[0];}return "MIN(" + args[0];}]}},sum:{description:'Returns sum of values',min_args:1,max_args:2,arg_types:[Config.NUMERIC,Config.BOOLEAN],return_type:Config.NUMERIC,is_group_function:true,format:{1:['SUM(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return "SUM(DISTINCT " + args[0];}return "SUM(" + args[0];}]}},having:{description:'Forces item into having statment',min_args:1,max_args:1,return_type:Config.ANY,is_group_function:true,format:[Config.ARG1]}};Config.COMPARITORS = new Set([_opcodesComparitorsEqualJs.EQUAL,_opcodesComparitorsGreater_thanJs.GREATER_THAN,_opcodesComparitorsLess_thanJs.LESS_THAN,_opcodesComparitorsLikeJs.LIKE,_opcodesComparitorsNo_valueJs.NO_VALUE,_opcodesComparitorsNot_equalJs.NOT_EQUAL,_opcodesComparitorsNot_likeJs.NOT_LIKE]); \ No newline at end of file +'use strict';Object.defineProperty(exports,'__esModule',{value:true});var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if('value' in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError('Cannot call a class as a function');}}var _data_typesJs=require('./data_types.js');var _opcodesComparitorsEqualJs=require('./opcodes/comparitors/equal.js');var _opcodesComparitorsGreater_thanJs=require('./opcodes/comparitors/greater_than.js');var _opcodesComparitorsLess_thanJs=require('./opcodes/comparitors/less_than.js');var _opcodesComparitorsLikeJs=require('./opcodes/comparitors/like.js');var _opcodesComparitorsNo_valueJs=require('./opcodes/comparitors/no_value.js');var _opcodesComparitorsNot_equalJs=require('./opcodes/comparitors/not_equal.js');var _opcodesComparitorsNot_likeJs=require('./opcodes/comparitors/not_like.js');var _opcodesConstants_arrayJs=require('./opcodes/constants_array.js');var _opcodesNullJs=require('./opcodes/null.js');var Config=(function(){function Config(){_classCallCheck(this,Config);} /* These are to make it easier to read the code for the function definitions */_createClass(Config,null,[{key:'ALL_ARGS',value:function ALL_ARGS(args){return args.join(', ');}}]);return Config;})();exports.Config = Config;Config.ARG1 = 0;Config.ARG2 = 1;Config.ARG3 = 2;Config.ARG4 = 3;Config.ARG5 = 4;Config.ARG6 = 5;Config.ARG7 = 6;Config.ARG8 = 7;Config.DB_MAP = {"bill":{"name":"bills","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"invoice_number":{"type":_data_typesJs.DATA_TYPES.STRING},"purchase_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"invoice_date":{"type":_data_typesJs.DATA_TYPES.DATE},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"payment_status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"term_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"due_date":{"type":_data_typesJs.DATA_TYPES.DATE},"accounting_system_id":{"type":_data_typesJs.DATA_TYPES.STRING},"vendor_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"effective_date":{"type":_data_typesJs.DATA_TYPES.DATE},"invoice_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipping_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"discount_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"tax_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"date_closed":{"type":_data_typesJs.DATA_TYPES.DATE},"currency":{"type":_data_typesJs.DATA_TYPES.STRING},"type":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"}},"linkFrom":{"shipment":{"table":"shipment","pql":"eq(shipment.bill_id,id)"},"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.bill_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Bill\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Bill\")"}}},"booking":{"name":"bookings","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_attn":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_name":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_address1":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_address2":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_city":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_state":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_zip":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_country":{"type":_data_typesJs.DATA_TYPES.STRING},"brand_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date":{"type":_data_typesJs.DATA_TYPES.DATE},"customer_po":{"type":_data_typesJs.DATA_TYPES.STRING},"sales_rep_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"total":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Booking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Booking\")"}}},"brand":{"name":"brands","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"primary_contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"brand_names":{"type":_data_typesJs.DATA_TYPES.STRING},"parent_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"active":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"website":{"type":_data_typesJs.DATA_TYPES.STRING},"temp_mybooks_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"warehouse_use_vendor_num":{"type":_data_typesJs.DATA_TYPES.BOOLEAN}},"linkTo":{"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"parent":{"table":"brand","pql":"eq(parent_id,parent.id)"}},"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.brand_id,id)"},"products":{"table":"product","pql":"eq(products.brand_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Brand\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Brand\")"}}},"carrier":{"name":"carriers","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"scac_code":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"shipment_methods":{"table":"shipment_method","pql":"eq(shipment_methods.carrier_id,id)"}}},"contact":{"name":"contacts","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"last_name":{"type":_data_typesJs.DATA_TYPES.STRING},"address1":{"type":_data_typesJs.DATA_TYPES.STRING},"address2":{"type":_data_typesJs.DATA_TYPES.STRING},"city":{"type":_data_typesJs.DATA_TYPES.STRING},"state":{"type":_data_typesJs.DATA_TYPES.STRING},"zip":{"type":_data_typesJs.DATA_TYPES.STRING},"country":{"type":_data_typesJs.DATA_TYPES.STRING},"email":{"type":_data_typesJs.DATA_TYPES.STRING},"phone":{"type":_data_typesJs.DATA_TYPES.STRING},"timezone_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"contact_hours":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"fax":{"type":_data_typesJs.DATA_TYPES.STRING},"alt_phone":{"type":_data_typesJs.DATA_TYPES.STRING},"fax_optout":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"email_optout":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"postal_optout":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"brand_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"parent_contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"timezone":{"table":"timezone","pql":"eq(timezone_id,timezone.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"parent_contact":{"table":"contact","pql":"eq(parent_contact_id,parent_contact.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.billing_contact_id,id)"},"customers_shipping":{"table":"customer","pql":"eq(customers_shipping.primary_shipping_contact_id,id)"},"customers_billing":{"table":"customer","pql":"eq(customers_billing.primary_billing_contact_id,id)"},"customers_primary":{"table":"customer","pql":"eq(customers_primary.primary_contact_id,id)"},"users":{"table":"user","pql":"eq(users.contact_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.contact_id,id)"},"brands":{"table":"brand","pql":"eq(brands.contact_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.primary_contact_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.contact_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Contact\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Contact\")"}}},"control_flag":{"name":"control_flags","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"control_key_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"value":{"type":_data_typesJs.DATA_TYPES.STRING},"module":{"type":_data_typesJs.DATA_TYPES.STRING},"item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"control_key":{"table":"control_key","pql":"eq(control_key_id,control_key.id)"}},"linkFrom":[]},"control_key":{"name":"control_keys","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"key":{"type":_data_typesJs.DATA_TYPES.STRING},"module_flags":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":[],"linkFrom":{"control_flags":{"table":"control_flag","pql":"eq(control_flags.control_key_id,id)"}}},"customer":{"name":"customers","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"primary_rep_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"current_credit":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"max_credit_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"primary_contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"primary_billing_contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"primary_shipping_contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"website":{"type":_data_typesJs.DATA_TYPES.STRING},"term_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"resale_tax_number":{"type":_data_typesJs.DATA_TYPES.STRING},"territory_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"federal_id":{"type":_data_typesJs.DATA_TYPES.STRING},"dunns":{"type":_data_typesJs.DATA_TYPES.STRING},"tax_code_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"temp_mybooks_id":{"type":_data_typesJs.DATA_TYPES.STRING},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"parent_customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"unpaid_invoice_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"primary_shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"primary_shipment_account_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"rep":{"table":"user","pql":"eq(primary_rep_id,rep.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"billing_contact":{"table":"contact","pql":"eq(primary_billing_contact_id,billing_contact.id)"},"shipping_contact":{"table":"contact","pql":"eq(primary_shipping_contact_id,shipping_contact.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"territory":{"table":"territory","pql":"eq(territory_id,territory.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"parent_customer":{"table":"customer","pql":"eq(parent_customer_id,parent_customer.id)"},"primary_shipment_method":{"table":"shipment_method","pql":"eq(primary_shipment_method_id,primary_shipment_method.id)"},"primary_shipment_account":{"table":"shipment_account","pql":"eq(primary_shipment_account_id,primary_shipment_account.id)"}},"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.customer_id,id)"},"payments":{"table":"payment","pql":"eq(payments.customer_id,id)"},"invoices":{"table":"invoice","pql":"eq(invoices.customer_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.customer_id,id)"},"orders":{"table":"order","pql":"eq(orders.customer_id,id)"},"child_customers":{"table":"customer","pql":"eq(child_customers.parent_customer_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer\")"},"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.customer_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer\")"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.customer_id,id)"},"customer_notifications":{"table":"customers_notifications","pql":"eq(customer_notifications.customer_id,id)"}}},"customer_franchises":{"name":"customer_franchises","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"franchise_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE},"dont_purge":{"type":_data_typesJs.DATA_TYPES.BOOLEAN}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customer_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customer_Franchises\")"}}},"customers_notifications":{"name":"customers_notifications","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"type":{"type":_data_typesJs.DATA_TYPES.STRING},"contact_method":{"type":_data_typesJs.DATA_TYPES.STRING},"contact_data":{"type":_data_typesJs.DATA_TYPES.STRING},"contact_name":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Customers_Notifications\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Customers_Notifications\")"}}},"cycle_count":{"name":"cycle_counts","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_completed":{"type":_data_typesJs.DATA_TYPES.DATE},"active":{"type":_data_typesJs.DATA_TYPES.BOOLEAN}},"linkTo":[],"linkFrom":[]},"draft_item":{"name":"draft_items","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_draft_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"qty":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sell_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"discount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sort_order":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"starin_promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"spiff_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"program_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_line_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"order_draft":{"table":"order_draft","pql":"eq(order_draft_id,order_draft.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Draft_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Draft_Item\")"}}},"edi_term_code":{"name":"edi_term_codes","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"term_code":{"type":_data_typesJs.DATA_TYPES.STRING},"description":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"terms":{"table":"term","pql":"eq(terms.edi_term_code_id,id)"}}},"edi_user":{"name":"edi_users","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"friendly_name":{"type":_data_typesJs.DATA_TYPES.STRING},"auth_qualifier":{"type":_data_typesJs.DATA_TYPES.STRING},"auth_info":{"type":_data_typesJs.DATA_TYPES.STRING},"security_qualifier":{"type":_data_typesJs.DATA_TYPES.STRING},"security_info":{"type":_data_typesJs.DATA_TYPES.STRING},"sender_qualifier":{"type":_data_typesJs.DATA_TYPES.STRING},"sender_id":{"type":_data_typesJs.DATA_TYPES.STRING},"receiver_qualifier":{"type":_data_typesJs.DATA_TYPES.STRING},"receiver_id":{"type":_data_typesJs.DATA_TYPES.STRING},"control_standard_id":{"type":_data_typesJs.DATA_TYPES.STRING},"control_version":{"type":_data_typesJs.DATA_TYPES.STRING},"ack_requested":{"type":_data_typesJs.DATA_TYPES.STRING},"is_test":{"type":_data_typesJs.DATA_TYPES.STRING},"sub_element_sep":{"type":_data_typesJs.DATA_TYPES.STRING},"func_id":{"type":_data_typesJs.DATA_TYPES.STRING},"application_sender_id":{"type":_data_typesJs.DATA_TYPES.STRING},"application_receiver_id":{"type":_data_typesJs.DATA_TYPES.STRING},"responsible_agency_code":{"type":_data_typesJs.DATA_TYPES.STRING},"version_id":{"type":_data_typesJs.DATA_TYPES.STRING},"transaction_set_id":{"type":_data_typesJs.DATA_TYPES.STRING},"element_seperator":{"type":_data_typesJs.DATA_TYPES.STRING},"tag_seperator":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":[]},"employee":{"name":"employees","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"office_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"work_area_location":{"type":_data_typesJs.DATA_TYPES.STRING},"computer_ip":{"type":_data_typesJs.DATA_TYPES.STRING},"position":{"type":_data_typesJs.DATA_TYPES.STRING},"actively_employed":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"extension":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Employee\")"},"users":{"table":"user","pql":"eq(users.user_id,id)"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Employee\")"}}},"event":{"name":"events","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"watch_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"transaction_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"message":{"type":_data_typesJs.DATA_TYPES.STRING},"date":{"type":_data_typesJs.DATA_TYPES.DATE},"has_read":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"module":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"watch":{"table":"watch","pql":"eq(watch_id,watch.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Event\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Event\")"}}},"franchise":{"name":"franchises","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"primary_brand_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"is_exclude":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"is_public":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"formula":{"type":_data_typesJs.DATA_TYPES.STRING},"dealer_col":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(primary_brand_id,brand.id)"}},"linkFrom":{"customer_franchises":{"table":"customer_franchises","pql":"eq(customer_franchises.franchise_id,id)"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.franchise_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise\")"}}},"franchise_products":{"name":"franchise_products","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"franchise_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"rule_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sell_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sugar_column":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Franchise_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Franchise_Products\")"}}},"gateway_account":{"name":"gateway_accounts","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"payment_gateway_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"billing_contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"gateway_ref":{"type":_data_typesJs.DATA_TYPES.STRING},"additional_ref":{"type":_data_typesJs.DATA_TYPES.STRING},"is_primary":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"last_updated":{"type":_data_typesJs.DATA_TYPES.DATE},"exp_date":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"type":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"payment_gateway":{"table":"payment_gateway","pql":"eq(payment_gateway_id,payment_gateway.id)"},"billing_contact":{"table":"contact","pql":"eq(billing_contact_id,billing_contact.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"order_draft":{"table":"order_draft","pql":"eq(order_draft.gateway_account_id,id)"},"orders":{"table":"order","pql":"eq(orders.gateway_account_id,id)"},"remits":{"table":"remit","pql":"eq(remits.gateway_account_id,id)"},"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.gateway_account_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Gateway_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Gateway_Account\")"}}},"groupping_products":{"name":"groupping_products","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"parent_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"child_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"num_of_children_in_parent":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"discount_percent":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"parent":{"table":"product","pql":"eq(parent_id,parent.id)"},"child":{"table":"product","pql":"eq(child_id,child.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Groupping_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Groupping_Products\")"}}},"invoice":{"name":"invoices_view","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"invoice_date":{"type":_data_typesJs.DATA_TYPES.DATE},"invoice_status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"invoice_sum":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"amount_due":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"amount_received":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"age":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"override_date":{"type":_data_typesJs.DATA_TYPES.DATE},"invoice_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"retired_date":{"type":_data_typesJs.DATA_TYPES.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.invoice_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.invoice_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.invoice_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.invoice_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoice\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoice\")"}}},"invoices_payments":{"name":"invoices_payments","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"payment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"invoice_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"applied_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_applied":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Invoices_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Invoices_Payments\")"}}},"item_exchange":{"name":"item_exchange","fields":{"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"product_item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"from_status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"to_status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"from_warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"to_warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"date":{"type":_data_typesJs.DATA_TYPES.DATE},"from_product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"to_product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"from_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"to_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"from_warehouse":{"table":"office","pql":"eq(from_warehouse_id,from_warehouse.id)"},"to_warehouse":{"table":"office","pql":"eq(to_warehouse_id,to_warehouse.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Item_Exchange\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Item_Exchange\")"}}},"kit_item":{"name":"kit_items","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sort_order":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_item_order_kits":{"table":"product_item","pql":"eq(product_item_order_kits.order_kit_id,id)"},"product_item_purchase_kits":{"table":"product_item","pql":"eq(product_item_purchase_kits.purchase_kit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Kit_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Kit_Item\")"}}},"last_modified":{"name":"last_modifieds","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date":{"type":_data_typesJs.DATA_TYPES.DATE},"module":{"type":_data_typesJs.DATA_TYPES.STRING},"item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"memute":{"name":"memutes","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"module":{"type":_data_typesJs.DATA_TYPES.STRING},"rule_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Memute\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Memute\")"}}},"note":{"name":"notes","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"note":{"type":_data_typesJs.DATA_TYPES.STRING},"date":{"type":_data_typesJs.DATA_TYPES.DATE},"public":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"module_flags":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"module_priority":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"category":{"type":_data_typesJs.DATA_TYPES.STRING},"code":{"type":_data_typesJs.DATA_TYPES.STRING},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"important":{"type":_data_typesJs.DATA_TYPES.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.note_id,id)"}}},"notes_link":{"name":"notes_link","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"note_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"module":{"type":_data_typesJs.DATA_TYPES.STRING},"item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date":{"type":_data_typesJs.DATA_TYPES.DATE},"user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"void":{"type":_data_typesJs.DATA_TYPES.BOOLEAN}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"note":{"table":"note","pql":"eq(note_id,note.id)"},"bill":{"table":"$module","pql":"eq(item_id,bill.id)"},"booking":{"table":"$module","pql":"eq(item_id,booking.id)"},"brand":{"table":"$module","pql":"eq(item_id,brand.id)"},"contact":{"table":"$module","pql":"eq(item_id,contact.id)"},"customer":{"table":"$module","pql":"eq(item_id,customer.id)"},"employee":{"table":"$module","pql":"eq(item_id,employee.id)"},"event":{"table":"$module","pql":"eq(item_id,event.id)"},"franchise":{"table":"$module","pql":"eq(item_id,franchise.id)"},"groupping_products":{"table":"$module","pql":"eq(item_id,groupping_products.id)"},"invoice":{"table":"$module","pql":"eq(item_id,invoice.id)"},"invoices_payments":{"table":"$module","pql":"eq(item_id,invoices_payments.id)"},"kit_item":{"table":"$module","pql":"eq(item_id,kit_item.id)"},"memute":{"table":"$module","pql":"eq(item_id,memute.id)"},"message":{"table":"$module","pql":"eq(item_id,message.id)"},"office":{"table":"$module","pql":"eq(item_id,office.id)"},"order":{"table":"$module","pql":"eq(item_id,order.id)"},"order_draft":{"table":"$module","pql":"eq(item_id,order_draft.id)"},"payment":{"table":"$module","pql":"eq(item_id,payment.id)"},"product":{"table":"$module","pql":"eq(item_id,product.id)"},"product_bar_code":{"table":"$module","pql":"eq(item_id,product_bar_code.id)"},"product_item":{"table":"$module","pql":"eq(item_id,product_item.id)"},"product_item_report":{"table":"$module","pql":"eq(item_id,product_item_report.id)"},"product_item_return":{"table":"$module","pql":"eq(item_id,product_item_return.id)"},"product_items_bills":{"table":"$module","pql":"eq(item_id,product_items_bills.id)"},"products_vendors":{"table":"$module","pql":"eq(item_id,products_vendors.id)"},"program":{"table":"$module","pql":"eq(item_id,program.id)"},"programs_customers":{"table":"$module","pql":"eq(item_id,programs_customers.id)"},"promo":{"table":"$module","pql":"eq(item_id,promo.id)"},"promos_franchises":{"table":"$module","pql":"eq(item_id,promos_franchises.id)"},"promos_products":{"table":"$module","pql":"eq(item_id,promos_products.id)"},"purchase":{"table":"$module","pql":"eq(item_id,purchase.id)"},"purchase_tracking":{"table":"$module","pql":"eq(item_id,purchase_tracking.id)"},"purchase_tracking_item":{"table":"$module","pql":"eq(item_id,purchase_tracking_item.id)"},"return_product_due":{"table":"$module","pql":"eq(item_id,return_product_due.id)"},"rule":{"table":"$module","pql":"eq(item_id,rule.id)"},"sales_rep":{"table":"$module","pql":"eq(item_id,sales_rep.id)"},"shipment":{"table":"$module","pql":"eq(item_id,shipment.id)"},"shipment_in":{"table":"$module","pql":"eq(item_id,shipment_in.id)"},"shipment_method":{"table":"$module","pql":"eq(item_id,shipment_method.id)"},"spiff":{"table":"$module","pql":"eq(item_id,spiff.id)"},"spiffs_franchises":{"table":"$module","pql":"eq(item_id,spiffs_franchises.id)"},"spiffs_products":{"table":"$module","pql":"eq(item_id,spiffs_products.id)"},"tax_code":{"table":"$module","pql":"eq(item_id,tax_code.id)"},"term":{"table":"$module","pql":"eq(item_id,term.id)"},"territory":{"table":"$module","pql":"eq(item_id,territory.id)"},"timezone":{"table":"$module","pql":"eq(item_id,timezone.id)"}},"linkFrom":[]},"office":{"name":"offices","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"foreman_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"address1":{"type":_data_typesJs.DATA_TYPES.STRING},"address2":{"type":_data_typesJs.DATA_TYPES.STRING},"city":{"type":_data_typesJs.DATA_TYPES.STRING},"state":{"type":_data_typesJs.DATA_TYPES.STRING},"zip":{"type":_data_typesJs.DATA_TYPES.STRING},"country":{"type":_data_typesJs.DATA_TYPES.STRING},"phone":{"type":_data_typesJs.DATA_TYPES.STRING},"private_name":{"type":_data_typesJs.DATA_TYPES.STRING},"is_primary":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"open_hours":{"type":_data_typesJs.DATA_TYPES.STRING},"is_warehouse":{"type":_data_typesJs.DATA_TYPES.BOOLEAN}},"linkTo":{"foreman":{"table":"user","pql":"eq(foreman_id,foreman.id)"},"user":{"table":"user","pql":"eq(foreman_id,user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.warehouse_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.warehouse_id,id)"},"employees":{"table":"employee","pql":"eq(employees.office_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"order":{"name":"orders","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_name":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_address1":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_address2":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_city":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_state":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_zip":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_country":{"type":_data_typesJs.DATA_TYPES.STRING},"lead_user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_step":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_created":{"type":_data_typesJs.DATA_TYPES.DATE},"order_modified":{"type":_data_typesJs.DATA_TYPES.DATE},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"term_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"po_number":{"type":_data_typesJs.DATA_TYPES.STRING},"requested_delivery_date":{"type":_data_typesJs.DATA_TYPES.DATE},"requested_delivery_date_end":{"type":_data_typesJs.DATA_TYPES.DATE},"ship_on_date":{"type":_data_typesJs.DATA_TYPES.DATE},"tax_code_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes_public":{"type":_data_typesJs.DATA_TYPES.STRING},"address_error":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_addr_hash":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_phone":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_email":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_attn":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"quote_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"currency":{"type":_data_typesJs.DATA_TYPES.STRING},"billing_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"gateway_account_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_account_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_quote_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_flags":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"bill_override":{"table":"contact","pql":"eq(billing_id,bill_override.id)"},"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"order_draft":{"table":"order_draft","pql":"eq(quote_id,order_draft.id)"}},"linkFrom":{"invoices":{"table":"invoice","pql":"eq(invoices.order_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.order_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.order_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.order_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.order_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.order_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order\")"},"orders_product_items_void":{"table":"orders_product_items_void","pql":"eq(orders_product_items_void.order_id,id)"}}},"order_draft":{"name":"order_drafts","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_attn":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_name":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_address1":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_address2":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_city":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_state":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_zip":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_country":{"type":_data_typesJs.DATA_TYPES.STRING},"lead_user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_step":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"draft_created":{"type":_data_typesJs.DATA_TYPES.DATE},"term_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"po_number":{"type":_data_typesJs.DATA_TYPES.STRING},"requested_delivery_date":{"type":_data_typesJs.DATA_TYPES.DATE},"requested_delivery_date_end":{"type":_data_typesJs.DATA_TYPES.DATE},"ship_on_date":{"type":_data_typesJs.DATA_TYPES.DATE},"tax_code_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_phone":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_email":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"currency":{"type":_data_typesJs.DATA_TYPES.STRING},"billing_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"gateway_account_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_flags":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_account_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_quote_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"source":{"type":_data_typesJs.DATA_TYPES.STRING},"state":{"type":_data_typesJs.DATA_TYPES.STRING},"reserved_order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"cart_id":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"lead_user":{"table":"user","pql":"eq(lead_user_id,lead_user.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"tax_code":{"table":"tax_code","pql":"eq(tax_code_id,tax_code.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"},"reserved_order":{"table":"order","pql":"eq(reserved_order_id,reserved_order.id)"}},"linkFrom":{"orders":{"table":"order","pql":"eq(orders.quote_id,id)"},"draft_items":{"table":"draft_item","pql":"eq(draft_items.order_draft_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Draft\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Order_Draft\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Draft\")"}}},"order_line":{"name":"order_lines","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_part_num":{"type":_data_typesJs.DATA_TYPES.STRING},"edi_customer_line_id":{"type":_data_typesJs.DATA_TYPES.STRING},"edi_entered_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"edi_entered_qty":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":[],"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.order_line_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.order_line_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.order_line_id,id)"}}},"order_return":{"name":"order_returns","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_entered":{"type":_data_typesJs.DATA_TYPES.DATE},"rma_number":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"date_returned":{"type":_data_typesJs.DATA_TYPES.DATE},"payment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"type":{"type":_data_typesJs.DATA_TYPES.STRING},"code":{"type":_data_typesJs.DATA_TYPES.STRING},"replacement_order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_rma_number":{"type":_data_typesJs.DATA_TYPES.STRING},"office_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"public_note":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"replacement_order":{"table":"order","pql":"eq(replacement_order_id,replacement_order.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"}},"linkFrom":{"shipments_ins":{"table":"shipment_in","pql":"eq(shipments_ins.order_return_id,id)"},"return_product_dues":{"table":"return_product_due","pql":"eq(return_product_dues.order_return_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.return_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Order_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Order_Return\")"}}},"orders_product_items_void":{"name":"orders_product_items_void","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"void_sell_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_kit_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_canceled":{"type":_data_typesJs.DATA_TYPES.DATE},"moved_from_order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"order":{"table":"order","pql":"eq(order_id,order.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"orig_order":{"table":"order","pql":"eq(moved_from_order_id,orig_order.id)"}},"linkFrom":[]},"package":{"name":"packages","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"track_code":{"type":_data_typesJs.DATA_TYPES.STRING},"weight":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"height":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"width":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"length":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"last_modified":{"type":_data_typesJs.DATA_TYPES.DATE}},"linkTo":{"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.package_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.package_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.package_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Package\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Package\")"}}},"payment":{"name":"payments","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"reference_number":{"type":_data_typesJs.DATA_TYPES.STRING},"date_claimed":{"type":_data_typesJs.DATA_TYPES.DATE},"date_effective":{"type":_data_typesJs.DATA_TYPES.DATE},"amount_applied":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"amount_received":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"payment_type":{"type":_data_typesJs.DATA_TYPES.STRING},"fee":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"freight_refunded":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"misc_refunded":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"tax_refunded":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"refunded_date":{"type":_data_typesJs.DATA_TYPES.DATE},"refunded_amount":{"type":_data_typesJs.DATA_TYPES.STRING},"refunded_method":{"type":_data_typesJs.DATA_TYPES.STRING},"refunded_notes":{"type":_data_typesJs.DATA_TYPES.STRING},"currency":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"payment_gateway_requests":{"table":"payment_gateway_request","pql":"eq(payment_gateway_requests.payment_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.payment_id,id)"},"order_returns":{"table":"order_return","pql":"eq(order_returns.payment_id,id)"},"invoices_payments":{"table":"invoices_payments","pql":"eq(invoices_payments.payment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment\")"}}},"payment_gateway":{"name":"payment_gateways","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"class_name":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"gateway_accounts":{"table":"gateway_account","pql":"eq(gateway_accounts.payment_gateway_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Payment_Gateway\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Payment_Gateway\")"}}},"payment_gateway_request":{"name":"payment_gateway_requests","fields":{"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"request_type":{"type":_data_typesJs.DATA_TYPES.STRING},"gateway_account_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"reference":{"type":_data_typesJs.DATA_TYPES.STRING},"confirmation_num":{"type":_data_typesJs.DATA_TYPES.STRING},"payment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"request_date":{"type":_data_typesJs.DATA_TYPES.DATE},"request_by":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"approved":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"deny_reason":{"type":_data_typesJs.DATA_TYPES.STRING},"full_request":{"type":_data_typesJs.DATA_TYPES.STRING},"full_response":{"type":_data_typesJs.DATA_TYPES.STRING},"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"},"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"request_user":{"table":"user","pql":"eq(request_by,request_user.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Office\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Office\")"}}},"product":{"name":"products","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"description":{"type":_data_typesJs.DATA_TYPES.STRING},"item_code":{"type":_data_typesJs.DATA_TYPES.STRING},"brand_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"category_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sort_order":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"weight":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"dimension_h":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"dimension_w":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"dimension_l":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"list_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"map_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"vendor_part_number":{"type":_data_typesJs.DATA_TYPES.STRING},"primary_vendor_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"taxable":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"freight_only":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"upc_code":{"type":_data_typesJs.DATA_TYPES.STRING},"replacement_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"bin_location":{"type":_data_typesJs.DATA_TYPES.STRING},"has_internal_serial":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"has_external_serial":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"ht_code":{"type":_data_typesJs.DATA_TYPES.STRING},"date_discontinued":{"type":_data_typesJs.DATA_TYPES.DATE},"master_pack_qty":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"automation_flags":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"primary_warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_changed":{"type":_data_typesJs.DATA_TYPES.DATE},"default_stock_type":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"primary_vendor":{"table":"vendor","pql":"eq(primary_vendor_id,primary_vendor.id)"},"replacement":{"table":"product","pql":"eq(replacement_id,replacement.id)"},"primary_warehouse":{"table":"office","pql":"eq(primary_warehouse_id,primary_warehouse.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.product_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.product_id,id)"},"children":{"table":"groupping_products","pql":"eq(children.child_id,id)"},"parent":{"table":"groupping_products","pql":"eq(parent.parent_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.product_id,id)"},"product_bar_codes":{"table":"product_bar_code","pql":"eq(product_bar_codes.product_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product\")"},"franchise_products":{"table":"franchise_products","pql":"eq(franchise_products.product_id,id)"}}},"product_bar_code":{"name":"product_bar_codes","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"bar_code":{"type":_data_typesJs.DATA_TYPES.STRING},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"type":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Bar_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Bar_Code\")"}}},"product_item":{"name":"product_items","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"serial_number":{"type":_data_typesJs.DATA_TYPES.STRING},"warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"warehouse_location":{"type":_data_typesJs.DATA_TYPES.STRING},"date_received":{"type":_data_typesJs.DATA_TYPES.DATE},"date_shipped":{"type":_data_typesJs.DATA_TYPES.DATE},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"item_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"roi_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"purchase_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sell_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"invoice_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sales_rep_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sort_order":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"tax_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"temp_cust_id":{"type":_data_typesJs.DATA_TYPES.STRING},"shipment_in_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_serial":{"type":_data_typesJs.DATA_TYPES.STRING},"override_date":{"type":_data_typesJs.DATA_TYPES.DATE},"order_kit_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"purchase_kit_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"discount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"starin_promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"spiff_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"program_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"package_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"has_changed":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"order_warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"stock_type":{"type":_data_typesJs.DATA_TYPES.STRING},"order_line_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"purchase_tracking_item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"product_items_bills":{"table":"product_items_bills","pql":"eq(product_items_bills.product_item_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.product_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_report":{"name":"product_items_reports","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"serial_number":{"type":_data_typesJs.DATA_TYPES.STRING},"warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"warehouse_location":{"type":_data_typesJs.DATA_TYPES.STRING},"date_received":{"type":_data_typesJs.DATA_TYPES.DATE},"date_shipped":{"type":_data_typesJs.DATA_TYPES.DATE},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"item_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"roi_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"purchase_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sell_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"invoice_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sales_rep_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sort_order":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"tax_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"temp_cust_id":{"type":_data_typesJs.DATA_TYPES.STRING},"shipment_in_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_serial":{"type":_data_typesJs.DATA_TYPES.STRING},"return_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"override_date":{"type":_data_typesJs.DATA_TYPES.DATE},"order_kit_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"purchase_kit_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"discount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"starin_promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"spiff_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"program_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"package_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"has_changed":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"order_warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_line_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"source":{"type":_data_typesJs.DATA_TYPES.STRING},"stock_type":{"type":_data_typesJs.DATA_TYPES.STRING},"purchase_tracking_item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"warehouse":{"table":"office","pql":"eq(warehouse_id,warehouse.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"},"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"sales_rep":{"table":"sales_rep","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"purchase_kit":{"table":"kit_item","pql":"eq(purchase_kit_id,purchase_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"},"purchase_tracking_item":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_item_id,purchase_tracking_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,product_item_id) eq(notes_links.module,\"Product_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,product_item_id) eq(last_modified.module,\"Product_Item\")"}}},"product_item_return":{"name":"product_items_returns","fields":{"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"product_item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"return_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"return_sell_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"restock_fee":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"invoice_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_shipped":{"type":_data_typesJs.DATA_TYPES.DATE},"date_return_received":{"type":_data_typesJs.DATA_TYPES.DATE},"sort_order":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sales_rep_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sell_price":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"tax_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_in_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"override_date":{"type":_data_typesJs.DATA_TYPES.DATE},"discount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"starin_promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"spiff_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"program_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"package_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_kit_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_warehouse_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_line_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"stock_type":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"},"order_return":{"table":"order_return","pql":"eq(return_id,order_return.id)"},"invoice":{"table":"invoice","pql":"eq(invoice_id,invoice.id)"},"shipment":{"table":"shipment","pql":"eq(shipment_id,shipment.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"},"sales_rep":{"table":"user","pql":"eq(sales_rep_id,sales_rep.id)"},"shipment_in":{"table":"shipment_in","pql":"eq(shipment_in_id,shipment_in.id)"},"order_kit":{"table":"kit_item","pql":"eq(order_kit_id,order_kit.id)"},"starin_promo":{"table":"promo","pql":"eq(starin_promo_id,starin_promo.id)"},"vendor_promo":{"table":"promo","pql":"eq(vendor_promo_id,vendor_promo.id)"},"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"program":{"table":"program","pql":"eq(program_id,program.id)"},"package":{"table":"package","pql":"eq(package_id,package.id)"},"order_warehouse":{"table":"office","pql":"eq(order_warehouse_id,order_warehouse.id)"},"order_line":{"table":"order_line","pql":"eq(order_line_id,order_line.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Return\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Return\")"}}},"product_items_bills":{"name":"product_items_bills","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"bill_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"item_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Item_Bills\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Item_Bills\")"}}},"products_vendors":{"name":"products_vendors","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"product":{"table":"product","pql":"eq(product_id,product.id)"},"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Product_Vendors\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Product_Vendors\")"}}},"program":{"name":"programs","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"start_date":{"type":_data_typesJs.DATA_TYPES.DATE},"end_date":{"type":_data_typesJs.DATA_TYPES.DATE},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE},"brand_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"rule_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"brand":{"table":"brand","pql":"eq(brand_id,brand.id)"},"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.program_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.program_id,id)"},"product_item_returns":{"table":"product_item_returns","pql":"eq(product_item_returns.program_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Program\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Program\")"}}},"programs_customers":{"name":"programs_customers","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"program_id":{"type":_data_typesJs.DATA_TYPES.STRING},"customer_id":{"type":_data_typesJs.DATA_TYPES.DATE},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE},"parameters":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"program":{"table":"program","pql":"eq(program_id,program.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Programs_Customers\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Programs_Customers\")"}}},"promo":{"name":"promos","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"start_date":{"type":_data_typesJs.DATA_TYPES.DATE},"end_date":{"type":_data_typesJs.DATA_TYPES.DATE},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE},"type":{"type":_data_typesJs.DATA_TYPES.STRING},"rule_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"brand_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"promo_code":{"type":_data_typesJs.DATA_TYPES.STRING},"before_order_rule_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"after_invoice_rule_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"rule":{"table":"rule","pql":"eq(rule_id,rule.id)"},"brand_id":{"table":"brand","pql":"eq(brand_id,brand_id.id)"}},"linkFrom":{"product_item_starin_promos":{"table":"product_item","pql":"eq(product_item_starin_promos.starin_promo_id,id)"},"product_item_vendor_promos":{"table":"product_item","pql":"eq(product_item_vendor_promos.vendor_promo_id,id)"},"product_item_return_starin_promos":{"table":"product_item_return","pql":"eq(product_item_return_starin_promos.starin_promo_id,id)"},"product_item_return_vendor_promos":{"table":"product_item_return","pql":"eq(product_item_return_vendor_promos.vendor_promo_id,id)"},"product_item_report_starin_promos":{"table":"product_item_report","pql":"eq(product_item_report_starin_promos.starin_promo_id,id)"},"product_item_report_vendor_promos":{"table":"product_item_report","pql":"eq(product_item_report_vendor_promos.vendor_promo_id,id)"},"promos_franchises":{"table":"promos_franchises","pql":"eq(promos_franchises.promo_id,id)"},"promos_products":{"table":"promos_products","pql":"eq(promos_products.promo_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promo\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promo\")"}}},"promos_franchises":{"name":"promos_franchises","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"franchise_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Franchises\")"}}},"promos_products":{"name":"promos_products","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"promo_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE},"description":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"promo":{"table":"promo","pql":"eq(promo_id,promo.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Promos_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Promos_Products\")"}}},"purchase":{"name":"purchases","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"vendor_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_ordered":{"type":_data_typesJs.DATA_TYPES.DATE},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"status":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"term_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"assigned_user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"sub_total":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"tax":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"freight":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"misc":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"total":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"office_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes_public":{"type":_data_typesJs.DATA_TYPES.STRING},"ship_account_num":{"type":_data_typesJs.DATA_TYPES.STRING},"est_received_date":{"type":_data_typesJs.DATA_TYPES.DATE},"vendor_order_number":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"vendor":{"table":"vendor","pql":"eq(vendor_id,vendor.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"order":{"table":"order","pql":"eq(order_id,order.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_id,id)"},"bills":{"table":"bill","pql":"eq(bills.purchase_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase\")"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"Purchase\")"}}},"purchase_tracking":{"name":"purchase_tracking","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"purchase_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"estimated_receive_date":{"type":_data_typesJs.DATA_TYPES.DATE},"tracking_number":{"type":_data_typesJs.DATA_TYPES.STRING},"shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"last_updated":{"type":_data_typesJs.DATA_TYPES.DATE},"variance":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"note":{"type":_data_typesJs.DATA_TYPES.STRING},"ref_number":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"purchase_tracking_items":{"table":"purchase_tracking_item","pql":"eq(purchase_tracking_items.purchase_tracking_id,id)"},"control_flags":{"table":"control_flag","pql":"eq(control_flags.item_id,id) eq(control_flags.module,\"PURCHASE_TRACKING\")"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking\")"}}},"purchase_tracking_item":{"name":"purchase_tracking_items","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"purchase_tracking_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"stock_type":{"type":_data_typesJs.DATA_TYPES.STRING},"qty":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"qty_received":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"purchase_tracking":{"table":"purchase_tracking","pql":"eq(purchase_tracking_id,purchase_tracking.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.purchase_tracking_item_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.purchase_tracking_item_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Purchase_Tracking_Item\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Purchase_Tracking_Item\")"}}},"remit":{"name":"remits","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"paid":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE},"amount_due":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"gateway_account_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"gateway_account":{"table":"gateway_account","pql":"eq(gateway_account_id,gateway_account.id)"}},"linkFrom":{"shipments":{"table":"shipment","pql":"eq(shipments.remit_id,id)"},"remits_payments":{"table":"remits_payments","pql":"eq(remits_payments.remit_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remit\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remit\")"}}},"remits_payments":{"name":"remits_payments","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"remit_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"payment_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_applied":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE}},"linkTo":{"payment":{"table":"payment","pql":"eq(payment_id,payment.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Remits_Payments\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Remits_Payments\")"}}},"return_product_due":{"name":"return_product_due","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_item_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_return_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"product_item":{"table":"product_item","pql":"eq(product_item_id,product_item.id)"}},"linkFrom":[]},"rule":{"name":"rules","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"code":{"type":_data_typesJs.DATA_TYPES.STRING},"file":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":[],"linkFrom":[]},"sales_rep":{"name":"sales_reps","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"assigned_user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"is_distributor":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"},"user":{"table":"user","pql":"eq(user_id,user.id)"},"assigned_user":{"table":"user","pql":"eq(assigned_user_id,assigned_user.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.sales_rep_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Sales_Rep\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Sales_Rep\")"}}},"shipment":{"name":"shipments","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"track_code":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"actual_cost":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_date":{"type":_data_typesJs.DATA_TYPES.DATE},"date_due":{"type":_data_typesJs.DATA_TYPES.DATE},"shipment_fee":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"handling_fee":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"flags":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_addr_hash":{"type":_data_typesJs.DATA_TYPES.STRING},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"bill_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"term_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"backorder_hash":{"type":_data_typesJs.DATA_TYPES.STRING},"remit_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"discount_amount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_account_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_flags":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"bill":{"table":"bill","pql":"eq(bill_id,bill.id)"},"term":{"table":"term","pql":"eq(term_id,term.id)"},"remit":{"table":"remit","pql":"eq(remit_id,remit.id)"},"shipment_account":{"table":"shipment_account","pql":"eq(shipment_account_id,shipment_account.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_id,id)"},"product_items_returns":{"table":"product_item_return","pql":"eq(product_items_returns.shipment_id,id)"},"product_items_reports":{"table":"product_item_report","pql":"eq(product_items_reports.shipment_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment\")"},"invoices":{"table":"invoice","pql":"eq(invoices.shipment_id,id)"}}},"shipment_account":{"name":"shipment_accounts","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"ship_account_num":{"type":_data_typesJs.DATA_TYPES.STRING},"third_party_contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"},"third_party_contact":{"table":"contact","pql":"eq(third_party_contact_id,third_party_contact.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Account\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Account\")"}}},"shipment_in":{"name":"shipments_in","fields":{"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"date_entered":{"type":_data_typesJs.DATA_TYPES.DATE},"purchase_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"order_return_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"track_code":{"type":_data_typesJs.DATA_TYPES.STRING},"office_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"purchase":{"table":"purchase","pql":"eq(purchase_id,purchase.id)"},"order_return":{"table":"order_return","pql":"eq(order_return_id,order_return.id)"},"office":{"table":"office","pql":"eq(office_id,office.id)"},"shipment_method":{"table":"shipment_method","pql":"eq(shipment_method_id,shipment_method.id)"}},"linkFrom":{"product_items":{"table":"product_item","pql":"eq(product_items.shipment_in_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_In\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_In\")"}}},"shipment_method":{"name":"shipment_methods","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"customer_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"prepaid":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"carrier_code":{"type":_data_typesJs.DATA_TYPES.STRING},"carrier":{"type":_data_typesJs.DATA_TYPES.STRING},"parent_shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"carrier_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"transportaion_method_code":{"type":_data_typesJs.DATA_TYPES.STRING},"is_freight":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"time_in_transit":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"service_level_code":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"customer":{"table":"customer","pql":"eq(customer_id,customer.id)"},"parent_shipment_method":{"table":"shipment_method","pql":"eq(parent_shipment_method_id,parent_shipment_method.id)"},"scac":{"table":"carrier","pql":"eq(carrier_id,scac.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.shipment_method_id,id)"},"shipments":{"table":"shipment","pql":"eq(shipments.shipment_method_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Shipment_Method\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Shipment_Method\")"},"child_shipment_methods":{"table":"shipment_method","pql":"eq(child_shipment_methods.parent_shipment_method_id,id)"},"shipment_accounts":{"table":"shipment_account","pql":"eq(shipment_accounts.shipment_method_id,id)"}}},"spiff":{"name":"spiffs","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"start_date":{"type":_data_typesJs.DATA_TYPES.DATE},"end_date":{"type":_data_typesJs.DATA_TYPES.DATE},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"max":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":[],"linkFrom":{"spiffs_franchises":{"table":"spiffs_franchises","pql":"eq(spiffs_franchises.spiff_id,id)"},"spiffs_products":{"table":"spiffs_products","pql":"eq(spiffs_products.spiff_id,id)"},"product_items":{"table":"product_item","pql":"eq(product_items.spiff_id,id)"},"product_item_returns":{"table":"product_item_return","pql":"eq(product_item_returns.spiff_id,id)"},"product_item_reports":{"table":"product_item_report","pql":"eq(product_item_reports.spiff_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff\")"}}},"spiffs_franchises":{"name":"spiffs_franchises","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"spiff_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"franchise_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"franchise":{"table":"franchise","pql":"eq(franchise_id,franchise.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiff_Franchises\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiff_Franchises\")"}}},"spiffs_products":{"name":"spiffs_products","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"spiff_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"product_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"qty":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date_created":{"type":_data_typesJs.DATA_TYPES.DATE},"date_voided":{"type":_data_typesJs.DATA_TYPES.DATE}},"linkTo":{"spiff":{"table":"spiff","pql":"eq(spiff_id,spiff.id)"},"product":{"table":"product","pql":"eq(product_id,product.id)"}},"linkFrom":{"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Spiffs_Products\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Spiffs_Products\")"}}},"tax_code":{"name":"tax_codes","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"percentage":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"shipment_tax":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":[],"linkFrom":{"orders":{"table":"order","pql":"eq(orders.tax_code_id,id)"},"customers":{"table":"customer","pql":"eq(customers.tax_code_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Tax_Code\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Tax_Code\")"}}},"term":{"name":"terms","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"due_days":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"discount":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"discount_days":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"order_override_flags":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"classification":{"type":_data_typesJs.DATA_TYPES.STRING},"grace_days":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"edi_term_code_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"edi_term_code":{"table":"edi_term_code","pql":"eq(edi_term_code_id,edi_term_code.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.term_id,id)"},"bills":{"table":"bill","pql":"eq(bills.term_id,id)"},"customers":{"table":"customer","pql":"eq(customers.term_id,id)"},"vendors":{"table":"vendor","pql":"eq(vendors.term_id,id)"},"orders":{"table":"order","pql":"eq(orders.term_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Term\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Term\")"}}},"territory":{"name":"territories","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"country":{"type":_data_typesJs.DATA_TYPES.STRING},"region":{"type":_data_typesJs.DATA_TYPES.STRING},"state_province":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"customers":{"table":"customer","pql":"eq(customers.territory_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Territory\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Territory\")"}}},"timezone":{"name":"timezones","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"utc":{"type":_data_typesJs.DATA_TYPES.STRING},"dst":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":[],"linkFrom":{"contacts":{"table":"contact","pql":"eq(contacts.timezone_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Timezone\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Timezone\")"}}},"user":{"name":"users_view","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"username":{"type":_data_typesJs.DATA_TYPES.STRING},"password":{"type":_data_typesJs.DATA_TYPES.STRING},"can_login":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"employee_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"wh_scan":{"type":_data_typesJs.DATA_TYPES.STRING}},"linkTo":{"employee":{"table":"employee","pql":"eq(employee_id,employee.id)"},"contact":{"table":"contact","pql":"eq(contact_id,contact.id)"}},"linkFrom":{"user_historys":{"table":"user_history","pql":"eq(user_historys.user_id,id)"},"voided_gateway_requests":{"table":"payment_gateway_request","pql":"eq(voided_gateway_requests.void_by,id)"},"approved_gateway_requests":{"table":"payment_gateway_request","pql":"eq(approved_gateway_requests.approved_by,id)"},"requested_gateway_requests":{"table":"payment_gateway_request","pql":"eq(requested_gateway_requests.request_by,id)"},"offices":{"table":"office","pql":"eq(offices.foreman_id,id)"},"customers":{"table":"customer","pql":"eq(customers.primary_rep_id,id)"},"purchases":{"table":"purchase","pql":"eq(purchases.assigned_user_id,id)"},"orders":{"table":"order","pql":"eq(orders.assigned_user_id,id)"},"sales_reps":{"table":"sales_rep","pql":"eq(sales_reps.user_id,id)"},"assigned_sales_reps":{"table":"sales_rep","pql":"eq(assigned_sales_reps.assigned_user_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"User\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"User\")"}}},"user_history":{"name":"user_historys","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"method":{"type":_data_typesJs.DATA_TYPES.STRING},"args":{"type":_data_typesJs.DATA_TYPES.STRING},"window_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"date":{"type":_data_typesJs.DATA_TYPES.DATE}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"}},"linkFrom":[]},"vendor":{"name":"vendors","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"name":{"type":_data_typesJs.DATA_TYPES.STRING},"notes":{"type":_data_typesJs.DATA_TYPES.STRING},"primary_contact_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"term_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"legacy_id":{"type":_data_typesJs.DATA_TYPES.STRING},"temp_mybooks_id":{"type":_data_typesJs.DATA_TYPES.STRING},"our_account_number":{"type":_data_typesJs.DATA_TYPES.STRING},"default_shipment_method_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"default_office_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"term":{"table":"term","pql":"eq(term_id,term.id)"},"primary_contact":{"table":"contact","pql":"eq(primary_contact_id,primary_contact.id)"},"default_shipment_method":{"table":"shipment_method","pql":"eq(default_shipment_method_id,default_shipment_method.id)"},"default_office":{"table":"office","pql":"eq(default_office_id,default_office.id)"}},"linkFrom":{"purchases":{"table":"purchase","pql":"eq(purchases.vendor_id,id)"},"contacts":{"table":"contact","pql":"eq(contacts.vendor_id,id)"},"primary_products":{"table":"product","pql":"eq(primary_products.vendor_id,id)"},"bills":{"table":"bill","pql":"eq(bills.vendor_id,id)"},"products_vendors":{"table":"products_vendors","pql":"eq(products_vendors.vendor_id,id)"},"notes_links":{"table":"notes_link","pql":"eq(notes_links.item_id,id) eq(notes_links.module,\"Vendor\")"},"last_modified":{"table":"last_modified","pql":"eq(last_modified.item_id,id) eq(last_modified.module,\"Vendor\")"}}},"watch":{"name":"watchs","fields":{"deleted":{"type":_data_typesJs.DATA_TYPES.BOOLEAN},"id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"user_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"record_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC},"created":{"type":_data_typesJs.DATA_TYPES.DATE},"note":{"type":_data_typesJs.DATA_TYPES.STRING},"memute_id":{"type":_data_typesJs.DATA_TYPES.NUMERIC}},"linkTo":{"user":{"table":"user","pql":"eq(user_id,user.id)"},"memute":{"table":"memute","pql":"eq(memute_id,memute.id)"}},"linkFrom":[]}};Config.FUNCTION_MAP = {eq:{description:'Compares two values',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsEqualJs.EQUAL(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},gt:{description:'Checks if first value is greater than second',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsGreater_thanJs.GREATER_THAN(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},lt:{description:'Checks if first value is less than second',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsLess_thanJs.LESS_THAN(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},ne:{description:'Checks if values are not equal',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsNot_equalJs.NOT_EQUAL(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},like:{description:'Checks if first value is like second. % sign is wild card character',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsLikeJs.LIKE(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},not_like:{description:'Checks if first value is not like second. % sign is wild card character',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var obj=new _opcodesComparitorsNot_likeJs.NOT_LIKE(pql);obj.setLeft(orig_args[0]);obj.setRight(orig_args[1]);return obj.getSQL(query_obj);}},'in':{description:'Checks if first value is any of the following values',min_args:2,max_args:Infinity,return_type:_data_typesJs.DATA_TYPES.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var out_args=[];var obj=new _opcodesComparitorsEqualJs.EQUAL(pql);orig_args.splice(1).forEach(function(v){out_args.push(v);});obj.setLeft(orig_args[0]);obj.setRight(new _opcodesConstants_arrayJs.CONSTANTS_ARRAY(pql,out_args));return obj.getSQL(query_obj);}},not_in:{description:'Checks if first value is not any of the following values',min_args:2,max_args:Infinity,return_type:_data_typesJs.DATA_TYPES.BOOLEAN,format:function format(args,orig_args,query_obj){var pql=this.getPqlObj();var out_args=[];var obj=new _opcodesComparitorsNot_equalJs.NOT_EQUAL(pql);orig_args.splice(1).forEach(function(v){out_args.push(v);});obj.setLeft(orig_args[0]);obj.setRight(new _opcodesConstants_arrayJs.CONSTANTS_ARRAY(pql,out_args));return obj.getSQL(query_obj);}},'if':{description:'If first argument is truethy returns second argument otherwise returns third',min_args:3,max_args:3,return_type:_data_typesJs.DATA_TYPES.ANY,format:['(CASE WHEN ',Config.ARG1,' THEN ',Config.ARG2,' ELSE ',Config.ARG3,' END)']}, /* Math functions */add:{description:'Adds values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' + ');}},sub:{description:'Subtracts values from eachother',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' - ');}},mul:{description:'Multiplies values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' * ');}},div:{description:'Divide values together',min_args:2,max_args:Infinity,return_type:Config.NUMBER,format:function format(args,orig_args,query_obj){return args.join(' / ');}},mod:{description:'Modulus values together',min_args:2,max_args:2,return_type:Config.NUMBER,format:['MOD(',Config.ARG1,', ',Config.ARG2,')']},pow:{description:'Powers values together',min_args:2,max_args:2,return_type:Config.NUMBER,format:['POW(',Config.ARG1,', ',Config.ARG2,')']},sqrt:{description:'Square roots a value',min_args:1,max_args:1,return_type:Config.NUMBER,format:['SQRT(',Config.ARG1,')']}, /* Standard SQL functions */abs:{description:'Gets absolute value',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['ABS(',Config.ARG1,')']},'char':{description:'Gets character from numerical ascii character',min_args:1,max_args:Infinity,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC],return_type:_data_typesJs.DATA_TYPES.STRING,format:['CHAR(',Config.ALL_ARGS,')']},coalesce:{description:'Returns first non-null value from arguments',min_args:1,max_args:Infinity,return_type:_data_typesJs.DATA_TYPES.ANY_TYPE,format:['COALESCE(',Config.ALL_ARGS,')']},ifnull:{description:'Returns first argument if not null otherwise returns second argument',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.ANY_TYPE,format:['IFNULL(',Config.ARG1,', ',Config.ARG2,')']},instr:{description:'Gets character position of argument two in argument one\'s string',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.NUMERIC,arg_types:[_data_typesJs.DATA_TYPES.STRING,_data_typesJs.DATA_TYPES.STRING],format:['INSTR(',Config.ARG1,', ',Config.ARG2,')']},hex:{description:'Returns hex value of argument',min_args:1,max_args:1,return_type:_data_typesJs.DATA_TYPES.STRING,format:['HEX(',Config.ARG1,')']},length:{description:'Returns the string length',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['LENGTH(',Config.ARG1,')']},lower:{description:'Returns string converted to lower case',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,format:['LOWER(',Config.ARG1,')']},ltrim:{description:'Returns left-trimmed string',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,format:['LTRIM(',Config.ARG1,')']},nullif:{description:'Returns null if argument one equals argument two',min_args:2,max_args:2,return_type:_data_typesJs.DATA_TYPES.ANY_TYPE,format:['NULLIF(',Config.ARG1,', ',Config.ARG2,')']},random:{description:'Returns random number (platform dependent)',min_args:0,max_args:0,return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['RANDOM()']},replace:{description:'Searches for argument two and replaces matches with argument three in argument one',min_args:3,max_args:3,arg_types:[_data_typesJs.DATA_TYPES.STRING,_data_typesJs.DATA_TYPES.STRING,_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,format:['REPLACE(',Config.ARG1,', ',Config.ARG2,', ',Config.ARG3,')']},round:{description:'Returns rounded value of argument one with decimal percision of argument two',min_args:1,max_args:2,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC,_data_typesJs.DATA_TYPES.NUMERIC],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['ROUND(',Config.ALL_ARGS,')']},rtrim:{description:'Returns right-trimmed value',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,format:['RTRIM(',Config.ARG1,')']},substr:{description:'Returns part of argument one string from argument two position with length of argument three',min_args:2,max_args:3,arg_types:[_data_typesJs.DATA_TYPES.STRING,_data_typesJs.DATA_TYPES.NUMERIC,_data_typesJs.DATA_TYPES.NUMERIC],return_type:_data_typesJs.DATA_TYPES.STRING,format:['SUBSTR(',Config.ALL_ARGS,')']},trim:{description:'Returns full trimmed string',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,format:['TRIM(',Config.ARG1,')']},upper:{description:'Returns value converted to upper case',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,format:['UPPER(',Config.ARG1,')']},concat:{description:'Returns multiple strings joined together',min_args:1,max_args:Infinity,arg_types:[_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,format:['CONCAT(',Config.ALL_ARGS,')']}, /* Date Functions */date_format:{description:'Returns date converted converted using format of argument two',min_args:2,max_args:2,arg_types:[_data_typesJs.DATA_TYPES.DATE,_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,format:['DATE_FORMAT(',Config.ARG1,', ',Config.ARG2,')']},date:{description:'Returns date porition of argument one',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.DATE,format:['DATE(',Config.ARG1,')']},day:{description:'Returns day number of date',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['DAY(',Config.ARG1,')']},from_unixtime:{description:'Returns date type from unix timestamp',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC],return_type:_data_typesJs.DATA_TYPES.DATE,format:['FROM_UNIXTIME(',Config.ARG1,')']},hour:{description:'Returns hour portion of date',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['HOUR(',Config.ARG1,')']},minute:{description:'Returns minute porition of date',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['MINUTE(',Config.ARG1,')']},month:{description:'Returns month number porition of date',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['MONTH(',Config.ARG1,')']},now:{description:'Returns current time/date',min_args:0,max_args:0,return_type:_data_typesJs.DATA_TYPES.DATE,format:['NOW()']},second:{description:'Returns second porition of date',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['SECOND(',Config.ARG1,')']},time:{description:'Returns time porition of date',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.STRING,format:['TIME(',Config.ARG1,')']},unix_timestamp:{description:'Returns unix timestamp from date',min_args:0,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['UNIX_TIMESTAMP(',Config.ARG1,')']},year:{description:'Returns year porition from date',min_args:1,max_args:1,arg_types:[_data_typesJs.DATA_TYPES.DATE],return_type:_data_typesJs.DATA_TYPES.NUMERIC,format:['YEAR(',Config.ARG1,')']}, /* Aggregate functions */avg:{description:'Returns average value',min_args:1,max_args:2,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC,_data_typesJs.DATA_TYPES.BOOLEAN],return_type:_data_typesJs.DATA_TYPES.NUMERIC,is_group_function:true,format:{1:['AVG(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return 'AVG(DISTINCT ' + args[0];}return 'AVG(' + args[0];}]}},count:{description:'Returns count of items',min_args:1,max_args:2,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC,_data_typesJs.DATA_TYPES.BOOLEAN],return_type:_data_typesJs.DATA_TYPES.NUMERIC,is_group_function:true,format:{1:['COUNT(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return 'COUNT(DISTINCT ' + args[0];}return 'COUNT(' + args[0];}]}}, // group_concat(expr[,distinct[,seperator[,order_by_expression,order_by_direction ...]]]); +group_concat:{description:'Returns the group concatinated string',min_args:1,max_args:Infinity,arg_types:[_data_typesJs.DATA_TYPES.STRING,_data_typesJs.DATA_TYPES.BOOLEAN,_data_typesJs.DATA_TYPES.STRING,_data_typesJs.DATA_TYPES.STRING,_data_typesJs.DATA_TYPES.STRING],return_type:_data_typesJs.DATA_TYPES.STRING,is_group_function:true,format:function format(args,orig_args){var distinct=orig_args.length >= 2 && Boolean(Number(orig_args[1].getValue()))?'DISTINCT ':'';var seperator='';if(orig_args.length >= 3){if(!orig_args[2].isConstant() && !orig_args[2].isInstanceOf(_opcodesNullJs.NULL)){throw 'Third argument of "group_concat" function must be a constant type';}if(!orig_args[2].isInstanceOf(_opcodesNullJs.NULL)){seperator = ' SEPARATOR ' + args[2];}}var order_bys=new Set();if(orig_args.length > 3){ // Check to make sure there are always pairs of order_by_expression and order_by_direction +if(orig_args.length % 2 == 0){throw 'GROUP_CONCAT function must have order_by_expression and order_by_direction in pairs';} // Inc in order of 2's +for(var i=3;i < args.length;i = i + 2) {var dir='ASC';if(orig_args[i + 1].isConstant()){dir = orig_args[i + 1].getValue().toString().toLowerCase() == 'desc'?'DESC':'ASC';}order_bys.add(args[i] + ' ' + dir);}}var order_by=undefined;if(order_bys.size){order_by = ' ORDER BY ' + Array.from(order_bys).join(',');}else {order_by = '';}return 'GROUP_CONCAT(' + distinct + args[0] + order_by + seperator + ')';}},max:{description:'Returns maximum value',min_args:1,max_args:2,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC,_data_typesJs.DATA_TYPES.BOOLEAN],return_type:_data_typesJs.DATA_TYPES.NUMERIC,is_group_function:true,format:{1:['MAX(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return 'MAX(DISTINCT ' + args[0];}return 'MAX(' + args[0];}]}},min:{description:'Returns minimum value',min_args:1,max_args:2,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC,_data_typesJs.DATA_TYPES.BOOLEAN],return_type:_data_typesJs.DATA_TYPES.NUMERIC,is_group_function:true,format:{1:['MIN(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return 'MIN(DISTINCT ' + args[0];}return 'MIN(' + args[0];}]}},sum:{description:'Returns sum of values',min_args:1,max_args:2,arg_types:[_data_typesJs.DATA_TYPES.NUMERIC,_data_typesJs.DATA_TYPES.BOOLEAN],return_type:_data_typesJs.DATA_TYPES.NUMERIC,is_group_function:true,format:{1:['SUM(',Config.ARG1,')'],2:[function(args,orig_args){var distinct=Boolean(Number(orig_args[1].getValue()));if(distinct){return 'SUM(DISTINCT ' + args[0];}return 'SUM(' + args[0];}]}},having:{description:'Forces item into having statment',min_args:1,max_args:1,return_type:_data_typesJs.DATA_TYPES.ANY,is_group_function:true,format:[Config.ARG1]}};Config.COMPARITORS = new Set([_opcodesComparitorsEqualJs.EQUAL,_opcodesComparitorsGreater_thanJs.GREATER_THAN,_opcodesComparitorsLess_thanJs.LESS_THAN,_opcodesComparitorsLikeJs.LIKE,_opcodesComparitorsNo_valueJs.NO_VALUE,_opcodesComparitorsNot_equalJs.NOT_EQUAL,_opcodesComparitorsNot_likeJs.NOT_LIKE]); \ No newline at end of file diff --git a/compiled/pql/data_types.js b/compiled/pql/data_types.js new file mode 100644 index 0000000..62feb70 --- /dev/null +++ b/compiled/pql/data_types.js @@ -0,0 +1,29 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var DATA_TYPES = function DATA_TYPES() { + _classCallCheck(this, DATA_TYPES); +}; + +exports.DATA_TYPES = DATA_TYPES; +; +DATA_TYPES.NUMERIC = { + is_numeric: true +}; +DATA_TYPES.DATE = { + is_numeric: false +}; +DATA_TYPES.STRING = { + is_numeric: false +}; +DATA_TYPES.BOOLEAN = { + is_numeric: true +}; +DATA_TYPES.ANY = { + is_numeric: false +}; \ No newline at end of file diff --git a/compiled/pql/opcodes/comparitors/comparitor.js b/compiled/pql/opcodes/comparitors/comparitor.js index d21c526..315d7b6 100644 --- a/compiled/pql/opcodes/comparitors/comparitor.js +++ b/compiled/pql/opcodes/comparitors/comparitor.js @@ -40,6 +40,12 @@ var COMPARITOR = (function (_OPCODE) { this.right = v; return this; } + }, { + key: 'setNeedsWrapped', + value: function setNeedsWrapped(val) { + this._needs_wrapped = val; + return this; + } }, { key: 'needsGroup', value: function needsGroup() { diff --git a/compiled/pql/opcodes/constant.js b/compiled/pql/opcodes/constant.js index f6133fe..2554662 100644 --- a/compiled/pql/opcodes/constant.js +++ b/compiled/pql/opcodes/constant.js @@ -36,6 +36,7 @@ var CONSTANT = (function (_OPCODE) { key: 'setForceNumeric', value: function setForceNumeric(force) { this._force_numeric = !!force; + return this; } }, { key: 'getValue', diff --git a/compiled/pql/opcodes/function.js b/compiled/pql/opcodes/function.js index 5e9eeb7..ff89461 100644 --- a/compiled/pql/opcodes/function.js +++ b/compiled/pql/opcodes/function.js @@ -14,6 +14,8 @@ function _inherits(subClass, superClass) { if (typeof superClass !== 'function' var _opcodeJs = require('./opcode.js'); +var _data_typesJs = require('../data_types.js'); + var FUNCTION = (function (_OPCODE) { _inherits(FUNCTION, _OPCODE); @@ -23,6 +25,7 @@ var FUNCTION = (function (_OPCODE) { _get(Object.getPrototypeOf(FUNCTION.prototype), 'constructor', this).call(this, pql_obj, fn_name); this._needs_group_cache = null; + this._return_type = null; this.setFunctionName(fn_name); } @@ -62,6 +65,7 @@ var FUNCTION = (function (_OPCODE) { throw 'Function \'' + fn_name + '\' is not allowed or not defined'; } this._fn_settings = this.getPqlObj().getConfig().FUNCTION_MAP[fn_name]; + this.setType(this._fn_settings.return_type || _data_typesJs.DATA_TYPES.ANY); this._fn_name = fn_name; } }, { @@ -79,6 +83,17 @@ var FUNCTION = (function (_OPCODE) { }); return this.buildFromFormat(this.getFormat(), args, this._arguments, query_obj); } + }, { + key: 'setType', + value: function setType(type) { + this._return_type = type; + return this; + } + }, { + key: 'getType', + value: function getType() { + return this._return_type; + } }, { key: 'needsGroup', value: function needsGroup() { diff --git a/compiled/pql/parser.js b/compiled/pql/parser.js index 7268435..be26424 100644 --- a/compiled/pql/parser.js +++ b/compiled/pql/parser.js @@ -36,12 +36,15 @@ var _opcodesConstants_arrayJs = require('./opcodes/constants_array.js'); var _parserTable_refJs = require('./parser/table_ref.js'); +var _data_typesJs = require('./data_types.js'); + var PARSER = (function () { function PARSER(query, ref_table) { var allow_seperator = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; var config = arguments.length <= 3 || arguments[3] === undefined ? null : arguments[3]; var table_refs = arguments.length <= 4 || arguments[4] === undefined ? [] : arguments[4]; var variables = arguments.length <= 5 || arguments[5] === undefined ? {} : arguments[5]; + var allow_compares = arguments.length <= 6 || arguments[6] === undefined ? false : arguments[6]; _classCallCheck(this, PARSER); @@ -51,6 +54,7 @@ var PARSER = (function () { this._comparitors = new _parserComparitorsJs.COMPARITORS(config.COMPARITORS); this._table_refs = table_refs; this._variables = {}; + this._allow_compares = !!allow_compares; // Defaults to false allow_seperator = !!allow_seperator; @@ -94,6 +98,11 @@ var PARSER = (function () { } _createClass(PARSER, [{ + key: 'getAllowCompares', + value: function getAllowCompares() { + return this._allow_compares; + } + }, { key: 'assignVariables', value: function assignVariables(var_list_obj) { for (var var_name in var_list_obj) { @@ -437,6 +446,7 @@ var PARSER = (function () { return [match[0].length, field]; //throw ["Expected T_COMPARITOR", str.length]; } + if (comparitor[1].isInstanceOf(_opcodesComparitorsNo_valueJs.NO_VALUE)) { return [match[0].length + comparitor[0], field]; } @@ -448,6 +458,13 @@ var PARSER = (function () { } comparitor[1].setLeft(field).setRight(value[1]); + if (!this.getAllowCompares()) { + var func = new _opcodesFunctionJs.FUNCTION(this, 'if'); + func.setArgs([comparitor[1], new _opcodesConstantJs.CONSTANT(this, '1').setForceNumeric(true), new _opcodesConstantJs.CONSTANT(this, '0').setForceNumeric(true)]); + func.setType(_data_typesJs.DATA_TYPES.BOOLEAN); + comparitor[1] = func; + } + return [match[0].length + comparitor[0] + value[0], comparitor[1]]; } @@ -509,6 +526,7 @@ var PARSER = (function () { return [match[0].length + sum_length + closer[0], func]; //throw ["Expected T_COMPARITOR", str.length]; } + if (comparitor[1].isInstanceOf(_opcodesComparitorsNo_valueJs.NO_VALUE)) { return [match[0].length + sum_length + closer[0] + comparitor[0], func]; } @@ -517,6 +535,13 @@ var PARSER = (function () { comparitor[1].setLeft(func); comparitor[1].setRight(value[1]); + if (!this.getAllowCompares()) { + var _func = new _opcodesFunctionJs.FUNCTION(this, 'if'); + _func.setArgs([comparitor[1], new _opcodesConstantJs.CONSTANT(this, '1'), new _opcodesConstantJs.CONSTANT(this, '0')]); + _func.setType(_data_typesJs.DATA_TYPES.BOOLEAN); + comparitor[1] = _func; + } + return [match[0].length + sum_length + closer[0] + comparitor[0] + value[0], comparitor[1]]; } diff --git a/compiled/pql/parser/sql_builder.js b/compiled/pql/parser/sql_builder.js index 9edf7cb..07bc03e 100644 --- a/compiled/pql/parser/sql_builder.js +++ b/compiled/pql/parser/sql_builder.js @@ -21,6 +21,7 @@ var SQL_BUILDER = (function () { var orderBys = _ref.orderBys; var limit = _ref.limit; var offset = _ref.offset; + var variables = _ref.variables; _classCallCheck(this, SQL_BUILDER); @@ -31,6 +32,7 @@ var SQL_BUILDER = (function () { this._orderBys = orderBys; this._limit = limit; this._offset = offset; + this._variables = variables; this._table_refs = new Map(); this._linked_tables = []; @@ -77,6 +79,11 @@ var SQL_BUILDER = (function () { value: function getOffset() { return this._offset; } + }, { + key: 'getVariables', + value: function getVariables() { + return this._variables; + } }, { key: 'toString', value: function toString() { @@ -223,7 +230,7 @@ var SQL_BUILDER = (function () { } // Pop last item off the array and clone it so it doesn't count itself - var parser = new _parserJs.PARSER(link_obj.pql, this.getTable(), false, this.getQuery().getConfig(), table_ary.slice(0, table_ary.length - 1)); + var parser = new _parserJs.PARSER(link_obj.pql, this.getTable(), false, this.getQuery().getConfig(), table_ary.slice(0, table_ary.length - 1), this.getVariables(), true); // This needs to happen here to ensure the tables get added in the proper order parser.getCodes().getSQL(this); diff --git a/compiled/unit_test/tests/functions.js b/compiled/unit_test/tests/functions.js index 1ac723e..b8e4837 100644 --- a/compiled/unit_test/tests/functions.js +++ b/compiled/unit_test/tests/functions.js @@ -156,7 +156,7 @@ window.QUnit.test('Functions - count', function (assert) { query: 'count(id) > 21', table: 'table1' }); - assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING COUNT("TablE1"."id") > \'21\'', "Passed!"); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING COUNT("TablE1"."id") > 21', "Passed!"); }); window.QUnit.test('Functions - group_concat 1', function (assert) { var query = _pqlPQLJs.PQL.getSQL({ diff --git a/compiled/unit_test/tests/variable.js b/compiled/unit_test/tests/variable.js index 4921960..51acd14 100644 --- a/compiled/unit_test/tests/variable.js +++ b/compiled/unit_test/tests/variable.js @@ -43,7 +43,7 @@ window.QUnit.test('Variable 4', function (assert) { amt: 3 } }); - assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > \'3\'', "Passed!"); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > 3', "Passed!"); }); window.QUnit.test('Variable 5', function (assert) { var query = _pqlPQLJs.PQL.getSQL({ @@ -55,7 +55,7 @@ window.QUnit.test('Variable 5', function (assert) { amt: 3 } }); - assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING ( "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > \'3\' ) IF(COUNT(\'4\') > \'-009\', \'3\', NULL)', "Passed!"); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" GROUP BY "TablE1"."id" HAVING ( "TablE1"."id" IS NULL OR COUNT(IFNULL("TablE1"."id", \'1\')) > 3 ) IF(COUNT(\'4\') > -009, \'3\', NULL)', "Passed!"); }); window.QUnit.test('Variable 6', function (assert) { var query = _pqlPQLJs.PQL.getSQL({ @@ -65,7 +65,7 @@ window.QUnit.test('Variable 6', function (assert) { id: 0 } }); - assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id" HAVING \'7\' = COUNT(\'0\')', "Passed!"); + assert.ok(query.replace(/\s+/g, ' ') === 'SELECT * FROM "TablE1" WHERE "TablE1"."id" = 3 GROUP BY "TablE1"."id" HAVING 7 = COUNT(\'0\')', "Passed!"); }); window.QUnit.test('Variable 7', function (assert) { var query = _pqlPQLJs.PQL.getSQL({