Merge pull request #1883 from shackbarth/24607
authorTravis Webb <me@traviswebb.com>
Mon, 6 Oct 2014 18:03:32 +0000 (14:03 -0400)
committerTravis Webb <me@traviswebb.com>
Mon, 6 Oct 2014 18:03:32 +0000 (14:03 -0400)
issue #24607: make sure we hit the proper error message

25 files changed:
enyo-client/database/source/xt/functions/pg_advisory_unlock.sql
enyo-client/database/source/xt/functions/trylock.sql
foundation-database/public/functions/issuetoshipping.sql
foundation-database/public/functions/voidapopenvoucher.sql
foundation-database/public/tables/metasql/cashReceipts-detail.mql
foundation-database/public/trigger_functions/pkgcmd.sql
foundation-database/public/trigger_functions/pkgcmdarg.sql
foundation-database/public/trigger_functions/pkgimage.sql
foundation-database/public/trigger_functions/pkgmetasql.sql
foundation-database/public/trigger_functions/pkgpriv.sql
foundation-database/public/trigger_functions/pkgreport.sql
foundation-database/public/trigger_functions/pkgscript.sql
foundation-database/public/trigger_functions/pkguiform.sql
lib/enyo-x/source/views/transaction_list_container.js
package.json
scripts/lib/util/convert_specialized.js
scripts/release_build.sh
scripts/xml/distribution_install.xml
scripts/xml/distribution_package.xml
scripts/xml/ent_install.xml [new file with mode: 0644]
scripts/xml/ent_package.xml [new file with mode: 0644]
scripts/xml/postbooks_package.xml
scripts/xml/xtmfg_install.xml
scripts/xml/xtmfg_package.xml
test/specs/invoice.js

index 25c3b7a..c892882 100644 (file)
@@ -1,8 +1,4 @@
 create or replace function xt.pg_advisory_unlock(oid integer, id integer) returns boolean as $$
-  var sql = "select pg_catalog.pg_advisory_unlock($1, $2) as result;";
-  return plv8.execute(sql, [oid, id])[0].result;
-  /* temporary: let qt client use advisory locks but web client use xt.lock */
-
   var pid = plv8.execute("select pg_backend_pid() as pid;")[0].pid,
     username = plv8.execute("select geteffectivextuser() as username;")[0].username,
     sql = "select * from xt.lock where lock_table_oid = $1 and lock_record_id = $2 and lock_username = $3 and lock_pid = $4;",
index 719607b..0c73312 100644 (file)
@@ -1,8 +1,4 @@
 create or replace function xt.trylock(oid integer, id integer) returns boolean as $$
-  var sql = "select public.trylock($1, $2) as result;";
-  return plv8.execute(sql, [oid, id])[0].result;
-  /* temporary: let qt client use advisory locks but web client use xt.lock */
-
   var pid = plv8.execute("select pg_backend_pid() as pid;")[0].pid,
     data = Object.create(XT.Data),
     lock = data.tryLock(oid, id, {pid: pid});
index 0ca7f39..ed8774f 100644 (file)
@@ -4,7 +4,7 @@ CREATE OR REPLACE FUNCTION issueToShipping(INTEGER, NUMERIC) RETURNS INTEGER AS
 BEGIN
   RETURN issueToShipping('SO', $1, $2, 0, CURRENT_TIMESTAMP);
 END;
-$$ LANGUAGE 'plpgsql';
+$$ LANGUAGE plpgsql;
 
 CREATE OR REPLACE FUNCTION issueToShipping(INTEGER, NUMERIC, INTEGER) RETURNS INTEGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
@@ -12,7 +12,7 @@ CREATE OR REPLACE FUNCTION issueToShipping(INTEGER, NUMERIC, INTEGER) RETURNS IN
 BEGIN
   RETURN issueToShipping('SO', $1, $2, $3, CURRENT_TIMESTAMP);
 END;
-$$ LANGUAGE 'plpgsql';
+$$ LANGUAGE plpgsql;
 
 CREATE OR REPLACE FUNCTION issueToShipping(TEXT, INTEGER, NUMERIC, INTEGER, TIMESTAMP WITH TIME ZONE) RETURNS INTEGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
