"isVoid": {
"update": false
}
+ },
+ "personal": {
+ "create": false,
+ "read": "ViewPersonalCRMAccounts",
+ "update": false,
+ "delete": false,
+ "properties": [
+ "crmaccountUsers"
+ ]
}
},
"properties": [
"column": "invchead_id",
"inverse": "source"
}
+ },
+ {
+ "name": "crmaccountUsers",
+ "toMany": {
+ "type": "ShareUsers",
+ "column": "obj_uuid",
+ "inverse": "uuid"
+ }
}
],
"isSystem": true
"public/tables/docass.sql",
"public/tables/grppriv.sql",
"public/tables/incdt.sql",
+ "public/tables/invchead.sql",
"public/tables/invcitem.sql",
"public/tables/invcitemtax.sql",
"public/tables/itemsite.sql",
--- /dev/null
+-- add uuid column here because there are views that need this
+select xt.add_column('invchead','obj_uuid', 'uuid', 'default xt.uuid_generate_v4()', 'public');
+select xt.add_inheritance('invchead', 'xt.obj');
+select xt.add_constraint('invchead', 'invchead_obj_uuid','unique(obj_uuid)', 'public');
"loadOrder": 30,
"databaseScripts": [
"xt/tables/rptdef.sql",
+ "xt/tables/sharetype.sql",
"xm/javascript/billing.sql",
"xm/javascript/cashrcpt.sql",
"xm/javascript/invoice.sql",
"xt/views/receivable_invoice_return.sql",
"xt/views/aropeninfo.sql",
"xt/views/receivable_applications.sql",
+ "xt/views/share_users_invchead.sql",
"xt/views/cashrcpt.sql"
]
}
--- /dev/null
+-- Invoice CRM Account's users.
+delete from xt.sharetype where sharetype_tblname = 'share_users_invchead';
+insert into xt.sharetype (
+ sharetype_nsname,
+ sharetype_tblname,
+ sharetype_col_obj_uuid,
+ sharetype_col_username
+) values (
+ 'xt',
+ 'share_users_invchead',
+ 'obj_uuid',
+ 'username'
+);
--- /dev/null
+/*
+ * 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 an Invoice based on what CRM Account it belongs to.
+ */
+
+select xt.create_view('xt.share_users_invchead', $$
+
+ -- Invoice CRM Account's users.
+ SELECT
+ invchead_cust_crmacct_ids.obj_uuid::uuid AS obj_uuid,
+ username::text AS username
+ FROM (
+ SELECT
+ invchead.obj_uuid,
+ crmacct_id
+ FROM invchead
+ LEFT JOIN custinfo ON invchead_cust_id = cust_id
+ LEFT JOIN crmacct ON cust_id = crmacct_cust_id
+ ) invchead_cust_crmacct_ids
+ LEFT JOIN xt.crmacct_users USING (crmacct_id)
+ WHERE 1=1
+ AND username IS NOT NULL;
+
+$$, false);