- "npm run-script test-datasource"
- "npm run-script test"
- "npm run-script jshint"
-
- # test an upgrade from 4.4.0
- - "wget http://sourceforge.net/projects/postbooks/files/03%20PostBooks-databases/4.4.0/postbooks_demo-4.4.0.backup"
- - "./scripts/build_app.js -d upgrade_test -i -b ./postbooks_demo-4.4.0.backup"
/* Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
See www.xtuple.com/CPAL for the full text of the software license. */
- var result,
- viewname,
- schemaname,
- i,
- sql = "select schemaname, viewname " +
- "from pg_views " +
- "where schemaname in ('xm','sys', 'xt');";
-
- result = plv8.execute(sql);
- for (i = 0; i < result.length; i++) {
- viewname = result[i].viewname;
- schemaname = result[i].schemaname;
- plv8.execute('drop view if exists ' + schemaname + '.' + viewname + ' cascade;');
- }
-
+ plv8.execute("select xt.js_init();");
plv8.execute("alter table xt.orm disable trigger orm_did_change;");
plv8.execute("delete from xt.orm where orm_json ~ '\"isSystem\":true';");
plv8.execute("alter table xt.orm enable trigger orm_did_change;");
--- /dev/null
+do $$
+ /* Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
+ See www.xm.ple.com/CPAL for the full text of the software license. */
+declare
+ sqlstring text;
+begin
+ select string_agg('drop view ' || t.oid::regclass || ';', ' ') into sqlstring
+ from pg_class t
+ join pg_namespace n on n.oid = relnamespace
+ where relkind = 'v'
+ and nspname in ('xm','sys', 'xt');
+ if length(sqlstring) > 0 then
+ execute sqlstring;
+ end if;
+end
+$$;
where aropen_cust_id = $1
and aropen_open
--and aropen_posted = false
- group by aropen_id
+ group by aropen_id, aropen_cust_id, aropen_curr_id, aropen_amount
) unalloc;
$$ language sql;
-select xt.add_report_definition('XM.Invoice', 0, $${
+select xt.add_report_definition('XM.Invoice', 0, $${
"settings": {
"detailAttribute": "lineItems",
"defaultFontSize": 12,
},
{"element": "bandLine", "size": 2},
{
+ "element": "band",
"definition": [
- {"attr": "subtotal", "label": true},
- {"attr": "taxTotal", "label": true},
- {"attr": "total", "label": true}
+ {"text": "_subtotal", "label": true, "width": 70, "align": "left"},
+ {"attr": "subtotal", "width": 100, "align": "right"}
],
- "options": {"width": 525, "align": "right"}
+ "options": {"border": 0, "x": 360}
+ },
+ {
+ "element": "band",
+ "definition": [
+ {"text": "_taxTotal", "label": true, "width": 70, "align": "left"},
+ {"attr": "taxTotal", "width": 100, "align": "right"}
+ ],
+ "options": {"border": 0, "x": 360}
+ },
+ {
+ "element": "band",
+ "definition": [
+ {"text": "_total", "label": true, "width": 70, "align": "left"},
+ {"attr": "total", "width": 100, "align": "right"}
+ ],
+ "options": {"border": 0, "x": 360}
+ },
+ {
+ "definition": []
}
],
"pageFooterElements": [
"_fullListUrl": "Full List URL",
"_generatingPrivateKey": "A new keypair will be generated for this OAUTH2 client. " +
"The public key will be available in the future with this client. The private key " +
- "is only available now as a one-time download.",
+ "is only available now as a one-time download. Note that this process can take up " +
+ "to a minute. Please wait until the key is downloaded.",
"_logoURL": "Logo URL",
"_maintainOauth2clients": "Maintain OAUTH2 Clients",
"_oauth2": "OAUTH2",
IF (_r.quitem_createorder) THEN
IF (_r.item_type IN ('M')) THEN
- SELECT createWo( CAST(_r.quhead_number AS INTEGER), supply.itemsite_id, 1, (_r.quitem_qtyord * _r.quitem_qty_invuomratio),
- _r.itemsite_leadtime, _r.quitem_scheddate, _r.quitem_memo, 'S', _soitemid, _r.quhead_prj_id ) INTO _orderId
+ SELECT createWo( CAST(_soNum AS INTEGER), supply.itemsite_id, 1,
+ (_r.quitem_qtyord * _r.quitem_qty_invuomratio),
+ _r.itemsite_leadtime, _r.quitem_scheddate, _r.quitem_memo,
+ 'S', _soitemid, _r.quhead_prj_id ) INTO _orderId
FROM itemsite sold, itemsite supply
WHERE ((sold.itemsite_item_id=supply.itemsite_item_id)
AND (supply.itemsite_warehous_id=_r.quitem_order_warehous_id)
AND (charass_target_id=_r.quitem_id));
ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopr) ) THEN
- SELECT createPr( CAST(_r.quhead_number AS INTEGER), _r.quitem_itemsite_id, (_r.quitem_qtyord * _r.quitem_qty_invuomratio),
+ SELECT createPr( CAST(_soNum AS INTEGER), _r.quitem_itemsite_id,
+ (_r.quitem_qtyord * _r.quitem_qty_invuomratio),
_r.quitem_scheddate, '', 'S', _soitemid ) INTO _orderId;
_orderType := 'R';
UPDATE pr SET pr_prj_id=_r.quhead_prj_id WHERE pr_id=_orderId;
RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, NULL, NULL, NULL);
END;
-$$ LANGUAGE 'plpgsql';
+$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION createPurchaseToSale(INTEGER, INTEGER, BOOLEAN, NUMERIC) RETURNS INTEGER AS $$
RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, NULL, NULL, pPrice);
END;
-$$ LANGUAGE 'plpgsql';
+$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION createPurchaseToSale(INTEGER, INTEGER, BOOLEAN, NUMERIC, DATE, NUMERIC) RETURNS INTEGER AS $$
RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, pQty, pDueDate, pPrice, NULL);
END;
-$$ LANGUAGE 'plpgsql';
+$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION createPurchaseToSale(INTEGER, INTEGER, BOOLEAN, NUMERIC, DATE, NUMERIC, INTEGER) RETURNS INTEGER AS $$
FROM pohead
WHERE ( (pohead_status = 'U')
AND (pohead_vend_id = _i.itemsrc_vend_id)
- AND (pohead_shiptoname = COALESCE(_s.cohead_shiptoname, _s.shipto_name, ''))
- AND (pohead_shiptoaddress1 = COALESCE(_s.cohead_shiptoaddress1, _s.addr_line1, ''))
- AND (pohead_shiptoaddress2 = COALESCE(_s.cohead_shiptoaddress2, _s.addr_line2, ''))
- AND (pohead_shiptoaddress3 = COALESCE(_s.cohead_shiptoaddress3, _s.addr_line3, ''))
- AND (pohead_shiptocity = COALESCE(_s.cohead_shiptocity, _s.addr_city, ''))
- AND (pohead_shiptostate = COALESCE(_s.cohead_shiptostate, _s.addr_state, ''))
- AND (pohead_shiptozipcode = COALESCE(_s.cohead_shiptozipcode, _s.addr_postalcode, ''))
- AND (pohead_shiptocountry = COALESCE(_s.cohead_shiptocountry, _s.addr_country, ''))
+ AND (COALESCE(pohead_shiptoname, '') = COALESCE(_s.cohead_shiptoname, _s.shipto_name, ''))
+ AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_s.cohead_shiptoaddress1, _s.addr_line1, ''))
+ AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_s.cohead_shiptoaddress2, _s.addr_line2, ''))
+ AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_s.cohead_shiptoaddress3, _s.addr_line3, ''))
+ AND (COALESCE(pohead_shiptocity, '') = COALESCE(_s.cohead_shiptocity, _s.addr_city, ''))
+ AND (COALESCE(pohead_shiptostate, '') = COALESCE(_s.cohead_shiptostate, _s.addr_state, ''))
+ AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_s.cohead_shiptozipcode, _s.addr_postalcode, ''))
+ AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_s.cohead_shiptocountry, _s.addr_country, ''))
AND ((pohead_id=pPoheadId) OR (pPoheadid IS NULL)) );
ELSE
SELECT COALESCE(pohead_id, -1) INTO _temp
FROM pohead
WHERE ( (pohead_status = 'U')
AND (pohead_vend_id = _i.itemsrc_vend_id)
- AND (pohead_shiptoaddress1 = COALESCE(_w.addr_line1, ''))
- AND (pohead_shiptoaddress2 = COALESCE(_w.addr_line2, ''))
- AND (pohead_shiptoaddress3 = COALESCE(_w.addr_line3, ''))
- AND (pohead_shiptocity = COALESCE(_w.addr_city, ''))
- AND (pohead_shiptostate = COALESCE(_w.addr_state, ''))
- AND (pohead_shiptozipcode = COALESCE(_w.addr_postalcode, ''))
- AND (pohead_shiptocountry = COALESCE(_w.addr_country, ''))
+ AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, ''))
+ AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, ''))
+ AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, ''))
+ AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, ''))
+ AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, ''))
+ AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, ''))
+ AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, ''))
AND ((pohead_id=pPoheadId) OR (pPoheadid IS NULL)) );
END IF;
RETURN _poitemid;
END;
-$$ LANGUAGE 'plpgsql' VOLATILE;
+$$ LANGUAGE plpgsql VOLATILE;
select xt.create_table('bankrecimport', 'public');
select xt.add_column('bankrecimport','bankrecimport_id', 'SERIAL', 'PRIMARY KEY', 'public');
-select xt.add_column('bankrecimport','bankrecimport_reference', 'TEXT', 'NOT NULL', 'public');
-select xt.add_column('bankrecimport','bankrecimport_descrip', 'TEXT', 'NOT NULL', 'public');
-select xt.add_column('bankrecimport','bankrecimport_comment', 'TEXT', 'NOT NULL', 'public');
-select xt.add_column('bankrecimport','bankrecimport_debit_amount', 'NUMERIC', 'NOT NULL', 'public');
-select xt.add_column('bankrecimport','bankrecimport_credit_amount', 'NUMERIC', 'NOT NULL', 'public');
-select xt.add_column('bankrecimport','bankrecimport_effdate', 'DATE', 'NOT NULL', 'public');
-select xt.add_column('bankrecimport','bankrecimport_curr_rate', 'NUMERIC', 'NOT NULL', 'public');
+select xt.add_column('bankrecimport','bankrecimport_reference', 'TEXT', NULL, 'public');
+select xt.add_column('bankrecimport','bankrecimport_descrip', 'TEXT', NULL, 'public');
+select xt.add_column('bankrecimport','bankrecimport_comment', 'TEXT', NULL, 'public');
+select xt.add_column('bankrecimport','bankrecimport_debit_amount', 'NUMERIC', NULL, 'public');
+select xt.add_column('bankrecimport','bankrecimport_credit_amount', 'NUMERIC', NULL, 'public');
+select xt.add_column('bankrecimport','bankrecimport_effdate', 'DATE', NULL, 'public');
+select xt.add_column('bankrecimport','bankrecimport_curr_rate', 'NUMERIC', NULL, 'public');
(currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance,
round((coitem_qtyord * coitem_qty_invuomratio) *
(coitem_unitcost / coitem_price_invuomratio), 2) AS extcost,
- (round((coitem_qtyord * coitem_qty_invuomratio) *
- (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) -
- round((coitem_qtyord * coitem_qty_invuomratio) *
- (coitem_unitcost / coitem_price_invuomratio), 2)) AS margin,
- CASE WHEN (coitem_price > 0.0) THEN
- (round((coitem_qtyord * coitem_qty_invuomratio) *
- (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) -
- round((coitem_qtyord * coitem_qty_invuomratio) *
- (coitem_unitcost / coitem_price_invuomratio), 2)) /
- round((coitem_qtyord * coitem_qty_invuomratio) *
- (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2)
- ELSE 0.0
+ CASE WHEN (coitem_price = 0.0) THEN 0.0
+ ELSE ROUND(coitem_qtyord * coitem_qty_invuomratio * (coitem_price - coitem_unitcost) / coitem_price_invuomratio,2)
+ END AS margin,
+ CASE WHEN (coitem_price = 0.0) THEN 0.0
+ ELSE ((coitem_price - coitem_unitcost) / coitem_price)
END AS marginpercent,
curr_abbr AS currAbbr,
-- TODO - not needed, remove? (very slow)
},
fetchSuccess = function (model, result) {
var sendExtensions = function (res, extensions) {
+ var filteredExtensions;
+ if (req.query.extensions) {
+ // the user is requesting to only see a certain set of extensions
+ filteredExtensions = JSON.parse(req.query.extensions);
+ extensions = extensions.filter(function (ext) {
+ return _.contains(filteredExtensions, ext.name);
+ });
+ }
+
extensions.sort(function (ext1, ext2) {
if (ext1.loadOrder !== ext2.loadOrder) {
return ext1.loadOrder - ext2.loadOrder;
function (req, res, next) {
var pathName = "/app";
if (req && req.session && !req.session.oauth2 && req.session.passport && req.session.passport.user && req.session.passport.user.organization) {
+ if (req.body.extensions) {
+ pathName = pathName + "?extensions=" + req.body.extensions;
+ }
if (req.body.hash && req.body.hash.charAt(0) === "#") {
pathName = pathName + req.body.hash;
}
(function () {
"use strict";
- var ursa = require("ursa"),
- exec = require("child_process").exec,
+ var exec = require("child_process").exec,
forge = require("node-forge"),
spawn = require("child_process").spawn,
async = require("async"),
res.send({isError: true, error: err});
},
genKey = function (model, result) {
- /**
- * This is REALLY slow in pure javascript. ursa is much faster.
- * @See: https://github.com/digitalbazaar/forge/issues/125
- forge.pki.rsa.generateKeyPair({bits: 2048, workers: 2}, function(err, keypair) {
+ forge.pki.rsa.generateKeyPair({bits: 2048, workers: -1}, function (err, keypair) {
if (err) {
res.send({isError: true, message: "Error generating keypair: " + err.message, error: err});
return;
fetchSuccess(model, result, keypair);
});
- */
-
- // Use ursa for the key gen and then convert to forge's format.
- var keypair = ursa.generatePrivateKey();
- var keys = {
- privateKey: forge.pki.privateKeyFromPem(keypair.toPrivatePem().toString()),
- publicKey: forge.pki.publicKeyFromPem(keypair.toPublicPem().toString())
- };
-
- fetchSuccess(model, result, keys);
},
sendP12 = function (keys) {
// It's possible and much easier to generate the p12 file without a
"version": "2.3.3",
"from": "underscore.string@~2.3.3"
},
- "ursa": {
- "version": "0.8.0",
- "from": "ursa@0.8.x"
- },
"winston": {
"version": "0.7.3",
"from": "winston@0.7.x",
}
},
"xtuple-linguist": {
- "version": "0.1.0",
+ "version": "0.1.1",
"from": "xtuple-linguist@0.1.x"
},
"xtuple-query": {
"underscore": "1.4.x",
"winston": "0.7.x",
"underscore.string": "~2.3.3",
- "ursa": "0.8.x",
"xtuple-linguist": "0.1.x",
"jquery": "~2.1.1"
},
baseName.indexOf('distribution') >= 0,
registerExtension: isExtension,
runJsInit: !isFoundation && !isLibOrm,
- wipeViews: isApplicationCore && spec.wipeViews,
+ wipeViews: isFoundation && spec.wipeViews,
+ wipeOrms: isApplicationCore && spec.wipeViews,
extensionLocation: isCoreExtension ? "/core-extensions" :
isPublicExtension ? "/xtuple-extensions" :
isPrivateExtension ? "/private-extensions" :
}
if (options.wipeViews) {
+ // If we want to pre-emptively wipe out the views, the best place to do it
+ // is at the start of the core application code
+ fs.readFile(path.join(__dirname, "../../../enyo-client/database/source/wipe_views.sql"),
+ function (err, wipeSql) {
+ if (err) {
+ callback(err);
+ return;
+ }
+ extensionSql = wipeSql + extensionSql;
+ callback(null, extensionSql);
+ });
+
+ } else if (options.wipeOrms) {
// If we want to pre-emptively wipe out the views, the best place to do it
// is at the start of the core application code
fs.readFile(path.join(__dirname, "../../../enyo-client/database/source/delete_system_orms.sql"),
@description When currency or invoice date is changed outstanding credit should be
recalculated.
*/
- it.skip("When currency or invoice date is changed outstanding credit should be recalculated",
+ it.("When currency or invoice date is changed outstanding credit should be recalculated",
function (done) {
- // frustratingly nondeterministic
+
this.timeout(9000);
var outstandingCreditChanged = function () {
if (invoiceModel.get("outstandingCredit")) {