Skip to content

Commit

Permalink
Merge pull request #40 from ya-erm/dev
Browse files Browse the repository at this point in the history
Version 2.5.2 (merged from dev)
  • Loading branch information
ya-erm authored Oct 16, 2023
2 parents 3151470 + ea6eaea commit 47be25c
Show file tree
Hide file tree
Showing 59 changed files with 1,532 additions and 185 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client",
"version": "2.3.0",
"version": "2.5.2",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
189 changes: 189 additions & 0 deletions src/lib/data/currencySymbols.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
export const currencySymbols: Record<string, string> = {
AED: 'د.إ',
AFN: '؋',
ALL: 'L',
AMD: '֏',
ANG: 'ƒ',
AOA: 'Kz',
ARS: '$',
AUD: '$',
AWG: 'ƒ',
AZN: '₼',
BAM: 'KM',
BBD: '$',
BDT: '৳',
BGN: 'лв',
BHD: '.د.ب',
BIF: 'FBu',
BMD: '$',
BND: '$',
BOB: '$b',
BOV: 'BOV',
BRL: 'R$',
BSD: '$',
BTC: '₿',
BTN: 'Nu.',
BWP: 'P',
BYN: 'Br',
BYR: 'Br',
BZD: 'BZ$',
CAD: '$',
CDF: 'FC',
CHE: 'CHE',
CHF: 'CHF',
CHW: 'CHW',
CLF: 'CLF',
CLP: '$',
CNH: '¥',
CNY: '¥',
COP: '$',
COU: 'COU',
CRC: '₡',
CUC: '$',
CUP: '₱',
CVE: '$',
CZK: 'Kč',
DJF: 'Fdj',
DKK: 'kr',
DOP: 'RD$',
DZD: 'دج',
EEK: 'kr',
EGP: '£',
ERN: 'Nfk',
ETB: 'Br',
ETH: 'Ξ',
EUR: '€',
FJD: '$',
FKP: '£',
GBP: '£',
GEL: '₾',
GGP: '£',
GHC: '₵',
GHS: 'GH₵',
GIP: '£',
GMD: 'D',
GNF: 'FG',
GTQ: 'Q',
GYD: '$',
HKD: '$',
HNL: 'L',
HRK: 'kn',
HTG: 'G',
HUF: 'Ft',
IDR: 'Rp',
ILS: '₪',
IMP: '£',
INR: '₹',
IQD: 'ع.د',
IRR: '﷼',
ISK: 'kr',
JEP: '£',
JMD: 'J$',
JOD: 'JD',
JPY: '¥',
KES: 'KSh',
KGS: 'лв',
KHR: '៛',
KMF: 'CF',
KPW: '₩',
KRW: '₩',
KWD: 'KD',
KYD: '$',
KZT: '₸',
LAK: '₭',
LBP: '£',
LKR: '₨',
LRD: '$',
LSL: 'M',
LTC: 'Ł',
LTL: 'Lt',
LVL: 'Ls',
LYD: 'LD',
MAD: 'MAD',
MDL: 'lei',
MGA: 'Ar',
MKD: 'ден',
MMK: 'K',
MNT: '₮',
MOP: 'MOP$',
MRO: 'UM',
MRU: 'UM',
MUR: '₨',
MVR: 'Rf',
MWK: 'MK',
MXN: '$',
MXV: 'MXV',
MYR: 'RM',
MZN: 'MT',
NAD: '$',
NGN: '₦',
NIO: 'C$',
NOK: 'kr',
NPR: '₨',
NZD: '$',
OMR: '﷼',
PAB: 'B/.',
PEN: 'S/.',
PGK: 'K',
PHP: '₱',
PKR: '₨',
PLN: 'zł',
PYG: 'Gs',
QAR: '﷼',
RMB: '¥',
RON: 'lei',
RSD: 'Дин.',
RUB: '₽',
RWF: 'R₣',
SAR: '﷼',
SBD: '$',
SCR: '₨',
SDG: 'ج.س.',
SEK: 'kr',
SGD: 'S$',
SHP: '£',
SLL: 'Le',
SOS: 'S',
SRD: '$',
SSP: '£',
STD: 'Db',
STN: 'Db',
SVC: '$',
SYP: '£',
SZL: 'E',
THB: '฿',
TJS: 'SM',
TMT: 'T',
TND: 'د.ت',
TOP: 'T$',
TRL: '₤',
TRY: '₺',
TTD: 'TT$',
TVD: '$',
TWD: 'NT$',
TZS: 'TSh',
UAH: '₴',
UGX: 'USh',
USD: '$',
UYI: 'UYI',
UYU: '$U',
UYW: 'UYW',
UZS: 'лв',
VEF: 'Bs',
VES: 'Bs.S',
VND: '₫',
VUV: 'VT',
WST: 'WS$',
XAF: 'FCFA',
XBT: 'Ƀ',
XCD: '$',
XOF: 'CFA',
XPF: '₣',
XSU: 'Sucre',
XUA: 'XUA',
YER: '﷼',
ZAR: 'R',
ZMW: 'ZK',
ZWD: 'Z$',
ZWL: '$',
};
20 changes: 20 additions & 0 deletions src/lib/data/groupings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Grouping } from './interfaces';
import { BaseService } from './service';

export class GroupingsService extends BaseService<Grouping> {
constructor() {
super('GroupingsService', 'groupings', 'grouping');
}

get groupings() {
return this.items;
}

get $groupings() {
return this.$items;
}
}

export const groupingsService = new GroupingsService();

