Merge pull request #1862 from gilmoskowitz/i24559_xtlocks
authorSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 19 Sep 2014 16:29:27 +0000 (12:29 -0400)
committerSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 19 Sep 2014 16:29:27 +0000 (12:29 -0400)
issue #24559 - add cascade

enyo-client/extensions/source/sales/database/source/manifest.js
enyo-client/extensions/source/sales/database/source/xt/tables/sharetype.sql
enyo-client/extensions/source/sales/database/source/xt/views/share_users_shipto_cust.sql [new file with mode: 0644]
foundation-database/public/tables/metasql/billingSelections-detail.mql
foundation-database/public/tables/report/BankrecHistory.xml
foundation-database/public/trigger_functions/usrpriv.sql
scripts/xml/distribution_install.xml
scripts/xml/distribution_package.xml
scripts/xml/postbooks_package.xml
scripts/xml/xtmfg_install.xml
scripts/xml/xtmfg_package.xml

index ce8ba77..a0938aa 100644 (file)
@@ -10,6 +10,7 @@
     "xt/views/share_users_shipto.sql",
     "xt/views/share_users_shipto_cntct.sql",
     "xt/views/share_users_shipto_addr.sql",
+    "xt/views/share_users_shipto_cust.sql",
     "xt/tables/sharetype.sql"
   ]
 }
index 69301f3..3e343bf 100644 (file)
@@ -54,6 +54,20 @@ insert into xt.sharetype (
   'username'
 );
 