@@ -20,38 +20,44 @@ CREATE OR REPLACE FUNCTION issueToShipping(TEXT, INTEGER, NUMERIC, INTEGER, TIME
 BEGIN
   RETURN issueToShipping($1, $2, $3, $4, $5, NULL);
 END;
-$$ LANGUAGE 'plpgsql';
-
-CREATE OR REPLACE FUNCTION issueToShipping(TEXT, INTEGER, NUMERIC, INTEGER, TIMESTAMP WITH TIME ZONE, INTEGER) RETURNS INTEGER AS $$
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION issueToShipping(pordertype TEXT,
+                                           pitemid INTEGER,
+                                           pQty NUMERIC,
+                                           pItemlocSeries INTEGER,
+                                           pTimestamp TIMESTAMP WITH TIME ZONE,
+                                           pinvhistid INTEGER) RETURNS INTEGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 DECLARE
-  pordertype           ALIAS FOR $1;
-  pitemid              ALIAS FOR $2;
-  pQty                 ALIAS FOR $3;
-  _itemlocSeries       INTEGER := $4;
-  _timestamp           TIMESTAMP WITH TIME ZONE := $5;
-  pinvhistid           ALIAS FOR $6;
-  _coholdtype          TEXT;
-  _invhistid           INTEGER;
-  _shipheadid          INTEGER;
-  _shipnumber          INTEGER;
+  _itemlocSeries        INTEGER;
+  _timestamp            TIMESTAMP WITH TIME ZONE;
+  _coholdtype           TEXT;
+  _balance              NUMERIC;
+  _invhistid            INTEGER;
+  _shipheadid           INTEGER;
+  _shipnumber           INTEGER;
   _cntctid              INTEGER;
   _p                    RECORD;
   _m                    RECORD;
   _value                NUMERIC;
-  _warehouseid         INTEGER;
-  _shipitemid          INTEGER;
+  _warehouseid          INTEGER;
+  _shipitemid           INTEGER;
   _freight              NUMERIC;
 
 BEGIN
 
-  IF (_timestamp IS NULL) THEN
+  IF (pTimestamp IS NULL) THEN
     _timestamp := CURRENT_TIMESTAMP;
+  ELSE
+    _timestamp := pTimestamp;
   END IF;
 
-  IF (_itemlocSeries = 0) THEN
+  IF (pItemlocSeries = 0) THEN
     _itemlocSeries := NEXTVAL('itemloc_series_seq');
+  ELSE
+    _itemlocSeries := pItemlocSeries;
   END IF;
 
   IF (pordertype = 'SO') THEN
@@ -88,6 +94,29 @@ BEGIN
       END IF;
     END IF; 
   
+    -- Check Credit Hold
+    SELECT cohead_holdtype INTO _coholdtype
+    FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)
+    WHERE (coitem_id=pitemid);
+
+    SELECT calcSalesOrderAmt(cohead_id) -
+           COALESCE(SUM(currToCurr(aropenalloc_curr_id, cohead_curr_id,
+                                   aropenalloc_amount, cohead_orderdate)),0) INTO _balance
+    FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)
+                LEFT OUTER JOIN aropenalloc ON (aropenalloc_doctype='S' AND
+                                                aropenalloc_doc_id=cohead_id)
+    WHERE (coitem_id=pitemid)
+    GROUP BY cohead_id;
+
+    --RAISE NOTICE 'issueToShipping - order balance is %', _balance;
+    IF ( (_coholdtype = 'C') AND (_balance > 0.0) ) THEN
+      RETURN -12;
+    ELSIF (_coholdtype = 'P') THEN
+      RETURN -13;
+    ELSIF (_coholdtype = 'R') THEN
+      RETURN -14;
+    END IF;
+
     SELECT shiphead_id INTO _shipheadid
     FROM shiphead, coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)
     WHERE ( (coitem_id=pitemid)
@@ -100,19 +129,6 @@ BEGIN
        RETURN -10;
       END IF;
 
-      SELECT cohead_holdtype INTO _coholdtype
-      FROM cohead, coitem
-      WHERE ((cohead_id=coitem_cohead_id)
-        AND  (coitem_id=pitemid));
-
-      IF (_coholdtype = 'C') THEN
-       RETURN -12;
-      ELSIF (_coholdtype = 'P') THEN
-       RETURN -13;
-      ELSIF (_coholdtype = 'R') THEN
-       RETURN -14;
-      END IF;
-
       INSERT INTO shiphead
       ( shiphead_id, shiphead_number, shiphead_order_id, shiphead_order_type,
        shiphead_shipped,
@@ -291,4 +307,4 @@ BEGIN
   RETURN _itemlocSeries;
 
 END;
-$$ LANGUAGE 'plpgsql';
+$$ LANGUAGE plpgsql;
index bbbdbf4..2555beb 100644 (file)
@@ -50,7 +50,8 @@ BEGIN
   WHERE ( (apopen_doctype='V')
     AND   (apopen_id=pApopenid) );
   IF (NOT FOUND) THEN
-    RAISE EXCEPTION 'Cannot Void Voucher #% as apopen not found', pApopenid;
+    RAISE EXCEPTION 'Cannot Void Voucher Id % as apopen not found [xtuple: voidAPOpenVoucher, -10, %]',
+                       pApopenid, pApopenid;
   END IF;
 
 --  Cache Voucher Infomation
@@ -63,7 +64,18 @@ BEGIN
               LEFT OUTER JOIN pohead ON (vohead_pohead_id = pohead_id)
   WHERE (vohead_number=_n.apopen_docnumber);
   IF (NOT FOUND) THEN
-    RAISE EXCEPTION 'Cannot Void Voucher #% as vohead not found', _n.apopen_docnumber;
+    RAISE EXCEPTION 'Cannot Void Voucher #% as vohead not found [xtuple: voidAPOpenVoucher, -20, %]',
+                       _n.apopen_docnumber, _n.apopen_docnumber;
+  END IF;
+
+--  Check for APApplications
+  SELECT apapply_id INTO _test
+  FROM apapply
+  WHERE (apapply_target_apopen_id=_n.apopen_id)
+  LIMIT 1;
+  IF (FOUND) THEN
+    RAISE EXCEPTION 'Cannot Void Voucher #% as applications exist [xtuple: voidAPOpenVoucher, -30, %]',
+                       _n.apopen_docnumber, _n.apopen_docnumber;
   END IF;
 
   _glDate := COALESCE(_p.vohead_gldistdate, _p.vohead_distdate);
@@ -130,7 +142,8 @@ BEGIN
        AND (expcat_liability_accnt_id=lb.accnt_id)
        AND (expcat_id=_g.poitem_expcat_id) );
       IF (NOT FOUND) THEN
-        RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts.', _p.vohead_number;
+        RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts [xtuple: voidAPOpenVoucher, -40, %]',
+                       _p.vohead_number, _p.vohead_number;
       END IF;
     ELSE
       SELECT pp.accnt_id AS pp_accnt_id,
@@ -140,7 +153,8 @@ BEGIN
        AND (costcat_liability_accnt_id=lb.accnt_id)
        AND (costcat_id=_g.costcatid) );
       IF (NOT FOUND) THEN