export const groupingsStore = groupingsService.$groupings;
1 change: 1 addition & 0 deletions src/lib/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { accountTagsService, accountTagsStore } from './accountTags';
export { accountsService, accountsStore } from './accounts';
export { categoriesService, categoriesStore } from './categories';
export { currencyRatesService, currencyRatesStore } from './currencyRates';
export { groupingsService, groupingsStore } from './groupings';
export { journalService } from './journal';
export { mainService } from './main';
export { memberSettingsStore, membersService, membersStore, selectedMemberStore } from './members';
Expand Down
22 changes: 22 additions & 0 deletions src/lib/data/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type MemberSettings = {
currency?: string | null;
encryption?: EncryptionVersion;
accountsOrder?: string[];
groupingId?: string | null;
};

export type JournalItem = {
Expand All @@ -42,6 +43,7 @@ export type JournalOperation = {
currencyRate?: CurrencyRate;
tag?: Tag;
accountsOrder?: string[];
grouping?: Grouping;
};

export type JournalSubscriber = {
Expand All @@ -65,6 +67,7 @@ export type Account = {
name: string;
currency: string;
icon?: string | null;
color?: string;
tagIds?: string[];
deleted?: boolean;
};
Expand Down Expand Up @@ -111,6 +114,20 @@ export type TransactionViewModel = TransactionWithAccountAndCategory & {
tags: Tag[];
};

export type Grouping = {
id: string;
name: string;
groups?: Group[];
deleted?: boolean;
};

export type Group = {
id: string;
name: string;
color?: string;
accountIds?: string[];
};

export interface LocalDB extends DBSchema {
globalSettings: {
key: string;
Expand Down Expand Up @@ -164,4 +181,9 @@ export interface LocalDB extends DBSchema {
value: WithOwner<CurrencyRate>;
indexes: { 'by-owner': string };
};
groupings: {
key: string;
value: WithOwner<Grouping>;
indexes: { 'by-owner': string };
};
}
2 changes: 2 additions & 0 deletions src/lib/data/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { membersService } from './members';
import { operationTagsService } from './operationTags';
import { operationsService } from './operations';
import { settingsService } from './settings';
import { groupingsService } from './groupings';

const logger = new Logger('MainService', { disabled: false, color: '#00cc55' });

Expand Down Expand Up @@ -52,6 +53,7 @@ class MainService implements Initialisable {
operationsService,
currencyRatesService,
operationTagsService,
groupingsService,
];

$initialized.set(false);
Expand Down
9 changes: 4 additions & 5 deletions src/lib/data/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ export class MembersService implements Initialisable, JournalSubscriber {

/** Apply journal updates and optional save to DB */
async applyChanges(changes: JournalItem[], saveToDB: boolean) {
changes
.filter((item) => item.data.accountsOrder)
.forEach(async (item) => {
await this.updateSettings({ accountsOrder: item.data.accountsOrder }, saveToDB);
});
const accountsOrder = changes.findLast((item) => item.data.accountsOrder);
if (accountsOrder) {
await this.updateSettings({ accountsOrder: accountsOrder.data.accountsOrder }, saveToDB);
}
}

// #endregion
Expand Down
2 changes: 1 addition & 1 deletion src/lib/data/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { journalService } from './journal';
import { membersService } from './members';
import { useDB } from './useDB';

type StorageName = 'categories' | 'accounts' | 'transactions' | 'tags' | 'accountTags' | 'currencyRates';
type StorageName = 'categories' | 'accounts' | 'transactions' | 'tags' | 'accountTags' | 'currencyRates' | 'groupings';

type EntityType = Category | Account | Transaction | Tag | CurrencyRate;

Expand Down
7 changes: 6 additions & 1 deletion src/lib/data/useDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { openDB } from 'idb';
import type { LocalDB } from './interfaces';

const CURRENT_VERSION = 9;
const CURRENT_VERSION = 10;

export async function useDB() {
return await openDB<LocalDB>('mk-2', CURRENT_VERSION, {
Expand Down Expand Up @@ -62,6 +62,11 @@ export async function useDB() {
const objectStore = db.createObjectStore('accountTags', { keyPath: 'id' });
objectStore.createIndex('by-owner', 'owner');
});

migration(10, 'Creating groupings store', () => {
const objectStore = db.createObjectStore('groupings', { keyPath: 'id' });
objectStore.createIndex('by-owner', 'owner');
});
},
});
}
20 changes: 20 additions & 0 deletions src/lib/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ type RouteKey =
| 'accounts.create'
| 'accounts.list'
| 'analytics'
| 'analytics.accounts'
| 'analytics.accounts.groupings'
| 'analytics.accounts.groupings.edit'
| 'analytics.categories'
| 'categories'
| 'categories.create'
| 'transactions'
Expand Down Expand Up @@ -77,6 +81,22 @@ export const routes: { [key in RouteKey]: Route } = {
path: '/analytics',
title: 'analytics.title',
},
'analytics.accounts': {
path: '/analytics/accounts',
title: 'analytics.title',
},
'analytics.accounts.groupings': {
path: '/analytics/accounts/groupings',
title: 'analytics.groupings.title',
},
'analytics.accounts.groupings.edit': {
path: '/analytics/accounts/groupings/edit',
title: 'analytics.groupings.title',
},
'analytics.categories': {
path: '/analytics/categories',
title: 'analytics.title',
},
categories: {
path: '/categories',
title: 'categories.title',
Expand Down
Loading

1 comment on commit 47be25c

@vercel
Copy link

@vercel vercel bot commented on 47be25c Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.