forked from unimatrix/web
11 lines
1 KiB
JavaScript
11 lines
1 KiB
JavaScript
import {organisationSubject} from './official-account.mjs';
|
|
// The Big Four and the verified Owner alias may inspect and credit every active
|
|
// account except P&O. This never grants authority to debit another account.
|
|
export async function canInspectAllBankAccounts(central,user){
|
|
if(!central||!user?.id)return false;
|
|
const subject=await organisationSubject(central,user.id);
|
|
const principal=await central.prepare("SELECT p.principal_kind FROM org_control_principals p JOIN site_accounts a ON a.id=p.user_id WHERE p.user_id=? AND a.password_hash NOT LIKE '!%'").bind(subject.userId).first();
|
|
return ['owner','executive'].includes(principal?.principal_kind);
|
|
}
|
|
export const ordinaryPaymentAccount=a=>!!a&&Number(a.entity_active)===1&&a.state==='active'&&a.package_state==='active'&&a.type_code!=='106'&&!a.system_key;
|
|
export const bankRecipientAllowed=(a,all=false)=>ordinaryPaymentAccount(a)||!!(all&&a&&a.state==='active'&&a.system_key!=='sys_payroll_po'&&(a.system_key||Number(a.entity_active)===1&&a.package_state==='active'));
|

Staff