-        RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts.', _p.vohead_number;
+        RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts [xtuple: voidAPOpenVoucher, -50, %]',
+                       _p.vohead_number, _p.vohead_number;
       END IF;
     END IF;
 
@@ -283,7 +297,8 @@ BEGIN
   WHERE ( (findAPAccount(vohead_vend_id)=0 OR accnt_id > 0) -- G/L interface might be disabled
     AND   (vohead_id=_p.vohead_id) );
   IF (NOT FOUND) THEN
-    RAISE EXCEPTION 'Cannot Void Voucher #% due to an unassigned A/P Account.', _p.vohead_number;
+    RAISE EXCEPTION 'Cannot Void Voucher #% due to an unassigned A/P Account [xtuple: voidAPOpenVoucher, -60, %]',
+                       _p.vohead_number, _p.vohead_number;
   END IF;
 
   PERFORM postGLSeries(_sequence, pJournalNumber);
@@ -323,7 +338,8 @@ BEGIN
   SELECT postAPCreditMemoApplication(_apopenid) INTO _result;
 
   IF (_result < 0) THEN
-    RAISE EXCEPTION 'Credit application failed with result %.', _result;
+    RAISE EXCEPTION 'Credit application failed with result % [xtuple: voidAPOpenVoucher, -70, %]',
+                       _result, _result;
   END IF;
 
 --  Reopen all of the P/O Items that were closed by this Voucher
