mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { reversed } from '@/core/base.ts';
|
|
import { TransactionTemplate } from '@/models/transaction_template.ts';
|
|
|
|
export function isNoAvailableTemplate(templates: TransactionTemplate[], showHidden: boolean): boolean {
|
|
for (const template of templates) {
|
|
if (showHidden || !template.hidden) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
export function getAvailableTemplateCount(templates: TransactionTemplate[], showHidden: boolean): number {
|
|
let count = 0;
|
|
|
|
for (const template of templates) {
|
|
if (showHidden || !template.hidden) {
|
|
count++;
|
|
}
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
export function getFirstShowingId(templates: TransactionTemplate[], showHidden: boolean): string | null {
|
|
for (const template of templates) {
|
|
if (showHidden || !template.hidden) {
|
|
return template.id;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
export function getLastShowingId(templates: TransactionTemplate[], showHidden: boolean): string | null {
|
|
for (const template of reversed(templates)) {
|
|
if (showHidden || !template.hidden) {
|
|
return template.id;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|