+-- Customer that a Ship To is on CRM Account's users.
+delete from xt.sharetype where sharetype_tblname = 'share_users_shipto_cust';
+insert into xt.sharetype (
+  sharetype_nsname,
+  sharetype_tblname,
+  sharetype_col_obj_uuid,
+  sharetype_col_username
+) values (
+  'xt',
+  'share_users_shipto_cust',
+  'obj_uuid',
+  'username'
+);
+
 -- Sales Order CRM Account's users.
 delete from xt.sharetype where sharetype_tblname = 'share_users_cohead';
 insert into xt.sharetype (
diff --git a/enyo-client/extensions/source/sales/database/source/xt/views/share_users_shipto_cust.sql b/enyo-client/extensions/source/sales/database/source/xt/views/share_users_shipto_cust.sql
new file mode 100644 (file)
index 0000000..d852f1f
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * This view lists all postgres usernames that are associated with a CRM
+ * Account that owns a resource. That associaiton is either the main user
+ * account, owner's user account, customer's sale rep's user account or
+ * a shared access that has been specifically granted.
+ *
+ * This view can be used to determine which users have personal privilege
+ * access to a Customer that a Ship To is on based on what CRM Account the
+ * Ship To belongs to.
+ */
+
+select xt.create_view('xt.share_users_shipto_cust', $$
+
+  -- Customer that is for a Ship To CRM Account's users.
+  SELECT
+    shipto_cust_crmacct_id.obj_uuid::uuid AS obj_uuid,
+    username::text AS username
+  FROM (
+    SELECT
+      custinfo.obj_uuid,
+      crmacct.crmacct_id
+    FROM shiptoinfo
+    LEFT JOIN crmacct ON crmacct_cust_id = shipto_cust_id
+    LEFT JOIN custinfo ON cust_id = shipto_cust_id
+  ) shipto_cust_crmacct_id
+  LEFT JOIN xt.crmacct_users USING (crmacct_id)
+  WHERE 1=1
+    AND username IS NOT NULL
+    AND obj_uuid IS NOT NULL;
+
+$$, false);
index 864b03b..66bfe7e 100644 (file)
@@ -1,8 +1,8 @@
 -- Group: billingSelections
 -- Name: detail
 -- Notes: used by dspBillingSelections
--- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
--- See www.xtuple.com/CPAL for the full text of the software license.
+--        Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
+--        See www.xtuple.com/CPAL for the full text of the software license.
 
 SELECT cobmisc_id, cohead_id,
        cohead_number, cust_number, cust_name,
@@ -21,7 +21,7 @@ FROM cobmisc, cohead, custinfo, coitem, cobill
 WHERE ((cobmisc_cohead_id=cohead_id)
    AND (cohead_cust_id=cust_id)
    AND (coitem_cohead_id=cohead_id)
-   AND (cobill_coitem_id=coitem_id)
+   AND (cobill_coitem_id=coitem_id) AND (COALESCE(cobill_invcnum,0) = 0)
    AND (NOT cobmisc_posted))
 GROUP BY cobmisc_id, cohead_id, cohead_number, cust_number,
          cust_name, cobmisc_misc, cobmisc_freight, cobmisc_tax, cobmisc_payment
index 8ffe63e..151a654 100644 (file)
@@ -24,7 +24,7 @@
   <name>head</name>
   <sql>SELECT (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bankaccnt,
        (formatDate(bankrec_opendate) || '-' || formatDate(bankrec_enddate)) AS f_bankrec,
-       bankrec_username AS f_username, formatDate(bankrec_created) AS f_created,
+       bankrec_username AS f_username, formatDate(bankrec_postdate) AS f_postdate,
        formatDate(bankrec_opendate) AS f_opendate,
        formatDate(bankrec_enddate) AS f_enddate,
        formatMoney(bankrec_openbal) AS f_openbal,
    <vcenter/>
    <data>
     <query>head</query>
-    <column>f_created</column>
+    <column>f_postdate</column>
    </data>
   </field>
   <label>
index 7ab0098..b35a826 100644 (file)
@@ -1,4 +1,4 @@
-CREATE OR REPLACE FUNCTION _usrprivTrigger() RETURNS TRIGGER AS $$
+CREATE OR REPLACE FUNCTION _usrprivTrigger() 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
@@ -8,6 +8,13 @@ BEGIN
   -- This looks like a candidate for a foreign key but isn't.
   -- fkeys don't work if the foreign key value resides in a child of the 
   -- table and not the table itself.
+  IF (NOT EXISTS(SELECT usrpriv_id 
+                 FROM usrpriv, priv  
+                 WHERE ((usrpriv_priv_id=priv_id) AND (priv_name ='MaintainUsers')
+                        AND (usrpriv_username=geteffectivextuser())))) THEN
+    RAISE EXCEPTION 'User have no privileges to modify user privileges.';
+  END IF;                
+
   IF ((TG_OP = 'UPDATE' OR TG_OP = 'INSERT') AND
       (NOT EXISTS(SELECT priv_id
                   FROM priv
index b82f1bd..0d32d93 100644 (file)
@@ -1,5 +1,5 @@
-<package id        = "distribution-install-460"
-         version   = "4.7.0Beta"
+<package id        = "distribution-install-470"
+         version   = "4.7.0"
          developer = "xTuple"
          descrip   = "load PostBooks resources"
          updater   = "2.2.4" >
@@ -19,8 +19,8 @@
 
   <prerequisite type = "query"
                 name = "Checking for too-new xTuple ERP database version" >
-    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.7.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0Beta.
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0.
     </message>
   </prerequisite>
 
index 9ff6ab6..0518ab7 100644 (file)
@@ -1,5 +1,5 @@
-<package id        = "distribution-upgrade-460"
-         version   = "4.7.0Beta"
+<package id        = "distribution-upgrade-470"
+         version   = "4.7.0"
          developer = "xTuple"
          descrip   = "load PostBooks resources"
          updater   = "2.2.4" >
@@ -19,8 +19,8 @@
 
   <prerequisite type = "query"
                 name = "Checking for too-new xTuple ERP database version" >
-    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.7.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0Beta.
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0.
     </message>
   </prerequisite>
 
index 041993b..464f2b8 100644 (file)
@@ -1,5 +1,5 @@
-<package id        = "postbooks-upgrade-460"
-         version   = "4.7.0Beta"
+<package id        = "postbooks-upgrade-470"
+         version   = "4.7.0"
          developer = "xTuple"
          descrip   = "load PostBooks resources"
          updater   = "2.2.4" >
@@ -19,8 +19,8 @@
 
   <prerequisite type = "query"
                 name = "Checking for too-new xTuple ERP database version" >
-    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.7.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0Beta.
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0.
     </message>
   </prerequisite>
 
index b6eb595..3d34014 100644 (file)
@@ -1,5 +1,5 @@
-<package id        = "manufacturing-install-460"
-         version   = "4.7.0Beta"
+<package id        = "manufacturing-install-470"
+         version   = "4.7.0"
          developer = "xTuple"
          descrip   = "load PostBooks resources"
          updater   = "2.2.4" >
@@ -19,8 +19,8 @@
 
   <prerequisite type = "query"
                 name = "Checking for too-new xTuple ERP database version" >
-    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.7.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0Beta.
+    <query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0.
     </message>
   </prerequisite>
 
index ff787b4..ef6ce2c 100644 (file)
@@ -1,5 +1,5 @@
-<package id        = "manufacturing-upgrade-460"
-         version   = "4.7.0Beta"
+<package id        = "manufacturing-upgrade-470"
+         version   = "4.7.0"
          developer = "xTuple"
          descrip   = "load PostBooks resources"
          updater   = "2.2.4" >
@@ -30,8 +30,8 @@
 
 <prerequisite type = "query"
                name = "Checking for too-new xTuple ERP database version" >
-<query>SELECT NOT fetchMetricText('ServerVersion') >= '4.7.0';</query>
-    <message>This package may not be applied to a database newer than 4.7.0Beta.
+<query>SELECT NOT fetchMetricText('ServerVersion') >= '4.8.0';</query>
+    <message>This package may not be applied to a database newer than 4.7.0.
     </message>
 </prerequisite>