index 0464b98..b365f97 100644 (file)
@@ -221,6 +221,9 @@ WHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDat
   AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)
 <? elseif exists("custtype_pattern") ?>
   AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))
+<? endif ?>
+<? if exists("fundstype") ?>
+  AND   (cashrcpt_fundstype=<? value("fundstype") ?>)
 <? endif ?>
       )
 
@@ -260,6 +263,9 @@ WHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDat
   AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)
 <? elseif exists("custtype_pattern") ?>
   AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))
+<? endif ?>
+<? if exists("fundstype") ?>
+  AND   (cashrcpt_fundstype=<? value("fundstype") ?>)
 <? endif ?>
       )
 
@@ -291,6 +297,9 @@ WHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDat
   AND   (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)
 <? elseif exists("custtype_pattern") ?>
   AND   (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))
+<? endif ?>
+<? if exists("fundstype") ?>
+  AND   (cashrcpt_fundstype=<? value("fundstype") ?>)
 <? endif ?>
       )
   ) AS data
index 3905379..be407b8 100644 (file)
@@ -45,7 +45,7 @@ CREATE OR REPLACE FUNCTION _pkgcmdalterTrigger() RETURNS TRIGGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 BEGIN
-  IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
+  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
     IF (TG_OP = 'DELETE') THEN
       RETURN OLD;
     ELSE
index 8eb9cb7..09eaa61 100644 (file)
@@ -27,7 +27,7 @@ CREATE OR REPLACE FUNCTION _pkgcmdargalterTrigger() RETURNS TRIGGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 BEGIN
-  IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
+  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
     IF (TG_OP = 'DELETE') THEN
       RETURN OLD;
     ELSE
index 1d51cb1..0f8ae1d 100644 (file)
@@ -43,7 +43,7 @@ CREATE OR REPLACE FUNCTION _pkgimagealterTrigger() RETURNS TRIGGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 BEGIN
-  IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
+  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
     IF (TG_OP = 'DELETE') THEN
       RETURN OLD;
     ELSE
index 10f7f07..3f9f3c3 100644 (file)
@@ -52,13 +52,8 @@ $$ LANGUAGE 'plpgsql';
 CREATE OR REPLACE FUNCTION _pkgmetasqlalterTrigger() RETURNS TRIGGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
-DECLARE
-  _isdba        BOOLEAN := false;
-
 BEGIN
-  SELECT rolsuper INTO _isdba FROM pg_roles WHERE (rolname=getEffectiveXtUser());
-
-  IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
+  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
     IF (TG_OP = 'DELETE') THEN
       RETURN OLD;
     ELSE
index edb8f63..b3af003 100644 (file)
@@ -47,7 +47,7 @@ CREATE OR REPLACE FUNCTION _pkgprivalterTrigger() RETURNS TRIGGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 BEGIN
-  IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
+  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
     IF (TG_OP = 'DELETE') THEN
       RETURN OLD;
     ELSE
index 94f9c4b..d32f4f0 100644 (file)
@@ -50,7 +50,7 @@ CREATE OR REPLACE FUNCTION _pkgreportalterTrigger() RETURNS TRIGGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 BEGIN
-  IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
+  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
     IF (TG_OP = 'DELETE') THEN
       RETURN OLD;
     ELSE
index 954418c..40e2fb4 100644 (file)
@@ -27,7 +27,7 @@ CREATE OR REPLACE FUNCTION _pkgscriptalterTrigger() RETURNS TRIGGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 BEGIN
-  IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
+  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
     IF (TG_OP = 'DELETE') THEN
       RETURN OLD;
     ELSE
index a5f1a92..dc0e307 100644 (file)
@@ -27,7 +27,7 @@ CREATE OR REPLACE FUNCTION _pkguiformalterTrigger() RETURNS TRIGGER AS $$
 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. 
 -- See www.xtuple.com/CPAL for the full text of the software license.
 BEGIN
