28 lines
960 B
JavaScript
28 lines
960 B
JavaScript
// Generated, do not edit. sha256:37f1d463b03d2b5d702238cb632740786fc53e2072e4691719327d700c59d56c
|
|
import { capacityReached } from '../license.mjs';
|
|
import * as db from '../db.js';
|
|
import { counts } from './counts.js';
|
|
import { RATE_ONLY_ASSET } from './_shared.js';
|
|
import { getBaseCurrency } from './portfolio.js';
|
|
|
|
function fiatAccountCount() {
|
|
return db.one(`SELECT COUNT(*) AS n FROM Account WHERE kind = 'bank'`).n;
|
|
}
|
|
|
|
function assetCount() {
|
|
return db.one(`SELECT COUNT(*) AS n FROM Asset WHERE symbol <> ? AND NOT ${RATE_ONLY_ASSET}`,
|
|
[getBaseCurrency()]).n;
|
|
}
|
|
|
|
export function currentCount(soort) {
|
|
const c = counts();
|
|
if (soort === 'assets') return assetCount();
|
|
if (soort === 'valuations') return c.valuations;
|
|
if (soort === 'fiatAccounts') return fiatAccountCount();
|
|
throw new Error(`No counter for capacity '${soort}' yet.`);
|
|
}
|
|
|
|
export function capacityReachedFor(soort) {
|
|
return capacityReached(soort, currentCount(soort));
|
|
}
|