-  IF (pkgMayBeModified(TG_TABLE_SCHEMA)) THEN
+  IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN
     IF (TG_OP = 'DELETE') THEN
       RETURN OLD;
     ELSE
index 2116df4..7e3518e 100644 (file)
@@ -227,7 +227,8 @@ trailing:true, white:true, strict:false*/
     */
     setList: function (options) {
       var component,
-      list = options.list;
+        contentHeader = this.$.contentHeader,
+        list = options.list;
 
       component = this.createComponent({
         name: "list",
@@ -248,6 +249,12 @@ trailing:true, white:true, strict:false*/
           memoizeEnabled: false,
           fit: true
         });
+
+        contentHeader.destroyClientControls();
+        if (component.headerComponents) {
+          contentHeader.createComponents(component.headerComponents);
+          contentHeader.render();
+        }
       }
 
       this.init = true;
index d848338..3f804e7 100644 (file)
@@ -61,7 +61,7 @@
     "googleapis": "~0.4.6"
   },
   "engines": {
-    "node": "^0.10"
+    "node": "0.10.32"
   },
   "main": "node-datasource/main.js",
   "scripts": {
index 95b8d52..af3f4eb 100644 (file)
@@ -50,10 +50,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
       grade = "0",
       tableName = defaultSchema ? defaultSchema + ".pkgreport" : "report",
       description,
-      disableSql,
-      updateSql,
-      insertSql,
-      enableSql;
+      upsertSql;
 
     if (lines[3].indexOf(" <name>") !== 0 ||
         lines[4].indexOf(" <description>") !== 0) {
@@ -68,40 +65,41 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
       grade = grade.substring(0, grade.indexOf("<"));
     }
 
-    disableSql = "ALTER TABLE " + tableName + " DISABLE TRIGGER ALL;";
-
-    insertSql = "insert into " + tableName + " (report_name, report_descrip, " +
-      "report_source, report_loaddate, report_grade) select " +
-      "'" + name + "'," +
-      "$$" + description + "$$," +
-      "$$" + content + "$$," +
-      "now(), " + grade +
-      " where not exists (select c.report_id from " + tableName + " c " +
-      "where report_name = '" + name +
-      "' and report_grade = " + grade + ");";
-
-    updateSql = "update " + tableName + " set " +
-      " report_descrip = $$" + description +
-      "$$, report_source = $$" + content +
-      "$$, report_loaddate = now() " +
-      "where report_name = '" + name +
-      "' and report_grade = " + grade + ";";
-
-    enableSql = "ALTER TABLE " + tableName + " ENABLE TRIGGER ALL;";
-
-    return disableSql + insertSql + updateSql + enableSql;
+    upsertSql = "do language plpgsql $do$" +
+                "declare _grade integer := null;" +
+                " begin" +
+                "  select min(report_grade) into _grade" +
+                "    from " + tableName +
+                "   where report_name = '" + name + "';" +
+                "  if _grade is null then" +
+                "    insert into " + tableName + " (report_name, report_descrip," +
+                "        report_source, report_loaddate, report_grade)" +
+                "      select '" + name + "', $$" + description + "$$," +
+                "        $$" + content + "$$, now(), min(sequence_value)" +
+                "        from sequence" +
+                "       where sequence_value >= " + grade + "" +
+                "         and sequence_value not in (" +
+                "        select report_grade from report" +
+                "         where report_name = '" + name + "'" +
+                "       );" +
+                "  else " +
+                "    update " + tableName + " set" +
+                "      report_descrip = $$" + description + "$$," +
+                "      report_source = $$" + content + "$$," +
+                "      report_loaddate = now() " +
+                "     where report_name = '" + name + "'" +
+                "      and report_grade = _grade;" +
+                "  end if;" +
+                " end $do$;";
+    return upsertSql;
   };
 
   var convertFromScript = function (content, filename, defaultSchema) {
     var name = path.basename(filename, '.js'),
       tableName = defaultSchema ? defaultSchema + ".pkgscript" : "unknown",
       notes = "", //"xtMfg package",
-      disableSql,
       insertSql,
-      updateSql,
-      enableSql;
-
-    disableSql = "ALTER TABLE " + tableName + " DISABLE TRIGGER ALL;";
+      updateSql;
 
     insertSql = "insert into " + tableName + " (script_name, script_order, script_enabled, " +
       "script_source, script_notes) select " +
@@ -117,21 +115,15 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
       "$$, script_notes = '" + notes + "' " +
       "where script_name = '" + name + "';";
 
-    enableSql = "ALTER TABLE " + tableName + " ENABLE TRIGGER ALL;";
-
-    return disableSql + insertSql + updateSql + enableSql;
+    return insertSql + updateSql;
   };
 
   var convertFromUiform = function (content, filename, defaultSchema) {
     var name = path.basename(filename, '.ui'),
       tableName = defaultSchema ? defaultSchema + ".pkguiform" : "unknown",
       notes = "", //"xtMfg package",
-      disableSql,
       insertSql,
-      updateSql,
-      enableSql;
-
-    disableSql = "ALTER TABLE " + tableName + " DISABLE TRIGGER ALL;";
+      updateSql;
 
     insertSql = "insert into " + tableName + " (uiform_name, uiform_order, uiform_enabled, " +
       "uiform_source, uiform_notes) select " +
@@ -146,9 +138,7 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
       "uiform_source = $$" + content + "$$, uiform_notes = '" + notes + "' " +
       "where uiform_name = '" + name + "';";
 
-    enableSql = "ALTER TABLE " + tableName + " ENABLE TRIGGER ALL;";
-
-    return disableSql + insertSql + updateSql + enableSql;
+    return insertSql + updateSql;
   };
 
   exports.conversionMap = {
index 133bf95..b2914f8 100755 (executable)
@@ -6,8 +6,8 @@ PAT=$3
 # Usage: ./scripts/release_build.sh 4 5 0-beta
 echo "BUILDING RELEASE "$MAJ"."$MIN"."$PAT""
 
-git fetch XTUPLE
-git checkout XTUPLE/$MAJ"_"$MIN"_"x
+#git fetch XTUPLE
+#git checkout XTUPLE/$MAJ"_"$MIN"_"x
 
 rm -rf scripts/output
 npm run-script build-basic-postbooks-package-sql
@@ -16,8 +16,8 @@ npm run-script build-basic-postbooks-demo
 npm run-script build-basic-quickstart
 cd ../private-extensions
 
-git fetch XTUPLE
-git checkout XTUPLE/$MAJ"_"$MIN"_"x
+#git fetch XTUPLE
+#git checkout XTUPLE/$MAJ"_"$MIN"_"x
 
 npm run-script build-basic-manufacturing-package-sql
 npm run-script build-basic-manufacturing-empty
@@ -79,9 +79,34 @@ cp scripts/output/manufacturing_upgrade.sql scripts/output/manufacturing-install
 cd scripts/output
 tar -zcvf manufacturing-install-$MAJ$MIN$PAT.gz manufacturing-install-$MAJ$MIN$PAT/
 
+#enterprise upgrade
+cd ../../
+mkdir scripts/output/enterprise-upgrade-$MAJ$MIN$PAT
+cp scripts/xml/ent_package.xml scripts/output/enterprise-upgrade-$MAJ$MIN$PAT/package.xml
+cp scripts/output/postbooks_upgrade.sql scripts/output/enterprise-upgrade-$MAJ$MIN$PAT
+cp scripts/output/inventory_upgrade.sql scripts/output/enterprise-upgrade-$MAJ$MIN$PAT
+cp scripts/output/distribution_upgrade.sql scripts/output/enterprise-upgrade-$MAJ$MIN$PAT
+cp scripts/output/manufacturing_upgrade.sql scripts/output/enterprise-upgrade-$MAJ$MIN$PAT
+cd scripts/output
+tar -zcvf enterprise-upgrade-$MAJ$MIN$PAT.gz enterprise-upgrade-$MAJ$MIN$PAT/
+
+#enterprise install
+cd ../../
+mkdir scripts/output/enterprise-install-$MAJ$MIN$PAT
+cp scripts/xml/ent_package.xml scripts/output/enterprise-install-$MAJ$MIN$PAT/package.xml
+cp scripts/output/postbooks_upgrade.sql scripts/output/enterprise-install-$MAJ$MIN$PAT
+cp scripts/output/inventory_basic_install.sql scripts/output/enterprise-install-$MAJ$MIN$PAT
+cp scripts/output/inventory_upgrade.sql scripts/output/enterprise-install-$MAJ$MIN$PAT
+cp scripts/output/distribution_basic_install.sql scripts/output/enterprise-install-$MAJ$MIN$PAT
+cp scripts/output/distribution_upgrade.sql scripts/output/enterprise-install-$MAJ$MIN$PAT
+cp scripts/output/manufacturing_basic_install.sql scripts/output/enterprise-install-$MAJ$MIN$PAT
+cp scripts/output/manufacturing_upgrade.sql scripts/output/enterprise-install-$MAJ$MIN$PAT
+cd scripts/output
+tar -zcvf enterprise-install-$MAJ$MIN$PAT.gz enterprise-install-$MAJ$MIN$PAT/
+
 ADMIN=admin
 PORT=5432
-HOST=xtuple-vagrant
+HOST=localhost
 
 DB_LIST="postbooks_demo empty quickstart distempty distquickstart mfgempty mfgquickstart mfgdemo";
 for DB in $DB_LIST ; do
@@ -100,5 +125,7 @@ rm -rf scripts/output/inventory_basic_install.sql
 rm -rf scripts/output/inventory_upgrade.sql
 rm -rf scripts/output/manufacturing-install-$MAJ$MIN$PAT/
 rm -rf scripts/output/manufacturing-upgrade-$MAJ$MIN$PAT/
+rm -rf scripts/output/enterprise-upgrade-$MAJ$MIN$PAT/
+rm -rf scripts/output/enterprise-install-$MAJ$MIN$PAT/
 rm -rf scripts/output/manufacturing_basic_install.sql
 rm -rf scripts/output/manufacturing_upgrade.sql
index 0d32d93..6ef7963 100644 (file)
@@ -19,8 +19,8 @@
 
   <prerequisite type = "query"
                 name = "Checking for too-new xTuple ERP database version" >
-    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0.
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0' AND fetchMetricText('ServerVersion') != '4.7.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0Beta2.
     </message>
   </prerequisite>
 
index 0518ab7..48ca1d1 100644 (file)
@@ -19,8 +19,8 @@
 
   <prerequisite type = "query"
                 name = "Checking for too-new xTuple ERP database version" >
-    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0.
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0' AND fetchMetricText('ServerVersion') != '4.7.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0Beta2.
     </message>
   </prerequisite>
 
diff --git a/scripts/xml/ent_install.xml b/scripts/xml/ent_install.xml
new file mode 100644 (file)
index 0000000..3007dea
--- /dev/null
@@ -0,0 +1,42 @@
+<package id        = "enterprise-install-470"
+         version   = "4.7.0"
+         developer = "xTuple"
+         descrip   = "load PostBooks resources"
+         updater   = "2.2.4" >
+
+  <prerequisite type = "query"
+                name = "Checking xTuple Edition" >
+    <query>SELECT fetchMetricText('Application') = 'PostBooks';</query>
+    <message>This package must be applied to a PostBooks database.</message>
+  </prerequisite>
+
+  <prerequisite type = "query"
+                name = "Checking for too-old xTuple ERP database version" >
+    <query>SELECT fetchMetricText('ServerVersion') > '4.4.';</query>
+    <message>This package must be applied to a 4.4+ database.
+    </message>
+  </prerequisite>
+
+  <prerequisite type = "query"
+                name = "Checking for too-new xTuple ERP database version" >
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0' AND fetchMetricText('ServerVersion') != '4.7.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0Beta2.
+    </message>
+  </prerequisite>
+
+ <prerequisite type = "query"
+               name = "Checking for mobile-enabled schemas" >
+    <query>SELECT NOT EXISTS(SELECT 1 FROM pg_namespace WHERE nspname = 'xm');</query>
+    <message>This package may not be applied to a mobile-enabled database. Please see your system administrator or contact xTuple.
+    </message>
+  </prerequisite>
+
+  <script file="postbooks_upgrade.sql" />
+  <script file="inventory_basic_install.sql" />
+  <script file="inventory_upgrade.sql" />
+  <script file="distribution_basic_install.sql" />
+  <script file="distribution_upgrade.sql" />
+  <script file="manufacturing_basic_install.sql" />
+  <script file="manufacturing_upgrade.sql" />
+
+</package>
diff --git a/scripts/xml/ent_package.xml b/scripts/xml/ent_package.xml
new file mode 100644 (file)
index 0000000..371811d
--- /dev/null
@@ -0,0 +1,50 @@
+<package id        = "enterprise-upgrade-470"
+         version   = "4.7.0"
+         developer = "xTuple"
+         descrip   = "load PostBooks resources"
+         updater   = "2.2.4" >
+
+  <prerequisite type = "query"
+                name = "Checking xTuple Edition" >
+    <query>SELECT fetchMetricText('Application') = 'Standard';</query>
+    <message>This package must be applied to a Manufacturing Edition database.</message>
+  </prerequisite>
+
+  <prerequisite type="query"
+               name ="Checking xtmfg package" >
+    <query>SELECT TRUE FROM pkghead WHERE pkghead_name = 'xtmfg';</query>
+    <message>This package must be applied to an xTuple ERP database that already contains the xtmfg package.</message>
+  </prerequisite>
+
+ <prerequisite type="query" name="Checking xtmfg Package Version">
+     <query>SELECT TRUE FROM pkghead WHERE pkghead_name = 'xtmfg' AND (pkghead_version >= '4.4');</query>
+    <message>This package must be applied against the 4.4+ version of the xtmfg package.</message>
+  </prerequisite>
+
+  <prerequisite type = "query"
+                name = "Checking for too-old xTuple ERP database version" >
+    <query>SELECT fetchMetricText('ServerVersion') > '4.4.';</query>
+    <message>This package must be applied to a 4.4+ database.
+    </message>
+  </prerequisite>
+
+  <prerequisite type = "query"
+                name = "Checking for too-new xTuple ERP database version" >
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0' AND fetchMetricText('ServerVersion') != '4.7.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0Beta2.
+    </message>
+  </prerequisite>
+
+ <prerequisite type = "query"
+               name = "Checking for mobile-enabled schemas" >
+    <query>SELECT NOT EXISTS(SELECT 1 FROM pg_namespace WHERE nspname = 'xm');</query>
+    <message>This package may not be applied to a mobile-enabled database. Please see your system administrator or contact xTuple.
+    </message>
+  </prerequisite>
+
+  <script file="postbooks_upgrade.sql" />
+  <script file="inventory_upgrade.sql" />
+  <script file="distribution_upgrade.sql" />
+  <script file="manufacturing_upgrade.sql" />
+
+</package>
index 464f2b8..5393463 100644 (file)
@@ -19,8 +19,8 @@
 
   <prerequisite type = "query"
                 name = "Checking for too-new xTuple ERP database version" >
-    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0.
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0' AND fetchMetricText('ServerVersion') != '4.7.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0Beta2.
     </message>
   </prerequisite>
 
index 3d34014..bdf2024 100644 (file)
@@ -19,8 +19,8 @@
 
   <prerequisite type = "query"
                 name = "Checking for too-new xTuple ERP database version" >
-    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0.
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0' AND fetchMetricText('ServerVersion') != '4.7.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0Beta2.
     </message>
   </prerequisite>
 
index ef6ce2c..c02dd0a 100644 (file)
     </message>
   </prerequisite>
 
-<prerequisite type = "query"
-               name = "Checking for too-new xTuple ERP database version" >
-<query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0.
+  <prerequisite type = "query"
+                name = "Checking for too-new xTuple ERP database version" >
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0' AND fetchMetricText('ServerVersion') != '4.7.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0Beta2.
     </message>
-</prerequisite>
-
+  </prerequisite>
 
  <prerequisite type = "query"
                name = "Checking for mobile-enabled schemas" >
index 0a43b8e..6169c36 100644 (file)
@@ -864,7 +864,7 @@ TODO deferred to later sprint:
         @description 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",
+      it.skip("When currency or invoice date is changed outstanding credit should be recalculated",
           function (done) {
 
         this.timeout(9000);